neu
This commit is contained in:
145
Aviso/WLAN/cWLANTicket.vb
Normal file
145
Aviso/WLAN/cWLANTicket.vb
Normal file
@@ -0,0 +1,145 @@
|
||||
|
||||
Imports System.IO
|
||||
|
||||
Class sWLANTicket
|
||||
|
||||
|
||||
Public Shared Function printTicket(Optional AVISO As VERAG_PROG_ALLGEMEIN.cAviso = Nothing) As Boolean
|
||||
Dim usr As String = ""
|
||||
Dim pwd As String = ""
|
||||
If genTicket(usr, pwd) Then
|
||||
|
||||
Dim rpt As New rptWLANTicket()
|
||||
|
||||
rpt.TextBox4.Text = Now.ToShortDateString & " " & Now.ToShortTimeString
|
||||
rpt.TextBox9.Text = Now.AddHours(24).ToShortDateString & " " & Now.AddHours(24).ToShortTimeString
|
||||
rpt.TextBox1.Text = usr
|
||||
rpt.TextBox5.Text = pwd
|
||||
rpt.TextBox11.Text = "FrontOffice_Guest"
|
||||
|
||||
If AVISO IsNot Nothing Then
|
||||
rpt.TextBox13.Text = AVISO.LKW_Nr
|
||||
rpt.TextBox15.Text = AVISO.Frächter
|
||||
End If
|
||||
|
||||
Dim printer = SDL.cProgramFunctions.getDruckernameBySearch("INFO", True)
|
||||
If printer = "" Then printer = SDL.cProgramFunctions.getDruckernameBySearch("EPSON", True)
|
||||
If printer <> "" Then
|
||||
SDL.cProgramFunctions.printRpt(rpt, printer, True)
|
||||
Else
|
||||
SDL.cProgramFunctions.showRpt(rpt, "AVISO", False)
|
||||
End If
|
||||
|
||||
Return True
|
||||
End If
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Public Shared Function genTicket(Optional ByRef user As String = "", Optional ByRef pwd As String = "") As Boolean
|
||||
'Dim a, b As String
|
||||
user = UsernamePasswordGenerator("u")
|
||||
pwd = UsernamePasswordGenerator("p")
|
||||
Return AddGastWLANUser(user, pwd)
|
||||
' MsgBox(a & vbCrLf & b)
|
||||
End Function
|
||||
|
||||
Public Shared Function UsernamePasswordGenerator(x As String, Optional ByVal Zeichenanzahl As Integer = 6) As String ' wenn u dann Username, sonst Password
|
||||
Dim str As String
|
||||
Dim up As String
|
||||
If x = "u" Then
|
||||
str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
Else
|
||||
str = "0123456789"
|
||||
End If
|
||||
|
||||
Dim r As New Random
|
||||
For i As Integer = 0 To Zeichenanzahl - 1
|
||||
up &= str(r.Next(0, str.Length)).ToString
|
||||
Next
|
||||
|
||||
Return up
|
||||
'MsgBox(up)
|
||||
|
||||
End Function
|
||||
|
||||
Public Shared Function AddGastWLANUser(Username As String, Optional ByVal Password As String = "verag1", Optional ByVal Zugangsdaten As String = "WLANAdmin@192.168.0.97 -pw 6a0D5Ys93uugLi3uVciV", Optional ByVal AblaufZeit As Integer = 2)
|
||||
Try
|
||||
If Not File.Exists(Application.StartupPath & "\Resources\WLAN\AddWLANUser.bat") Then File.Create(Application.StartupPath & "\Resources\WLAN\AddWLANUser.bat")
|
||||
Dim AddWLANUser As String = Application.StartupPath & "\Resources\WLAN\AddWLANUser.bat"
|
||||
Dim exptime As String = Date.Now.AddHours(AblaufZeit).ToString("yyyy-MM-dd HH:mm")
|
||||
Dim battext As String = ""
|
||||
battext = "(
|
||||
echo configure terminal
|
||||
echo dynamic-guest username " & Username & "
|
||||
echo password " & Password & "
|
||||
echo expire-time " & exptime & "
|
||||
echo group Fahrer_Gruppe
|
||||
|
||||
echo exit
|
||||
echo exit
|
||||
echo exit
|
||||
) | plink -ssh " & Zugangsdaten & "
|
||||
exit"
|
||||
|
||||
WriteToFile(AddWLANUser, battext)
|
||||
Threading.Thread.Sleep(1500)
|
||||
|
||||
Dim Add As New Process
|
||||
Add.StartInfo.FileName = Application.StartupPath & "\Resources\WLAN\RunNHide.exe"
|
||||
Add.StartInfo.Arguments = AddWLANUser
|
||||
Add.Start()
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message & ex.StackTrace)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
Public Shared Function DeleteGastWLANUser(Username As String, Optional ByVal Zugangsdaten As String = "WLANAdmin@192.168.0.97 -pw 6a0D5Ys93uugLi3uVciV")
|
||||
Try
|
||||
|
||||
If Not File.Exists(Application.StartupPath & "\Resources\WLAN\DELWLANUser.bat") Then File.Create(Application.StartupPath & "\Resources\WLAN\DELWLANUser.bat")
|
||||
Dim DELWLANUser As String = Application.StartupPath & "\Resources\WLAN\DELWLANUser.bat"
|
||||
Dim battext As String = ""
|
||||
battext = "(
|
||||
echo configure terminal
|
||||
|
||||
echo no dynamic-guest " & Username & "
|
||||
|
||||
|
||||
echo exit
|
||||
echo exit
|
||||
echo exit
|
||||
) | plink -ssh " & Zugangsdaten & "
|
||||
exit"
|
||||
|
||||
WriteToFile(DELWLANUser, battext)
|
||||
Threading.Thread.Sleep(1500)
|
||||
|
||||
Dim del As New Process
|
||||
del.StartInfo.FileName = Application.StartupPath & "\Resources\WLAN\RunNHide.exe"
|
||||
del.StartInfo.Arguments = DELWLANUser
|
||||
del.Start()
|
||||
|
||||
'Process.Start(Application.StartupPath & "\RunNHide.exe " & DELWLANUser)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message & ex.StackTrace)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Shared Function WriteToFile(filepath As String, texttowrite As String)
|
||||
Try
|
||||
Dim objWriter As New System.IO.StreamWriter(filepath)
|
||||
objWriter.Write(texttowrite)
|
||||
objWriter.Close()
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
MsgBox(filepath & vbCrLf & " konnte nicht geschrieben werden." & vbCrLf & ex.Message)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user