32 |
|
|
33 |
|
uses |
34 |
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, |
35 |
< |
ActnList, Menus, IBServices, IB; |
35 |
> |
ActnList, Menus, IBXServices, IB; |
36 |
> |
|
37 |
> |
const |
38 |
> |
sDefaultDatabaseName = 'employee'; |
39 |
|
|
40 |
|
type |
41 |
|
|
44 |
|
{ TMainForm } |
45 |
|
|
46 |
|
TMainForm = class(TForm) |
47 |
< |
IBConfigService1: TIBConfigService; |
47 |
> |
IBConfigService1: TIBXConfigService; |
48 |
> |
IBXServicesConnection1: TIBXServicesConnection; |
49 |
|
MenuItem6: TMenuItem; |
50 |
|
Shutdown: TAction; |
51 |
|
BringOnline: TAction; |
66 |
|
ServerLOgBtn: TButton; |
67 |
|
DatabaseBtn: TButton; |
68 |
|
UsersBtn: TButton; |
69 |
< |
IBLogService1: TIBLogService; |
70 |
< |
IBOnlineValidationService1: TIBOnlineValidationService; |
71 |
< |
IBServerProperties1: TIBServerProperties; |
72 |
< |
IBStatisticalService1: TIBStatisticalService; |
73 |
< |
IBValidationService1: TIBValidationService; |
69 |
> |
IBLogService1: TIBXLogService; |
70 |
> |
IBOnlineValidationService1: TIBXOnlineValidationService; |
71 |
> |
IBServerProperties1: TIBXServerProperties; |
72 |
> |
IBStatisticalService1: TIBXStatisticalService; |
73 |
> |
IBValidationService1: TIBXValidationService; |
74 |
|
Memo1: TMemo; |
75 |
|
procedure BringOnlineExecute(Sender: TObject); |
76 |
|
procedure BringOnlineUpdate(Sender: TObject); |
77 |
|
procedure CLoseBtnClick(Sender: TObject); |
78 |
|
procedure BackupBtnClick(Sender: TObject); |
79 |
+ |
procedure IBXServicesConnection1Login(Service: TIBXServicesConnection; |
80 |
+ |
var aServerName: string; LoginParams: TStrings); |
81 |
+ |
procedure IBXServicesConnection1SecurityContextException( |
82 |
+ |
Service: TIBXServicesConnection; var aAction: TSecContextAction); |
83 |
|
procedure RestoreBtnClick(Sender: TObject); |
84 |
|
procedure ServerLOgBtnClick(Sender: TObject); |
85 |
|
procedure DatabaseBtnClick(Sender: TObject); |
87 |
|
procedure SweepExecute(Sender: TObject); |
88 |
|
procedure UsersBtnClick(Sender: TObject); |
89 |
|
procedure FormShow(Sender: TObject); |
82 |
– |
procedure IBServerProperties1Login(Service: TIBCustomService; |
83 |
– |
LoginParams: TStrings); |
84 |
– |
procedure AltSecDBLogin(Service: TIBCustomService; |
85 |
– |
LoginParams: TStrings); |
90 |
|
procedure LimboTransactionsExecute(Sender: TObject); |
91 |
|
procedure StatisticsExecute(Sender: TObject); |
92 |
|
procedure ValidateExecute(Sender: TObject); |
93 |
|
private |
94 |
|
{ private declarations } |
91 |
– |
FValidationService: TIBControlAndQueryService; |
95 |
|
FDBName: string; |
96 |
|
FServerUserName: string; |
97 |
|
FServerPassword: string; |
98 |
< |
FShutDownMode: TShutdownMode; |
98 |
> |
FShutDownMode: TDBShutdownMode; |
99 |
|
FDelay: integer; |
100 |
|
procedure SetDBName(AValue: string); |
98 |
– |
procedure UseServerLogin; |
99 |
– |
function RunService(aService: TIBCustomService; RunProc: TRunServiceProc |
100 |
– |
): boolean; |
101 |
– |
procedure RunShowStatistics; |
102 |
– |
procedure RunValidation; |
103 |
– |
procedure RunLimboTransactions; |
104 |
– |
procedure RunSweep; |
105 |
– |
procedure RunBringOnline; |
106 |
– |
procedure RunShutdown; |
101 |
|
property DBName: string read FDBName write SetDBName; |
102 |
|
public |
103 |
|
{ public declarations } |
111 |
|
|
112 |
|
{$R *.lfm} |
113 |
|
|
114 |
< |
uses IBErrorCodes, FBMessages, ServicesLoginDlgUnit, SelectValidationDlgUnit, SelectDBDlgUnit, |
115 |
< |
BackupDlgUnit, RestoreDlgUnit, ListUsersUnit, LimboTransactionsUnit, AltDBSvcLoginDlgUnit, |
114 |
> |
uses FBMessages, ServicesLoginDlgUnit, SelectValidationDlgUnit, SelectDBDlgUnit, |
115 |
> |
BackupDlgUnit, RestoreDlgUnit, ListUsersUnit, LimboTransactionsUnit, |
116 |
|
ShutdownDatabaseDlgUnit, ShutdownRegDlgUnit; |
117 |
|
|
118 |
|
resourcestring |
119 |
|
sDBSweep = 'Database sweep started'; |
120 |
|
sSweepOK = 'Sweep successfully completed'; |
121 |
+ |
sSecContext = 'This database appears to use an alternative security database. '+ |
122 |
+ |
'You must now log into the alternative security database using login '+ |
123 |
+ |
'credentials for the alternative security database.'; |
124 |
|
|
125 |
|
|
126 |
|
{ TMainForm } |
129 |
|
var i: integer; |
130 |
|
begin |
131 |
|
{Set IB Exceptions to only show text message - omit SQLCode and Engine Code} |
132 |
< |
FirebirdAPI.GetStatus.SetIBDataBaseErrorMessages([ShowIBMessage]); |
133 |
< |
RestoreDlg.IBRestoreService1.DatabaseName.Clear; |
134 |
< |
RestoreDlg.IBRestoreService1.DatabaseName.Add(GetTempDir + 'mytest.fdb'); |
135 |
< |
FDBName := IBStatisticalService1.DatabaseName; |
136 |
< |
with IBServerProperties1 do |
132 |
> |
IBXServicesConnection1.FirebirdAPI.GetStatus.SetIBDataBaseErrorMessages([ShowIBMessage]); |
133 |
> |
Application.ExceptionDialog := aedOkMessageBox; |
134 |
> |
FDBName := sDefaultDatabaseName; |
135 |
> |
|
136 |
> |
{Open the Services API connection } |
137 |
> |
with IBXServicesConnection1 do |
138 |
|
begin |
139 |
< |
while not Active do |
139 |
> |
while not Connected do |
140 |
|
begin |
141 |
|
try |
142 |
< |
Active := true; |
142 |
> |
Connected := true; |
143 |
|
except |
144 |
|
on E:EIBClientError do |
145 |
|
begin |
150 |
|
MessageDlg(E.Message,mtError,[mbOK],0); |
151 |
|
end; |
152 |
|
end; {Loop until logged in or user cancels} |
153 |
+ |
end; |
154 |
|
|
155 |
< |
{Display the server properties} |
156 |
< |
FetchVersionInfo; |
155 |
> |
{Now display the server properties} |
156 |
> |
with IBServerProperties1, ServicesConnection do |
157 |
> |
begin |
158 |
> |
Memo1.Lines.Add('Firebird Library PathName = ' + IBXServicesConnection1.FirebirdAPI.GetFBLibrary.GetLibraryFilePath); |
159 |
|
Memo1.Lines.Add('Server Version = ' + VersionInfo.ServerVersion); |
160 |
|
Memo1.Lines.Add('Server Implementation = ' + VersionInfo.ServerImplementation); |
161 |
|
Memo1.Lines.Add('Service Version = ' + IntToStr(VersionInfo.ServiceVersion)); |
163 |
|
ServerVersionNo[2], |
164 |
|
ServerVersionNo[3], |
165 |
|
ServerVersionNo[4]])); |
165 |
– |
FetchDatabaseInfo; |
166 |
|
Memo1.Lines.Add('No. of attachments = ' + IntToStr(DatabaseInfo.NoOfAttachments)); |
167 |
|
Memo1.Lines.Add('No. of databases = ' + IntToStr(DatabaseInfo.NoOfDatabases)); |
168 |
|
for i := 0 to DatabaseInfo.NoOfDatabases - 1 do |
169 |
|
Memo1.Lines.Add('DB Name = ' + DatabaseInfo.DbName[i]); |
170 |
– |
FetchConfigParams; |
170 |
|
Memo1.Lines.Add('Base Location = ' + ConfigParams.BaseLocation); |
171 |
|
Memo1.Lines.Add('Lock File Location = ' + ConfigParams.LockFileLocation); |
172 |
|
Memo1.Lines.Add('Security Database Location = ' + ConfigParams.SecurityDatabaseLocation); |
173 |
|
Memo1.Lines.Add('Message File Location = ' + ConfigParams.MessageFileLocation); |
174 |
|
for i := Low(ConfigParams.ConfigFileParams) to High(ConfigParams.ConfigFileParams) do |
175 |
< |
writeln(ConfigParams.ConfigFileParams[i]); |
175 |
> |
Memo1.Lines.Add(ConfigParams.ConfigFileParams[i]); |
176 |
|
for i := Low(ConfigParams.ConfigFileData.ConfigFileKey) to High(ConfigParams.ConfigFileData.ConfigFileKey) do |
177 |
< |
writeln(ConfigParams.ConfigFileData.ConfigFileKey[i],' = ',ConfigParams.ConfigFileData.ConfigFileValue[i]); |
177 |
> |
Memo1.Lines.Add(Format('%d=%s',[ConfigParams.ConfigFileData.ConfigFileKey[i],ConfigParams.ConfigFileData.ConfigFileValue[i]])); |
178 |
|
end; |
180 |
– |
IBServerProperties1.OnLogin := @AltSecDBLogin; |
181 |
– |
{Leave IBServerProperties1 as active and use this as the common service interface} |
179 |
|
end; |
180 |
|
|
184 |
– |
{This is the initial logon to the default security database on the server} |
185 |
– |
|
186 |
– |
procedure TMainForm.IBServerProperties1Login(Service: TIBCustomService; |
187 |
– |
LoginParams: TStrings); |
188 |
– |
var aServiceName: string; |
189 |
– |
aUserName: string; |
190 |
– |
aPassword: string; |
191 |
– |
begin |
192 |
– |
aServiceName := Service.ServerName; |
193 |
– |
aUserName := LoginParams.Values['user_name']; |
194 |
– |
aPassword := ''; |
195 |
– |
if SvcLoginDlg.ShowModal(aServiceName, aUserName, aPassword) = mrOK then |
196 |
– |
begin |
197 |
– |
Service.ServerName := aServiceName; |
198 |
– |
LoginParams.Values['user_name'] := aUserName; |
199 |
– |
LoginParams.Values['password'] := aPassword; |
200 |
– |
FServerUserName := aUserName; |
201 |
– |
FServerPassword := aPassword; |
202 |
– |
end |
203 |
– |
else |
204 |
– |
IBError(ibxeOperationCancelled, [nil]); |
205 |
– |
end; |
206 |
– |
|
207 |
– |
{This is the login dialog for a alt. security database} |
208 |
– |
|
209 |
– |
procedure TMainForm.AltSecDBLogin(Service: TIBCustomService; |
210 |
– |
LoginParams: TStrings); |
211 |
– |
var aServiceName: string; |
212 |
– |
aUserName: string; |
213 |
– |
aPassword: string; |
214 |
– |
begin |
215 |
– |
aServiceName := Service.ServerName; |
216 |
– |
aUserName := LoginParams.Values['user_name']; |
217 |
– |
aPassword := ''; |
218 |
– |
if AltDBSvcLoginDlg.ShowModal(aServiceName, aUserName, aPassword) = mrOK then |
219 |
– |
begin |
220 |
– |
Service.ServerName := aServiceName; |
221 |
– |
LoginParams.Values['user_name'] := aUserName; |
222 |
– |
LoginParams.Values['password'] := aPassword; |
223 |
– |
end |
224 |
– |
else |
225 |
– |
IBError(ibxeOperationCancelled, [nil]); |
226 |
– |
end; |
181 |
|
|
182 |
|
procedure TMainForm.LimboTransactionsExecute(Sender: TObject); |
183 |
|
var aDBName: string; |
188 |
|
if SelectDBDlg.ShowModal(aDBName) = mrOK then |
189 |
|
begin |
190 |
|
DBName := aDBName; |
191 |
< |
RunService(LimboTransactionValidation,@RunLimboTransactions); |
191 |
> |
IBXLimboTransactionResolutionService1.DatabaseName := DBName; |
192 |
> |
ShowModal; |
193 |
|
end; |
194 |
|
end; |
195 |
|
end; |
202 |
|
begin |
203 |
|
DBName := aDBName; |
204 |
|
IBStatisticalService1.Options := [DataPages]; |
205 |
< |
RunService(IBStatisticalService1,@RunShowStatistics); |
205 |
> |
IBStatisticalService1.DatabaseName := DBName; |
206 |
> |
Memo1.Lines.Add('Database Statistics for ' + IBStatisticalService1.DatabaseName); |
207 |
> |
IBStatisticalService1.Execute(Memo1.Lines); |
208 |
|
end; |
209 |
|
end; |
210 |
|
|
214 |
|
begin |
215 |
|
UseOnlineValidation := false; |
216 |
|
aDBName := DBName; |
217 |
< |
if SelectValidationDlg.ShowModal(IBServerProperties1.ServerName,aDBName,UseOnlineValidation) = mrOK then |
217 |
> |
if SelectValidationDlg.ShowModal(IBXServicesConnection1.ServerName,aDBName,UseOnlineValidation) = mrOK then |
218 |
|
begin |
219 |
|
DBName := aDBName; |
220 |
+ |
Memo1.Lines.Add('Running...'); |
221 |
|
if UseOnlineValidation then |
222 |
< |
FValidationService := IBOnlineValidationService1 |
222 |
> |
begin |
223 |
> |
IBOnlineValidationService1.DatabaseName := DBName; |
224 |
> |
IBOnlineValidationService1.Execute(Memo1.Lines); |
225 |
> |
end |
226 |
|
else |
227 |
|
begin |
267 |
– |
FValidationService := IBValidationService1; |
228 |
|
IBValidationService1.Options := [ValidateFull]; |
229 |
+ |
IBValidationService1.DatabaseName := DBName; |
230 |
+ |
IBValidationService1.Execute(Memo1.Lines); |
231 |
|
end; |
232 |
< |
RunService(FValidationService,@RunValidation); |
232 |
> |
Memo1.Lines.Add('Validation Completed'); |
233 |
> |
MessageDlg('Validation Completed',mtInformation,[mbOK],0); |
234 |
|
end; |
235 |
|
end; |
236 |
|
|
237 |
|
procedure TMainForm.SetDBName(AValue: string); |
238 |
|
begin |
239 |
|
if FDBName = AValue then Exit; |
277 |
– |
UseServerLogin; |
240 |
|
FDBName := AValue; |
241 |
|
end; |
242 |
|
|
281 |
– |
procedure TMainForm.UseServerLogin; |
282 |
– |
var index: integer; |
283 |
– |
begin |
284 |
– |
index := IBServerProperties1.Params.IndexOfName('expected_db'); |
285 |
– |
if index <> -1 then |
286 |
– |
begin |
287 |
– |
{Log back in at Server Level} |
288 |
– |
IBServerProperties1.Active := false; |
289 |
– |
IBServerProperties1.LoginPrompt := false; |
290 |
– |
IBServerProperties1.Params.Values['user_name'] := FServerUserName; |
291 |
– |
IBServerProperties1.Params.Values['password'] := FServerPassword; |
292 |
– |
IBServerProperties1.Params.Delete(index); |
293 |
– |
IBServerProperties1.Active := true; |
294 |
– |
end; |
295 |
– |
end; |
296 |
– |
|
297 |
– |
{Common code for launching a service that might need to use and alt. security database} |
298 |
– |
|
299 |
– |
function TMainForm.RunService(aService: TIBCustomService; RunProc: TRunServiceProc |
300 |
– |
): boolean; |
301 |
– |
|
302 |
– |
procedure AltDBLogin; |
303 |
– |
var index: integer; |
304 |
– |
begin |
305 |
– |
with IBServerProperties1 do |
306 |
– |
begin |
307 |
– |
Active := false; |
308 |
– |
LoginPrompt := true; |
309 |
– |
Params.Add('expected_db='+DBName); |
310 |
– |
index := Params.IndexOfName('password'); |
311 |
– |
if index <> -1 then |
312 |
– |
Params.Delete(index); |
313 |
– |
|
314 |
– |
{Now make sure we are logged in} |
315 |
– |
|
316 |
– |
while not Active do |
317 |
– |
begin |
318 |
– |
try |
319 |
– |
Active := true; |
320 |
– |
except |
321 |
– |
on E:EIBClientError do |
322 |
– |
raise; |
323 |
– |
On E:Exception do |
324 |
– |
begin |
325 |
– |
MessageDlg(E.Message,mtError,[mbOK],0); |
326 |
– |
Active := false; |
327 |
– |
end; |
328 |
– |
end; |
329 |
– |
end; {Loop until logged in or user cancels} |
330 |
– |
|
331 |
– |
end; |
332 |
– |
end; |
333 |
– |
|
334 |
– |
begin |
335 |
– |
Result := false; |
336 |
– |
if aService is TIBValidationService then |
337 |
– |
TIBValidationService(aService).DatabaseName := DBName |
338 |
– |
else |
339 |
– |
if aService is TIBOnlineValidationService then |
340 |
– |
TIBOnlineValidationService(aService).DatabaseName := DBName |
341 |
– |
else |
342 |
– |
if aService is TIBStatisticalService then |
343 |
– |
TIBStatisticalService(aService).DatabaseName := DBName |
344 |
– |
else |
345 |
– |
if aService is TIBConfigService then |
346 |
– |
TIBConfigService(aService).DatabaseName := DBName; |
347 |
– |
try |
348 |
– |
repeat |
349 |
– |
with aService do |
350 |
– |
begin |
351 |
– |
Active := false; |
352 |
– |
Assign(IBServerProperties1); |
353 |
– |
end; |
354 |
– |
try |
355 |
– |
RunProc; |
356 |
– |
Result := true; |
357 |
– |
except |
358 |
– |
on E:EIBClientError do {Typically Login cancelled} |
359 |
– |
begin |
360 |
– |
MessageDlg(E.Message,mtError,[mbOK],0); |
361 |
– |
Exit; |
362 |
– |
end; |
363 |
– |
on E: EIBInterBaseError do |
364 |
– |
if E.IBErrorCode = isc_sec_context then {Need expected_db} |
365 |
– |
AltDBLogin |
366 |
– |
else |
367 |
– |
raise; |
368 |
– |
end; |
369 |
– |
aService.Active := false; |
370 |
– |
until Result; |
371 |
– |
except on E:Exception do |
372 |
– |
MessageDlg(E.Message,mtError,[mbOK],0); |
373 |
– |
end; |
374 |
– |
end; |
375 |
– |
|
376 |
– |
procedure TMainForm.RunShowStatistics; |
377 |
– |
begin |
378 |
– |
with IBStatisticalService1 do |
379 |
– |
begin |
380 |
– |
ServiceStart; |
381 |
– |
Memo1.Lines.Add('Database Statistics for ' + IBStatisticalService1.DatabaseName); |
382 |
– |
while not Eof do |
383 |
– |
begin |
384 |
– |
Memo1.Lines.Add(GetNextLine); |
385 |
– |
Application.ProcessMessages; |
386 |
– |
end; |
387 |
– |
end; |
388 |
– |
end; |
389 |
– |
|
390 |
– |
procedure TMainForm.RunValidation; |
391 |
– |
begin |
392 |
– |
with FValidationService do |
393 |
– |
begin |
394 |
– |
ServiceStart; |
395 |
– |
Memo1.Lines.Add('Running...'); |
396 |
– |
while not Eof do |
397 |
– |
begin |
398 |
– |
Memo1.Lines.Add(GetNextLine); |
399 |
– |
Application.ProcessMessages; |
400 |
– |
end; |
401 |
– |
Memo1.Lines.Add('Validation Completed'); |
402 |
– |
MessageDlg('Validation Completed',mtInformation,[mbOK],0); |
403 |
– |
end; |
404 |
– |
end; |
405 |
– |
|
406 |
– |
procedure TMainForm.RunLimboTransactions; |
407 |
– |
begin |
408 |
– |
with LimboTransactionsForm do |
409 |
– |
begin |
410 |
– |
{test access credentials} |
411 |
– |
LimboTransactionValidation.ServiceStart; |
412 |
– |
LimboTransactionValidation.FetchLimboTransactionInfo; |
413 |
– |
ShowModal; |
414 |
– |
end; |
415 |
– |
end; |
416 |
– |
|
417 |
– |
procedure TMainForm.RunSweep; |
418 |
– |
var ReportCount: integer; |
419 |
– |
begin |
420 |
– |
ReportCount := 0; |
421 |
– |
with IBValidationService1 do |
422 |
– |
begin |
423 |
– |
Memo1.Lines.Add(Format(sDBSweep,[DatabaseName])); |
424 |
– |
try |
425 |
– |
ServiceStart; |
426 |
– |
While not Eof do |
427 |
– |
begin |
428 |
– |
Inc(ReportCount); |
429 |
– |
Memo1.Lines.Add(GetNextLine); |
430 |
– |
Application.ProcessMessages; |
431 |
– |
end |
432 |
– |
finally |
433 |
– |
while IsServiceRunning do; |
434 |
– |
end |
435 |
– |
end; |
436 |
– |
Memo1.Lines.Add(sSweepOK); |
437 |
– |
end; |
438 |
– |
|
243 |
|
function TMainForm.IsDatabaseOnline: boolean; |
244 |
< |
var Line: string; |
244 |
> |
var Lines: TStringList; |
245 |
> |
i: integer; |
246 |
> |
line: string; |
247 |
|
begin |
248 |
|
{Scan header page to see if database is online - assumes that service is already set up} |
249 |
|
Result := true; |
250 |
|
with IBStatisticalService1 do |
251 |
|
begin |
446 |
– |
Assign(IBServerProperties1); |
252 |
|
Options := [HeaderPages]; |
253 |
< |
Active := True; |
253 |
> |
DatabaseName := DBName; |
254 |
> |
Lines := TStringList.Create; |
255 |
|
try |
256 |
< |
ServiceStart; |
257 |
< |
while not Eof do |
256 |
> |
Execute(Lines); |
257 |
> |
for i := 0 to Lines.Count - 1 do |
258 |
|
begin |
259 |
< |
Line := GetNextLine; |
259 |
> |
line := Lines[i]; |
260 |
|
if (Pos('Attributes',Line) <> 0) and ((Pos('database shutdown',Line) <> 0) |
261 |
|
or (Pos('multi-user maintenance',Line) <> 0)) then |
262 |
+ |
begin |
263 |
|
Result := false; |
264 |
+ |
break; |
265 |
+ |
end; |
266 |
|
|
267 |
|
end; |
459 |
– |
while IsServiceRunning do; |
268 |
|
finally |
269 |
< |
Active := False; |
269 |
> |
Lines.Free; |
270 |
|
end |
271 |
|
end; |
272 |
|
end; |
273 |
|
|
466 |
– |
procedure TMainForm.RunBringOnline; |
467 |
– |
begin |
468 |
– |
if IsDatabaseOnline then |
469 |
– |
MessageDlg('Database is already online!',mtInformation,[mbOK],0) |
470 |
– |
else |
471 |
– |
begin |
472 |
– |
IBConfigService1.Assign(IBServerProperties1); |
473 |
– |
IBConfigService1.DatabaseName := DBName; |
474 |
– |
IBConfigService1.BringDatabaseOnline; |
475 |
– |
while IBConfigService1.IsServiceRunning do; |
476 |
– |
if IsDatabaseOnline then |
477 |
– |
MessageDlg('Database is back online',mtInformation,[mbOK],0) |
478 |
– |
else |
479 |
– |
MessageDlg('Database is still shutdown!',mtError,[mbOK],0); |
480 |
– |
end; |
481 |
– |
end; |
482 |
– |
|
483 |
– |
procedure TMainForm.RunShutdown; |
484 |
– |
begin |
485 |
– |
if not IsDatabaseOnline then |
486 |
– |
MessageDlg('Database is already shutdown!',mtInformation,[mbOK],0) |
487 |
– |
else |
488 |
– |
begin |
489 |
– |
ShutdownDatabaseDlg.IBConfigService.DatabaseName := DBName; |
490 |
– |
ShutdownDatabaseDlg.Shutdown(FShutDownMode,FDelay); |
491 |
– |
end; |
492 |
– |
end; |
493 |
– |
|
274 |
|
procedure TMainForm.CLoseBtnClick(Sender: TObject); |
275 |
|
begin |
276 |
|
Close |
283 |
|
if SelectDBDlg.ShowModal(aDBName) = mrOK then |
284 |
|
begin |
285 |
|
DBName := aDBName; |
286 |
< |
RunService(IBStatisticalService1,@RunBringOnline); |
286 |
> |
if IsDatabaseOnline then |
287 |
> |
MessageDlg('Database is already online!',mtInformation,[mbOK],0) |
288 |
> |
else |
289 |
> |
begin |
290 |
> |
IBConfigService1.DatabaseName := DBName; |
291 |
> |
IBConfigService1.BringDatabaseOnline; |
292 |
> |
if IsDatabaseOnline then |
293 |
> |
MessageDlg('Database is back online',mtInformation,[mbOK],0) |
294 |
> |
else |
295 |
> |
MessageDlg('Database is still shutdown!',mtError,[mbOK],0); |
296 |
> |
end; |
297 |
|
end; |
298 |
|
end; |
299 |
|
|
303 |
|
end; |
304 |
|
|
305 |
|
procedure TMainForm.BackupBtnClick(Sender: TObject); |
306 |
+ |
var aDBName: string; |
307 |
|
begin |
308 |
< |
BackupDlg.IBBackupService1.ServerName := IBServerProperties1.ServerName; |
309 |
< |
BackupDlg.IBBackupService1.DatabaseName := DBName; |
310 |
< |
if BackupDlg.ShowModal = mrOK then |
308 |
> |
aDBName := DBName; |
309 |
> |
if BackupDlg.ShowModal(aDBName,Memo1.Lines) = mrOK then |
310 |
> |
DBName := aDBName; |
311 |
> |
end; |
312 |
> |
|
313 |
> |
{Logon to the current security database on the server} |
314 |
> |
|
315 |
> |
procedure TMainForm.IBXServicesConnection1Login( |
316 |
> |
Service: TIBXServicesConnection; var aServerName: string; LoginParams: TStrings); |
317 |
> |
var aServiceName: string; |
318 |
> |
aUserName: string; |
319 |
> |
aPassword: string; |
320 |
> |
begin |
321 |
> |
aServiceName := aServerName; |
322 |
> |
aUserName := LoginParams.Values['user_name']; |
323 |
> |
aPassword := ''; |
324 |
> |
if SvcLoginDlg.ShowModal(aServiceName, aUserName, aPassword) = mrOK then |
325 |
|
begin |
326 |
< |
DBName := BackupDlg.IBBackupService1.DatabaseName; |
327 |
< |
Runservice(BackupDlg.IBBackupService1,@BackupDlg.RunBackup); |
328 |
< |
end; |
326 |
> |
Service.ServerName := aServiceName; |
327 |
> |
LoginParams.Values['user_name'] := aUserName; |
328 |
> |
LoginParams.Values['password'] := aPassword; |
329 |
> |
FServerUserName := aUserName; |
330 |
> |
FServerPassword := aPassword; |
331 |
> |
aServerName := aServiceName; |
332 |
> |
end |
333 |
> |
else |
334 |
> |
IBError(ibxeOperationCancelled, [nil]); |
335 |
> |
end; |
336 |
> |
|
337 |
> |
procedure TMainForm.IBXServicesConnection1SecurityContextException( |
338 |
> |
Service: TIBXServicesConnection; var aAction: TSecContextAction); |
339 |
> |
begin |
340 |
> |
if MessageDlg(sSecContext,mtInformation,[mbYes,mbNo],0) = mrYes then |
341 |
> |
aAction := scReconnect; |
342 |
|
end; |
343 |
|
|
344 |
|
procedure TMainForm.RestoreBtnClick(Sender: TObject); |
345 |
+ |
var aDBName: string; |
346 |
|
begin |
347 |
< |
RestoreDlg.IBRestoreService1.ServerName := IBServerProperties1.ServerName; |
348 |
< |
RestoreDlg.IBRestoreService1.DatabaseName[0] := DBName; |
349 |
< |
if RestoreDlg.ShowModal = mrOK then |
531 |
< |
begin |
532 |
< |
DBName := RestoreDlg.IBRestoreService1.DatabaseName[0]; |
533 |
< |
UseServerLogin; {Avoid server hanging if we use an alt. sec. database wrongly} |
534 |
< |
RunService(RestoreDlg.IBRestoreService1,@RestoreDlg.RunRestore); |
535 |
< |
end; |
347 |
> |
aDBName := DBName; |
348 |
> |
if RestoreDlg.ShowModal(aDBName,Memo1.Lines) = mrOK then |
349 |
> |
DBName := aDBName; |
350 |
|
end; |
351 |
|
|
352 |
|
procedure TMainForm.ServerLOgBtnClick(Sender: TObject); |
353 |
|
begin |
354 |
|
Memo1.Lines.Add('Server Log'); |
355 |
< |
{No chance that we will need an alt. security database - so just assign it the |
542 |
< |
server connection} |
543 |
< |
IBLogService1.Assign(IBServerProperties1); |
544 |
< |
with IBLogService1 do |
545 |
< |
begin |
546 |
< |
ServiceStart; |
547 |
< |
while not Eof do |
548 |
< |
begin |
549 |
< |
Memo1.Lines.Add(GetNextLine); |
550 |
< |
Application.ProcessMessages; |
551 |
< |
end; |
552 |
< |
end; |
355 |
> |
IBLogService1.Execute(Memo1.Lines); |
356 |
|
end; |
357 |
|
|
358 |
|
procedure TMainForm.DatabaseBtnClick(Sender: TObject); |
368 |
|
if ShutdownReqDlg.ShowModal(aDBName,FShutDownMode,FDelay) = mrOK then |
369 |
|
begin |
370 |
|
DBName := aDBName; |
371 |
< |
RunService(ShutdownDatabaseDlg.IBConfigService,@RunShutdown); |
371 |
> |
if not IsDatabaseOnline then |
372 |
> |
MessageDlg('Database is already shutdown!',mtInformation,[mbOK],0) |
373 |
> |
else |
374 |
> |
ShutdownDatabaseDlg.Shutdown(DBName,FShutDownMode,FDelay); |
375 |
|
end; |
376 |
|
end; |
377 |
|
|
380 |
|
begin |
381 |
|
aDBName := DBName; |
382 |
|
if SelectDBDlg.ShowModal(aDBName) = mrOK then |
383 |
+ |
with IBValidationService1 do |
384 |
|
begin |
385 |
|
DBName := aDBName; |
386 |
< |
IBValidationService1.Options := [SweepDB]; |
387 |
< |
RunService(IBValidationService1,@RunSweep); |
386 |
> |
DatabaseName := DBName; |
387 |
> |
Options := [SweepDB]; |
388 |
> |
Memo1.Lines.Add(Format(sDBSweep,[DatabaseName])); |
389 |
> |
Execute(Memo1.Lines); |
390 |
> |
Memo1.Lines.Add(sSweepOK); |
391 |
|
end; |
392 |
|
end; |
393 |
|
|
394 |
|
procedure TMainForm.UsersBtnClick(Sender: TObject); |
395 |
|
begin |
396 |
< |
UseServerLogin; |
587 |
< |
with ListUsersForm do |
588 |
< |
begin |
589 |
< |
{No chance that we will need an alt. security database - so just assign it the |
590 |
< |
server connection} |
591 |
< |
IBSecurityService1.Assign(IBServerProperties1); |
592 |
< |
ShowModal; |
593 |
< |
end; |
396 |
> |
ListUsersForm.ShowModal; |
397 |
|
end; |
398 |
|
|
399 |
|
end. |