ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/examples/DBAdmin/dlg/BackupDlgUnit.pas
Revision: 209
Committed: Wed Mar 14 12:48:51 2018 UTC (6 years, 1 month ago) by tony
Content type: text/x-pascal
File size: 4854 byte(s)
Log Message:
Fixes Merged

File Contents

# Content
1 (*
2 * BackupDlgUnit.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 BackupDlgUnit;
19
20 {$mode objfpc}{$H+}
21
22 interface
23
24 uses
25 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
26 Buttons, ExtCtrls, ComCtrls, IBXServices;
27
28 type
29
30 { TBackupDlg }
31
32 TBackupDlg = class(TForm)
33 Button1: TButton;
34 Button2: TButton;
35 IBXClientSideBackupService1: TIBXClientSideBackupService;
36 IBXServerSideBackupService1: TIBXServerSideBackupService;
37 NoDBTriggers: TCheckBox;
38 NoGarbageCollection: TCheckBox;
39 MetadataOnly: TCheckBox;
40 IgnoreLimboTransactions: TCheckBox;
41 IgnoreChecksums: TCheckBox;
42 ServerName: TEdit;
43 DBName: TEdit;
44 BackupFileName: TEdit;
45 Label1: TLabel;
46 Label2: TLabel;
47 Label3: TLabel;
48 Report: TMemo;
49 PageControl1: TPageControl;
50 ServerSideBtn: TRadioButton;
51 ClientSideBtn: TRadioButton;
52 SaveDialog1: TSaveDialog;
53 SpeedButton1: TSpeedButton;
54 SelectTab: TTabSheet;
55 ReportTab: TTabSheet;
56 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
57 procedure FormShow(Sender: TObject);
58 procedure ReportTabShow(Sender: TObject);
59 procedure SpeedButton1Click(Sender: TObject);
60 private
61 { private declarations }
62 procedure DoClientBackup(Data: PtrInt);
63 procedure DoServerBackup(Data: PtrInt);
64 public
65 { public declarations }
66 end;
67
68 var
69 BackupDlg: TBackupDlg;
70
71 implementation
72
73 {$R *.lfm}
74
75 { TBackupDlg }
76
77 procedure TBackupDlg.SpeedButton1Click(Sender: TObject);
78 begin
79 if SaveDialog1.Execute then
80 BackupFileName.Text := SaveDialog1.Filename;
81 end;
82
83 procedure TBackupDlg.DoClientBackup(Data: PtrInt);
84 var BackupCount: integer;
85 begin
86 with IBXClientSideBackupService1 do
87 begin
88 Options := [];
89 if IgnoreChecksums.Checked then
90 Options := Options + [IBXServices.IgnoreChecksums];
91 if IgnoreLimboTransactions.Checked then
92 Options := Options + [IgnoreLimbo];
93 if MetadataOnly.Checked then
94 Options := Options + [IBXServices.MetadataOnly];
95 if NoGarbageCollection.Checked then
96 Options := Options + [IBXServices.NoGarbageCollection];
97 if NoDBTriggers.Checked then
98 Options := Options + [IBXServices.NoDBTriggers];
99
100 Report.Lines.Add('Starting Backup');
101 BackupToFile(BackupFileName.Text, BackupCount);
102 end;
103 Report.Lines.Add(Format('Backup Completed - File Size = %d bytes',[BackupCount]));
104 MessageDlg(Format('Backup Completed - File Size = %d bytes',[BackupCount]),mtInformation,[mbOK],0);
105 end;
106
107 procedure TBackupDlg.DoServerBackup(Data: PtrInt);
108 begin
109 with IBXServerSideBackupService1 do
110 begin
111 BackupFiles.Clear;
112 BackupFiles.Add(BackupFileName.Text);
113 Options := [];
114 if IgnoreChecksums.Checked then
115 Options := Options + [IBXServices.IgnoreChecksums];
116 if IgnoreLimboTransactions.Checked then
117 Options := Options + [IgnoreLimbo];
118 if MetadataOnly.Checked then
119 Options := Options + [IBXServices.MetadataOnly];
120 if NoGarbageCollection.Checked then
121 Options := Options + [IBXServices.NoGarbageCollection];
122 if NoDBTriggers.Checked then
123 Options := Options + [IBXServices.NoDBTriggers];
124 Report.Lines.Add('Starting Backup');
125 Execute(Report.Lines);
126 Report.Lines.Add('Backup Completed');
127 MessageDlg('Backup Completed',mtInformation,[mbOK],0);
128 end;
129 end;
130
131 procedure TBackupDlg.FormShow(Sender: TObject);
132 begin
133 PageControl1.ActivePage := SelectTab;
134 ServerName.Text := IBXClientSideBackupService1.ServicesConnection.ServerName;
135 DBName.Text := IBXClientSideBackupService1.DatabaseName;
136 BackupFileName.Text := '';
137 end;
138
139 procedure TBackupDlg.ReportTabShow(Sender: TObject);
140 begin
141 Report.Lines.Clear;
142 end;
143
144 procedure TBackupDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction);
145 begin
146 if ModalResult <> mrOK then Exit;
147
148 if PageControl1.ActivePage = SelectTab then
149 begin
150 CloseAction := caNone;
151 if BackupFileName.Text = '' then
152 raise Exception.Create('A Backup File Name must be given');
153 PageControl1.ActivePage := ReportTab;
154 if ServerSideBtn.Checked then
155 Application.QueueAsyncCall(@DoServerBackup,0)
156 else
157 Application.QueueAsyncCall(@DoClientBackup,0);
158 end;
159 end;
160
161 end.
162