07-02-18, 02:27 AM
السلام عليكم
عندى سيرفر mikrotik
فى فورم فى برنامج ال mikrotik بجيب الناس الى شغالة الان على الانترنت عندى
عايز اجيب بيانات الناس الى شغالة من الفروم ده وينزلها فى DataGridView
دى بيانات الناس الى شغالة الان واليوزرات
ده api الخاص بجلب البيانات من السيرفر
/ip/hotspot/active/print
!re=.id=*D00000A=server=hotspot1=user=00=address=10.0.0.13=mac-address=00:E0:4C:95:C2:77=login-by=cookie=uptime=08:22:07==00:02:00=radius=false
!re=.id=*5600000A=server=hotspot1=user=12=address=10.0.0.86=mac-address=F8:3F:51:7F:C8:07=login-by=cookie=uptime=00:28:17=keepalive-timeout=00:02:00=radius=false
!re=.id=*BC00000A=server=hotspot1=user=0=address=10.0.0.188=mac-address=EC:51:BC:24:E4:59=login-by=cookie=uptime=00:33:00=keepalive-timeout=00:02:00=radius=false
!re=.id=*FE00000A=server=hotspot1=user=3=address=10.0.0.254=mac-address=98:0C:A5:05:A2:3F=login-by=http-chap=uptime=00:42:39=keepalive-timeout=00:02:00=radius=false
!re=.id=*5600000A=server=hotspot1=user=12=address=10.0.0.86=mac-address=F8:3F:51:7F:C8:07=login-by=cookie=uptime=00:28:17=keepalive-timeout=00:02:00=radius=false
!re=.id=*BC00000A=server=hotspot1=user=0=address=10.0.0.188=mac-address=EC:51:BC:24:E4:59=login-by=cookie=uptime=00:33:00=keepalive-timeout=00:02:00=radius=false
!re=.id=*FE00000A=server=hotspot1=user=3=address=10.0.0.254=mac-address=98:0C:A5:05:A2:3F=login-by=http-chap=uptime=00:42:39=keepalive-timeout=00:02:00=radius=false
الكود اهو بس كل ماجى افتح المشروع واضغط على البوتن عشان يجيب المتصلين الان يقولى have some error
كود :
Dim IPAddress As System.Net.IPAddress = System.Net.IPAddress.Parse(ip.Text)
Dim mk = New Mikrotik(IPAddress)
If Not mk.Login(user.Text, pass.Text) Then
Console.WriteLine("Cant log in")
mk.Close()
Console.ReadLine()
Return
End If
Try
mk.Send("/ip/hotspot/active/print", False)
mk.Send("=.proplist=.id", False)
mk.Send("=.proplist=server", False)
mk.Send("=.proplist=user", False)
mk.Send("=.proplist=address", False)
mk.Send("=.proplist=mac-address=", False)
mk.Send("=.proplist=uptime=", False)
mk.Send("=.proplist=keepalive-timeout=", False)
mk.Send("=.proplist=disabled", True)
For Each row In mk.Read()
Dim a = row.Replace("!re", "")
Dim b = a.Replace("=.id=", "")
Dim c = b.Replace("=server=", "/")
Dim z = c.Replace("=user=", "/")
Dim x = b.Replace("=address=", "/")
Dim d = c.Replace("=mac-address=", "/")
Dim v = b.Replace("=uptime=", "/")
Dim n = c.Replace("=keepalive-timeout=", "/")
Dim f = d.Replace("=profile=", "/")
Dim r = g.Replace("!done", "")
Dim q = r.Replace("=disabled=", "/")
If q = "" Then
Else
Dim info = q.Split(New Char() {"/"c}, StringSplitOptions.RemoveEmptyEntries)
Dim id = info(0)
Dim name = info(1)
Dim password = info(2)
Dim profile = info(3)
Dim status = info(4)
Conn.Close()
Dim sql1 As String = "select * from customer_db Where m_id = '" & id & "'"
Dim cmd1 As New OleDbCommand(sql1, Conn)
cmd1.Parameters.Clear()
Conn.Open()
dr = cmd1.ExecuteReader
dr.Read()
If dr.HasRows = False Then
If r = "" Then
Else
Try
Dim sqlz As String = "select * from speed Where profile = '" & RTL(profile) & "'"
Dim cmdz As New OleDbCommand(sqlz, conn2)
Dim drz As OleDbDataReader
cmdz.Parameters.Clear()
conn2.Open()
drz = cmdz.ExecuteReader
drz.Read()
Label5.Text = drz.Item("price")
conn2.Close()
Catch
MsgBox(" غير مدرج في قائمة الاسعار" & RTL(profile) & "البروفايل ")
End Try
Conn.Close()
Dim sql = "INSERT INTO customer_db (m_id , m_us , m_pas , profile , c_name , c_add , c_tell , r_date , p_date , status , type , ip , mac , price , a_model , a_ip , a_mac , c_to , a_speed ) VALUES ('" & id & "' , '" & RTL(name) & "' , '" & convert(RTL(password)) & "' , '" & profile & "' , 'na' , 'na' , 'na' , '" & Date.Today & "' , '" & DateTime.Today.AddMonths(1) & "' , '" & conv(status) & "' , 'cable' , '0.0.0.0' , '00:00:00:00:00:00' , '" & Label5.Text & "' , 'na' , '0.0.0.0' , '00:00:00:00:00:00', 'na' , '" & profile & "')"
Dim cmd = New OleDb.OleDbCommand(sql, Conn)
Conn.Open()
cmd.ExecuteNonQuery()
Conn.Close()
End If
Else
Dim SavInto As New OleDb.OleDbCommand
Conn.Close()
SavInto.Connection = Conn
SavInto.CommandType = CommandType.Text
SavInto.CommandText = "UPDATE customer_db SET m_us = '" & RTL(name) & "',m_pas = '" & convert(RTL(password)) & "' where m_id = '" & id & "' "
Conn.Open()
SavInto.ExecuteNonQuery()
Conn.Close()
End If
End If
Next
refrish1.Show()
Me.Close()
MsgBox("تم تحديث البيانات")
Catch
MsgBox("have some error")
End Try
Conn.Close()