44 |
|
interface |
45 |
|
|
46 |
|
uses |
47 |
– |
LMessages, LCLIntf, LCLType, LCLProc, Forms, Controls, Dialogs, |
47 |
|
IB, IBUtils, IBSQL, IBCustomDataSet, IBDatabase, IBServices, IBXConst,SysUtils, |
48 |
|
Classes, |
49 |
|
{$IFDEF WINDOWS } |
70 |
|
{$DEFINE HAS_SEMTIMEDOP} |
71 |
|
{$ENDIF} |
72 |
|
|
74 |
– |
const |
75 |
– |
WM_MIN_IBSQL_MONITOR = WM_USER; |
76 |
– |
WM_MAX_IBSQL_MONITOR = WM_USER + 512; |
77 |
– |
WM_IBSQL_SQL_EVENT = WM_MIN_IBSQL_MONITOR + 1; |
78 |
– |
|
73 |
|
type |
74 |
|
TIBCustomSQLMonitor = class; |
75 |
|
|
142 |
|
implementation |
143 |
|
|
144 |
|
uses |
145 |
< |
contnrs, syncobjs |
145 |
> |
contnrs, syncobjs, CustApp |
146 |
|
{$IFDEF USE_SV5_IPC} |
147 |
|
,ipc, Errors, baseunix |
148 |
|
{$IF FPC_FULLVERSION <= 20402 } , initc {$ENDIF} |
283 |
|
_MonitorHook: TIBSQLMonitorHook; |
284 |
|
bDone: Boolean; |
285 |
|
CS : TCriticalSection; |
286 |
+ |
|
287 |
+ |
const |
288 |
+ |
ApplicationTitle: string = 'Unknown'; |
289 |
|
|
290 |
|
{ TIBCustomSQLMonitor } |
291 |
|
|
292 |
|
constructor TIBCustomSQLMonitor.Create(AOwner: TComponent); |
293 |
+ |
var aParent: TComponent; |
294 |
|
begin |
295 |
|
inherited Create(AOwner); |
296 |
|
FTraceFlags := [tfqPrepare .. tfMisc]; |
297 |
|
if not (csDesigning in ComponentState) then |
298 |
|
begin |
299 |
+ |
aParent := AOwner; |
300 |
+ |
while aParent <> nil do |
301 |
+ |
begin |
302 |
+ |
if aParent is TCustomApplication then |
303 |
+ |
begin |
304 |
+ |
ApplicationTitle := TCustomApplication(aParent).Title; |
305 |
+ |
break; |
306 |
+ |
end; |
307 |
+ |
aParent := aParent.Owner; |
308 |
+ |
end; |
309 |
|
MonitorHook.RegisterMonitor(self); |
310 |
|
end; |
311 |
|
FEnabled := true; |
340 |
|
(st.FDataType in FTraceFlags) then |
341 |
|
FOnSQLEvent(st.FMsg, st.FTimeStamp); |
342 |
|
st.Free; |
335 |
– |
{$IFDEF WINDOWS} |
336 |
– |
Application.ProcessMessages |
337 |
– |
{$ENDIF} |
343 |
|
end; |
344 |
|
|
345 |
|
procedure TIBCustomSQLMonitor.SetEnabled(const Value: Boolean); |
707 |
|
{$IFDEF DEBUG}writeln('Write SQL Data: '+Text);{$ENDIF} |
708 |
|
if not assigned(FGlobalInterface) then |
709 |
|
FGlobalInterface := TGlobalInterface.Create; |
710 |
< |
Text := CRLF + '[Application: ' + Application.Title + ']' + CRLF + Text; {do not localize} |
710 |
> |
Text := CRLF + '[Application: ' + ApplicationTitle + ']' + CRLF + Text; {do not localize} |
711 |
|
if not Assigned(FWriterThread) then |
712 |
|
FWriterThread := TWriterThread.Create(FGLobalInterface); |
713 |
|
FWriterThread.WriteSQLData(Text, DataType); |