diff --git a/TSAnmeldung/Main.Designer.vb b/TSAnmeldung/Main.Designer.vb index d1d9013..8da183d 100644 --- a/TSAnmeldung/Main.Designer.vb +++ b/TSAnmeldung/Main.Designer.vb @@ -33,10 +33,14 @@ Partial Class Main Me.TimerReport = New System.Windows.Forms.Timer(Me.components) Me.TelAnmelden = New System.Windows.Forms.Button() Me.Label1 = New System.Windows.Forms.Label() + Me.chkdebug = New System.Windows.Forms.CheckBox() + Me.Button1 = New System.Windows.Forms.Button() + Me.btnShowAnydesk = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'btnLogOFF ' + Me.btnLogOFF.BackColor = System.Drawing.Color.IndianRed Me.btnLogOFF.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.btnLogOFF.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btnLogOFF.ImageAlign = System.Drawing.ContentAlignment.MiddleRight @@ -45,10 +49,11 @@ Partial Class Main Me.btnLogOFF.Size = New System.Drawing.Size(184, 28) Me.btnLogOFF.TabIndex = 28 Me.btnLogOFF.Text = "Abmelden" - Me.btnLogOFF.UseVisualStyleBackColor = True + Me.btnLogOFF.UseVisualStyleBackColor = False ' 'btnResetSession ' + Me.btnResetSession.BackColor = System.Drawing.Color.YellowGreen Me.btnResetSession.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.btnResetSession.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btnResetSession.ImageAlign = System.Drawing.ContentAlignment.MiddleRight @@ -57,7 +62,7 @@ Partial Class Main Me.btnResetSession.Size = New System.Drawing.Size(184, 28) Me.btnResetSession.TabIndex = 29 Me.btnResetSession.Text = "Sitzung (neu) starten" - Me.btnResetSession.UseVisualStyleBackColor = True + Me.btnResetSession.UseVisualStyleBackColor = False ' 'Timer1 ' @@ -65,6 +70,7 @@ Partial Class Main ' 'btnShutdown ' + Me.btnShutdown.BackColor = System.Drawing.Color.Red Me.btnShutdown.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.btnShutdown.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btnShutdown.ImageAlign = System.Drawing.ContentAlignment.MiddleRight @@ -73,12 +79,12 @@ Partial Class Main Me.btnShutdown.Size = New System.Drawing.Size(184, 28) Me.btnShutdown.TabIndex = 31 Me.btnShutdown.Text = "Ausschalten" - Me.btnShutdown.UseVisualStyleBackColor = True + Me.btnShutdown.UseVisualStyleBackColor = False ' 'cboxStandort ' Me.cboxStandort.FormattingEnabled = True - Me.cboxStandort.Items.AddRange(New Object() {"VERAG SUB (rdpintern.verag.ag)", "VERAG SBG (terminalsbg.verag.ag)", "BACKUP", "Personalisiert"}) + Me.cboxStandort.Items.AddRange(New Object() {"VERAG SUB (rdpintern.verag.ag)", "Personalisiert"}) Me.cboxStandort.Location = New System.Drawing.Point(12, 80) Me.cboxStandort.Name = "cboxStandort" Me.cboxStandort.Size = New System.Drawing.Size(183, 21) @@ -94,6 +100,7 @@ Partial Class Main ' 'TelAnmelden ' + Me.TelAnmelden.BackColor = System.Drawing.SystemColors.ActiveCaption Me.TelAnmelden.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.TelAnmelden.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.TelAnmelden.ImageAlign = System.Drawing.ContentAlignment.MiddleRight @@ -102,24 +109,60 @@ Partial Class Main Me.TelAnmelden.Size = New System.Drawing.Size(184, 28) Me.TelAnmelden.TabIndex = 34 Me.TelAnmelden.Text = "Telefon neu anmelden" - Me.TelAnmelden.UseVisualStyleBackColor = True + Me.TelAnmelden.UseVisualStyleBackColor = False ' 'Label1 ' Me.Label1.AutoSize = True - Me.Label1.Location = New System.Drawing.Point(13, 183) + Me.Label1.Location = New System.Drawing.Point(9, 246) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(39, 13) Me.Label1.TabIndex = 35 Me.Label1.Text = "Label1" ' + 'chkdebug + ' + Me.chkdebug.AutoSize = True + Me.chkdebug.Location = New System.Drawing.Point(11, 262) + Me.chkdebug.Name = "chkdebug" + Me.chkdebug.Size = New System.Drawing.Size(58, 17) + Me.chkdebug.TabIndex = 36 + Me.chkdebug.Text = "Debug" + Me.chkdebug.UseVisualStyleBackColor = True + ' + 'Button1 + ' + Me.Button1.BackColor = System.Drawing.SystemColors.Control + Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.Button1.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Button1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight + Me.Button1.Location = New System.Drawing.Point(11, 182) + Me.Button1.Name = "Button1" + Me.Button1.Size = New System.Drawing.Size(184, 28) + Me.Button1.TabIndex = 37 + Me.Button1.Text = "Update" + Me.Button1.UseVisualStyleBackColor = False + ' + 'btnShowAnydesk + ' + Me.btnShowAnydesk.Location = New System.Drawing.Point(107, 236) + Me.btnShowAnydesk.Name = "btnShowAnydesk" + Me.btnShowAnydesk.Size = New System.Drawing.Size(75, 23) + Me.btnShowAnydesk.TabIndex = 38 + Me.btnShowAnydesk.Text = "Button2" + Me.btnShowAnydesk.UseVisualStyleBackColor = True + Me.btnShowAnydesk.Visible = False + ' 'Main ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.BackColor = System.Drawing.SystemColors.ControlLightLight - Me.ClientSize = New System.Drawing.Size(208, 214) + Me.ClientSize = New System.Drawing.Size(208, 291) Me.ControlBox = False + Me.Controls.Add(Me.btnShowAnydesk) + Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.chkdebug) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.TelAnmelden) Me.Controls.Add(Me.cboxStandort) @@ -127,7 +170,7 @@ Partial Class Main Me.Controls.Add(Me.btnResetSession) Me.Controls.Add(Me.btnLogOFF) Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) - Me.MaximumSize = New System.Drawing.Size(224, 300) + Me.MaximumSize = New System.Drawing.Size(224, 330) Me.MinimizeBox = False Me.MinimumSize = New System.Drawing.Size(224, 230) Me.Name = "Main" @@ -147,4 +190,7 @@ Partial Class Main Friend WithEvents TimerReport As Timer Friend WithEvents TelAnmelden As Button Friend WithEvents Label1 As Label + Friend WithEvents chkdebug As CheckBox + Friend WithEvents Button1 As Button + Friend WithEvents btnShowAnydesk As Button End Class diff --git a/TSAnmeldung/Main.vb b/TSAnmeldung/Main.vb index d04581c..057de74 100644 --- a/TSAnmeldung/Main.vb +++ b/TSAnmeldung/Main.vb @@ -15,6 +15,7 @@ Public Class Main Public ConType As String Public MAC As String Public ClientMode As Boolean + Public Seriennummer As String = "" Dim lastupdate As DateTime @@ -27,25 +28,27 @@ Public Class Main WoBinIch() mstsc.EnableRaisingEvents = True - Try - Dim GroupList As List(Of String) = cRes.GetUserGroupMembership(Environment.UserName, LDAP) - For Each group As String In GroupList - If group = "CN=SG_DEBUG" Then - debug = True - Timer2.Enabled = True - End If - Next - Catch ex As Exception + 'Try + ' Dim GroupList As List(Of String) = cRes.GetUserGroupMembership(Environment.UserName, LDAP) + ' For Each group As String In GroupList + ' If group = "CN=SG_DEBUG" Then + ' debug = True + ' Timer2.Enabled = True + ' End If + ' Next + 'Catch ex As Exception - End Try + 'End Try Dim i As Integer For Each s As String In Environment.GetCommandLineArgs If i > 0 Then If s = "/d" Or s = "-d" Then + debug = True autoconnect = False autologoff = False - cRes.LocalUser.FillWithLoggedOnUser(False) : Report() : TimerReport.Enabled = True + cRes.LocalUser.FillWithLoggedOnUser(False) + 'Report() : TimerReport.Enabled = True ElseIf s = "/c" Or s = "-c" Then autoconnect = False autologoff = False @@ -70,13 +73,24 @@ Public Class Main Timer1.Enabled = autoconnect 'cRes.LocalUser.FillWithLoggedOnUser(False) - cRes.LocalTeamviewerID = getTeamViewerID() - - ' Report() - Dim meh As New cPascom - meh.Anmelden() + If Not debug Then + cRes.LocalTeamviewerID = getTeamViewerID() + Seriennummer = cRes.getserialnumber() + MAC = cRes.getMacAddress() + Report() + CallmeHome() + + Dim meh As New cPascom + meh.Anmelden() + Else + MsgBox("DebugMode") + End If + + + + chkdebug.Checked = debug If ClientMode = True Then btnResetSession.PerformClick() @@ -85,21 +99,50 @@ Public Class Main Public Function Report() lastupdate = Date.Now - - Dim ds As New DataSet - cSQL.SQL2DS("select * from TbL_ThinClients where Benutzeranmeldename = '" & cRes.LocalUser.BenutzeranmeldeName & " ' ", ds) - If Not ds.Tables(0).Rows.Count = 0 Then - RemoveSitzung() - End If - cSQL.InsertSQL("TbL_ThinClients", "(Benutzeranmeldename, Name, TeamviewerID, LastReport, ClientName, Domain, Company, SystemUpTime) VALUES ( + Try + Dim ds As New DataSet + cSQL.SQL2DS("select * from TbL_ThinClients where Benutzeranmeldename = '" & cRes.LocalUser.BenutzeranmeldeName & " ' ", ds) + If Not ds.Tables(0).Rows.Count = 0 Then + RemoveSitzung() + End If + cSQL.InsertSQL("TbL_ThinClients", "(Benutzeranmeldename, Name, TeamviewerID, LastReport, ClientName, Domain, Company, AnydeskID, SystemUpTime) VALUES ( '" & cRes.LocalUser.BenutzeranmeldeName & "', '" & cRes.LocalUser.Name & "', '" & cRes.LocalTeamviewerID & "', -'" & Date.Now & "', +'" & Date.Now.ToString & "', '" & cRes.LocalUser.Hostname & "', '" & cRes.LocalUser.Domäne & "', '" & cRes.LocalUser.Company & "', +'" & GetAnyDeskID() & "', '" & cRes.getuptime(True) & "')") + Catch ex As Exception + If debug = True Then + MsgBox(ex.Message) + End If + End Try + + End Function + + Public Function CallmeHome() + Try + Dim ds As New DataSet + cSQL.SQL2DS("select * from TbL_ThinClientHosts where Seriennummer = '" & Seriennummer & " ' ", ds) + If Not ds.Tables(0).Rows.Count = 0 Then + 'Update + cSQL.UpdateSQL("TbL_ThinClientHosts", "Hostname = '" & cRes.LocalUser.Hostname & "', TeamviewerID = '" & cRes.LocalTeamviewerID & "', Domain = '" & cRes.LocalUser.Domäne & "', LastUser = '" & cRes.LocalUser.BenutzeranmeldeName & "', MAC = '" & MAC & "'", "Seriennummer = '" & Seriennummer & " ' ") + Else + 'Erstellen + cSQL.InsertSQL("TbL_ThinClientHosts", "(Hostname, Seriennummer, TeamviewerID, Domain, LastUser, MAC) VALUES ( +'" & cRes.LocalUser.Hostname & "', +'" & Seriennummer & "', +'" & cRes.LocalTeamviewerID & "', +'" & cRes.LocalUser.Domäne & "', +'" & cRes.LocalUser.BenutzeranmeldeName & "', +'" & MAC & "')") + End If + Catch ex As Exception + MsgBox(ex.Message) + End Try End Function Sub RemoveSitzung() @@ -116,11 +159,6 @@ Public Class Main LDAP = "LDAP://DC=VERAG,DC=OST,DC=DMN" autoconnect = True autologoff = True - Case "VERAG-SBG" - cboxStandort.SelectedItem = "VERAG SBG (terminalsbg.verag.ag)" - LDAP = "LDAP://DC=VERAG-SBG,DC=LOCAL" - autoconnect = True - autologoff = True Case "IMEX" cboxStandort.SelectedItem = "VERAG SUB (rdpintern.verag.ag)" LDAP = "LDAP://DC=IMEX,DC=LOCAL" @@ -151,11 +189,14 @@ Public Class Main Me.ControlBox = True End If - If Not LoadParameters(Environment.UserName, ConType, ConString) = False Then - cboxStandort.SelectedItem = "Personalisiert" - 'ConString = LoadParameters(Environment.UserName) + If Not debug Then + If Not LoadParameters(Environment.UserName, ConType, ConString) = False Then + cboxStandort.SelectedItem = "Personalisiert" + 'ConString = LoadParameters(Environment.UserName) + End If End If + 'Select Case Environment.UserName ' Case "miesenbeck" ' cboxStandort.SelectedItem = "Personalisiert" @@ -279,7 +320,10 @@ Public Class Main End Sub Private Sub Main_Closed(sender As Object, e As EventArgs) Handles Me.Closed - LogOff() + If debug = False Then + LogOff() + End If + End Sub Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick @@ -288,7 +332,7 @@ Public Class Main Public Sub LogOff() RemoveSitzung() - If sAppPath Like "*\bin\Debug" Or Environment.UserName = "miesenbeck" Or Environment.UserName = "Administrator" Or autologoff = False Then + If sAppPath Like "*\bin\Debug" Or Environment.UserName = "miesenbeck" Or Environment.UserName = "Administrator" Or autologoff = False Or debug = True Then Me.ControlBox = True Else Try @@ -317,7 +361,7 @@ Public Class Main Public Function LoadParameters(ByVal Benutzername As String, ByRef _ConType As String, ByRef _ConString As String) Try - Dim lines = IO.File.ReadAllLines("\\dc01.verag.ost.dmn\NETLOGON\TSAnmeldung.ini") + Dim lines = IO.File.ReadAllLines("\\verag.ost.dmn\NETLOGON\TSAnmeldung.ini") Dim colCount = lines.First.Split(";"c).Length For Each line In lines @@ -355,6 +399,14 @@ Public Class Main 'End If End Sub + Private Sub chkdebug_CheckedChanged(sender As Object, e As EventArgs) Handles chkdebug.CheckedChanged + debug = chkdebug.Checked + End Sub + + Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click + Process.Start("C:\Verag\ROBO_2_C_Verag.bat") + 'CallmeHome() + End Sub Function getTeamViewerID() Dim Reg As String = Nothing @@ -375,4 +427,36 @@ Public Class Main End Function + + Private Sub btnShowAnydesk_Click(sender As Object, e As EventArgs) Handles btnShowAnydesk.Click + Report() + End Sub + + Public Function GetAnyDeskID() As String + Try + ' Erstelle den Prozessstart-Info + Dim startInfo As New ProcessStartInfo() + startInfo.FileName = "cmd.exe" + startInfo.Arguments = "/C ""C:\Verag\AnyDeskClient-Portable.exe"" --get-id" + startInfo.RedirectStandardOutput = True + startInfo.UseShellExecute = False + startInfo.CreateNoWindow = True + + ' Starte den Prozess + Dim process As Process = Process.Start(startInfo) + + ' Lese die Ausgabe des Befehls + Dim output As String = process.StandardOutput.ReadToEnd() + process.WaitForExit() + + ' Bereinige und gebe die ID zurück + output = output.Trim() + Return output + + Catch ex As Exception + ' Fehlerbehandlung + Return "Fehler beim Abrufen der AnyDesk-ID: " & ex.Message + End Try + End Function + End Class diff --git a/TSAnmeldung/My Project/Resources.Designer.vb b/TSAnmeldung/My Project/Resources.Designer.vb index b455779..17aaf1e 100644 --- a/TSAnmeldung/My Project/Resources.Designer.vb +++ b/TSAnmeldung/My Project/Resources.Designer.vb @@ -81,7 +81,7 @@ Namespace My.Resources End Property ''' - ''' Sucht eine lokalisierte Zeichenfolge, die 1.1.0.0 ähnelt. + ''' Sucht eine lokalisierte Zeichenfolge, die 1.2.2.1 ähnelt. ''' Public ReadOnly Property ProgVersion() As String Get diff --git a/TSAnmeldung/My Project/Resources.resx b/TSAnmeldung/My Project/Resources.resx index c85c2bd..7bdaea9 100644 --- a/TSAnmeldung/My Project/Resources.resx +++ b/TSAnmeldung/My Project/Resources.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 1.1.0.0 + 1.2.2.1 diff --git a/TSAnmeldung/cBenutzer.vb b/TSAnmeldung/cBenutzer.vb index a77d05b..c4ba85f 100644 --- a/TSAnmeldung/cBenutzer.vb +++ b/TSAnmeldung/cBenutzer.vb @@ -29,7 +29,8 @@ Public Class cBenutzer Hostname = Environment.MachineName SystemUpTime = GetSystemUpTimeInfo() ' MsgBox(SystemUpTime) - Catch + Catch ex As Exception + MsgBox("FillWithLoggedOnUser" & ex.Message) End Try Domäne = System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain.ToString BenutzeranmeldeName = Environment.UserDomainName & "\" & Environment.UserName diff --git a/TSAnmeldung/cChilkat_Helper.vb b/TSAnmeldung/cChilkat_Helper.vb index d6ec367..d0be751 100644 --- a/TSAnmeldung/cChilkat_Helper.vb +++ b/TSAnmeldung/cChilkat_Helper.vb @@ -6,7 +6,8 @@ Public Class cChilkat_Helper Public Shared Sub UnlockCilkat() Dim glob As Chilkat.[Global] = New Chilkat.[Global]() - Dim success As Boolean = glob.UnlockBundle("VERAGS.CB1122022_JJ6kgS2zoR0g") + 'Dim success As Boolean = glob.UnlockBundle("VERAGS.CB1122022_JJ6kgS2zoR0g") + Dim success As Boolean = glob.UnlockBundle("LUXBAU.CB1112026_zH49BXhFm802") If success <> True Then Debug.WriteLine(glob.LastErrorText) diff --git a/TSAnmeldung/cPascom.vb b/TSAnmeldung/cPascom.vb index 5c86869..ab8ee21 100644 --- a/TSAnmeldung/cPascom.vb +++ b/TSAnmeldung/cPascom.vb @@ -29,7 +29,8 @@ Public Class cPascom 'BASIC Auth String: bW9ieTpYZ0RzRm1NU3V0YU1MQTE = cChilkat_Helper.UnlockCilkat() - Dim API_STRING = "pbx3.flashnet.at" + ' Dim API_STRING = "pbx3.flashnet.at" + Dim API_STRING = TelUrl Dim rest As New Chilkat.Rest Dim success As Boolean @@ -117,7 +118,7 @@ Public Class cPascom Public Function GetTelArbeitsplatz4Host() As Boolean Try - Dim lines = IO.File.ReadAllLines("\\dc01.verag.ost.dmn\NETLOGON\Telefonarbeitsplaetze.ini") + Dim lines = IO.File.ReadAllLines("\\verag.ost.dmn\NETLOGON\Telefonarbeitsplaetze.ini") Dim colCount = lines.First.Split(";"c).Length For Each line In lines diff --git a/TSAnmeldung/cRes.vb b/TSAnmeldung/cRes.vb index 8e6b1d8..d8063e6 100644 --- a/TSAnmeldung/cRes.vb +++ b/TSAnmeldung/cRes.vb @@ -1,6 +1,7 @@ Imports System.IO Imports System.Net.Sockets Imports System.Diagnostics.Process +Imports System.Net.NetworkInformation Public Class cRes @@ -61,21 +62,21 @@ Public Class cRes 'sOutput = Date.Now & " : " & sOutputLine(sOutputLine.Count - 1).ToString() End Using sw.WriteLine(sOutput) - sw.Close() - Catch meh As Exception - sw.WriteLine(Date.Now & ": Fehler beim Ausfuehren des Prozesses: " & meh.Message) - sw.Close() - End Try + sw.Close() + Catch meh As Exception + sw.WriteLine(Date.Now & ": Fehler beim Ausfuehren des Prozesses: " & meh.Message) + sw.Close() + End Try - Dim lineCount = File.ReadAllLines(speicherort).Length - If lineCount > 2048 Then - Dim lines As List(Of String) = File.ReadAllLines(speicherort).ToList - lines.RemoveRange(0, 8) - File.WriteAllLines(speicherort, lines) - End If + Dim lineCount = File.ReadAllLines(speicherort).Length + If lineCount > 2048 Then + Dim lines As List(Of String) = File.ReadAllLines(speicherort).ToList + lines.RemoveRange(0, 8) + File.WriteAllLines(speicherort, lines) + End If - End Using + End Using ' MsgBox("Hier") Catch ex As Exception End Try @@ -152,5 +153,21 @@ Public Class cRes End Function + Public Shared Function getserialnumber() As String + Dim colItems As New Object + Dim sn As String = "" + colItems = (GetObject("winmgmts:\\.\root\cimv2")).ExecQuery("Select * from Win32_Bios") + For Each objItem In colItems + 'MsgBox("Seriennummer: " & objItem.SerialNumber) + sn = objItem.SerialNumber + Next + Return sn + End Function + + Public Shared Function getMacAddress() As String + Dim nics() As NetworkInterface = NetworkInterface.GetAllNetworkInterfaces() + Return nics(1).GetPhysicalAddress.ToString + End Function + End Class