[476] | 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 | SharedRPCBroker;
|
---|
| 9 |
|
---|
| 10 | type
|
---|
| 11 | TfrmXWBOnFail = class(TForm)
|
---|
| 12 | btnConnect: TButton;
|
---|
| 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 | RPCB: TSharedRPCBroker;
|
---|
| 26 | procedure btnConnectClick(Sender: TObject);
|
---|
| 27 | procedure btnExitClick(Sender: TObject);
|
---|
| 28 | procedure FormCreate(Sender: TObject);
|
---|
| 29 | procedure Exit1Click(Sender: TObject);
|
---|
| 30 | procedure About1Click(Sender: TObject);
|
---|
| 31 | private
|
---|
| 32 | { Private declarations }
|
---|
| 33 | public
|
---|
| 34 | { Public declarations }
|
---|
| 35 | procedure MyErrorHandler(RPCBroker: TRPCBroker);
|
---|
| 36 | end;
|
---|
| 37 |
|
---|
| 38 | var
|
---|
| 39 | frmXWBOnFail: TfrmXWBOnFail;
|
---|
| 40 |
|
---|
| 41 | implementation
|
---|
| 42 |
|
---|
| 43 | {$R *.DFM}
|
---|
| 44 |
|
---|
| 45 | procedure TfrmXWBOnFail.MyErrorHandler(RPCBroker: TRPCBroker);
|
---|
| 46 | var
|
---|
| 47 | ErrorText: String;
|
---|
| 48 | Path: String;
|
---|
| 49 | StrLoc: TStringList;
|
---|
| 50 | NowVal: TDateTime;
|
---|
| 51 | begin
|
---|
| 52 | NowVal := Now;
|
---|
| 53 | ErrorText := RPCB.RPCBError;
|
---|
| 54 | StrLoc := TStringList.Create;
|
---|
| 55 | Path := ExtractFilePath(Application.ExeName);
|
---|
| 56 | Path := Path + 'Error.Log';
|
---|
| 57 | if FileExists(Path) then
|
---|
| 58 | StrLoc.LoadFromFile(Path);
|
---|
| 59 | StrLoc.Add(FormatDateTime('mm/dd/yyyy hh:mm:ss ',NowVal) + ErrorText);
|
---|
| 60 | StrLoc.SaveToFile(Path);
|
---|
| 61 | end;
|
---|
| 62 |
|
---|
| 63 | procedure TfrmXWBOnFail.btnConnectClick(Sender: TObject);
|
---|
| 64 | begin
|
---|
| 65 | if btnConnect.Caption = 'Connect' then
|
---|
| 66 | begin
|
---|
| 67 | edtErrorText.Text := ''; // Clear out old values
|
---|
| 68 | edtLoginError.Text := '';
|
---|
| 69 | RPCB.AccessVerifyCodes := '';
|
---|
| 70 | RPCB.KernelLogIn := True;
|
---|
| 71 | if cbxBadAccess.Checked then
|
---|
| 72 | RPCB.AccessVerifyCodes := 'monkeysee;monkeydo';
|
---|
| 73 | RPCB.OnRPCBFailure := nil;
|
---|
| 74 | RPCB.ShowErrorMsgs := semRaise;
|
---|
| 75 | case rgrSelectAction.ItemIndex of //
|
---|
| 76 | 0: RPCB.OnRPCBFailure := MyErrorHandler;
|
---|
| 77 | 1: RPCB.ShowErrorMsgs := semRaise;
|
---|
| 78 | 2: RPCB.ShowErrorMsgs := semQuiet;
|
---|
| 79 | end; // case
|
---|
| 80 | try
|
---|
| 81 | RPCB.Connected := True;
|
---|
| 82 | if RPCB.Connected then
|
---|
| 83 | btnConnect.Caption := 'Disconnect';
|
---|
| 84 | finally
|
---|
| 85 | edtErrorText.Text := RPCB.RPCBError;
|
---|
| 86 | edtLoginError.Text := RPCB.LogIn.ErrorText;
|
---|
| 87 | end;
|
---|
| 88 | end
|
---|
| 89 | else
|
---|
| 90 | begin
|
---|
| 91 | RPCB.Connected := False;
|
---|
| 92 | btnConnect.Caption := 'Connect';
|
---|
| 93 | end;
|
---|
| 94 | end;
|
---|
| 95 |
|
---|
| 96 | procedure TfrmXWBOnFail.btnExitClick(Sender: TObject);
|
---|
| 97 | begin
|
---|
| 98 | halt;
|
---|
| 99 | end;
|
---|
| 100 |
|
---|
| 101 | procedure TfrmXWBOnFail.FormCreate(Sender: TObject);
|
---|
| 102 | var
|
---|
| 103 | Server: String;
|
---|
| 104 | Port: String;
|
---|
| 105 | begin
|
---|
| 106 | GetServerInfo(Server, Port);
|
---|
| 107 | RPCB.Server := Server;
|
---|
| 108 | RPCB.ListenerPort := StrToInt(Port);
|
---|
| 109 | end;
|
---|
| 110 |
|
---|
| 111 | procedure TfrmXWBOnFail.Exit1Click(Sender: TObject);
|
---|
| 112 | begin
|
---|
| 113 | Halt;
|
---|
| 114 | end;
|
---|
| 115 |
|
---|
| 116 | procedure TfrmXWBOnFail.About1Click(Sender: TObject);
|
---|
| 117 | begin
|
---|
| 118 | ShowAboutBox;
|
---|
| 119 | end;
|
---|
| 120 |
|
---|
| 121 | end.
|
---|