source: cprs/branches/tmg-cprs/BDK32/SharedBrokerDebugger/fClientRPCLogger.pas@ 1536

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

Initial upload of TMG-CPRS 1.0.26.69

File size: 5.8 KB
Line 
1unit fClientRPCLogger;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, ExtCtrls, ComCtrls, Clipbrd, Menus, uRpcLogEntry;
8
9type
10 TfrmRpcClientLogger = class(TForm)
11 cbxEnableRPCLogging: TCheckBox;
12 lblMaxRPCEntries: TLabel;
13 UpDown1: TUpDown;
14 maxRpcLogEntriesNumericUpDown: TEdit;
15 rpcLogListBox: TListBox;
16 Panel1: TPanel;
17 lblRPCName: TLabel;
18 lblRPCDebugID: TLabel;
19 lblClientName: TLabel;
20 lblClientDebugID: TLabel;
21 lblContext: TLabel;
22 lblDuration: TLabel;
23 edtRPCName: TEdit;
24 edtRPCDebugID: TEdit;
25 edtClientName: TEdit;
26 edtClientDebugID: TEdit;
27 edtContext: TEdit;
28 edtDuration1: TEdit;
29 lblParams: TLabel;
30 lblResults: TLabel;
31 MainMenu1: TMainMenu;
32 PopupMenu1: TPopupMenu;
33 File1: TMenuItem;
34 mnuFileClose: TMenuItem;
35 Edit1: TMenuItem;
36 HGelp1: TMenuItem;
37 mnuHelpAbout: TMenuItem;
38 mnuEditCopyToClipboard: TMenuItem;
39 mnuPopupCopyToClipboard: TMenuItem;
40 ParamsMemoBox: TRichEdit;
41 ResultsMemoBox: TRichEdit;
42 Edit2: TEdit;
43 btnClose: TButton;
44 procedure FormClose(Sender: TObject; var Action: TCloseAction);
45 procedure UpDown1Click(Sender: TObject; Button: TUDBtnType);
46 procedure mnuEditCopyToClipboardClick(Sender: TObject);
47 procedure rpcLogListBoxClick(Sender: TObject);
48 procedure mnuPopupCopyToClipboardClick(Sender: TObject);
49 procedure mnuFileCloseClick(Sender: TObject);
50 procedure btnCloseClick(Sender: TObject);
51 private
52 { Private declarations }
53 public
54 { Public declarations }
55 procedure DisplayRpcEntry(entry: TRpcLogEntry);
56 procedure AddRpcLogEntry(entry: TRPCLogEntry; overrideCheckBox: Boolean);
57 end;
58
59var
60 frmRpcClientLogger: TfrmRpcClientLogger;
61
62implementation
63
64{$R *.DFM}
65
66procedure TfrmRpcClientLogger.AddRpcLogEntry(entry: TRPCLogEntry; overrideCheckBox: Boolean);
67var
68 Str, Str1: String;
69 Max: Integer;
70begin
71 if (cbxEnableRPCLogging.Checked or overrideCheckBox) then
72 begin
73 // If the list is full we need to delete the 0th item till we have room for one.
74 while (rpcLogListBox.Items.Count >= StrToInt(maxRpcLogEntriesNumericUpDown.Text)) do
75 rpcLogListBox.Items.Delete(0);
76 with entry do
77 begin
78 Max := 30;
79 if Length(Name) > 30 then
80 Max := Length(Name);
81 Str := Copy(Name+' ',1,Max);
82 Str1 := ' '+IntToStr(Duration);
83 Str := Str + ' cId: '+IntToStr(UniqueClientId)+' time ='+Copy(Str1,Length(Str1)-5,Length(Str1))+' ms rpcId: '+IntToStr(UniqueId)+' '+ClientName;
84 end; // with
85 rpcLogListBox.Items.AddObject(Str, entry);
86 end;
87end;
88
89 procedure TfrmRpcClientLogger.FormClose(Sender: TObject; var Action: TCloseAction);
90 begin
91 //
92 end;
93 procedure TfrmRpcClientLogger.UpDown1Click(Sender: TObject; Button: TUDBtnType);
94 begin
95 //
96 end;
97
98procedure TfrmRpcClientLogger.mnuEditCopyToClipboardClick(Sender: TObject);
99begin
100 if RpcLogListBox.ItemIndex > -1 then
101 mnuPopupCopyToClipboardClick(Self);
102end;
103procedure TfrmRpcClientLogger.rpcLogListBoxClick(Sender: TObject);
104begin
105 DisplayRpcEntry(TRpcLogEntry(rpcLogListBox.Items.Objects[rpcLogListBox.ItemIndex]));
106 mnuEditCopyToClipboard.Enabled := True;
107end;
108
109procedure TfrmRpcClientLogger.mnuPopupCopyToClipboardClick(Sender: TObject);
110var
111 RPCEntry: TRpcLogEntry;
112begin
113 RPCEntry := TRpcLogEntry(RpcLogListBox.Items.Objects[RpcLogListBox.ItemIndex]);
114 Edit2.Text := RPCEntry.CreateClipBoardString;
115 Edit2.SelectAll;
116 Edit2.CopyToClipBoard;
117end;
118
119
120
121// private void rpcLogListBox_SelectedIndexChanged(object sender, System.EventArgs e)
122
123procedure TfrmRpcClientLogger.DisplayRpcEntry(entry: TRpcLogEntry);
124var
125 Str : String;
126begin
127 Str := entry.CreateParamsDisplayString; //.Split('\n');
128 ParamsMemoBox.Lines.Clear;
129 ParamsMemoBox.Lines.Add(Str);
130
131 resultsMemoBox.Text := entry.CreateResultsDisplayString();
132 edtRpcName.Text := entry.Name;
133 edtRPCDebugId.Text := IntToStr(entry.UniqueId);
134 edtContext.Text := entry.Context;
135 if(entry.Duration < 1) then
136 edtDuration1.Text := '<1ms'
137 else
138 edtDuration1.Text := IntToStr(entry.Duration) + ' ms';
139 edtClientName.Text := entry.ClientName;
140 edtClientDebugId.Text := IntToStr(entry.UniqueClientId);
141end;
142
143{
144procedure TfrmRpcClientLogger.FormClose(Sender: TObject;
145 var Action: TCloseAction);
146begin
147 OnRpcLoggerClose(Self,nil);
148end;
149
150procedure TfrmRpcClientLogger.UpDown1Click(Sender: TObject;
151 Button: TUDBtnType);
152begin
153 // In case the max entry value is less than the rpc log entries delete the entries
154 while (StrToInt(maxRpcLogEntriesNumericUpDown.Text) < rpcLogListBox.Items.Count)
155 rpcLogListBox.Items.Delete(0);
156end;
157
158procedure TfrmRpcClientLogger.mnuEditCopyToClipboardClick(Sender: TObject);
159var
160 Clip: TClipBoard;
161begin
162 // Build a string and put it on the clipboard here.
163// Clipboard.SetDataObject(((RpcLogEntry)rpcLogListBox.SelectedItem).CreateClipboardString());
164 Clip ::= ClipBoard;
165 Clip.SetTextBuf(PChar((RpcLogEntry)(rpcLogListBox.Items[rpcLogListBox.ItemIndex]).CreateClipboardString));
166end;
167
168procedure TfrmRpcClientLogger.rpcLogListBoxClick(Sender: TObject);
169begin
170 DisplayRpcEntry((RpcLogEntry)rpcLogListBox.Items[rpcLogListBox.SelectedIndex]);
171 mnuEditCopyToClipboard.Enabled := True;
172end;
173
174procedure TfrmRpcClientLogger.mnuPopupCopyToClipboardClick(
175 Sender: TObject);
176begin
177 mnuEditCopyToClipboardClick(Sender);
178end;
179}
180procedure TfrmRpcClientLogger.mnuFileCloseClick(Sender: TObject);
181begin
182 Self.Visible := False;
183end;
184
185procedure TfrmRpcClientLogger.btnCloseClick(Sender: TObject);
186begin
187 Self.Visible := False;
188end;
189
190end.
Note: See TracBrowser for help on using the repository browser.