123
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Reflection
|
||||
|
||||
Public Class Class1
|
||||
|
||||
@@ -11,7 +12,12 @@ Public Class Class1
|
||||
Public Shared FilePath As String ' = "\\192.168.0.90\f\EDV-Wartung\Dokumentation"
|
||||
Public Shared Absender As String = "Absender Standard"
|
||||
|
||||
|
||||
Public Shared Sub EnableDoubleBuffered(ByVal dgv As DataGridView)
|
||||
Dim dgvType As Type = dgv.[GetType]()
|
||||
Dim pi As PropertyInfo = dgvType.GetProperty("DoubleBuffered",
|
||||
BindingFlags.Instance Or BindingFlags.NonPublic)
|
||||
pi.SetValue(dgv, True, Nothing)
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
@@ -166,6 +172,16 @@ Public Class Class1
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Shared Function ip2ipnet(ip As String)
|
||||
Dim lastbutnotleast As String = "."
|
||||
|
||||
Do
|
||||
ip = ip.Remove((ip.Length - 1), 1)
|
||||
Loop Until ip.EndsWith(".")
|
||||
|
||||
Return ip
|
||||
End Function
|
||||
|
||||
Public Shared Function netmaskseperator(nm As String, ByRef a As Integer, ByRef b As Integer, ByRef c As Integer, ByRef d As Integer, ByRef nwbits As Integer, ByRef hostbits As Integer)
|
||||
Dim bitstring As String
|
||||
Try
|
||||
@@ -319,6 +335,18 @@ Public Class Class1
|
||||
IPShort = NWAddress
|
||||
End Function
|
||||
|
||||
Public Shared Function getStartEndHost(ByVal ip As String, ByRef starthost As Integer, ByRef endhost As Integer)
|
||||
Dim Standort, Name, subnetmask As String
|
||||
Dim nwbits As Integer
|
||||
Dim nwad As String = IP2ShortNW(ip)
|
||||
NetzwerkadresseInfo(nwad, Standort, Name, subnetmask)
|
||||
mask2nwbit(subnetmask, nwbits)
|
||||
Dim Hostbits As Integer = 32 - nwbits
|
||||
Dim AnzahlHosts As Integer = (2 ^ Hostbits) - 2
|
||||
starthost = IP2Host(nwad) + 1
|
||||
endhost = starthost + (AnzahlHosts - 1)
|
||||
End Function
|
||||
|
||||
Public Shared Function Netzwerkfuellen(NWAdresse As String, NWBits As Integer, Netname As String, NWStandort As String)
|
||||
Dim con As New SqlConnection
|
||||
Dim cmd As New SqlCommand
|
||||
@@ -598,8 +626,8 @@ Public Class Class1
|
||||
Dim dataadapter As New SqlDataAdapter("SELECT Distinct " & spalte & " from " & Tabelle & "", con)
|
||||
dataadapter.Fill(ds)
|
||||
|
||||
txtbox.AutoCompleteMode = AutoCompleteMode.SuggestAppend
|
||||
txtbox.AutoCompleteSource = AutoCompleteSource.CustomSource
|
||||
' txtbox.AutoCompleteMode = AutoCompleteMode.SuggestAppend
|
||||
' txtbox.AutoCompleteSource = AutoCompleteSource.CustomSource
|
||||
txtbox.AutoCompleteCustomSource = tmp
|
||||
|
||||
For Each dr As DataRow In ds.Tables(0).Rows
|
||||
@@ -665,4 +693,42 @@ Public Class Class1
|
||||
|
||||
End Function
|
||||
|
||||
Public Shared Function IsLinked(ByVal IPAdresse As String)
|
||||
Dim con As New SqlConnection
|
||||
Dim cmd As New SqlCommand
|
||||
Dim reader As SqlDataReader
|
||||
con.ConnectionString = Class1.DBConString
|
||||
cmd.Connection = con
|
||||
Dim Linked As String
|
||||
|
||||
|
||||
con.Open()
|
||||
cmd.CommandText = "SELECT Linked FROM TbL_Netzwerkclients WHERE IPAdresse = '" & IPAdresse & "' "
|
||||
reader = cmd.ExecuteReader()
|
||||
Do While reader.Read
|
||||
Linked = ReadNullAsEmptyString(reader, "Linked")
|
||||
'Type = ReadNullAsEmptyString(reader, "Type")
|
||||
Loop
|
||||
con.Close()
|
||||
Return Linked
|
||||
End Function
|
||||
|
||||
Public Shared Function DBNull2emptyString(totest As Object)
|
||||
|
||||
If IsDBNull(totest) Then
|
||||
Return ""
|
||||
Else
|
||||
Return totest
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Public Shared Function OrderDataTableby(dt As DataTable, orderby As String)
|
||||
Dim dv As New DataView(dt)
|
||||
|
||||
dv.Sort = orderby
|
||||
Dim returnTable As DataTable = dv.ToTable
|
||||
'returnTable = dv.Table
|
||||
Return returnTable
|
||||
End Function
|
||||
End Class
|
||||
|
||||
@@ -74,10 +74,16 @@ Public Class DHCP
|
||||
Public Shared Sub ListSubnetClients(DHCP_Server As String, Scope As String, ByRef DHCP_Clients() As DHCP_CLIENT_INFO)
|
||||
|
||||
'Dim Client_Array As DHCP_CLIENT_INFO_ARRAY
|
||||
'Dim DHCP_Clients() As DHCP_CLIENT_INFO
|
||||
' Dim DHCP_Clients() As DHCP_CLIENT_INFO
|
||||
|
||||
' Why would you use int16 for a loop counter and for a pointer offset ?
|
||||
|
||||
'If My.Computer.Network.Ping(DHCP_Server) Then
|
||||
'Else
|
||||
' MsgBox("DHCP Server nicht erreichbar")
|
||||
' Exit Sub
|
||||
'End If
|
||||
|
||||
Dim i, j As Int16
|
||||
|
||||
|
||||
|
||||
53
Dokumentation/Classes/Ext_Programme.vb
Normal file
53
Dokumentation/Classes/Ext_Programme.vb
Normal file
@@ -0,0 +1,53 @@
|
||||
Public Class Ext_Programme
|
||||
|
||||
Public Shared Function startlink(URL As String)
|
||||
|
||||
Try
|
||||
If URL.Contains("http") Or URL.Contains("https") Then
|
||||
Process.Start(URL)
|
||||
ElseIf URL = "" Then
|
||||
Exit Function
|
||||
Else
|
||||
Dim mstsc As New Process
|
||||
mstsc.StartInfo.FileName = "mstsc.exe"
|
||||
mstsc.StartInfo.Arguments = " /v: " & URL
|
||||
mstsc.Start()
|
||||
|
||||
End If
|
||||
|
||||
' Process.Start("mstsc.exe", "/v: dc01")
|
||||
Catch ex As Exception
|
||||
'MsgBox(ex.Message)
|
||||
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Public Shared Function startputty(IP As String)
|
||||
Dim Benutzer, Passwort As String
|
||||
Class1.GetUserPasswort(IP, Benutzer, Passwort)
|
||||
Try
|
||||
Dim putty As New Process
|
||||
putty.StartInfo.FileName = "putty.exe"
|
||||
If Benutzer = "" And Passwort = "" Then
|
||||
putty.StartInfo.Arguments = IP
|
||||
Else
|
||||
putty.StartInfo.Arguments = IP & " -l " & Benutzer & " -pw " & Passwort
|
||||
End If
|
||||
putty.Start()
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Shared Function pingip(ip As String)
|
||||
Dim ping As New Process
|
||||
ping.StartInfo.FileName = "cmd.exe"
|
||||
ping.StartInfo.Arguments = " /k ping " & ip
|
||||
ping.Start()
|
||||
End Function
|
||||
|
||||
End Class
|
||||
102
Dokumentation/Classes/FirewallEntry.vb
Normal file
102
Dokumentation/Classes/FirewallEntry.vb
Normal file
@@ -0,0 +1,102 @@
|
||||
Imports System.Data.SqlClient
|
||||
|
||||
Public Class FirewallEntry
|
||||
Property fwr_ID As String = ""
|
||||
Property fwr_hostip As String = ""
|
||||
Property fwr_in As String = ""
|
||||
Property fwr_out As String = ""
|
||||
Property fwr_portsin As String = ""
|
||||
Property fwr_portsout As String = ""
|
||||
Property fwr_dienste As String = ""
|
||||
Property fwr_FQDN As String = ""
|
||||
Property fwr_info As String = ""
|
||||
Property fwr_direct As Boolean = False
|
||||
|
||||
|
||||
|
||||
Function getparameterlist() As List(Of SQLVariable)
|
||||
Dim list As New List(Of SQLVariable)
|
||||
list.Add(New SQLVariable("fwr_ID", fwr_ID))
|
||||
list.Add(New SQLVariable("fwr_hostip", fwr_hostip))
|
||||
list.Add(New SQLVariable("fwr_in", fwr_in))
|
||||
list.Add(New SQLVariable("fwr_out", fwr_out))
|
||||
list.Add(New SQLVariable("fwr_portsin", fwr_portsin))
|
||||
list.Add(New SQLVariable("fwr_portsout", fwr_portsout))
|
||||
list.Add(New SQLVariable("fwr_dienste", fwr_dienste))
|
||||
list.Add(New SQLVariable("fwr_FQDN", fwr_FQDN))
|
||||
list.Add(New SQLVariable("fwr_info", fwr_info))
|
||||
list.Add(New SQLVariable("fwr_direct", fwr_direct))
|
||||
Return list
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Public Shared Function getFirewallEntrys(ByRef ds As DataSet, ByVal HostIP As String)
|
||||
Dim selector As String = "Select
|
||||
[fwr_ID]
|
||||
,[fwr_in]
|
||||
,[fwr_out]
|
||||
,[fwr_portsin]
|
||||
,[fwr_portsout]
|
||||
,[fwr_dienste]
|
||||
,[fwr_FQDN]
|
||||
,[fwr_info]
|
||||
, case when [fwr_direct] is null then '0'
|
||||
else [fwr_direct] end as [fwr_direct]
|
||||
From [Doku].[dbo].[TbL_FirewallRules] where [fwr_hostip] = '" & HostIP & "'
|
||||
ORDER BY [fwr_in]"
|
||||
|
||||
SQL.SQL2DS(selector, ds)
|
||||
|
||||
End Function
|
||||
|
||||
Public Function getUpdateCmd(ByRef update As String, ByRef where As String)
|
||||
|
||||
Dim list As List(Of SQLVariable) = getparameterlist()
|
||||
'Dim str As String
|
||||
|
||||
For Each i In list
|
||||
If Not i.SQLText = "fwr_ID" Then
|
||||
update &= "[" & i.SQLText & "]='" & i.SQLValue & "',"
|
||||
Else
|
||||
where &= "fwr_ID = '" & i.SQLValue & "'"
|
||||
End If
|
||||
Next
|
||||
update = update.Substring(0, update.Length - 1) 'wg. ','
|
||||
' Return str
|
||||
|
||||
End Function
|
||||
|
||||
Public Function getInsertCmd(ByRef insert As String)
|
||||
|
||||
Dim list As List(Of SQLVariable) = getparameterlist()
|
||||
Dim text, value As String
|
||||
|
||||
For Each i In list
|
||||
text &= i.SQLText & ", "
|
||||
value &= "'" & i.SQLValue & "', "
|
||||
Next
|
||||
text = text.Substring(0, text.Length - 2)
|
||||
value = value.Substring(0, value.Length - 2)
|
||||
|
||||
insert = "(" & text & ") VALUES (" & value & ")"
|
||||
|
||||
End Function
|
||||
|
||||
Public Function insertFirewallEntry(ByRef entry As FirewallEntry)
|
||||
Dim insert As String
|
||||
getInsertCmd(insert)
|
||||
SQL.InsertSQL("TbL_FirewallRules", insert)
|
||||
End Function
|
||||
|
||||
Public Function updateFirewallEntry(ByRef entry As FirewallEntry)
|
||||
Dim update, where As String
|
||||
getUpdateCmd(update, where)
|
||||
SQL.UpdateSQL("TbL_FirewallRules", update, where)
|
||||
'MsgBox(update & where)
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
310
Dokumentation/Classes/Host.vb
Normal file
310
Dokumentation/Classes/Host.vb
Normal file
@@ -0,0 +1,310 @@
|
||||
Imports System.Reflection
|
||||
|
||||
Public Class Host
|
||||
Property FQDN As String = ""
|
||||
Property QINFO As String = ""
|
||||
Property IPAdresse As String = ""
|
||||
Property NETNAME As String = ""
|
||||
Property Seriennummer As String = ""
|
||||
Property MAC As String = ""
|
||||
Property Benutzer As String = ""
|
||||
Property Passwort As String = ""
|
||||
Property LINK As String = ""
|
||||
Property INFO As String = ""
|
||||
Property TYPE As String = ""
|
||||
Property HOST As Object = Nothing
|
||||
Property NWSTANDORT As String = ""
|
||||
Property Modell As String = ""
|
||||
Property Linked As Object = Nothing
|
||||
Property LinkedWith As String = ""
|
||||
Property AddIP As String = ""
|
||||
Property Standort As String = ""
|
||||
Property DHCP As String = ""
|
||||
Property Netzwerk As String = ""
|
||||
Property Firewall As Boolean = False
|
||||
|
||||
|
||||
|
||||
|
||||
Function getparameterlistMaster() As List(Of SQLVariable)
|
||||
Dim list As New List(Of SQLVariable)
|
||||
list.Add(New SQLVariable("FQDN", FQDN))
|
||||
list.Add(New SQLVariable("QINFO", QINFO))
|
||||
list.Add(New SQLVariable("IPAdresse", IPAdresse))
|
||||
list.Add(New SQLVariable("NETNAME", NETNAME))
|
||||
list.Add(New SQLVariable("Seriennummer", Seriennummer))
|
||||
list.Add(New SQLVariable("MAC", MAC))
|
||||
list.Add(New SQLVariable("Benutzer", Benutzer))
|
||||
list.Add(New SQLVariable("Passwort", Passwort))
|
||||
list.Add(New SQLVariable("Link", LINK))
|
||||
list.Add(New SQLVariable("INFO", INFO))
|
||||
list.Add(New SQLVariable("TYPE", TYPE))
|
||||
list.Add(New SQLVariable("HOST", HOST))
|
||||
list.Add(New SQLVariable("NWSTANDORT", NWSTANDORT))
|
||||
list.Add(New SQLVariable("Modell", Modell))
|
||||
list.Add(New SQLVariable("Linked", Linked))
|
||||
list.Add(New SQLVariable("LinkedWith", LinkedWith))
|
||||
list.Add(New SQLVariable("AddIP", AddIP))
|
||||
list.Add(New SQLVariable("Standort", Standort))
|
||||
list.Add(New SQLVariable("DHCP", DHCP))
|
||||
list.Add(New SQLVariable("Netzwerk", Netzwerk))
|
||||
list.Add(New SQLVariable("Firewall", Firewall))
|
||||
Return list
|
||||
|
||||
End Function
|
||||
|
||||
Function getparameterlistSlave() As List(Of SQLVariable)
|
||||
Dim list As New List(Of SQLVariable)
|
||||
list.Add(New SQLVariable("FQDN", FQDN))
|
||||
list.Add(New SQLVariable("QINFO", QINFO))
|
||||
list.Add(New SQLVariable("IPAdresse", IPAdresse))
|
||||
'list.Add(New SQLVariable("NETNAME", NETNAME))
|
||||
list.Add(New SQLVariable("Seriennummer", Seriennummer))
|
||||
list.Add(New SQLVariable("MAC", MAC))
|
||||
list.Add(New SQLVariable("Benutzer", Benutzer))
|
||||
list.Add(New SQLVariable("Passwort", Passwort))
|
||||
list.Add(New SQLVariable("Link", LINK))
|
||||
list.Add(New SQLVariable("INFO", INFO))
|
||||
list.Add(New SQLVariable("TYPE", TYPE))
|
||||
'list.Add(New SQLVariable("HOST", HOST))
|
||||
'list.Add(New SQLVariable("NWSTANDORT", NWSTANDORT))
|
||||
list.Add(New SQLVariable("Modell", Modell))
|
||||
'list.Add(New SQLVariable("Linked", Linked))
|
||||
list.Add(New SQLVariable("LinkedWith", LinkedWith))
|
||||
list.Add(New SQLVariable("AddIP", AddIP))
|
||||
list.Add(New SQLVariable("Standort", Standort))
|
||||
list.Add(New SQLVariable("DHCP", DHCP))
|
||||
'list.Add(New SQLVariable("Netzwerk", Netzwerk))
|
||||
list.Add(New SQLVariable("Firewall", Firewall))
|
||||
Return list
|
||||
|
||||
End Function
|
||||
|
||||
Function clear()
|
||||
Me.FQDN = ""
|
||||
Me.QINFO = ""
|
||||
Me.IPAdresse = ""
|
||||
Me.NETNAME = ""
|
||||
Me.Seriennummer = ""
|
||||
Me.MAC = ""
|
||||
Me.Benutzer = ""
|
||||
Me.Passwort = ""
|
||||
Me.LINK = ""
|
||||
Me.INFO = ""
|
||||
Me.TYPE = ""
|
||||
Me.HOST = Nothing
|
||||
Me.NWSTANDORT = ""
|
||||
Me.Modell = ""
|
||||
Me.Linked = Nothing
|
||||
Me.LinkedWith = ""
|
||||
Me.AddIP = ""
|
||||
Me.Standort = ""
|
||||
Me.DHCP = ""
|
||||
Me.Netzwerk = ""
|
||||
Me.Firewall = False
|
||||
End Function
|
||||
|
||||
Public Shared Function getHostsEntrys(ByRef ds As DataSet, ByVal HostIP As String)
|
||||
Dim selector As String = "Select
|
||||
[fwr_ID]
|
||||
,[fwr_in]
|
||||
,[fwr_out]
|
||||
,[fwr_portsin]
|
||||
,[fwr_portsout]
|
||||
,[fwr_dienste]
|
||||
,[fwr_FQDN]
|
||||
,[fwr_info]
|
||||
, case when [fwr_direct] is null then '0'
|
||||
else [fwr_direct] end as [fwr_direct]
|
||||
From [Doku].[dbo].[TbL_FirewallRules] where [fwr_hostip] = '" & HostIP & "'
|
||||
ORDER BY [fwr_in]"
|
||||
|
||||
SQL.SQL2DS(selector, ds)
|
||||
|
||||
End Function
|
||||
|
||||
Public Function gethost(ip As String)
|
||||
Dim ds As New DataSet
|
||||
Dim test As String = ""
|
||||
SQL.SQL2DS("select * from TbL_Netzwerkclients where IPAdresse = '" & ip & "'", ds)
|
||||
For Each c As DataColumn In ds.Tables(0).Columns
|
||||
Dim propInfo As PropertyInfo = Me.GetType.GetProperty(c.ColumnName)
|
||||
If propInfo IsNot Nothing Then
|
||||
If Not IsDBNull(c.Table.Rows(0).Item(c)) Then
|
||||
propInfo.SetValue(Me, c.Table.Rows(0).Item(c))
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
' MsgBox("hier")
|
||||
End Function
|
||||
|
||||
Public Function getUpdateCmd(ByRef update As String, ByRef where As String, Optional ByRef slaveupdate As String = "", Optional ByRef slavewhere As String = "", Optional ByVal Linked As Boolean = False, Optional ByVal newhost As Host = Nothing)
|
||||
If newhost Is Nothing Then
|
||||
slavewhere = ""
|
||||
Dim list As List(Of SQLVariable) = getparameterlistMaster()
|
||||
Dim slavelist As List(Of SQLVariable) = getparameterlistSlave()
|
||||
|
||||
For Each i In list ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''dieser Host
|
||||
If Not i.SQLText = "IPAdresse" Then
|
||||
update &= "[" & i.SQLText & "]='" & i.SQLValue & "',"
|
||||
Else
|
||||
where &= "IPAdresse = '" & i.SQLValue & "'"
|
||||
End If
|
||||
Next
|
||||
update = update.Substring(0, update.Length - 1) 'wg. ','
|
||||
|
||||
For Each i In slavelist ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''alle Hosts, bei denen dieser Host als LinkedWith eingetragen ist
|
||||
If Not i.SQLText = "IPAdresse" And Not i.SQLText = "LinkedWith" Then
|
||||
slaveupdate &= "[" & i.SQLText & "]='" & i.SQLValue & "',"
|
||||
ElseIf i.SQLText = "IPAdresse" Then
|
||||
slavewhere &= "(Linked = 'True' AND (LinkedWith = '" & i.SQLValue & "'"
|
||||
End If
|
||||
Next
|
||||
slaveupdate = slaveupdate.Substring(0, slaveupdate.Length - 1)
|
||||
|
||||
If Linked = True Then '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
||||
|
||||
For Each i In slavelist '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''Masterhost
|
||||
If i.SQLText = "LinkedWith" Then
|
||||
slavewhere &= "OR LinkedWith = '" & i.SQLValue & "') OR IPAdresse = '" & i.SQLValue & "')"
|
||||
End If
|
||||
Next
|
||||
ElseIf Linked = False Then
|
||||
slavewhere &= "))"
|
||||
End If
|
||||
|
||||
Else
|
||||
|
||||
Dim list As List(Of SQLVariable) = newhost.getparameterlistMaster()
|
||||
|
||||
For Each i In list ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''dieser Host
|
||||
If Not i.SQLText = "IPAdresse" Then
|
||||
update &= "[" & i.SQLText & "]='" & i.SQLValue & "',"
|
||||
Else
|
||||
where &= "IPAdresse = '" & i.SQLValue & "'"
|
||||
End If
|
||||
Next
|
||||
update = update.Substring(0, update.Length - 1) 'wg. ','
|
||||
|
||||
End If
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
Public Function updateHostEntry(ByRef entry As Host)
|
||||
Dim update, where, slaveupdate, slavewhere As String
|
||||
getUpdateCmd(update, where, slaveupdate, slavewhere, Me.Linked)
|
||||
SQL.UpdateSQL("TbL_Netzwerkclients", update, where)
|
||||
SQL.UpdateSQL("TbL_Netzwerkclients", slaveupdate, slavewhere)
|
||||
'MsgBox(update & where)
|
||||
|
||||
End Function
|
||||
|
||||
Function checkIfIPExist(ByVal ip As String)
|
||||
Dim ds As New DataSet
|
||||
SQL.SQL2DS("SELECT * FROM TbL_Netzwerkclients WHERE IPADRESSE = '" & ip & "'", ds)
|
||||
If ds.Tables(0).Rows.Count > 0 Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function DeleteHost(Optional ByVal supress As Boolean = False)
|
||||
If supress = False Then
|
||||
If MessageBox.Show("Eintrag " & Me.FQDN & " wirklich löschen?", "Hosteintrag löschen", MessageBoxButtons.OKCancel) = DialogResult.OK Then
|
||||
Dim ds As New DataSet
|
||||
Dim Slaves As String = ""
|
||||
SQL.SQL2DS("SELECT * FROM TbL_Netzwerkclients WHERE LinkedWith ='" & Me.IPAdresse & "'", ds)
|
||||
|
||||
If ds.Tables(0).Rows.Count > 0 Then
|
||||
For Each r As DataRow In ds.Tables(0).Rows
|
||||
Slaves &= r.Item("IPAdresse").ToString & vbCrLf
|
||||
Next
|
||||
|
||||
If MessageBox.Show("
|
||||
Achtung! " & vbCrLf & "Der Eintrag " & Me.FQDN & " ist ein MasterEintrag für die IP Adressen " & vbCrLf & Slaves & "
|
||||
Diese Einträge werden ebenfalls gelöscht. Fortfahren?", "Hosteintrag löschen", MessageBoxButtons.OKCancel) = DialogResult.OK Then
|
||||
SQL.DeleteSQL("TbL_Netzwerkclients", "LinkedWith = '" & Me.IPAdresse & "'")
|
||||
ElseIf DialogResult.Cancel Then
|
||||
Exit Function
|
||||
End If
|
||||
End If
|
||||
SQL.DeleteSQL("TbL_Netzwerkclients", "IPAdresse = '" & Me.IPAdresse & "'")
|
||||
Class1.RefillNW(Me.Netzwerk)
|
||||
ElseIf DialogResult.Cancel Then
|
||||
Exit Function
|
||||
End If
|
||||
Else
|
||||
SQL.DeleteSQL("TbL_Netzwerkclients", "IPAdresse = '" & Me.IPAdresse & "'")
|
||||
Class1.RefillNW(Me.Netzwerk)
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Public Function MoveHost(newip As String)
|
||||
If checkIfIPExist(newip) = False Then MsgBox("Die Adresse kann nicht verwendet werden. Bitte überprüfen.") : Return Me : Exit Function
|
||||
|
||||
Dim oldip As String = Me.IPAdresse
|
||||
Dim newhost As New Host
|
||||
newhost.gethost(newip)
|
||||
|
||||
'Get Slaves of LinkedMaster
|
||||
Dim ds As New DataSet
|
||||
SQL.SQL2DS("SELECT * FROM TbL_Netzwerkclients WHERE LinkedWith = '" & Me.IPAdresse & "'", ds)
|
||||
|
||||
'Ziel prüfen und gegebenenfalls anzeigen
|
||||
If (
|
||||
newhost.FQDN = "" And
|
||||
newhost.Modell = "" And
|
||||
newhost.TYPE = "") Then
|
||||
Else
|
||||
If MsgBox("Ziel ist bereits belegt. Anzeigen?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
|
||||
Me.gethost(newip)
|
||||
Else
|
||||
Me.gethost(oldip)
|
||||
End If
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
'If Host = LinkedMaster then Update Slaves
|
||||
If ds.Tables(0).Rows.Count > 0 Then
|
||||
SQL.UpdateSQL("TbL_Netzwerkclients", "LinkedWith = '" & newip & "'", "LinkedWith = '" & oldip & "'")
|
||||
End If
|
||||
|
||||
newhost.FQDN = Me.FQDN
|
||||
newhost.QINFO = Me.QINFO
|
||||
newhost.Seriennummer = Me.Seriennummer
|
||||
newhost.MAC = Me.MAC
|
||||
newhost.Benutzer = Me.Benutzer
|
||||
newhost.Passwort = Me.Passwort
|
||||
newhost.LINK = Me.LINK
|
||||
newhost.INFO = Me.INFO
|
||||
newhost.TYPE = Me.TYPE
|
||||
newhost.Modell = Me.Modell
|
||||
newhost.Linked = Me.Linked
|
||||
newhost.LinkedWith = Me.LinkedWith
|
||||
newhost.AddIP = Me.AddIP
|
||||
newhost.Standort = Me.Standort
|
||||
newhost.DHCP = Me.DHCP
|
||||
newhost.Firewall = Me.Firewall
|
||||
|
||||
Dim update, where As String
|
||||
getUpdateCmd(update, where, "", "", newhost.Linked, newhost)
|
||||
SQL.UpdateSQL("TbL_Netzwerkclients", update, where)
|
||||
|
||||
cFolder.FolderMove(Me.NWSTANDORT & "_" & Me.NETNAME, Me.HOST, newhost.NWSTANDORT & "_" & newhost.NETNAME, newhost.HOST)
|
||||
|
||||
Me.DeleteHost(True)
|
||||
Return newhost
|
||||
|
||||
End Function
|
||||
|
||||
Public Shared Function getSlaves(ByVal ip As String, ByRef ds As DataSet)
|
||||
|
||||
SQL.SQL2DS("SELECT IPAdresse , (NWSTANDORT + ' ' + NETNAME) as Netzwerk FROM TbL_Netzwerkclients WHERE LinkedWith = '" & ip & "'", ds)
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
79
Dokumentation/Classes/SQL.vb
Normal file
79
Dokumentation/Classes/SQL.vb
Normal file
@@ -0,0 +1,79 @@
|
||||
Imports System.Data.SqlClient
|
||||
|
||||
Public Class SQL
|
||||
|
||||
Public Shared Sub SQL2DS(ByRef selector As String, ByRef ds As DataSet)
|
||||
Dim con As New SqlConnection
|
||||
Dim cmd As New SqlCommand
|
||||
con.ConnectionString = Class1.DBConString
|
||||
cmd.Connection = con
|
||||
|
||||
Dim dataadapter As New SqlDataAdapter(selector, con)
|
||||
con.Open()
|
||||
dataadapter.Fill(ds)
|
||||
con.Close()
|
||||
End Sub
|
||||
|
||||
Public Shared Sub UpdateSQL(ByRef table As String, ByRef values As String, ByRef where As String)
|
||||
Dim con As New SqlConnection
|
||||
Dim cmd As New SqlCommand
|
||||
con.ConnectionString = Class1.DBConString
|
||||
cmd.Connection = con
|
||||
|
||||
con.Open()
|
||||
cmd.CommandText = "UPDATE " & table & " SET " & values & " WHERE " & where & ""
|
||||
cmd.ExecuteNonQuery()
|
||||
con.Close()
|
||||
End Sub
|
||||
|
||||
Public Shared Sub InsertSQL(ByRef table As String, ByRef insert As String)
|
||||
Dim con As New SqlConnection
|
||||
Dim cmd As New SqlCommand
|
||||
con.ConnectionString = Class1.DBConString
|
||||
cmd.Connection = con
|
||||
|
||||
con.Open()
|
||||
cmd.CommandText = "INSERT INTO " & table & " " & insert & ""
|
||||
cmd.ExecuteNonQuery()
|
||||
con.Close()
|
||||
End Sub
|
||||
|
||||
Public Shared Sub DeleteSQL(ByRef table As String, ByRef where As String)
|
||||
Dim con As New SqlConnection
|
||||
Dim cmd As New SqlCommand
|
||||
con.ConnectionString = Class1.DBConString
|
||||
cmd.Connection = con
|
||||
|
||||
con.Open()
|
||||
cmd.CommandText = "DELETE FROM " & table & " WHERE " & where & ""
|
||||
cmd.ExecuteNonQuery()
|
||||
con.Close()
|
||||
End Sub
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Public Class SQLVariable
|
||||
Private Text, Value As String
|
||||
Private prim As Boolean
|
||||
|
||||
Public Sub New(ByVal btext As String, ByVal bvalue As String, Optional bprim As Boolean = False)
|
||||
Me.value = bvalue
|
||||
Me.Text = btext
|
||||
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property SQLText() As String
|
||||
Get
|
||||
Return Text
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property SQLValue() As Object
|
||||
Get
|
||||
Return value
|
||||
End Get
|
||||
End Property
|
||||
|
||||
End Class
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Public Class Folder
|
||||
Public Class cFolder
|
||||
|
||||
Public Shared Function FolderMove(oldID As String, oldHost As String, newID As String, NewHost As String)
|
||||
Dim PathOld As String
|
||||
Dim PathNew As String
|
||||
@@ -13,11 +14,31 @@
|
||||
If IO.Directory.Exists(Class1.FilePath & "\" & newID) Then
|
||||
Else
|
||||
IO.Directory.CreateDirectory(Class1.FilePath & "\" & newID)
|
||||
End if
|
||||
End If
|
||||
|
||||
If IO.Directory.Exists(PathOld) Then
|
||||
IO.Directory.Move(PathOld, PathNew)
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Public Shared Function explorerstarten(ip As String)
|
||||
Dim Path, nwstandort, netname As String
|
||||
Dim host As New Host
|
||||
host.gethost(ip)
|
||||
If host.Linked = True Then
|
||||
host.gethost(host.LinkedWith)
|
||||
End If
|
||||
Class1.ip2netname(host.IPAdresse, nwstandort, netname)
|
||||
|
||||
Path = Class1.FilePath & "\" & nwstandort & "_" & netname & "\" & host.HOST
|
||||
|
||||
If IO.Directory.Exists(Path) Then
|
||||
Process.Start(Path)
|
||||
Else
|
||||
IO.Directory.CreateDirectory(Path)
|
||||
Process.Start(Path)
|
||||
End If
|
||||
'MsgBox(path)
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user