Private Sub pingipss_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pingipss.Click
cargaesto()
staprog.Enabled = False
stoprog.Enabled = False
Ipnoreg.Enabled = False
bck.Enabled = False
mensaje = True
If DataGridView1.Visible = False Then
DataGridView1.Visible = True
guardaripsactivas.Visible = True
DataGridView2.Visible = False
guardaipnoreg.Visible = False
inventario.Visible = True
End If
PictureBox1.Visible = True
DataGridView2.Rows.Clear()
pingipss.Enabled = False
cncel.Enabled = True
guardaripsactivas.Enabled = False
DataGridView2.Visible = False
MyThread1 = New Thread(New ThreadStart(AddressOf thischecck))
MyThread2 = New Thread(New ThreadStart(AddressOf thischecck2))
MyThread1.Start()
MyThread2.Start()
End Sub
Private Sub thischecck()
Dim found As Boolean = True
Dim macfound As Boolean
Dim num1 As String
Dim num2 As String
Dim num01 As String
Dim num02 As String
Dim hello As String
Dim sum As Integer
Dim dom As String
For sum = 0 ip28.Rows.Count - 1
hello = ip28.Rows.Item(sum).Cells.Item(1).Value ''this checks the ip of row 2 cell 2
Try
If My.Computer.Network.Ping(hello, 300) Then ''this will ping the ip address and return true or false
ip28.Rows.Item(sum).Cells.Item(2).Value = "ON" '' this checks or not the checkbox for true or false
ip28.Rows.Item(sum).Cells.Item(3).Value = "-"
For ver = 0 To inventario.Rows.Count - 1
If inventario.Rows.Item(ver).Cells.Item(1).Value Is DBNull.Value Then
num2 = "0"
Else
num2 = inventario.Rows.Item(ver).Cells.Item(1).Value 'ip
End If
If inventario.Rows.Item(ver).Cells.Item(7).Value Is DBNull.Value Then
num02 = "0"
Else
num02 = inventario.Rows.Item(ver).Cells.Item(7).Value 'mac
End If
If num1 = num2 Then
If num01 = num02 Then
found = True
macfound = True
ip28.Rows.Item(sum).Cells.Item(7).Value = "YES"
inventario.Rows.Item(ver).Cells.Item(0).Value = "YES"
inventario.Rows.Item(ver).Cells.Item(4).Value = (DataGridView1.Rows.Item(sum).Cells.Item(6).Value)
Exit For
Else
found = True
macfound = False
ip28.Rows.Item(sum).Cells.Item(8).Value = "YES"
inventario.Rows.Item(ver).Cells.Item(0).Value = "YES"
ip28.Rows.Item(sum).Cells.Item(7).Value = "YES But Different MAC "
Exit For
End If
Else
found = False
End If
Next
If found = False Then
ip28.Rows.Item(sum).Cells.Item(7).Value = "Not Found"
End If
Dim hi As String
SyncLock DataGridView1
For oki = 0 To DataGridView1.Rows.Count - 1
hi1 = DataGridView1.Rows.Item(oki).Cells.Item(1).Value
If hi = hi Then
DataGridView1.Rows.Item(oki).Cells.Item(2).Value = ip28.Rows.Item(sumadoe).Cells.Item(2).Value
DataGridView1.Rows.Item(oki).Cells.Item(3).Value = ip28.Rows.Item(sumadoe).Cells.Item(3).Value
Exit For
End If
Next
End SyncLock
End If
Catch ex As Exception
Debug.WriteLine(ex.Source)
End Try
My.Application.DoEvents()
found = True
Next
end sub
Private Sub thischecck2()
Dim found1 As Boolean = True
Dim macfind As Boolean
Dim no1 As String
Dim no2 As String
Dim no01 As String
Dim no02 As String
Dim hi As String
Dim sumadoe As Integer
Dim dmnio1 As String
For sumadoe = 0 To 100
hi = ip42.Rows.Item(sumadoe).Cells.Item(1).Value ''this checks the ip of row 2 cell 2
Try
If My.Computer.Network.Ping(hi, 300) Then ''this will ping the ip address and return true or false
ip42.Rows.Item(sumadoe).Cells.Item(2).Value = "ON" '' this checks or not the checkbox for true or false
ip42.Rows.Item(sumadoe).Cells.Item(3).Value = "-"
For ver = 0 To inventario.Rows.Count - 1
If inventario.Rows.Item(ver).Cells.Item(1).Value Is DBNull.Value Then
no2 = "0"
Else
no2 = inventario.Rows.Item(ver).Cells.Item(1).Value 'ip
End If
If inventario.Rows.Item(ver).Cells.Item(7).Value Is DBNull.Value Then
no02 = "0"
Else
no02 = inventario.Rows.Item(ver).Cells.Item(7).Value 'mac
End If
If no1 = no2 Then
If no01 = no02 Then
found1 = True
macfind = True
ip42.Rows.Item(sumadoe).Cells.Item(7).Value = "YES"
inventario.Rows.Item(ver).Cells.Item(0).Value = "YES"
inventario.Rows.Item(ver).Cells.Item(4).Value = (ip42.Rows.Item(sumadoe).Cells.Item(6).Value)
Exit For
Else
found1 = True
macfind = False
ip42.Rows.Item(sumadoe).Cells.Item(8).Value = "YES"
inventario.Rows.Item(ver).Cells.Item(0).Value = "YES"
ip42.Rows.Item(sumadoe).Cells.Item(7).Value = "YES But Different MAC "
Exit For
End If
Else
found1 = False
End If
Next
If found1 = False Then
ip42.Rows.Item(sumadoe).Cells.Item(7).Value = "Not found"
End If
Dim hi1 As String
SyncLock DataGridView1
For oki = 0 To DataGridView1.Rows.Count - 1
hi1 = DataGridView1.Rows.Item(oki).Cells.Item(1).Value
If hi1 = hi Then
DataGridView1.Rows.Item(oki).Cells.Item(2).Value = ip42.Rows.Item(sumadoe).Cells.Item(2).Value
DataGridView1.Rows.Item(oki).Cells.Item(3).Value = ip42.Rows.Item(sumadoe).Cells.Item(3).Value
Exit For
End If
Next
End SyncLock
End If
Catch ex As Exception
Debug.WriteLine(ex.Source)
End Try
My.Application.DoEvents()
found1 = True
Next
flagi2 = True
End Sub
public sub thisisnext()
pingipss.Enabled = True
DataGridView1.AutoResizeColumn(1, DataGridViewAutoSizeColumnMode.AllCells)
DataGridView1.AutoResizeColumn(2, DataGridViewAutoSizeColumnMode.AllCells)
inventario.AutoResizeColumn(0, DataGridViewAutoSizeColumnMode.AllCells)
inventario.AutoResizeColumn(1, DataGridViewAutoSizeColumnMode.AllCells)
If mensaje = True Then
MsgBox("El en Linea")
End If
If parado = True Then
MsgBox("ElCancelado")
End If
PictureBox1.Visible = False
pingipss.Enabled = True
cncel.Enabled = False
guardaripsactivas.Enabled = True
guardaripsactivas.Visible = True
staprog.Enabled = True
bck.Enabled = True
Ipnoreg.Enabled = True
stoprog.Enabled = True
Ipnoreg.Visible = True
End Sub