danikf / tik4net

Manage mikrotik routers with .NET C# code via ADO.NET like API or enjoy O/R mapper like highlevel api.
Apache License 2.0
174 stars 93 forks source link

How to reset-counters #27

Closed RaelKbg closed 6 years ago

RaelKbg commented 6 years ago

Hi there

I'm putting a tool in place that will help reset the download used in the user-manager. I'm using the query below from mikrotik's terminal and it works: /tool user-manager user print where download-used >=1000000000;[/tool user-manager user reset-counters numbers=0]

I'm using the tik4net to accomplish this, unfortunately my codes aren't working. please see below and advise a work around:

connection.Open(ip, user, pwd);

            string[] str = new string[4];
            str[0] = ">download-used";
            str[1] = "1000000000;";
            str[2] = "/tool/user-manager/user/reset-counters/numbers";
            str[3] = txtreset.Text;

            ITikCommand cmd = connection.CreateCommandAndParameters("/tool/user- 
                                    manager/user/print", str); 
danikf commented 6 years ago

From another thread:

when I'm trying to reset-counters im getting a 'no such command' error.

Please help, this is my code: var cmd= connection.CreateCommandAndParameters("/tool/user-manager/user/reset-counters ", "?=numbers", txtreset.Text);

Answer: Numbers are not supported via API. Use Ids.

May be this thread will help you: https://forum.mikrotik.com/viewtopic.php?t=43718

BTW - please use support forum and not issues to ask questions.

D

RaelKbg commented 6 years ago

I tried using the .id but got the same no such command error. I tested the command from the terminal, you can only reset-counters per numbers not per .id.

I followed the logic for the php api to reset-counters that also didn't work.

I will create another post on the forum.

RaelKbg commented 6 years ago

Hi danikf

I tried using .id instead of numbers but Im getting the same error "no such command". I tested the command query from the terminal and .id isnt recognised to reset-counters.

Do you have any work around? please help

thanks


De : Daniel Frantik notifications@github.com Envoyé : jeudi 12 avril 2018 09:50 À : danikf/tik4net Cc : RaelKbg; Author Objet : Re: [danikf/tik4net] How to reset-counters (#27)

From another thread:

when I'm trying to reset-counters im getting a 'no such command' error.

Please help, this is my code: var cmd= connection.CreateCommandAndParameters("/tool/user-manager/user/reset-counters ", "?=numbers", txtreset.Text);

Answer: Numbers are not supported via API. Use Ids.

May be this thread will help you: https://forum.mikrotik.com/viewtopic.php?t=43718

BTW - please use support forum and not issues to ask questions.

D

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/danikf/tik4net/issues/27#issuecomment-380727550, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APFQ2TA0bRvhApjjk8L0tKdEh6jh8AXyks5tnxVGgaJpZM4TOc9T.

danikf commented 6 years ago

The command should be in this format (example is for QT but I hope you will understand it):

/queue/tree/reset-counters
=.id=*10009D3

And command should be executed with proper .id value (obtained by /print) and via ExecuteNonQuery (if you want to use ADO like API).

Or (taken from PHP api https://github.com/nunenuh/mikrotik-api/blob/master/src/MikrotikAPI/Commands/IP/Hotspot/HotspotUsers.php):

/ip/hotspot/user/reset-counter
=.id=*10009D3

REMARKS missing 's'

D