[829] | 1 | unit fXWBOnFail;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses
|
---|
| 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
| 7 | StdCtrls, Trpcb, Rpcconf1, ExtCtrls, frmVistAAbout, Menus;
|
---|
| 8 |
|
---|
| 9 | type
|
---|
| 10 | TfrmXWBOnFail = class(TForm)
|
---|
| 11 | btnConnect: TButton;
|
---|
| 12 | RPCB: TRPCBroker;
|
---|
| 13 | rgrSelectAction: TRadioGroup;
|
---|
| 14 | btnExit: TButton;
|
---|
| 15 | Memo1: TMemo;
|
---|
| 16 | edtErrorText: TEdit;
|
---|
| 17 | edtLoginError: TEdit;
|
---|
| 18 | lblLogin_ErrorText: TLabel;
|
---|
| 19 | cbxBadAccess: TCheckBox;
|
---|
| 20 | MainMenu1: TMainMenu;
|
---|
| 21 | File1: TMenuItem;
|
---|
| 22 | Exit1: TMenuItem;
|
---|
| 23 | Help1: TMenuItem;
|
---|
| 24 | About1: TMenuItem;
|
---|
| 25 | procedure btnConnectClick(Sender: TObject);
|
---|
| 26 | procedure btnExitClick(Sender: TObject);
|
---|
| 27 | procedure FormCreate(Sender: TObject);
|
---|
| 28 | procedure Exit1Click(Sender: TObject);
|
---|
| 29 | procedure About1Click(Sender: TObject);
|
---|
| 30 | private
|
---|
| 31 | { Private declarations }
|
---|
| 32 | public
|
---|
| 33 | { Public declarations }
|
---|
| 34 | procedure MyErrorHandler(RPCBroker: TRPCBroker);
|
---|
| 35 | end;
|
---|
| 36 |
|
---|
| 37 | var
|
---|
| 38 | frmXWBOnFail: TfrmXWBOnFail;
|
---|
| 39 |
|
---|
| 40 | implementation
|
---|
| 41 |
|
---|
| 42 | {$R *.DFM}
|
---|
| 43 |
|
---|
| 44 | procedure TfrmXWBOnFail.MyErrorHandler(RPCBroker: TRPCBroker);
|
---|
| 45 | var
|
---|
| 46 | ErrorText: String;
|
---|
| 47 | Path: String;
|
---|
| 48 | StrLoc: TStringList;
|
---|
| 49 | NowVal: TDateTime;
|
---|
| 50 | begin
|
---|
| 51 | NowVal := Now;
|
---|
| 52 | ErrorText := RPCB.RPCBError;
|
---|
| 53 | StrLoc := TStringList.Create;
|
---|
| 54 | Path := ExtractFilePath(Application.ExeName);
|
---|
| 55 | Path := Path + 'Error.Log';
|
---|
| 56 | if FileExists(Path) then
|
---|
| 57 | StrLoc.LoadFromFile(Path);
|
---|
| 58 | StrLoc.Add(FormatDateTime('mm/dd/yyyy hh:mm:ss ',NowVal) + ErrorText);
|
---|
| 59 | StrLoc.SaveToFile(Path);
|
---|
| 60 | end;
|
---|
| 61 |
|
---|
| 62 | procedure TfrmXWBOnFail.btnConnectClick(Sender: TObject);
|
---|
| 63 | begin
|
---|
| 64 | if btnConnect.Caption = 'Connect' then
|
---|
| 65 | begin
|
---|
| 66 | edtErrorText.Text := ''; // Clear out old values
|
---|
| 67 | edtLoginError.Text := '';
|
---|
| 68 | RPCB.AccessVerifyCodes := '';
|
---|
| 69 | RPCB.KernelLogIn := True;
|
---|
| 70 | if cbxBadAccess.Checked then
|
---|
| 71 | RPCB.AccessVerifyCodes := 'monkeysee;monkeydo';
|
---|
| 72 | RPCB.OnRPCBFailure := nil;
|
---|
| 73 | RPCB.ShowErrorMsgs := semRaise;
|
---|
| 74 | case rgrSelectAction.ItemIndex of //
|
---|
| 75 | 0: RPCB.OnRPCBFailure := MyErrorHandler;
|
---|
| 76 | 1: RPCB.ShowErrorMsgs := semRaise;
|
---|
| 77 | 2: RPCB.ShowErrorMsgs := semQuiet;
|
---|
| 78 | end; // case
|
---|
| 79 | try
|
---|
| 80 | RPCB.Connected := True;
|
---|
| 81 | if RPCB.Connected then
|
---|
| 82 | btnConnect.Caption := 'Disconnect';
|
---|
| 83 | finally
|
---|
| 84 | edtErrorText.Text := RPCB.RPCBError;
|
---|
| 85 | edtLoginError.Text := RPCB.LogIn.ErrorText;
|
---|
| 86 | end;
|
---|
| 87 | end
|
---|
| 88 | else
|
---|
| 89 | begin
|
---|
| 90 | RPCB.Connected := False;
|
---|
| 91 | btnConnect.Caption := 'Connect';
|
---|
| 92 | end;
|
---|
| 93 | end;
|
---|
| 94 |
|
---|
| 95 | procedure TfrmXWBOnFail.btnExitClick(Sender: TObject);
|
---|
| 96 | begin
|
---|
| 97 | halt;
|
---|
| 98 | end;
|
---|
| 99 |
|
---|
| 100 | procedure TfrmXWBOnFail.FormCreate(Sender: TObject);
|
---|
| 101 | var
|
---|
| 102 | Server: String;
|
---|
| 103 | Port: String;
|
---|
| 104 | begin
|
---|
| 105 | GetServerInfo(Server, Port);
|
---|
| 106 | RPCB.Server := Server;
|
---|
| 107 | RPCB.ListenerPort := StrToInt(Port);
|
---|
| 108 | end;
|
---|
| 109 |
|
---|
| 110 | procedure TfrmXWBOnFail.Exit1Click(Sender: TObject);
|
---|
| 111 | begin
|
---|
| 112 | Halt;
|
---|
| 113 | end;
|
---|
| 114 |
|
---|
| 115 | procedure TfrmXWBOnFail.About1Click(Sender: TObject);
|
---|
| 116 | begin
|
---|
| 117 | ShowAboutBox;
|
---|
| 118 | end;
|
---|
| 119 |
|
---|
| 120 | end.
|
---|