1 |
(* |
2 |
* MainFormUnit.pas |
3 |
* Copyright (C) 2018 Tony Whyman <tony@mwasoftware.co.uk> |
4 |
* |
5 |
* DBAdmin is free software: you can redistribute it and/or modify it |
6 |
* under the terms of the GNU General Public License as published by the |
7 |
* Free Software Foundation, either version 3 of the License, or |
8 |
* (at your option) any later version. |
9 |
* |
10 |
* DBAdmin is distributed in the hope that it will be useful, but |
11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13 |
* See the GNU General Public License for more details. |
14 |
* |
15 |
* You should have received a copy of the GNU General Public License along |
16 |
* with this program. If not, see <http://www.gnu.org/licenses/>. |
17 |
*) |
18 |
unit MainFormUnit; |
19 |
|
20 |
{$mode objfpc}{$H+} |
21 |
|
22 |
interface |
23 |
|
24 |
uses |
25 |
Classes, SysUtils, FileUtil, SynEdit, SynHighlighterSQL, SynGutterCodeFolding, |
26 |
Forms, Controls, Graphics, Dialogs, Menus, ComCtrls, ActnList, StdCtrls, |
27 |
DbCtrls, ExtCtrls, Buttons, db, IBLookupComboEditBox, IBDynamicGrid, |
28 |
IBTreeView, IBDatabaseInfo, IBXServices, IBExtract, IB; |
29 |
|
30 |
type |
31 |
|
32 |
{ TMainForm } |
33 |
|
34 |
TMainForm = class(TForm) |
35 |
AccessRightsPopup: TPopupMenu; |
36 |
AccessRightsSource: TDataSource; |
37 |
ClientLibrary: TLabel; |
38 |
ConfigDataGrid: TIBDynamicGrid; |
39 |
ConfigDataLabel: TLabel; |
40 |
ConfigDataSource: TDataSource; |
41 |
Edit12: TEdit; |
42 |
Edit2: TEdit; |
43 |
Edit3: TEdit; |
44 |
Edit4: TEdit; |
45 |
Edit5: TEdit; |
46 |
Edit6: TEdit; |
47 |
Edit7: TEdit; |
48 |
Edit8: TEdit; |
49 |
Edit9: TEdit; |
50 |
Label44: TLabel; |
51 |
ClientServerVersion: TMemo; |
52 |
Label45: TLabel; |
53 |
Label46: TLabel; |
54 |
Label47: TLabel; |
55 |
Label48: TLabel; |
56 |
Label49: TLabel; |
57 |
Label50: TLabel; |
58 |
Label51: TLabel; |
59 |
Label52: TLabel; |
60 |
Label53: TLabel; |
61 |
Label54: TLabel; |
62 |
OpenDatabasesList: TMemo; |
63 |
MenuItem20: TMenuItem; |
64 |
MenuItem21: TMenuItem; |
65 |
Panel10: TPanel; |
66 |
RunScript: TAction; |
67 |
AutoAdmin: TCheckBox; |
68 |
DatabaseAliasName: TEdit; |
69 |
DBEdit5: TDBEdit; |
70 |
DBEdit6: TDBEdit; |
71 |
IncludeUserGrants: TCheckBox; |
72 |
Label41: TLabel; |
73 |
Label42: TLabel; |
74 |
Label43: TLabel; |
75 |
DBComments: TMemo; |
76 |
MenuItem19: TMenuItem; |
77 |
RevokeAll: TAction; |
78 |
AuthMapSource: TDataSource; |
79 |
SubjectAccessRightsSource: TDataSource; |
80 |
DBTablesSource: TDataSource; |
81 |
IBDynamicGrid5: TIBDynamicGrid; |
82 |
SubjectAccessRightsGrid: TIBDynamicGrid; |
83 |
AccessRightsTreeView: TIBTreeView; |
84 |
SelectAllTables: TCheckBox; |
85 |
Label40: TLabel; |
86 |
SelectedTablesGrid: TIBDynamicGrid; |
87 |
Label37: TLabel; |
88 |
Panel8: TPanel; |
89 |
DBTablesPanel: TPanel; |
90 |
Panel9: TPanel; |
91 |
Phase2Repair: TAction; |
92 |
ApplySelected: TAction; |
93 |
AuthMethLabel: TLabel; |
94 |
AuthMethod: TDBEdit; |
95 |
Button7: TButton; |
96 |
IgnoreChecksumsOnRepair: TCheckBox; |
97 |
DBTablesSplitter: TSplitter; |
98 |
Alltables: TRadioButton; |
99 |
SelectedTablesOnly: TRadioButton; |
100 |
MappingsTab: TTabSheet; |
101 |
AccessRightsTab: TTabSheet; |
102 |
Splitter5: TSplitter; |
103 |
ToolButton6: TToolButton; |
104 |
ToolButton7: TToolButton; |
105 |
UpdateColsPanel: TPanel; |
106 |
ValidateRepairRecordFragments: TCheckBox; |
107 |
IgnoreChecksums: TCheckBox; |
108 |
Label34: TLabel; |
109 |
ReadOnlyValidation: TCheckBox; |
110 |
RecordFragments: TCheckBox; |
111 |
Commit2Phase: TAction; |
112 |
DBOwner: TEdit; |
113 |
AttmntODS12Panel: TPanel; |
114 |
Label33: TLabel; |
115 |
RepairOptionsTab: TTabSheet; |
116 |
ValidateOptions: TPageControl; |
117 |
RemoteOSLabel: TLabel; |
118 |
RemoteOSUser: TDBEdit; |
119 |
SecDatabase: TEdit; |
120 |
RollbackAll: TAction; |
121 |
CommitAll: TAction; |
122 |
Button3: TButton; |
123 |
Button4: TButton; |
124 |
Button5: TButton; |
125 |
Button6: TButton; |
126 |
IBDynamicGrid3: TIBDynamicGrid; |
127 |
Label38: TLabel; |
128 |
Label39: TLabel; |
129 |
LimboListSource: TDataSource; |
130 |
LimboReport: TMemo; |
131 |
RunRepair: TAction; |
132 |
Button2: TButton; |
133 |
SelectRepairAction: TComboBox; |
134 |
DisconnectAttachment: TAction; |
135 |
LimboTab: TTabSheet; |
136 |
ValidateOptionsTab: TTabSheet; |
137 |
MenuItem17: TMenuItem; |
138 |
AttmtPopup: TPopupMenu; |
139 |
MenuItem18: TMenuItem; |
140 |
RepairTab: TTabSheet; |
141 |
ToggleAutoRefresh: TAction; |
142 |
AttachSource: TDataSource; |
143 |
DBCheckBox1: TDBCheckBox; |
144 |
DBEdit2: TDBEdit; |
145 |
DBEdit3: TDBEdit; |
146 |
DBEdit7: TDBEdit; |
147 |
DeleteTag: TAction; |
148 |
AddTag: TAction; |
149 |
AttmtGrid: TIBDynamicGrid; |
150 |
Label31: TLabel; |
151 |
Label32: TLabel; |
152 |
Label35: TLabel; |
153 |
MenuItem11: TMenuItem; |
154 |
MenuItem12: TMenuItem; |
155 |
MenuItem13: TMenuItem; |
156 |
MenuItem14: TMenuItem; |
157 |
MenuItem15: TMenuItem; |
158 |
MenuItem16: TMenuItem; |
159 |
Panel7: TPanel; |
160 |
AttDetailsPanel: TPanel; |
161 |
UserPopup: TPopupMenu; |
162 |
UserTagPopup: TPopupMenu; |
163 |
SaveChanges: TAction; |
164 |
DeleteUser: TAction; |
165 |
ChgPassword: TAction; |
166 |
AddUser: TAction; |
167 |
AddFileBtn: TButton; |
168 |
AddShadowBtn: TButton; |
169 |
AllocatedPages: TEdit; |
170 |
Button1: TButton; |
171 |
DatabaseOnline: TCheckBox; |
172 |
DBCharacterSet: TIBLookupComboEditBox; |
173 |
DBCharSetRO: TDBEdit; |
174 |
DateDbCreated: TDBEdit; |
175 |
DBEdit4: TDBEdit; |
176 |
DBIsReadOnly: TCheckBox; |
177 |
DBText1: TDBText; |
178 |
DropDatabase: TAction; |
179 |
Edit1: TEdit; |
180 |
Edit10: TEdit; |
181 |
Edit11: TEdit; |
182 |
PageBuffers: TEdit; |
183 |
ODSVersionString: TEdit; |
184 |
ServerVersionNo: TEdit; |
185 |
DBSQLDialect: TEdit; |
186 |
ConnectString: TEdit; |
187 |
UserManagerTab: TTabSheet; |
188 |
FilesTab: TTabSheet; |
189 |
IBDynamicGrid1: TIBDynamicGrid; |
190 |
IBDynamicGrid2: TIBDynamicGrid; |
191 |
AttmtTimer: TTimer; |
192 |
UserManagerGrid: TIBDynamicGrid; |
193 |
RolesGrid: TIBDynamicGrid; |
194 |
TagsGrid: TIBDynamicGrid; |
195 |
IsShadowChk: TCheckBox; |
196 |
Label1: TLabel; |
197 |
Label10: TLabel; |
198 |
Label11: TLabel; |
199 |
Label12: TLabel; |
200 |
Label13: TLabel; |
201 |
Label14: TLabel; |
202 |
Label15: TLabel; |
203 |
Label16: TLabel; |
204 |
Label17: TLabel; |
205 |
Label18: TLabel; |
206 |
Label19: TLabel; |
207 |
Label2: TLabel; |
208 |
Label20: TLabel; |
209 |
Label21: TLabel; |
210 |
Label22: TLabel; |
211 |
DateDBCreatedLabel: TLabel; |
212 |
Label24: TLabel; |
213 |
Label25: TLabel; |
214 |
Label26: TLabel; |
215 |
Label27: TLabel; |
216 |
Label28: TLabel; |
217 |
Label29: TLabel; |
218 |
Label3: TLabel; |
219 |
Label30: TLabel; |
220 |
Label36: TLabel; |
221 |
Label4: TLabel; |
222 |
Label5: TLabel; |
223 |
Label6: TLabel; |
224 |
Label7: TLabel; |
225 |
Label8: TLabel; |
226 |
Label9: TLabel; |
227 |
LingerDelay: TEdit; |
228 |
MenuItem10: TMenuItem; |
229 |
MenuItem9: TMenuItem; |
230 |
MenuItem8: TMenuItem; |
231 |
NoReserve: TCheckBox; |
232 |
PageControl1: TPageControl; |
233 |
PagesAvail: TEdit; |
234 |
PagesUsed: TEdit; |
235 |
Panel1: TPanel; |
236 |
Panel2: TPanel; |
237 |
Panel3: TPanel; |
238 |
Panel4: TPanel; |
239 |
Panel5: TPanel; |
240 |
RolesHeaderPanel: TPanel; |
241 |
TagsHeader: TPanel; |
242 |
PrimaryDBFile: TEdit; |
243 |
Properties: TTabSheet; |
244 |
RemoveShadowBtn: TButton; |
245 |
RoleSource: TDataSource; |
246 |
Save: TAction; |
247 |
IBExtract1: TIBExtract; |
248 |
SaveDialog: TSaveDialog; |
249 |
SchemaTab: TTabSheet; |
250 |
ServerLog: TMemo; |
251 |
ServerTab: TTabSheet; |
252 |
Splitter1: TSplitter; |
253 |
Splitter2: TSplitter; |
254 |
Splitter3: TSplitter; |
255 |
Splitter4: TSplitter; |
256 |
SQlSaveDialog: TSaveDialog; |
257 |
RemoveShadow: TAction; |
258 |
AddShadowSet: TAction; |
259 |
AddSecondary: TAction; |
260 |
MenuItem6: TMenuItem; |
261 |
MenuItem7: TMenuItem; |
262 |
OpenDatabase: TAction; |
263 |
CharSetSource: TDataSource; |
264 |
DatabaseSource: TDataSource; |
265 |
AttmtSource: TDataSource; |
266 |
DBCharSetSource: TDataSource; |
267 |
IBDatabaseInfo: TIBDatabaseInfo; |
268 |
MenuItem3: TMenuItem; |
269 |
MenuItem4: TMenuItem; |
270 |
MenuItem5: TMenuItem; |
271 |
Restore: TAction; |
272 |
Backup: TAction; |
273 |
MenuImages: TImageList; |
274 |
MenuItem1: TMenuItem; |
275 |
MenuItem2: TMenuItem; |
276 |
Quit: TAction; |
277 |
ActionList1: TActionList; |
278 |
MainMenu1: TMainMenu; |
279 |
SecDBFilesSource: TDataSource; |
280 |
ShadowSource: TDataSource; |
281 |
StatisticsTab: TTabSheet; |
282 |
StatsMemo: TMemo; |
283 |
StatsOptions: TComboBox; |
284 |
StatusBar1: TStatusBar; |
285 |
SweepInterval: TEdit; |
286 |
SyncWrites: TCheckBox; |
287 |
SynEdit1: TSynEdit; |
288 |
SynSQLSyn1: TSynSQLSyn; |
289 |
AttachmentsTab: TTabSheet; |
290 |
ToolBar1: TToolBar; |
291 |
ToolButton1: TToolButton; |
292 |
ToolButton2: TToolButton; |
293 |
ToolButton3: TToolButton; |
294 |
ToolButton4: TToolButton; |
295 |
ToolButton5: TToolButton; |
296 |
UserListSource: TDataSource; |
297 |
UserTagsSource: TDataSource; |
298 |
ValidationReport: TMemo; |
299 |
procedure AccessRightsTabHide(Sender: TObject); |
300 |
procedure AccessRightsTabShow(Sender: TObject); |
301 |
procedure AddSecondaryExecute(Sender: TObject); |
302 |
procedure AddShadowSetExecute(Sender: TObject); |
303 |
procedure AddTagExecute(Sender: TObject); |
304 |
procedure AddTagUpdate(Sender: TObject); |
305 |
procedure AddUserExecute(Sender: TObject); |
306 |
procedure AddUserUpdate(Sender: TObject); |
307 |
procedure ApplySelectedExecute(Sender: TObject); |
308 |
procedure AttachmentsTabHide(Sender: TObject); |
309 |
procedure AttachmentsTabShow(Sender: TObject); |
310 |
procedure AttmtTimerTimer(Sender: TObject); |
311 |
procedure AutoAdminChange(Sender: TObject); |
312 |
procedure BackupExecute(Sender: TObject); |
313 |
procedure ChgPasswordExecute(Sender: TObject); |
314 |
procedure ChgPasswordUpdate(Sender: TObject); |
315 |
procedure Commit2PhaseExecute(Sender: TObject); |
316 |
procedure CommitAllExecute(Sender: TObject); |
317 |
procedure CommitAllUpdate(Sender: TObject); |
318 |
procedure DatabaseOnlineChange(Sender: TObject); |
319 |
procedure DBCharacterSetEditingDone(Sender: TObject); |
320 |
procedure DBCommentsEditingDone(Sender: TObject); |
321 |
procedure DBIsReadOnlyChange(Sender: TObject); |
322 |
procedure DBSQLDialectEditingDone(Sender: TObject); |
323 |
procedure DeleteTagExecute(Sender: TObject); |
324 |
procedure DeleteTagUpdate(Sender: TObject); |
325 |
procedure DeleteUserExecute(Sender: TObject); |
326 |
procedure DeleteUserUpdate(Sender: TObject); |
327 |
procedure DisconnectAttachmentExecute(Sender: TObject); |
328 |
procedure DisconnectAttachmentUpdate(Sender: TObject); |
329 |
procedure DropDatabaseExecute(Sender: TObject); |
330 |
procedure DropDatabaseUpdate(Sender: TObject); |
331 |
procedure AccessRightsTreeViewSelectionChanged(Sender: TObject); |
332 |
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); |
333 |
procedure MappingsTabHide(Sender: TObject); |
334 |
procedure MappingsTabShow(Sender: TObject); |
335 |
procedure PageBuffersEditingDone(Sender: TObject); |
336 |
procedure QuitExecute(Sender: TObject); |
337 |
procedure RepairTabHide(Sender: TObject); |
338 |
procedure RepairTabShow(Sender: TObject); |
339 |
procedure RevokeAllExecute(Sender: TObject); |
340 |
procedure RevokeAllUpdate(Sender: TObject); |
341 |
procedure RunScriptExecute(Sender: TObject); |
342 |
procedure SelectAllTablesChange(Sender: TObject); |
343 |
procedure SelectedTablesOnlyChange(Sender: TObject); |
344 |
procedure SelectRepairActionCloseUp(Sender: TObject); |
345 |
procedure SubjectAccessRightsSourceDataChange(Sender: TObject; Field: TField |
346 |
); |
347 |
procedure UserManagerTabHide(Sender: TObject); |
348 |
procedure UserManagerTabShow(Sender: TObject); |
349 |
procedure FilesTabShow(Sender: TObject); |
350 |
procedure FormShow(Sender: TObject); |
351 |
procedure IsShadowChkChange(Sender: TObject); |
352 |
procedure LimboTabHide(Sender: TObject); |
353 |
procedure LimboTabShow(Sender: TObject); |
354 |
procedure LingerDelayEditingDone(Sender: TObject); |
355 |
procedure NoReserveChange(Sender: TObject); |
356 |
procedure OpenDatabaseExecute(Sender: TObject); |
357 |
procedure PropertiesShow(Sender: TObject); |
358 |
procedure RemoveShadowExecute(Sender: TObject); |
359 |
procedure RemoveShadowUpdate(Sender: TObject); |
360 |
procedure RestoreExecute(Sender: TObject); |
361 |
procedure RollbackAllExecute(Sender: TObject); |
362 |
procedure RunRepairExecute(Sender: TObject); |
363 |
procedure SaveChangesExecute(Sender: TObject); |
364 |
procedure SaveChangesUpdate(Sender: TObject); |
365 |
procedure SaveExecute(Sender: TObject); |
366 |
procedure SaveUpdate(Sender: TObject); |
367 |
procedure SchemaTabShow(Sender: TObject); |
368 |
procedure ServerTabHide(Sender: TObject); |
369 |
procedure ServerTabShow(Sender: TObject); |
370 |
procedure StatisticsTabHide(Sender: TObject); |
371 |
procedure StatisticsTabShow(Sender: TObject); |
372 |
procedure StatsOptionsCloseUp(Sender: TObject); |
373 |
procedure SweepIntervalEditingDone(Sender: TObject); |
374 |
procedure SyncWritesChange(Sender: TObject); |
375 |
procedure ToggleAutoRefreshExecute(Sender: TObject); |
376 |
procedure ToggleAutoRefreshUpdate(Sender: TObject); |
377 |
private |
378 |
FLoading: boolean; |
379 |
FLastStatsIndex: integer; |
380 |
FServerError: boolean; |
381 |
procedure DoDBOpen(Data: PtrInt); |
382 |
procedure LoadServerData; |
383 |
procedure DoExtract(Data: PtrInt); |
384 |
procedure ConfigureOnlineValidation; |
385 |
protected |
386 |
procedure HandleDBConnect(Sender: TObject); |
387 |
procedure HandleLoadData(Sender: TObject); |
388 |
procedure ConfigureForServerVersion; virtual; |
389 |
procedure ConnectToDatabase; virtual; |
390 |
procedure LoadData; virtual; |
391 |
public |
392 |
end; |
393 |
|
394 |
var |
395 |
MainForm: TMainForm; |
396 |
|
397 |
implementation |
398 |
|
399 |
{$R *.lfm} |
400 |
|
401 |
uses DataModule, ShutdownRegDlgUnit, AddSecondaryFileDlgUnit, NewUserDlgUnit, |
402 |
ChgPasswordDlgUnit, FBMessages, ExecuteSQLScriptDlgUnit; |
403 |
|
404 |
{ TMainForm } |
405 |
|
406 |
procedure TMainForm.FormShow(Sender: TObject); |
407 |
begin |
408 |
{Set IB Exceptions to only show text message - omit SQLCode and Engine Code} |
409 |
DBDataModule.IBDatabase1.FirebirdAPI.GetStatus.SetIBDataBaseErrorMessages([ShowIBMessage]); |
410 |
Application.ExceptionDialog := aedOkMessageBox; |
411 |
PageControl1.ActivePage := Properties; |
412 |
DBDataModule.AfterDBConnect := @HandleDBConnect; |
413 |
DBDataModule.AfterDataReload := @HandleLoadData; |
414 |
AccessRightsTreeView.DataSource := nil; |
415 |
AccessRightsTreeView.DataSource := AccessRightsSource; |
416 |
SubjectAccessRightsGrid.DataSource := nil; |
417 |
SubjectAccessRightsGrid.DataSource := SubjectAccessRightsSource; |
418 |
PageControl1.Visible := false; |
419 |
Application.QueueAsyncCall(@DoDBOpen,0); |
420 |
end; |
421 |
|
422 |
procedure TMainForm.IsShadowChkChange(Sender: TObject); |
423 |
begin |
424 |
if FLoading then Exit; |
425 |
if not DBDataModule.IsShadowDatabase then |
426 |
begin |
427 |
MessageDlg('A Normal Database cannot be changed into a Shadow Database',mtError,[mbOK],0); |
428 |
FLoading := true; |
429 |
try |
430 |
IsShadowChk.Checked := false; |
431 |
finally |
432 |
FLoading := false; |
433 |
end; |
434 |
end |
435 |
else |
436 |
DBDataModule.ActivateShadow; |
437 |
end; |
438 |
|
439 |
procedure TMainForm.LimboTabHide(Sender: TObject); |
440 |
begin |
441 |
LimboListSource.DataSet.Active := false; |
442 |
end; |
443 |
|
444 |
procedure TMainForm.LimboTabShow(Sender: TObject); |
445 |
begin |
446 |
if not Visible or not IBDatabaseInfo.Database.Connected then Exit; |
447 |
LimboListSource.DataSet.Active := true; |
448 |
end; |
449 |
|
450 |
procedure TMainForm.LingerDelayEditingDone(Sender: TObject); |
451 |
begin |
452 |
if FLoading then Exit; |
453 |
DBDataModule.LingerDelay := LingerDelay.Text; |
454 |
end; |
455 |
|
456 |
procedure TMainForm.NoReserveChange(Sender: TObject); |
457 |
begin |
458 |
if FLoading then Exit; |
459 |
DBDataModule.NoReserve := NoReserve.Checked; |
460 |
end; |
461 |
|
462 |
procedure TMainForm.DBCharacterSetEditingDone(Sender: TObject); |
463 |
begin |
464 |
with DBCharSetSource.Dataset do |
465 |
if State = dsEdit then |
466 |
Post; |
467 |
end; |
468 |
|
469 |
procedure TMainForm.DBCommentsEditingDone(Sender: TObject); |
470 |
begin |
471 |
DBDataModule.Description := DBComments.Lines.Text; |
472 |
end; |
473 |
|
474 |
procedure TMainForm.AutoAdminChange(Sender: TObject); |
475 |
begin |
476 |
if FLoading then Exit; |
477 |
try |
478 |
DBDataModule.AutoAdmin := AutoAdmin.Checked; |
479 |
except on E:Exception do |
480 |
begin |
481 |
MessageDlg(E.message,mtError,[mbOK],0); |
482 |
FLoading := true; |
483 |
try |
484 |
AutoAdmin.Checked := not AutoAdmin.Checked; |
485 |
finally |
486 |
FLoading := false; |
487 |
end; |
488 |
end; |
489 |
end; |
490 |
end; |
491 |
|
492 |
procedure TMainForm.AddSecondaryExecute(Sender: TObject); |
493 |
var FileName: string; |
494 |
StartAt: integer; |
495 |
FileLength: integer; |
496 |
Pages: boolean; |
497 |
begin |
498 |
StartAt := 0; |
499 |
if DBDataModule.IsDatabaseOnline then |
500 |
begin |
501 |
MessageDlg('The database must be shutdown before adding secondary files', |
502 |
mtError,[mbOK],0); |
503 |
exit; |
504 |
end; |
505 |
|
506 |
if AddSecondaryFileDlg.ShowModal(FileName,StartAt,FileLength,Pages) = mrOK then |
507 |
begin |
508 |
if not Pages then |
509 |
begin |
510 |
StartAt := StartAt*1024*1024 div IBDatabaseInfo.PageSize; |
511 |
if FileLength <> -1 then |
512 |
FileLength := FileLength*1024*1024 div IBDatabaseInfo.PageSize; |
513 |
end; |
514 |
DBDataModule.AddSecondaryFile(FileName,StartAt,FileLength); |
515 |
end; |
516 |
end; |
517 |
|
518 |
procedure TMainForm.AccessRightsTabShow(Sender: TObject); |
519 |
begin |
520 |
if not Visible or not IBDatabaseInfo.Database.Connected then Exit; |
521 |
UserListSource.DataSet.Active := true; |
522 |
AccessRightsSource.DataSet.Active := true; |
523 |
AccessRightsTreeViewSelectionChanged(nil); |
524 |
end; |
525 |
|
526 |
procedure TMainForm.AccessRightsTabHide(Sender: TObject); |
527 |
begin |
528 |
SubjectAccessRightsSource.DataSet.Active := false; |
529 |
AccessRightsSource.DataSet.Active := false; |
530 |
UserListSource.DataSet.Active := PageControl1.ActivePage = UserManagerTab; |
531 |
end; |
532 |
|
533 |
procedure TMainForm.AddShadowSetExecute(Sender: TObject); |
534 |
begin |
535 |
DBDataModule.AddShadowSet; |
536 |
end; |
537 |
|
538 |
procedure TMainForm.AddTagExecute(Sender: TObject); |
539 |
begin |
540 |
UserTagsSource.DataSet.Append; |
541 |
end; |
542 |
|
543 |
procedure TMainForm.AddTagUpdate(Sender: TObject); |
544 |
begin |
545 |
(Sender as TAction).Enabled := (UserTagsSource.State = dsBrowse); |
546 |
end; |
547 |
|
548 |
procedure TMainForm.AddUserExecute(Sender: TObject); |
549 |
var NewUserName: string; |
550 |
NewPassword: string; |
551 |
begin |
552 |
NewUserName := ''; |
553 |
if NewUserDlg.ShowModal(NewUserName,NewPassword) = mrOK then |
554 |
with UserListSource.DataSet do |
555 |
begin |
556 |
Append; |
557 |
FieldByName('SEC$USER_NAME').AsString := AnsiUpperCase(NewUserName); |
558 |
FieldByName('SEC$PASSWORD').AsString := NewPassword; |
559 |
end; |
560 |
end; |
561 |
|
562 |
procedure TMainForm.AddUserUpdate(Sender: TObject); |
563 |
begin |
564 |
(Sender as TAction).Enabled := (UserListSource.State = dsBrowse) and |
565 |
((DBDataModule.ServiceUserName = 'SYSDBA') or DBDataModule.HasUserAdminPrivilege); |
566 |
end; |
567 |
|
568 |
procedure TMainForm.ApplySelectedExecute(Sender: TObject); |
569 |
begin |
570 |
DBDataModule.LimboResolution(NoGlobalAction,LimboReport.Lines); |
571 |
end; |
572 |
|
573 |
procedure TMainForm.AttachmentsTabHide(Sender: TObject); |
574 |
begin |
575 |
AttachSource.DataSet.Active := false; |
576 |
AttmtTimer.Enabled := false; |
577 |
end; |
578 |
|
579 |
procedure TMainForm.AttachmentsTabShow(Sender: TObject); |
580 |
begin |
581 |
if not Visible or not IBDatabaseInfo.Database.Connected then Exit; |
582 |
AttachSource.DataSet.Active := true; |
583 |
AttmtGrid.ShowEditorPanel; {assume located at current connection} |
584 |
end; |
585 |
|
586 |
procedure TMainForm.AttmtTimerTimer(Sender: TObject); |
587 |
begin |
588 |
DBDataModule.CurrentTransaction.Commit; {force a refresh} |
589 |
end; |
590 |
|
591 |
procedure TMainForm.BackupExecute(Sender: TObject); |
592 |
begin |
593 |
DBDataModule.BackupDatabase; |
594 |
end; |
595 |
|
596 |
procedure TMainForm.ChgPasswordExecute(Sender: TObject); |
597 |
var NewPassword: string; |
598 |
begin |
599 |
NewPassword := ''; |
600 |
if ChgPasswordDlg.ShowModal(NewPassword) = mrOK then |
601 |
with UserListSource.DataSet do |
602 |
begin |
603 |
Edit; |
604 |
FieldByName('SEC$PASSWORD').AsString := NewPassword; |
605 |
try |
606 |
Post |
607 |
except |
608 |
Cancel; |
609 |
raise; |
610 |
end; |
611 |
end; |
612 |
end; |
613 |
|
614 |
procedure TMainForm.ChgPasswordUpdate(Sender: TObject); |
615 |
begin |
616 |
(Sender as TAction).Enabled := UserListSource.DataSet.Active and (UserListSource.DataSet.RecordCount > 0); |
617 |
end; |
618 |
|
619 |
procedure TMainForm.Commit2PhaseExecute(Sender: TObject); |
620 |
begin |
621 |
DBDataModule.LimboResolution(RecoverTwoPhaseGlobal,LimboReport.Lines); |
622 |
end; |
623 |
|
624 |
procedure TMainForm.CommitAllExecute(Sender: TObject); |
625 |
begin |
626 |
DBDataModule.LimboResolution(CommitGlobal,LimboReport.Lines); |
627 |
end; |
628 |
|
629 |
procedure TMainForm.CommitAllUpdate(Sender: TObject); |
630 |
begin |
631 |
with LimboListSource.DataSet do |
632 |
(Sender as TAction).Enabled := Active and (RecordCount > 0); |
633 |
end; |
634 |
|
635 |
procedure TMainForm.DatabaseOnlineChange(Sender: TObject); |
636 |
var ShutDownMode: TDBShutDownMode; |
637 |
Delay: integer; |
638 |
begin |
639 |
if FLoading then Exit; |
640 |
ShutDownMode := DenyTransaction; |
641 |
Delay := 60; |
642 |
if DatabaseOnline.Checked then |
643 |
DBDataModule.BringDatabaseOnline |
644 |
else |
645 |
if ShutdownReqDlg.ShowModal(DatabaseAliasName.Text,ShutDownMode,Delay) = mrOK then |
646 |
DBDataModule.Shutdown(ShutdownMode,Delay); |
647 |
end; |
648 |
|
649 |
procedure TMainForm.DBIsReadOnlyChange(Sender: TObject); |
650 |
begin |
651 |
if FLoading then Exit; |
652 |
try |
653 |
DBDataModule.DBReadOnly := DBIsReadOnly.Checked; |
654 |
except on E:Exception do |
655 |
MessageDlg(E.message,mtError,[mbOK],0); |
656 |
end; |
657 |
end; |
658 |
|
659 |
procedure TMainForm.DBSQLDialectEditingDone(Sender: TObject); |
660 |
begin |
661 |
if FLoading then Exit; |
662 |
DBDataModule.DBSQLDialect := StrToInt(DBSQLDialect.Text); |
663 |
end; |
664 |
|
665 |
procedure TMainForm.DeleteTagExecute(Sender: TObject); |
666 |
begin |
667 |
UserTagsSource.DataSet.Delete; |
668 |
end; |
669 |
|
670 |
procedure TMainForm.DeleteTagUpdate(Sender: TObject); |
671 |
begin |
672 |
(Sender as TAction).Enabled := UserTagsSource.DataSet.Active and (UserTagsSource.DataSet.RecordCount > 0); |
673 |
end; |
674 |
|
675 |
procedure TMainForm.DeleteUserExecute(Sender: TObject); |
676 |
begin |
677 |
if MessageDlg('Do you really want to delete user ' + Trim(UserListSource.DataSet.FieldByName('SEC$USER_NAME').AsString), |
678 |
mtConfirmation,[mbYes,mbNo],0) = mrYes then |
679 |
UserListSource.DataSet.Delete; |
680 |
end; |
681 |
|
682 |
procedure TMainForm.DeleteUserUpdate(Sender: TObject); |
683 |
begin |
684 |
(Sender as TAction).Enabled := UserListSource.DataSet.Active and (UserListSource.DataSet.RecordCount > 0) and |
685 |
((DBDataModule.ServiceUserName = 'SYSDBA') or DBDataModule.HasUserAdminPrivilege); |
686 |
end; |
687 |
|
688 |
procedure TMainForm.DisconnectAttachmentExecute(Sender: TObject); |
689 |
begin |
690 |
if MessageDlg('Disconnect Attachment ID ' + AttachSource.DataSet.FieldByName('MON$ATTACHMENT_ID').AsString, |
691 |
mtConfirmation,[mbYes,mbNo],0) = mrYes then |
692 |
AttachSource.DataSet.Delete; |
693 |
end; |
694 |
|
695 |
procedure TMainForm.DisconnectAttachmentUpdate(Sender: TObject); |
696 |
begin |
697 |
with AttachSource.DataSet do |
698 |
(Sender as TAction).Enabled := Active and (RecordCount > 0) |
699 |
and (FieldByName('MON$ATTACHMENT_ID').AsInteger <> |
700 |
AttmtSource.DataSet.FieldByName('MON$ATTACHMENT_ID').AsInteger); |
701 |
end; |
702 |
|
703 |
procedure TMainForm.DropDatabaseExecute(Sender: TObject); |
704 |
begin |
705 |
if MessageDlg(Format('Do you really want to delete the database "%s". You will lose all your data!', |
706 |
[IBDatabaseInfo.Database.DatabaseName]),mtConfirmation,[mbYes,mbNo],0) = mrYes then |
707 |
begin |
708 |
DBDataModule.DropDatabase; |
709 |
DBDataModule.Connect; |
710 |
if not IBDatabaseInfo.Database.Connected then Close; |
711 |
end; |
712 |
end; |
713 |
|
714 |
procedure TMainForm.DropDatabaseUpdate(Sender: TObject); |
715 |
begin |
716 |
(Sender as TAction).Enabled := IBDatabaseInfo.Database.Connected; |
717 |
end; |
718 |
|
719 |
procedure TMainForm.AccessRightsTreeViewSelectionChanged(Sender: TObject); |
720 |
begin |
721 |
if SubjectAccessRightsSource.DataSet = nil then Exit; |
722 |
if AccessRightsSource.DataSet.Active then |
723 |
begin |
724 |
if (AccessRightsTreeView.Selected = nil) or (AccessRightsTreeView.Selected.Parent = nil) then |
725 |
SubjectAccessRightsSource.DataSet.Active := false |
726 |
else |
727 |
DBDataModule.SyncSubjectAccessRights(TIBTreeNode(AccessRightsTreeView.Selected).KeyValue); |
728 |
end; |
729 |
end; |
730 |
|
731 |
procedure TMainForm.FormClose(Sender: TObject; var CloseAction: TCloseAction); |
732 |
begin |
733 |
DBDataModule.Disconnect; |
734 |
end; |
735 |
|
736 |
procedure TMainForm.MappingsTabHide(Sender: TObject); |
737 |
begin |
738 |
AuthMapSource.DataSet.Active := false; |
739 |
end; |
740 |
|
741 |
procedure TMainForm.MappingsTabShow(Sender: TObject); |
742 |
begin |
743 |
if not Visible or not IBDatabaseInfo.Database.Connected then Exit; |
744 |
AuthMapSource.DataSet.Active := IBDatabaseInfo.ODSMajorVersion > 11; |
745 |
end; |
746 |
|
747 |
procedure TMainForm.PageBuffersEditingDone(Sender: TObject); |
748 |
begin |
749 |
DBDataModule.PageBuffers := StrToInt(PageBuffers.Text); |
750 |
end; |
751 |
|
752 |
procedure TMainForm.QuitExecute(Sender: TObject); |
753 |
begin |
754 |
Close; |
755 |
end; |
756 |
|
757 |
procedure TMainForm.RepairTabHide(Sender: TObject); |
758 |
begin |
759 |
DBTablesSource.DataSet.Active := false; |
760 |
end; |
761 |
|
762 |
procedure TMainForm.RepairTabShow(Sender: TObject); |
763 |
begin |
764 |
if not Visible or not IBDatabaseInfo.Database.Connected then Exit; |
765 |
SelectRepairActionCloseUp(nil); |
766 |
ValidateOptions.ActivePage := ValidateOptionsTab; |
767 |
end; |
768 |
|
769 |
procedure TMainForm.RevokeAllExecute(Sender: TObject); |
770 |
begin |
771 |
if MessageDlg('Revoke all Access Rights from User ' + Trim(AccessRightsTreeView.Selected.Text), |
772 |
mtConfirmation,[mbYes,mbNo],0) = mrYes then |
773 |
DBDataModule.RevokeAll; |
774 |
end; |
775 |
|
776 |
procedure TMainForm.RevokeAllUpdate(Sender: TObject); |
777 |
begin |
778 |
with AccessRightsSource.DataSet do |
779 |
(Sender as TAction).Enabled := Active and (RecordCount > 0) and |
780 |
(FieldByName('SUBJECT_TYPE').AsInteger = 8); |
781 |
end; |
782 |
|
783 |
procedure TMainForm.RunScriptExecute(Sender: TObject); |
784 |
begin |
785 |
ExecuteSQLScriptDlg.ShowModal; |
786 |
end; |
787 |
|
788 |
procedure TMainForm.SelectAllTablesChange(Sender: TObject); |
789 |
var aBookmark: TBookmark; |
790 |
begin |
791 |
with DBTablesSource.DataSet do |
792 |
if Active then |
793 |
begin |
794 |
aBookmark := Bookmark; |
795 |
DisableControls; |
796 |
try |
797 |
First; |
798 |
while not EOF do |
799 |
begin |
800 |
Edit; |
801 |
if SelectAllTables.Checked then |
802 |
FieldByName('Selected').AsInteger := 1 |
803 |
else |
804 |
FieldByName('Selected').AsInteger := 0; |
805 |
Post; |
806 |
Next; |
807 |
end; |
808 |
finally |
809 |
Bookmark := aBookmark; |
810 |
EnableControls; |
811 |
end; |
812 |
end; |
813 |
end; |
814 |
|
815 |
procedure TMainForm.SelectedTablesOnlyChange(Sender: TObject); |
816 |
begin |
817 |
SelectedTablesGrid.Enabled := SelectedTablesOnly.Checked; |
818 |
SelectAllTables.Enabled := SelectedTablesOnly.Checked; |
819 |
end; |
820 |
|
821 |
procedure TMainForm.SelectRepairActionCloseUp(Sender: TObject); |
822 |
begin |
823 |
if (SelectRepairAction.ItemIndex = 1) and (IBDatabaseInfo.ODSMajorVersion < 12) then |
824 |
begin |
825 |
MessageDlg('Online validation is not support by Firebird prior to release 3', |
826 |
mtError,[mbOK],0); |
827 |
SelectRepairAction.ItemIndex := 2; |
828 |
end; |
829 |
ValidateOptions.Enabled := SelectRepairAction.ItemIndex = 2; |
830 |
ConfigureOnlineValidation; |
831 |
end; |
832 |
|
833 |
procedure TMainForm.SubjectAccessRightsSourceDataChange(Sender: TObject; |
834 |
Field: TField); |
835 |
begin |
836 |
if (Field = nil) and (not (Sender as TDataSource).Dataset.FieldByName('UPDATE_COLUMNS').IsNull or |
837 |
not (Sender as TDataSource).Dataset.FieldByName('REFERENCE_COLUMNS').IsNull) then |
838 |
SubjectAccessRightsGrid.ShowEditorPanel; |
839 |
end; |
840 |
|
841 |
procedure TMainForm.UserManagerTabHide(Sender: TObject); |
842 |
begin |
843 |
UserListSource.DataSet.Active := PageControl1.ActivePage = AccessRightsTab; |
844 |
end; |
845 |
|
846 |
procedure TMainForm.UserManagerTabShow(Sender: TObject); |
847 |
begin |
848 |
if not Visible or not IBDatabaseInfo.Database.Connected or DBDataModule.EmbeddedMode then Exit; |
849 |
UserListSource.DataSet.Active := true; |
850 |
end; |
851 |
|
852 |
procedure TMainForm.FilesTabShow(Sender: TObject); |
853 |
begin |
854 |
if not Visible or not IBDatabaseInfo.Database.Connected then Exit; |
855 |
PrimaryDBFile.Text := IBDatabaseInfo.DBFileName; |
856 |
SecDBFilesSource.DataSet.Active := true; |
857 |
ShadowSource.DataSet.Active := true; |
858 |
end; |
859 |
|
860 |
procedure TMainForm.OpenDatabaseExecute(Sender: TObject); |
861 |
begin |
862 |
PageControl1.ActivePage := Properties; |
863 |
DBDataModule.Connect; |
864 |
if not IBDatabaseInfo.Database.Connected then Close; |
865 |
end; |
866 |
|
867 |
procedure TMainForm.PropertiesShow(Sender: TObject); |
868 |
begin |
869 |
if Visible and (IBDatabaseInfo.Database <> nil) and IBDatabaseInfo.Database.Connected then |
870 |
LoadData; |
871 |
end; |
872 |
|
873 |
procedure TMainForm.RemoveShadowExecute(Sender: TObject); |
874 |
var ShadowSet: integer; |
875 |
begin |
876 |
ShadowSet := ShadowSource.DataSet.FieldByName('RDB$Shadow_Number').AsInteger; |
877 |
DBDataModule.RemoveShadowSet(ShadowSet); |
878 |
end; |
879 |
|
880 |
procedure TMainForm.RemoveShadowUpdate(Sender: TObject); |
881 |
begin |
882 |
(Sender as TAction).Enabled := ShadowSource.DataSet.Active and (ShadowSource.DataSet.RecordCount > 0); |
883 |
end; |
884 |
|
885 |
procedure TMainForm.RestoreExecute(Sender: TObject); |
886 |
begin |
887 |
DBDataModule.RestoreDatabase; |
888 |
end; |
889 |
|
890 |
procedure TMainForm.RollbackAllExecute(Sender: TObject); |
891 |
begin |
892 |
DBDataModule.LimboResolution(RollbackGlobal,LimboReport.Lines); |
893 |
end; |
894 |
|
895 |
procedure TMainForm.RunRepairExecute(Sender: TObject); |
896 |
var Options: TValidateOptions; |
897 |
begin |
898 |
ValidationReport.Lines.Clear; |
899 |
case SelectRepairAction.ItemIndex of |
900 |
0: {sweep} |
901 |
Options := [SweepDB]; |
902 |
1: {Online Validation } |
903 |
begin |
904 |
DBDataModule.OnlineValidation(ValidationReport.Lines,SelectedTablesOnly.Checked); |
905 |
Exit; |
906 |
end; |
907 |
2: {Full Validation} |
908 |
if ValidateOptions.ActivePage = ValidateOptionsTab then |
909 |
begin |
910 |
Options := [ValidateDB]; |
911 |
if RecordFragments.Checked then |
912 |
Options += [ValidateFull]; |
913 |
if ReadOnlyValidation.Checked then |
914 |
Options += [CheckDB]; |
915 |
if IgnoreChecksums.Checked then |
916 |
Options += [IgnoreChecksum]; |
917 |
end |
918 |
else |
919 |
begin |
920 |
Options := [MendDB]; |
921 |
if ValidateRepairRecordFragments.Checked then |
922 |
Options += [ValidateFull]; |
923 |
if IgnoreChecksumsOnRepair.Checked then |
924 |
Options += [IgnoreChecksum]; |
925 |
end; |
926 |
3: {Kill Shadows} |
927 |
Options := [KillShadows]; |
928 |
end; |
929 |
|
930 |
DBDataModule.DatabaseRepair(Options,ValidationReport.Lines); |
931 |
if (SelectRepairAction.ItemIndex = 2) and (ValidateDB in Options) then |
932 |
ValidateOptions.ActivePage := RepairOptionsTab |
933 |
else |
934 |
ValidateOptions.ActivePage := ValidateOptionsTab; |
935 |
end; |
936 |
|
937 |
procedure TMainForm.SaveChangesExecute(Sender: TObject); |
938 |
begin |
939 |
if UserTagsSource.DataSet.State in [dsEdit,dsInsert] then |
940 |
UserTagsSource.DataSet.Post; |
941 |
if RoleSource.DataSet.State in [dsEdit,dsInsert] then |
942 |
RoleSource.DataSet.Post; |
943 |
if UserListSource.DataSet.State in [dsEdit,dsInsert] then |
944 |
UserListSource.DataSet.Post; |
945 |
end; |
946 |
|
947 |
procedure TMainForm.SaveChangesUpdate(Sender: TObject); |
948 |
begin |
949 |
(Sender as TAction).Enabled := (UserListSource.DataSet.State in [dsInsert,dsEdit]) or |
950 |
(RoleSource.DataSet.State in [dsInsert,dsEdit]) or |
951 |
(UserTagsSource.DataSet.State in [dsInsert,dsEdit]) ; |
952 |
end; |
953 |
|
954 |
procedure TMainForm.SaveExecute(Sender: TObject); |
955 |
begin |
956 |
if PageControl1.ActivePage = SchemaTab then |
957 |
begin |
958 |
if SQLSaveDialog.Execute then |
959 |
SynEdit1.Lines.SaveToFile(SQLSaveDialog.FileName); |
960 |
end |
961 |
else |
962 |
if PageControl1.ActivePage = StatisticsTab then |
963 |
begin |
964 |
if SaveDialog.Execute then |
965 |
StatsMemo.Lines.SaveToFile(SaveDialog.FileName); |
966 |
end; |
967 |
end; |
968 |
|
969 |
procedure TMainForm.SaveUpdate(Sender: TObject); |
970 |
begin |
971 |
(Sender as TAction).Enabled := (PageControl1.ActivePage = SchemaTab) or |
972 |
(PageControl1.ActivePage = StatisticsTab); |
973 |
end; |
974 |
|
975 |
procedure TMainForm.SchemaTabShow(Sender: TObject); |
976 |
begin |
977 |
if not Visible or not IBDatabaseInfo.Database.Connected then Exit; |
978 |
SynEdit1.Lines.Clear; |
979 |
Application.QueueAsyncCall(@DoExtract,0); |
980 |
end; |
981 |
|
982 |
procedure TMainForm.ServerTabHide(Sender: TObject); |
983 |
begin |
984 |
FServerError := false; |
985 |
end; |
986 |
|
987 |
procedure TMainForm.ServerTabShow(Sender: TObject); |
988 |
begin |
989 |
if not Visible or FServerError then Exit; |
990 |
try |
991 |
LoadServerData; |
992 |
DBDataModule.LoadServerLog(ServerLog.Lines); |
993 |
except |
994 |
FServerError := true; |
995 |
ServerLog.Lines.Clear; |
996 |
raise; |
997 |
end; |
998 |
end; |
999 |
|
1000 |
procedure TMainForm.StatisticsTabHide(Sender: TObject); |
1001 |
begin |
1002 |
FLastStatsIndex := -1; |
1003 |
end; |
1004 |
|
1005 |
procedure TMainForm.StatisticsTabShow(Sender: TObject); |
1006 |
begin |
1007 |
if not Visible or not IBDatabaseInfo.Database.Connected then Exit; |
1008 |
if FLastStatsIndex <> StatsOptions.ItemIndex then {avoids loops if exception raise in load stats} |
1009 |
StatsOptionsCloseUp(nil); |
1010 |
end; |
1011 |
|
1012 |
procedure TMainForm.StatsOptionsCloseUp(Sender: TObject); |
1013 |
begin |
1014 |
StatsMemo.Lines.Clear; |
1015 |
FLastStatsIndex := StatsOptions.ItemIndex; |
1016 |
DBDataModule.LoadDatabaseStatistics(StatsOptions.ItemIndex,StatsMemo.Lines); |
1017 |
end; |
1018 |
|
1019 |
procedure TMainForm.SweepIntervalEditingDone(Sender: TObject); |
1020 |
begin |
1021 |
if FLoading then Exit; |
1022 |
DBDataModule.SweepInterval := StrtoInt(SweepInterval.Text); |
1023 |
end; |
1024 |
|
1025 |
procedure TMainForm.SyncWritesChange(Sender: TObject); |
1026 |
begin |
1027 |
if FLoading then Exit; |
1028 |
DBDataModule.ForcedWrites := SyncWrites.Checked; |
1029 |
end; |
1030 |
|
1031 |
procedure TMainForm.ToggleAutoRefreshExecute(Sender: TObject); |
1032 |
begin |
1033 |
AttmtTimer.Enabled := not AttmtTimer.Enabled; |
1034 |
end; |
1035 |
|
1036 |
procedure TMainForm.ToggleAutoRefreshUpdate(Sender: TObject); |
1037 |
begin |
1038 |
(Sender as TAction).Enabled := AttachSource.DataSet.Active; |
1039 |
(Sender as TAction).Checked := AttmtTimer.Enabled; |
1040 |
end; |
1041 |
|
1042 |
procedure TMainForm.DoDBOpen(Data: PtrInt); |
1043 |
begin |
1044 |
ConnectToDatabase; |
1045 |
end; |
1046 |
|
1047 |
procedure TMainForm.HandleDBConnect(Sender: TObject); |
1048 |
begin |
1049 |
ConfigureForServerVersion; |
1050 |
PageControl1.ActivePage := Properties; |
1051 |
ValidationReport.Lines.Clear; |
1052 |
LimboReport.Lines.Clear; |
1053 |
FLastStatsIndex := -1; |
1054 |
end; |
1055 |
|
1056 |
procedure TMainForm.HandleLoadData(Sender: TObject); |
1057 |
begin |
1058 |
if DBDataModule.EmbeddedMode then |
1059 |
StatusBar1.SimpleText := Format('Database: %s - Logged in as user %s in embedded mode', |
1060 |
[DBDataModule.IBDatabase1.DatabaseName,DBDataModule.IBDatabase1.Params.Values['user_name'] |
1061 |
]) |
1062 |
else |
1063 |
if DBDataModule.DBUserName = 'SYSDBA' then |
1064 |
StatusBar1.SimpleText := Format('Database: %s - Logged in as user %s by %s, using %s security database.', |
1065 |
[DBDataModule.IBDatabase1.DatabaseName,DBDataModule.DBUserName, |
1066 |
DBDataModule.AuthMethod, DBDataModule.SecurityDatabase]) |
1067 |
else |
1068 |
StatusBar1.SimpleText := Format('Database: %s - Logged in as user %s by %s, using %s security database. Role = %s', |
1069 |
[DBDataModule.IBDatabase1.DatabaseName,DBDataModule.DBUserName, |
1070 |
DBDataModule.AuthMethod, DBDataModule.SecurityDatabase,DBDataModule.RoleName]); |
1071 |
if assigned(PageControl1.ActivePage.OnShow) then |
1072 |
PageControl1.ActivePage.OnShow(nil); |
1073 |
ClientLibrary.Caption := 'Firebird Client Library: ' + DBDataModule.IBDatabase1.FirebirdAPI.GetFBLibrary.GetLibraryFilePath + |
1074 |
' (API Version = ' + DBDataModule.IBDatabase1.FirebirdAPI.GetImplementationVersion + ')'; |
1075 |
end; |
1076 |
|
1077 |
procedure TMainForm.LoadData; |
1078 |
begin |
1079 |
if FLoading then Exit; |
1080 |
FLoading := true; |
1081 |
try |
1082 |
DatabaseAliasName.Text := DBDataModule.DatabaseName; |
1083 |
Edit1.Text := IBDatabaseInfo.DBSiteName; |
1084 |
ODSVersionString.Text := Format('%d.%d',[IBDatabaseInfo.ODSMajorVersion,IBDatabaseInfo.ODSMinorVersion]); |
1085 |
ServerVersionNo.Text := IBDatabaseInfo.Version; |
1086 |
DBSQLDialect.Text := IntToStr(DBDataModule.DBSQLDialect); |
1087 |
ConnectString.Text := DBDataModule.IBDatabase1.DatabaseName; |
1088 |
Edit10.Text := IntToStr(IBDatabaseInfo.CurrentMemory); |
1089 |
Edit11.Text := IntToStr(IBDatabaseInfo.MaxMemory); |
1090 |
PageBuffers.Text := IntToStr(DBDataModule.PageBuffers); |
1091 |
AllocatedPages.Text := IntToStr(IBDatabaseInfo.Allocation); |
1092 |
DBIsReadOnly.Checked := DBDataModule.DBReadOnly; |
1093 |
SyncWrites.Checked := DBDataModule.ForcedWrites; |
1094 |
SweepInterval.Text := IntToStr(IBDatabaseInfo.SweepInterval); |
1095 |
NoReserve.Checked := DBDataModule.NoReserve; |
1096 |
LingerDelay.Text := DBDataModule.LingerDelay; |
1097 |
SecDatabase.Text := DBDataModule.SecurityDatabase; |
1098 |
DBOwner.Text := DBDataModule.DBOwner; |
1099 |
DatabaseOnline.Checked := DBDataModule.IsDatabaseOnline; |
1100 |
IsShadowChk.Checked := DBDataModule.IsShadowDatabase; |
1101 |
if IBDatabaseInfo.ODSMajorVersion >= 12 then |
1102 |
begin |
1103 |
PagesUsed.Text := IntToStr(IBDatabaseInfo.PagesUsed); |
1104 |
PagesAvail.Text := IntToStr(IBDatabaseInfo.PagesFree); |
1105 |
AutoAdmin.Checked := not DBDataModule.EmbeddedMode and DBDataModule.AutoAdmin; |
1106 |
end |
1107 |
else |
1108 |
begin |
1109 |
PagesUsed.Text := 'n/a'; |
1110 |
PagesAvail.Text := 'n/a'; |
1111 |
AutoAdmin.Checked := false; |
1112 |
end; |
1113 |
DBDataModule.IBDatabase1.Attachment.getFBVersion(ClientServerVersion.Lines); |
1114 |
DBComments.Lines.Text := DBDataModule.Description; |
1115 |
finally |
1116 |
FLoading := false; |
1117 |
end; |
1118 |
end; |
1119 |
|
1120 |
procedure TMainForm.LoadServerData; |
1121 |
var i: integer; |
1122 |
begin |
1123 |
with DBDataModule.IBServerProperties1 do |
1124 |
begin |
1125 |
Edit3.Text := VersionInfo.ServerVersion; |
1126 |
Edit2.Text := IntToStr(VersionInfo.ServiceVersion); |
1127 |
Edit4.Text := VersionInfo.ServerImplementation; |
1128 |
OpenDatabasesList.Clear; |
1129 |
for i := 0 to DatabaseInfo.NoOfDatabases - 1 do |
1130 |
OpenDatabasesList.Lines.Add(DatabaseInfo.DbName[i]); |
1131 |
ConfigDataGrid.Visible := DBDataModule.LoadConfigData(ConfigParams.ConfigFileData); |
1132 |
ConfigDataLabel.Visible := ConfigDataGrid.Visible; |
1133 |
if ConfigDataGrid.Visible then |
1134 |
begin |
1135 |
OpenDatabasesList.Height := ConfigDataLabel.Top - OpenDatabasesList.Top - 6; |
1136 |
OpenDatabasesList.Anchors := OpenDatabasesList.Anchors - [akBottom]; |
1137 |
end |
1138 |
else |
1139 |
begin |
1140 |
OpenDatabasesList.Height := ConfigDataGrid.Top - OpenDatabasesList.Top + ConfigDataGrid.Height; |
1141 |
OpenDatabasesList.Anchors := OpenDatabasesList.Anchors + [akBottom]; |
1142 |
end; |
1143 |
Edit5.Text := ConfigParams.BaseLocation; |
1144 |
Edit6.Text := ConfigParams.LockFileLocation; |
1145 |
Edit7.Text := ConfigParams.SecurityDatabaseLocation; |
1146 |
Edit9.Text := ConfigParams.MessageFileLocation; |
1147 |
Edit8.Text := ServicesConnection.ServerName; |
1148 |
Edit12.Text := IntToStr(DatabaseInfo.NoOfAttachments); |
1149 |
end; |
1150 |
end; |
1151 |
|
1152 |
procedure TMainForm.DoExtract(Data: PtrInt); |
1153 |
begin |
1154 |
Screen.Cursor := crHourGlass; |
1155 |
try |
1156 |
Application.ProcessMessages; |
1157 |
if IncludeUserGrants.Checked then |
1158 |
IBExtract1.ExtractObject(eoDatabase,'',[etGrantsToUser]) |
1159 |
else |
1160 |
IBExtract1.ExtractObject(eoDatabase); |
1161 |
SynEdit1.Lines.Assign(IBExtract1.Items); |
1162 |
finally |
1163 |
Screen.Cursor := crDefault; |
1164 |
end; |
1165 |
end; |
1166 |
|
1167 |
procedure TMainForm.ConfigureForServerVersion; |
1168 |
var i: integer; |
1169 |
begin |
1170 |
if (IBDatabaseInfo.ODSMajorVersion >= 12) and |
1171 |
((DBDataModule.ServiceUserName = 'SYSDBA') or (DBDataModule.RoleName = 'RDB$ADMIN') or |
1172 |
not DBDataModule.HasUserAdminPrivilege) then |
1173 |
begin |
1174 |
for i in [9,10] do |
1175 |
UserManagerGrid.Columns[i].Visible := false; |
1176 |
for i in [4,6,7,8] do |
1177 |
UserManagerGrid.Columns[i].Visible := true ; |
1178 |
UserListSource.DataSet := DBDataModule.UserList; |
1179 |
TagsHeader.Visible := true; |
1180 |
TagsGrid.Visible := true; |
1181 |
end |
1182 |
else |
1183 |
begin |
1184 |
for i in [4,6,7,8] do |
1185 |
UserManagerGrid.Columns[i].Visible := false; |
1186 |
for i in [9,10] do |
1187 |
UserManagerGrid.Columns[i].Visible := true; |
1188 |
UserListSource.DataSet := DBDataModule.LegacyUserList; |
1189 |
TagsHeader.Visible := false; |
1190 |
TagsGrid.Visible := false; |
1191 |
end; |
1192 |
|
1193 |
if IBDatabaseInfo.ODSMajorVersion >= 12 then |
1194 |
begin |
1195 |
AttmtGrid.Columns[2].Visible := true; |
1196 |
AttmntODS12Panel.Visible := true; |
1197 |
DBCharacterSet.Visible := true; |
1198 |
DBCharSetRO.Visible := false; |
1199 |
end |
1200 |
else |
1201 |
begin |
1202 |
AttmtGrid.Columns[2].Visible := false; |
1203 |
AttmntODS12Panel.Visible := false; |
1204 |
DBCharacterSet.Visible := false; |
1205 |
DBCharSetRO.Visible := true; |
1206 |
end; |
1207 |
MappingsTab.TabVisible := not DBDataModule.EmbeddedMode and |
1208 |
((IBDatabaseInfo.ODSMajorVersion > 11) or |
1209 |
((IBDatabaseInfo.ODSMajorVersion = 11) and (IBDatabaseInfo.ODSMinorVersion > 0))); |
1210 |
UserManagerTab.TabVisible := not DBDataModule.EmbeddedMode; |
1211 |
AccessRightsTab.TabVisible := not DBDataModule.EmbeddedMode; |
1212 |
AutoAdmin.Enabled := not DBDataModule.EmbeddedMode; |
1213 |
end; |
1214 |
|
1215 |
procedure TMainForm.ConnectToDatabase; |
1216 |
begin |
1217 |
if not DBDataModule.Connect then Close; |
1218 |
PageControl1.Visible := true; |
1219 |
end; |
1220 |
|
1221 |
procedure TMainForm.ConfigureOnlineValidation; |
1222 |
begin |
1223 |
if SelectRepairAction.ItemIndex = 1 then |
1224 |
begin |
1225 |
DBTablesPanel.Visible := true; |
1226 |
DBTablesSplitter.Visible := true; |
1227 |
SelectedTablesGrid.Enabled := SelectedTablesOnly.Checked; |
1228 |
SelectAllTables.Checked := true; |
1229 |
DBTablesSource.DataSet.Active := true; |
1230 |
end |
1231 |
else |
1232 |
begin |
1233 |
DBTablesPanel.Visible := false; |
1234 |
DBTablesSplitter.Visible := false; |
1235 |
SelectAllTables.Enabled := false; |
1236 |
DBTablesSource.DataSet.Active := false; |
1237 |
end; |
1238 |
end; |
1239 |
|
1240 |
end. |
1241 |
|