CRT Error
-
- Posts: 17
- Joined: Mon Mar 31, 2014 6:47 pm
CRT Error
Imports System.Windows.Forms
Imports System
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.DateandTime
Imports System.IO
Imports System.Net
Imports System.Text
Imports DevExpress.Utils
Public Class UserScript
Implements CMLibrary.IWebScript
Dim Web as CMLibrary.IBrowser
Dim result as Object
Dim message as String
Dim warning as String
Dim errormsg as String
Public Sub Initialize(ByVal browser As CMLibrary.IBrowser) Implements CMLibrary.IWebScript.Initialize
Me.Web=browser
End Sub
Public Sub RunScript(ByVal scriptName As String, ByVal parms As System.Collections.ArrayList) Implements CMLibrary.IWebScript.RunScript
result = Nothing
message = ""
warning = ""
errorMsg = ""
Select Case scriptName
Case "W46e2238eb67f44aca23f9b75e83d1cde"
W46e2238eb67f44aca23f9b75e83d1cde(parms)
End Select
Web.Result.Result = result
Web.Result.Message = message
Web.Result.Warning = warning
Web.Result.ErrorMsg = errormsg
End Sub
Public Sub W46e2238eb67f44aca23f9b75e83d1cde(parms As System.Collections.ArrayList)
' -->
Dim Comm_Session_UserID1 As String = ""
Try
Comm_Session_UserID1 = CStr(parms(0))
Catch ex As System.Exception
End Try
Dim Comm_Session_Password1 As String = ""
Try
Comm_Session_Password1 = CStr(parms(1))
Catch ex As System.Exception
End Try
Dim Comm_Session_UserID2 As String = ""
Try
Comm_Session_UserID2 = CStr(parms(2))
Catch ex As System.Exception
End Try
Dim Comm_Session_Password2 As String = ""
Try
Comm_Session_Password2 = CStr(parms(3))
Catch ex As System.Exception
End Try
Dim Comm_Receiver_Name As String = ""
Try
Comm_Receiver_Name = CStr(parms(4))
Catch ex As System.Exception
End Try
Try
Dim Username As String
Username = Comm_Session_UserID1
Dim Password As String
Password = Comm_Session_Password1
Dim ChangePassword As String
ChangePassword = Comm_Session_UserID2
Dim OldPassword As String
OldPassword = Comm_Session_Password2
Dim LogonPrompt As String
LogonPrompt = "LOGIN:"
Dim PasswordPrompt As String
PasswordPrompt = "PASSWORD:"
Dim PasswordChangeWarningPrompt As String
PasswordChangeWarningPrompt = "!!!"
Dim PasswordChangePrompt As String
PasswordChangePrompt = "!!!"
Dim NewPasswordPrompt As String
NewPasswordPrompt = "ew password"
Dim PasswordChangeConfirmPrompt As String
PasswordChangeConfirmPrompt = "firm"
Dim PasswordChangeSuccessful As String
PasswordChangeSuccessful = "updated"
Dim TempPassword As String
Dim MainMenuPrompt As String
MainMenuPrompt = "SELECTION ==>"
'Dim AfterLogOnPrompt As String
' AfterLogOnPrompt = "to continue ->"
'Dim UpLoadPrompt As String
' UpLoadPrompt = "Starting zmodem transfer."
'Dim ProtocolPrompt As String
' ProtocolPrompt = "SELECTION:"
Dim ReportsMenuPrompt As String
ReportsMenuPrompt= "select it"
dim DownLoadPrompt As String
DownLoadPrompt = "Y/N"
Dim DownLoadPrompt1 As String
DownLoadPrompt1 = "SS.."
Dim NoFilesPrompt As String
NoFilesPrompt = "UE.."
Dim TransferCompletePrompt As String
TransferCompletePrompt = "SELECTION ==>"
Dim ReceiveCompletePrompt As String
ReceiveCompletePrompt = "SELECTION ==>"
Dim lStr As String
lStr=""
Dim msg as string = ""
dim dlgResult as dialogresult
'************************************************************
'* Make the connection
'************************************************************
crt.startprocess(1)
crt.connect
CRT.UploadSucceeded(False)
do while not crt.IsConnected
crt.connect
If not crt.IsConnected Then
msg = Comm_Receiver_Name & " did not answer!" & vbLf & vblf _
& "Would you like to try again?"
dlgResult = crt.msgbox( msg, "No Answer",4 )
if dlgResult <> DialogResult.Yes then ' quit and go home!
ErrorMsg = "No Answer!"
Crt.Disconnect
Result = False
exit sub
end if
End IF
loop ' while trying to connect
crt.finishprocess(1,crt.isconnected)
'************************************************************
'* Generate New Password
'************************************************************
CRT.PassGen.AllowRepeating = False
CRT.PassGen.Size = (8)
CRT.PassGen.IncludeUpper = True
CRT.PassGen.IncludeLower = False
CRT.PassGen.IncludeNumbers = True
CRT.PassGen.IncludeSymbols = False
CRT.PassGen.RequireUpperLower = False
'CRT.PassGen.ExclusionSet = "*"
CRT.PassGen.RequireSymbol = False
TempPassword = CRT.PassGen.Generate()
'************************************************************
'* Log In
'************************************************************
If not CRT.WaitForString( LogonPrompt ,40 ) then ' no password
msg = Comm_Receiver_Name & " didn't ask for Logon!"
dlgResult = crt.msgbox( msg, "No Logon Prompt" )
Result=False
crt.FinishProcess(2,False)
CRT.Disconnect
Exit Sub
end If
crt.wait(2)
CRT.WriteLine( Username )
if not CRT.WaitForString( PasswordPrompt ,30 ) then ' no password
msg = Comm_Receiver_Name & " didn't ask for password!"
dlgResult = crt.msgbox( msg, "No Password" )
Result=False
crt.FinishProcess(2,False)
CRT.Disconnect
Exit sub
end If
crt.wait(2)
CRT.WriteLine( Password )
CRT.WaitItems.Clear
CRT.WaitItems.Add( PasswordChangeWarningPrompt )
CRT.WaitItems.Add( MainMenuPrompt )
Select Case CRT.WaitForItems(30)
Case 1 ' The password needs to be changed
crt.wait(2)
CRT.WriteLine( Password )' Sends the current password
If not CRT.WaitForString( NewPasswordPrompt ,30 ) then ' no password
msg = Comm_Receiver_Name & " failed to get the password change prompt!"
dlgResult = crt.msgbox( msg, "No Password" )
Result=False
crt.FinishProcess(2,False)
CRT.Disconnect
Exit sub
end If
crt.wait(2)
CRT.WriteLine( TempPassword ) ' Sends the new password
If not CRT.WaitForString( PasswordChangeConfirmPrompt ,30 ) then ' no password
msg = Comm_Receiver_Name & " failed to get confirm new password prompt!"
dlgResult = crt.msgbox( msg, "No Password" )
Result=False
crt.FinishProcess(2,False)
CRT.Disconnect
Exit sub
end If
crt.wait(2)
CRT.WriteLine( TempPassword ) ' Sends the new password again
If not CRT.WaitForString( PasswordChangeSuccessful ,30 ) then ' no password
msg = Comm_Receiver_Name & " failed to change password!"
dlgResult = crt.msgbox( msg, "No Password" )
Result=False
crt.FinishProcess(2,False)
CRT.Disconnect
Exit sub
end If
'Saves the password and continues to Main Menu
CRT.SavePassword( "Password2", "Old Password = " + Password )
CRT.SavePassword( "Password1", TempPassword )
crt.FinishProcess(2,True)
Case 2 ' The password was is valid. Now At the Main Menu Prompt
crt.FinishProcess(2,True)
'crt.msgbox("Got the Main Menu!")
Case Else ' timeout!
msg = Comm_Receiver_Name & " Failed to Login!"
dlgResult = crt.msgbox( msg, "Login Failed" )
Result=False
CRT.Disconnect
crt.finishprocess(2,False)
Exit Sub
End Select
'************************************************************
'* Send Claims
'************************************************************
crt.wait(2)
crt.startprocess(3)
CRT.WriteLine( "xs") ' Sends a "xs" to go to the Upload Claims
crt.wait(2)
crt.SendFile() ' Send the Claim File
If not CRT.WaitForString( MainMenuPrompt ,40 ) then
msg = Comm_Receiver_Name & " Failed to Send Claim File!"
dlgResult = crt.msgbox( msg, "Transmission Failed" )
Result=False
CRT.Disconnect
crt.finishprocess(3,False)
CRT.UploadSucceeded(False)
exit sub
end If
CRT.UploadSucceeded(True)
crt.finishprocess(3,True)
'************************************************************
'* Retrieve Reports - Acknowledgement reports - XR
'************************************************************
crt.wait(3)
crt.startprocess(4)
CRT.WriteLine( "xr" ) ' Sends xack get XR reports
If not CRT.WaitForString( MainMenuPrompt ,40 ) then ' Download the file
crt.wait(2)
CRT.ReceiveFile(1)
If not CRT.WaitForString( MainMenuPrompt ,20 ) then '
msg = Comm_Receiver_Name & " Failed to get Main Menu Prompt After Confirmation Reports!"
dlgResult = crt.msgbox( msg, "After Confirmation Reports" )
Result=False
exit sub
end if
Else
'Moving on to the Main Menu no Confirmation Reports!
End If
'************************************************************
'* Retrieve Reports - Acknowledgement reports - ACK
'************************************************************
crt.wait(3)
CRT.WriteLine( "xack" ) ' Sends xack get 997 reports
If not CRT.WaitForString( MainMenuPrompt ,10 ) then ' Download the file
crt.wait(2)
CRT.ReceiveFile(1)
If not CRT.WaitForString( MainMenuPrompt ,20 ) then '
msg = Comm_Receiver_Name & " Failed to get Main Menu Prompt After XACK Reports!"
dlgResult = crt.msgbox( msg, "After XACK Reports" )
Result=False
exit sub
end if
Else
'Moving on to the Main Menu no Confirmation Reports!
End If
'************************************************************
'* Retrieve Reports - Acknowledgement reports - X277
'************************************************************
crt.wait(3)
CRT.WriteLine( "x277" ) ' Sends xack get 277 reports
If not CRT.WaitForString( MainMenuPrompt ,10 ) then ' Download the file
crt.wait(2)
CRT.ReceiveFile(1)
If not CRT.WaitForString( MainMenuPrompt ,20 ) then '
msg = Comm_Receiver_Name & " Failed to get Main Menu Prompt After X277 Reports!"
dlgResult = crt.msgbox( msg, "After X277 Reports" )
Result=False
exit sub
end if
Else
'Moving on to the Main Menu no Confirmation Reports!
End If
'************************************************************
'* Retrieve Reports - Acknowledgement reports - X271
'************************************************************
crt.wait(3)
CRT.WriteLine( "x271" ) ' Sends xack get 271 reports
If not CRT.WaitForString( MainMenuPrompt ,10 ) then ' Download the file
crt.wait(2)
CRT.ReceiveFile(1)
If not CRT.WaitForString( MainMenuPrompt ,20 ) then '
msg = Comm_Receiver_Name & " Failed to get Main Menu Prompt After X271 Reports!"
dlgResult = crt.msgbox( msg, "After X271 Reports" )
Result=False
exit sub
end if
Else
'Moving on to the Main Menu no Confirmation Reports!
End If
'*******************************************************************************
'* Retrieve Reports - MCS Edit Reports
'*******************************************************************************
crt.wait(2)
CRT.WriteLine( "A" ) ' Sends an A to get MCS Edit reports
if not CRT.WaitForString( DownLoadPrompt ,30 ) then ' Failed to get the Download Prompt!
msg = Comm_Receiver_Name & " Failed to get to Download Prompt!"
dlgResult = crt.msgbox( msg, "Unable to Get MCS Edit Reports" )
exit sub
end If
crt.wait(2)
crt.write("Y") 'sends a Y to start the download
If not CRT.WaitForString( NoFilesPrompt ,10 ) then ' Download the file
crt.wait(2)
CRT.ReceiveFile(1)
Else
CRT.WriteLine("") ' Send a CR to get to the main menu
End If
If not CRT.WaitForString( MainMenuPrompt ,20 ) then '
msg = Comm_Receiver_Name & " Failed to get Main Menu Prompt After MCS Edit Reports!"
dlgResult = crt.msgbox( msg, "After MCS Edit Reports" )
Result=False
exit sub
end if
crt.finishprocess(4,True)
crt.startprocess(5)
crt.wait(3)
crt.finishprocess(5,True)
crt.wait(3)
crt.startprocess(6)
crt.wait(3)
CRT.Disconnect
crt.finishprocess(6,true)
'CRT.exit
exit sub
Catch ex As System.Exception
result = Nothing
errorMsg = ex.message
End Try
End Sub
End Class
- Gavin Walker
- Posts: 4626
- Joined: Wed Apr 04, 2007 10:11 pm
- Location: Springfield, MO
- Contact:
Re: CRT Error
Walker Tek Solutions, LLC
417-890-6777 x0
fax: 417-763-6386
-
- Posts: 17
- Joined: Mon Mar 31, 2014 6:47 pm
Re: CRT Error
- Gavin Walker
- Posts: 4626
- Joined: Wed Apr 04, 2007 10:11 pm
- Location: Springfield, MO
- Contact: