SystemUpTimeReport, ... kleinigkeiten

This commit is contained in:
ms
2020-09-22 09:43:50 +02:00
parent 4a982be285
commit 0594a02a88
5 changed files with 76 additions and 22 deletions

View File

@@ -66,12 +66,13 @@ Public Class Main
If Not ds.Tables(0).Rows.Count = 0 Then If Not ds.Tables(0).Rows.Count = 0 Then
RemoveSitzung() RemoveSitzung()
End If End If
cSQL.InsertSQL("TbL_ThinClients", "(Benutzeranmeldename, Name, TeamviewerID, LastReport, ClientName) VALUES ( cSQL.InsertSQL("TbL_ThinClients", "(Benutzeranmeldename, Name, TeamviewerID, LastReport, ClientName, SystemUpTime) VALUES (
'" & cRes.LocalUser.BenutzeranmeldeName & "', '" & cRes.LocalUser.BenutzeranmeldeName & "',
'" & cRes.LocalUser.Name & "', '" & cRes.LocalUser.Name & "',
'" & cRes.LocalTeamviewerID & "', '" & cRes.LocalTeamviewerID & "',
'" & Date.Now & "', '" & Date.Now & "',
'" & cRes.LocalUser.Hostname & "')") '" & cRes.LocalUser.Hostname & "',
'" & cRes.getuptime(True) & "')")
End Function End Function
Sub RemoveSitzung() Sub RemoveSitzung()
@@ -80,20 +81,43 @@ Public Class Main
Public Sub WoBinIch() Public Sub WoBinIch()
If Environment.UserDomainName = "VERAGOST" Then 'MsgBox(Environment.UserDomainName)
Select Case Environment.UserDomainName
Case "VERAGOST"
cboxStandort.SelectedItem = "VERAG SUB (rdpintern.verag.ag)" cboxStandort.SelectedItem = "VERAG SUB (rdpintern.verag.ag)"
LDAP = "LDAP://DC=VERAG,DC=OST,DC=DMN" LDAP = "LDAP://DC=VERAG,DC=OST,DC=DMN"
autoconnect = True autoconnect = True
autologoff = True autologoff = True
ElseIf Environment.UserDomainName = "VERAG-SBG" Then Case "VERAG-SBG"
cboxStandort.SelectedItem = "VERAG SBG (terminalsbg.verag.ag)" cboxStandort.SelectedItem = "VERAG SBG (terminalsbg.verag.ag)"
LDAP = "LDAP://DC=VERAG-SBG,DC=LOCAL" LDAP = "LDAP://DC=VERAG-SBG,DC=LOCAL"
autoconnect = True autoconnect = True
autologoff = True autologoff = True
Else Case "IMEX"
cboxStandort.SelectedItem = "VERAG SUB (rdpintern.verag.ag)"
LDAP = "LDAP://DC=IMEX,DC=LOCAL"
autoconnect = True
autologoff = True
Case Else
autoconnect = False autoconnect = False
autologoff = False autologoff = False
End If End Select
'If Environment.UserDomainName = "VERAGOST" Then
' cboxStandort.SelectedItem = "VERAG SUB (rdpintern.verag.ag)"
' LDAP = "LDAP://DC=VERAG,DC=OST,DC=DMN"
' autoconnect = True
' autologoff = True
'ElseIf Environment.UserDomainName = "VERAG-SBG" Then
' cboxStandort.SelectedItem = "VERAG SBG (terminalsbg.verag.ag)"
' LDAP = "LDAP://DC=VERAG-SBG,DC=LOCAL"
' autoconnect = True
' autologoff = True
'Else
' autoconnect = False
' autologoff = False
'End If
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 Then
autoconnect = False autoconnect = False

View File

@@ -71,7 +71,7 @@ Namespace My.Resources
End Property End Property
'''<summary> '''<summary>
''' Sucht eine lokalisierte Zeichenfolge, die 1.0.1.2 ähnelt. ''' Sucht eine lokalisierte Zeichenfolge, die 1.0.1.7 ähnelt.
'''</summary> '''</summary>
Public ReadOnly Property ProgVersion() As String Public ReadOnly Property ProgVersion() As String
Get Get

View File

@@ -122,7 +122,7 @@
<value>..\Resources\LogOff20.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\LogOff20.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="ProgVersion" xml:space="preserve"> <data name="ProgVersion" xml:space="preserve">
<value>1.0.1.2</value> <value>1.0.1.7</value>
</data> </data>
<data name="Reload20" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="Reload20" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Reload20.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\Reload20.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>

View File

@@ -16,7 +16,7 @@ Public Class cBenutzer
Property localdistinguishedName As String = "" Property localdistinguishedName As String = ""
Property suchname As String = "" Property suchname As String = ""
Property Hostname As String = "" Property Hostname As String = ""
Property SystemUpTime As String = ""
@@ -26,17 +26,41 @@ Public Class cBenutzer
userPrincipalName = System.DirectoryServices.AccountManagement.UserPrincipal.Current.UserPrincipalName userPrincipalName = System.DirectoryServices.AccountManagement.UserPrincipal.Current.UserPrincipalName
Name = System.DirectoryServices.AccountManagement.UserPrincipal.Current.Name Name = System.DirectoryServices.AccountManagement.UserPrincipal.Current.Name
Hostname = Environment.MachineName Hostname = Environment.MachineName
SystemUpTime = GetSystemUpTimeInfo()
' MsgBox(SystemUpTime)
Catch Catch
End Try End Try
Domäne = System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain.ToString Domäne = System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain.ToString
BenutzeranmeldeName = Environment.UserDomainName & "\" & Environment.UserName BenutzeranmeldeName = Environment.UserDomainName & "\" & Environment.UserName
If dcabfrage = True Then If dcabfrage = True Then
'cRes.DebugText = userPrincipalName & LDAPa 'Class1.DebugText = userPrincipalName & LDAPa
FillFromDC(userPrincipalName, "userPrincipalName", LDAPa) FillFromDC(userPrincipalName, "userPrincipalName", LDAPa)
End If End If
End Function End Function
Private Shared Function GetSystemUpTimeInfo() As String
Try
Dim time = GetSystemUpTime()
Dim upTime = String.Format("{0:D2}d-{1:D2}h:{2:D2}m", time.Days, time.Hours, time.Minutes) ':{2:D2}s:{3:D3}ms , time.Seconds, time.Milliseconds
Return String.Format("{0}", upTime)
Catch ex As Exception
'handle the exception your way
Return String.Empty
End Try
End Function
Private Shared Function GetSystemUpTime() As TimeSpan
Try
Dim uptime = New PerformanceCounter("System", "System Up Time")
uptime.NextValue
Return TimeSpan.FromSeconds(uptime.NextValue)
Catch ex As Exception
'handle the exception your way
Return New TimeSpan(0, 0, 0, 0)
End Try
End Function
Function FillFromDC(ByVal searchname As String, Optional ByVal searchfilter As String = "distinguishedName", Optional ByVal LDAP As String = "LDAP://DC=VERAG,DC=OST,DC=DMN") Function FillFromDC(ByVal searchname As String, Optional ByVal searchfilter As String = "distinguishedName", Optional ByVal LDAP As String = "LDAP://DC=VERAG,DC=OST,DC=DMN")
Try Try
localdistinguishedName = searchname localdistinguishedName = searchname

View File

@@ -7,7 +7,8 @@ Public Class cRes
Public Shared LocalUser As New cBenutzer Public Shared LocalUser As New cBenutzer
Public Shared LocalTeamviewerID As String Public Shared LocalTeamviewerID As String
Public Shared DBConString As String = "Server=buchhaltung.verag.ost.dmn\SQLEXPRESS;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;" 'Public Shared DBConString As String = "Server=buchhaltung.verag.ost.dmn\SQLEXPRESS;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
Public Shared DBConString As String = "Server=sqlcluster.verag.ost.dmn\verag;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
Public Shared DBConstringDev As String = "Server=DEVELOPER.verag.ost.dmn\DEVSQL;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;" Public Shared DBConstringDev As String = "Server=DEVELOPER.verag.ost.dmn\DEVSQL;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
Public Shared Function GetUserGroupMembership(ByVal locUsername As String, ByVal LDAP As String) As List(Of String) Public Shared Function GetUserGroupMembership(ByVal locUsername As String, ByVal LDAP As String) As List(Of String)
@@ -95,13 +96,18 @@ Public Class cRes
msgsend.Start() msgsend.Start()
End Function End Function
Public Shared Function getuptime() Public Shared Function getuptime(Optional ByVal Shorty As Boolean = False)
Dim pc As PerformanceCounter = New PerformanceCounter("System", "System Up Time") Dim pc As PerformanceCounter = New PerformanceCounter("System", "System Up Time")
pc.NextValue() ' This returns zero for a reason I don't know pc.NextValue() ' This returns zero for a reason I don't know
' This call to NextValue gets the correct value ' This call to NextValue gets the correct value
Dim ts As TimeSpan = TimeSpan.FromSeconds(pc.NextValue()) Dim ts As TimeSpan = TimeSpan.FromSeconds(pc.NextValue())
If Shorty = True Then
Dim upTime = String.Format("{0:D2}d-{1:D2}h:{2:D2}m", ts.Days, ts.Hours, ts.Minutes)
Return upTime
Exit Function
End If
Return ts.ToString() Return ts.ToString()
End Function End Function