ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/FBTransaction.pas
(Generate patch)

Comparing ibx/trunk/fbintf/client/FBTransaction.pas (file contents):
Revision 262 by tony, Mon Mar 6 10:20:02 2017 UTC vs.
Revision 263 by tony, Thu Dec 6 15:55:01 2018 UTC

# Line 72 | Line 72 | unit FBTransaction;
72   interface
73  
74   uses
75 <  Classes, SysUtils, IB, FBParamBlock, FBActivityMonitor;
75 >  Classes, SysUtils, IB, FBParamBlock, FBActivityMonitor, FBClientAPI;
76  
77   type
78    { TFBTransaction }
79  
80    TFBTransaction = class(TActivityReporter, IActivityMonitor,ITransaction)
81    private
82 +    FFirebirdAPI: TFBClientAPI;
83      function GenerateTPB(sl: array of byte): ITPB;
84    protected
85      FTPB: ITPB;
# Line 87 | Line 88 | type
88      FAttachments: array of IAttachment; {Keep reference to attachment - ensures
89                                            attachment cannot be freed before transaction}
90      function GetActivityIntf(att: IAttachment): IActivityMonitor; virtual; abstract;
91 +    procedure SetInterface(api: TFBClientAPI); virtual;
92    public
93 <    constructor Create(Attachments: array of IAttachment; Params: array of byte; DefaultCompletion: TTransactionAction); overload;
94 <    constructor Create(Attachments: array of IAttachment; TPB: ITPB; DefaultCompletion: TTransactionAction); overload;
95 <    constructor Create(Attachment: IAttachment; Params: array of byte; DefaultCompletion: TTransactionAction); overload;
96 <    constructor Create(Attachment: IAttachment; TPB: ITPB; DefaultCompletion: TTransactionAction); overload;
93 >    constructor Create(api: TFBClientAPI; Attachments: array of IAttachment; Params: array of byte; DefaultCompletion: TTransactionAction); overload;
94 >    constructor Create(api: TFBClientAPI; Attachments: array of IAttachment; TPB: ITPB; DefaultCompletion: TTransactionAction); overload;
95 >    constructor Create(api: TFBClientAPI; Attachment: IAttachment; Params: array of byte; DefaultCompletion: TTransactionAction); overload;
96 >    constructor Create(api: TFBClientAPI; Attachment: IAttachment; TPB: ITPB; DefaultCompletion: TTransactionAction); overload;
97      destructor Destroy; override;
98      procedure DoDefaultTransactionEnd(Force: boolean);
99 +    property FirebirdAPI: TFBClientAPI read FFirebirdAPI;
100  
101    public
102      {ITransaction}
# Line 123 | Line 126 | function TFBTransaction.GenerateTPB(sl:
126   var
127    i: Integer;
128   begin
129 <  Result := TTPB.Create;
129 >  Result := TTPB.Create(FFirebirdAPI);
130    for i := 0 to Length(sl) - 1 do
131      Result.Add(sl[i]);
132   end;
133  
134 < constructor TFBTransaction.Create(Attachments: array of IAttachment;
134 > procedure TFBTransaction.SetInterface(api: TFBClientAPI);
135 > begin
136 >  FFirebirdAPI := api;
137 > end;
138 >
139 > constructor TFBTransaction.Create(api: TFBClientAPI; Attachments: array of IAttachment;
140    Params: array of byte; DefaultCompletion: TTransactionAction);
141   begin
142 <  Create(Attachments,GenerateTPB(Params), DefaultCompletion);
142 >  Create(api, Attachments,GenerateTPB(Params), DefaultCompletion);
143   end;
144  
145 < constructor TFBTransaction.Create(Attachments: array of IAttachment; TPB: ITPB;
145 > constructor TFBTransaction.Create(api: TFBClientAPI; Attachments: array of IAttachment; TPB: ITPB;
146    DefaultCompletion: TTransactionAction);
147   var
148    i: Integer;
149   begin
150    inherited Create(nil);
151 +  SetInterface(api);
152    if Length(Attachments) = 0 then
153      IBError(ibxeEmptyAttachmentsList,[nil]);
154  
155 +  {make sure all attachments use same Firebird API}
156 +  for i := 0 to Length(Attachments) - 1 do
157 +    if Attachments[i].getFirebirdAPI.GetFBLibrary.GetHandle <> FFirebirdAPI.GetFBLibrary.GetHandle then
158 +      IBError(ibxeDifferentAPIs,[nil]);
159 +
160    SetLength(FAttachments,Length(Attachments));
161    for i := 0 to Length(Attachments) - 1 do
162    begin
# Line 153 | Line 167 | begin
167    Start(DefaultCompletion);
168   end;
169  
170 < constructor TFBTransaction.Create(Attachment: IAttachment;
170 > constructor TFBTransaction.Create(api: TFBClientAPI; Attachment: IAttachment;
171    Params: array of byte; DefaultCompletion: TTransactionAction);
172   begin
173 <  Create(Attachment,GenerateTPB(Params),DefaultCompletion);
173 >  Create(api,Attachment,GenerateTPB(Params),DefaultCompletion);
174   end;
175  
176 < constructor TFBTransaction.Create(Attachment: IAttachment; TPB: ITPB;
176 > constructor TFBTransaction.Create(api: TFBClientAPI; Attachment: IAttachment; TPB: ITPB;
177    DefaultCompletion: TTransactionAction);
178   begin
179    inherited Create(nil);
180 +  SetInterface(api);
181    AddMonitor(GetActivityIntf(Attachment));
182    SetLength(FAttachments,1);
183    FAttachments[0] := Attachment;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines