source: cprs/branches/GUI-config/BDK32/Samples/SharedRPCBroker/SilentSignOn/fXWBOnFail.pas@ 1591

Last change on this file since 1591 was 476, checked in by Kevin Toppenberg, 16 years ago

New WorldVistA Config Utility

File size: 2.9 KB
RevLine 
[476]1unit fXWBOnFail;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, Trpcb, Rpcconf1, ExtCtrls, frmVistAAbout, Menus,
8 SharedRPCBroker;
9
10type
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
38var
39 frmXWBOnFail: TfrmXWBOnFail;
40
41implementation
42
43{$R *.DFM}
44
45procedure TfrmXWBOnFail.MyErrorHandler(RPCBroker: TRPCBroker);
46var
47 ErrorText: String;
48 Path: String;
49 StrLoc: TStringList;
50 NowVal: TDateTime;
51begin
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);
61end;
62
63procedure TfrmXWBOnFail.btnConnectClick(Sender: TObject);
64begin
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;
94end;
95
96procedure TfrmXWBOnFail.btnExitClick(Sender: TObject);
97begin
98 halt;
99end;
100
101procedure TfrmXWBOnFail.FormCreate(Sender: TObject);
102var
103 Server: String;
104 Port: String;
105begin
106 GetServerInfo(Server, Port);
107 RPCB.Server := Server;
108 RPCB.ListenerPort := StrToInt(Port);
109end;
110
111procedure TfrmXWBOnFail.Exit1Click(Sender: TObject);
112begin
113 Halt;
114end;
115
116procedure TfrmXWBOnFail.About1Click(Sender: TObject);
117begin
118 ShowAboutBox;
119end;
120
121end.
Note: See TracBrowser for help on using the repository browser.