32 |
|
|
33 |
|
uses |
34 |
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, |
35 |
< |
Grids, IBServices; |
35 |
> |
ActnList, db, IBXServices, IBDynamicGrid; |
36 |
|
|
37 |
|
type |
38 |
|
{ TLimboTransactionsForm } |
39 |
|
|
40 |
|
TLimboTransactionsForm = class(TForm) |
41 |
+ |
ApplySelectedAction: TAction; |
42 |
+ |
Commit2PhaseAll: TAction; |
43 |
+ |
|
44 |
+ |
IBXLimboTransactionResolutionService1: TIBXLimboTransactionResolutionService; |
45 |
+ |
InLimboList: TIBXServicesLimboTransactionsList; |
46 |
+ |
RollbackAll: TAction; |
47 |
+ |
CommitAll: TAction; |
48 |
+ |
ActionList1: TActionList; |
49 |
|
Button1: TButton; |
50 |
|
Button2: TButton; |
51 |
|
Button3: TButton; |
52 |
|
Button4: TButton; |
53 |
< |
LimboTransactionValidation: TIBValidationService; |
54 |
< |
Label1: TLabel; |
55 |
< |
StringGrid1: TStringGrid; |
56 |
< |
procedure Button1Click(Sender: TObject); |
57 |
< |
procedure Button2Click(Sender: TObject); |
58 |
< |
procedure Button3Click(Sender: TObject); |
59 |
< |
procedure Button4Click(Sender: TObject); |
53 |
> |
Button5: TButton; |
54 |
> |
IBDynamicGrid3: TIBDynamicGrid; |
55 |
> |
Label38: TLabel; |
56 |
> |
Label39: TLabel; |
57 |
> |
LimboListSource: TDataSource; |
58 |
> |
LimboReport: TMemo; |
59 |
> |
procedure ApplySelectedActionExecute(Sender: TObject); |
60 |
> |
procedure Commit2PhaseAllExecute(Sender: TObject); |
61 |
> |
procedure CommitAllExecute(Sender: TObject); |
62 |
> |
procedure CommitAllUpdate(Sender: TObject); |
63 |
|
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); |
64 |
|
procedure FormShow(Sender: TObject); |
65 |
< |
procedure StringGrid1EditingDone(Sender: TObject); |
65 |
> |
procedure RollbackAllExecute(Sender: TObject); |
66 |
|
private |
67 |
|
{ private declarations } |
68 |
|
procedure DoRefresh(Data: PtrInt); |
58 |
– |
function StateToStr(State: TTransactionState): string; |
59 |
– |
function AdviseToStr(Advise: TTransactionAdvise): string; |
60 |
– |
function ActionToStr(anAction: TTransactionAction): string; |
61 |
– |
procedure RunGFix; |
69 |
|
public |
70 |
|
{ public declarations } |
71 |
|
end; |
77 |
|
|
78 |
|
{$R *.lfm} |
79 |
|
|
73 |
– |
uses MainFormUnit; |
74 |
– |
|
80 |
|
{ TLimboTransactionsForm } |
81 |
|
|
82 |
|
procedure TLimboTransactionsForm.FormShow(Sender: TObject); |
83 |
|
begin |
84 |
|
Application.QueueAsyncCall(@DoRefresh,0); |
85 |
+ |
LimboReport.Lines.Clear; |
86 |
|
end; |
87 |
|
|
88 |
< |
procedure TLimboTransactionsForm.Button1Click(Sender: TObject); |
88 |
> |
procedure TLimboTransactionsForm.RollbackAllExecute(Sender: TObject); |
89 |
|
begin |
90 |
< |
LimboTransactionValidation.GlobalAction := CommitGlobal; |
85 |
< |
RunGFix; |
90 |
> |
InLimboList.FixErrors(RollbackGlobal,LimboReport.Lines); |
91 |
|
end; |
92 |
|
|
93 |
< |
procedure TLimboTransactionsForm.Button2Click(Sender: TObject); |
93 |
> |
procedure TLimboTransactionsForm.ApplySelectedActionExecute(Sender: TObject); |
94 |
|
begin |
95 |
< |
LimboTransactionValidation.GlobalAction := RollbackGlobal; |
91 |
< |
RunGFix; |
95 |
> |
InLimboList.FixErrors(NoGlobalAction,LimboReport.Lines); |
96 |
|
end; |
97 |
|
|
98 |
< |
procedure TLimboTransactionsForm.Button3Click(Sender: TObject); |
98 |
> |
procedure TLimboTransactionsForm.Commit2PhaseAllExecute(Sender: TObject); |
99 |
|
begin |
100 |
< |
LimboTransactionValidation.GlobalAction := NoGlobalAction; |
97 |
< |
RunGFix; |
100 |
> |
InLimboList.FixErrors(RecoverTwoPhaseGlobal,LimboReport.Lines); |
101 |
|
end; |
102 |
|
|
103 |
< |
procedure TLimboTransactionsForm.Button4Click(Sender: TObject); |
103 |
> |
procedure TLimboTransactionsForm.CommitAllExecute(Sender: TObject); |
104 |
|
begin |
105 |
< |
LimboTransactionValidation.GlobalAction := RecoverTwoPhaseGlobal; |
103 |
< |
RunGFix; |
105 |
> |
InLimboList.FixErrors(CommitGlobal,LimboReport.Lines); |
106 |
|
end; |
107 |
|
|
108 |
< |
procedure TLimboTransactionsForm.FormClose(Sender: TObject; |
107 |
< |
var CloseAction: TCloseAction); |
108 |
> |
procedure TLimboTransactionsForm.CommitAllUpdate(Sender: TObject); |
109 |
|
begin |
110 |
+ |
(Sender as TAction).Enabled := InLimboList.Active and (InLimboList.RecordCount > 0); |
111 |
|
end; |
112 |
|
|
113 |
< |
procedure TLimboTransactionsForm.StringGrid1EditingDone(Sender: TObject); |
113 |
> |
procedure TLimboTransactionsForm.FormClose(Sender: TObject; |
114 |
> |
var CloseAction: TCloseAction); |
115 |
|
begin |
116 |
< |
with StringGrid1, LimboTransactionValidation do |
114 |
< |
if col = 7 then |
115 |
< |
begin |
116 |
< |
if Cells[7,row] = 'Commit' then |
117 |
< |
LimboTransactionInfo[row-1].Action := CommitAction |
118 |
< |
else |
119 |
< |
if Cells[7,row] = 'Rollback' then |
120 |
< |
LimboTransactionInfo[row-1].Action := RollbackAction |
121 |
< |
end; |
116 |
> |
InLimboList.Active := false; |
117 |
|
end; |
118 |
|
|
119 |
|
procedure TLimboTransactionsForm.DoRefresh(Data: PtrInt); |
125 |
– |
var i: integer; |
126 |
– |
begin |
127 |
– |
with LimboTransactionValidation do |
128 |
– |
begin |
129 |
– |
Active := true; |
130 |
– |
ServiceStart; |
131 |
– |
FetchLimboTransactionInfo; |
132 |
– |
StringGrid1.RowCount := LimboTransactionInfoCount + 1; |
133 |
– |
for i := 0 to LimboTransactionInfoCount - 1 do |
134 |
– |
with LimboTransactionInfo[i] do |
135 |
– |
begin |
136 |
– |
StringGrid1.Cells[0,i+1] := IntToStr(ID); |
137 |
– |
if MultiDatabase then |
138 |
– |
StringGrid1.Cells[1,i+1] := 'Multi DB' |
139 |
– |
else |
140 |
– |
StringGrid1.Cells[1,i+1] := 'Single DB'; |
141 |
– |
StringGrid1.Cells[2,i+1] := HostSite; |
142 |
– |
StringGrid1.Cells[3,i+1] := RemoteSite; |
143 |
– |
StringGrid1.Cells[4,i+1] := RemoteDatabasePath; |
144 |
– |
StringGrid1.Cells[5,i+1] := StateToStr(State); |
145 |
– |
StringGrid1.Cells[6,i+1] := AdviseToStr(Advise); |
146 |
– |
StringGrid1.Cells[7,i+1] := ActionToStr(Action); |
147 |
– |
end; |
148 |
– |
end; |
149 |
– |
end; |
150 |
– |
|
151 |
– |
function TLimboTransactionsForm.StateToStr(State: TTransactionState): string; |
152 |
– |
begin |
153 |
– |
case State of |
154 |
– |
LimboState: |
155 |
– |
Result := 'Limbo'; |
156 |
– |
CommitState: |
157 |
– |
Result := 'Commit'; |
158 |
– |
RollbackState: |
159 |
– |
Result := 'Rollback'; |
160 |
– |
else |
161 |
– |
Result := 'Unknown'; |
162 |
– |
end; |
163 |
– |
end; |
164 |
– |
|
165 |
– |
function TLimboTransactionsForm.AdviseToStr(Advise: TTransactionAdvise): string; |
166 |
– |
begin |
167 |
– |
case Advise of |
168 |
– |
CommitAdvise: |
169 |
– |
Result := 'Commit'; |
170 |
– |
RollbackAdvise: |
171 |
– |
Result := 'Rollback'; |
172 |
– |
else |
173 |
– |
Result := 'Unknown'; |
174 |
– |
end; |
175 |
– |
end; |
176 |
– |
|
177 |
– |
function TLimboTransactionsForm.ActionToStr(anAction: TTransactionAction |
178 |
– |
): string; |
179 |
– |
begin |
180 |
– |
case anAction of |
181 |
– |
CommitAction: |
182 |
– |
Result := 'Commit'; |
183 |
– |
RollbackAction: |
184 |
– |
Result := 'Rollback'; |
185 |
– |
end; |
186 |
– |
end; |
187 |
– |
|
188 |
– |
procedure TLimboTransactionsForm.RunGFix; |
120 |
|
begin |
121 |
< |
with LimboTransactionValidation do |
122 |
< |
begin |
192 |
< |
MainForm.Memo1.Lines.Add('Starting Limbo transaction resolution'); |
193 |
< |
FixLimboTransactionErrors; |
194 |
< |
while not Eof do |
195 |
< |
begin |
196 |
< |
MainForm.Memo1.Lines.Add(GetNextLine); |
197 |
< |
Application.ProcessMessages; |
198 |
< |
end; |
199 |
< |
MainForm.Memo1.Lines.Add('Limbo Transaction resolution complete'); |
200 |
< |
Application.QueueAsyncCall(@DoRefresh,0); |
201 |
< |
end; |
121 |
> |
InLimboList.Active := false; |
122 |
> |
InLimboList.Active := true; |
123 |
|
end; |
124 |
|
|
125 |
|
end. |