279 |
|
|
280 |
|
TIBTransaction = class(TComponent) |
281 |
|
private |
282 |
+ |
FAfterTransactionEnd: TNotifyEvent; |
283 |
+ |
FBeforeTransactionEnd: TNotifyEvent; |
284 |
|
FIBLoaded: Boolean; |
285 |
|
FCanTimeout : Boolean; |
286 |
|
FDatabases : TList; |
297 |
|
FTRParams : TStrings; |
298 |
|
FTRParamsChanged : Boolean; |
299 |
|
FInEndTransaction : boolean; |
300 |
+ |
FEndAction : TTransactionAction; |
301 |
+ |
procedure DoBeforeTransactionEnd; |
302 |
+ |
procedure DoAfterTransactionEnd; |
303 |
|
procedure EnsureNotInTransaction; |
304 |
|
procedure EndTransaction(Action: TTransactionAction; Force: Boolean); |
305 |
|
function GetDatabase(Index: Integer): TIBDatabase; |
341 |
|
function AddDatabase(db: TIBDatabase): Integer; |
342 |
|
function FindDatabase(db: TIBDatabase): Integer; |
343 |
|
function FindDefaultDatabase: TIBDatabase; |
344 |
+ |
function GetEndAction: TTransactionAction; |
345 |
|
procedure RemoveDatabase(Idx: Integer); |
346 |
|
procedure RemoveDatabases; |
347 |
|
procedure CheckDatabasesInList; |
363 |
|
property DefaultAction: TTransactionAction read FDefaultAction write SetDefaultAction default taCommit; |
364 |
|
property Params: TStrings read FTRParams write SetTRParams; |
365 |
|
property OnIdleTimer: TNotifyEvent read FOnIdleTimer write FOnIdleTimer; |
366 |
+ |
property BeforeTransactionEnd: TNotifyEvent read FBeforeTransactionEnd |
367 |
+ |
write FBeforeTransactionEnd; |
368 |
+ |
property AfterTransactionEnd: TNotifyEvent read FAfterTransactionEnd |
369 |
+ |
write FAfterTransactionEnd; |
370 |
|
end; |
371 |
|
|
372 |
|
{ TIBBase } |
1394 |
|
IBError(ibxeNotInTransaction, [nil]); |
1395 |
|
end; |
1396 |
|
|
1397 |
+ |
procedure TIBTransaction.DoBeforeTransactionEnd; |
1398 |
+ |
begin |
1399 |
+ |
if Assigned(FBeforeTransactionEnd) then |
1400 |
+ |
FBeforeTransactionEnd(self); |
1401 |
+ |
end; |
1402 |
+ |
|
1403 |
+ |
procedure TIBTransaction.DoAfterTransactionEnd; |
1404 |
+ |
begin |
1405 |
+ |
if Assigned(FAfterTransactionEnd) then |
1406 |
+ |
FAfterTransactionEnd(self); |
1407 |
+ |
end; |
1408 |
+ |
|
1409 |
|
procedure TIBTransaction.EnsureNotInTransaction; |
1410 |
|
begin |
1411 |
|
if csDesigning in ComponentState then |
1482 |
|
CheckInTransaction; |
1483 |
|
if FInEndTransaction then Exit; |
1484 |
|
FInEndTransaction := true; |
1485 |
+ |
FEndAction := Action; |
1486 |
|
try |
1487 |
|
case Action of |
1488 |
|
TARollback, TACommit: |
1491 |
|
(Action <> FDefaultAction) and |
1492 |
|
(not Force) then |
1493 |
|
IBError(ibxeCantEndSharedTransaction, [nil]); |
1494 |
+ |
DoBeforeTransactionEnd; |
1495 |
|
for i := 0 to FSQLObjects.Count - 1 do if FSQLObjects[i] <> nil then |
1496 |
|
SQLObjects[i].DoBeforeTransactionEnd; |
1497 |
|
if InTransaction then |
1516 |
|
IBDataBaseError; |
1517 |
|
for i := 0 to FSQLObjects.Count - 1 do if FSQLObjects[i] <> nil then |
1518 |
|
SQLObjects[i].DoAfterTransactionEnd; |
1519 |
+ |
DoAfterTransactionEnd; |
1520 |
|
end; |
1521 |
|
end; |
1522 |
|
TACommitRetaining: |
1607 |
|
end; |
1608 |
|
end; |
1609 |
|
|
1610 |
+ |
function TIBTransaction.GetEndAction: TTransactionAction; |
1611 |
+ |
begin |
1612 |
+ |
if FInEndTransaction then |
1613 |
+ |
Result := FEndAction |
1614 |
+ |
else |
1615 |
+ |
IBError(ibxeIB60feature, [nil]) |
1616 |
+ |
end; |
1617 |
+ |
|
1618 |
|
|
1619 |
|
function TIBTransaction.GetIdleTimer: Integer; |
1620 |
|
begin |