ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/examples/DBAdmin/dlg/RestoreDlgUnit.pas
Revision: 272
Committed: Mon Feb 4 13:34:37 2019 UTC (5 years, 2 months ago) by tony
Content type: text/x-pascal
File size: 6109 byte(s)
Log Message:
Fixes merged

File Contents

# Content
1 (*
2 * RestoreDlgUnit.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 RestoreDlgUnit;
19
20 {$mode objfpc}{$H+}
21
22 interface
23
24 uses
25 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
26 StdCtrls, Buttons, ComCtrls, IBXServices;
27
28 type
29
30 { TRestoreDlg }
31
32 TRestoreDlg = class(TForm)
33 Button1: TButton;
34 Button2: TButton;
35 DeActivateIndexes: TCheckBox;
36 IBXClientSideRestoreService1: TIBXClientSideRestoreService;
37 IBXServerSideRestoreService1: TIBXServerSideRestoreService;
38 PageBuffers: TEdit;
39 Label6: TLabel;
40 NoShadow: TCheckBox;
41 NoValidityCheck: TCheckBox;
42 OneRelationAtATime: TCheckBox;
43 ProgressBar1: TProgressBar;
44 RestoreMetaDataOnly: TCheckBox;
45 UseAllSpace: TCheckBox;
46 ServerName: TEdit;
47 DBName: TEdit;
48 SourceArchive: TEdit;
49 PageSize: TEdit;
50 Label1: TLabel;
51 Label2: TLabel;
52 Label3: TLabel;
53 Label4: TLabel;
54 Label5: TLabel;
55 Report: TMemo;
56 OpenDialog1: TOpenDialog;
57 PageControl1: TPageControl;
58 ServerSideBtn: TRadioButton;
59 ClientSideBtn: TRadioButton;
60 SpeedButton1: TSpeedButton;
61 SelectTab: TTabSheet;
62 ReportTab: TTabSheet;
63 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
64 procedure FormShow(Sender: TObject);
65 procedure IBXClientSideRestoreService1GetNextLine(Sender: TObject;
66 var Line: string);
67 procedure ReportTabShow(Sender: TObject);
68 procedure SpeedButton1Click(Sender: TObject);
69 private
70 { private declarations }
71 procedure DoClientRestore(Data: PtrInt);
72 procedure DoServerRestore(Data: PtrInt);
73 public
74 { public declarations }
75 function ShowModal(DefaultPageSize, DefaultNumBuffers: integer): TModalResult;
76 end;
77
78 var
79 RestoreDlg: TRestoreDlg;
80
81 implementation
82
83 {$R *.lfm}
84
85 { TRestoreDlg }
86
87 procedure TRestoreDlg.SpeedButton1Click(Sender: TObject);
88 begin
89 if OpenDialog1.Execute then
90 SourceArchive.Text := OpenDialog1.Filename;
91 end;
92
93 procedure TRestoreDlg.DoClientRestore(Data: PtrInt);
94 begin
95 Progressbar1.Visible := true;
96 with IBXClientSideRestoreService1 do
97 begin
98 PageSize := StrToInt(self.PageSize.Text);
99 PageBuffers := StrToInt(self.PageBuffers.Text);
100 Options := [Replace];
101 if DeactivateIndexes.Checked then
102 Options := Options + [IBXServices.DeactivateIndexes];
103 if NoShadow.Checked then
104 Options := Options + [IBXServices.NoShadow];
105 if NoValidityCheck.Checked then
106 Options := Options + [IBXServices.NoValidityCheck];
107 if OneRelationAtATime.Checked then
108 Options := Options + [IBXServices.OneRelationAtATime];
109 if RestoreMetaDataOnly.Checked then
110 Options := Options + [IBXServices.RestoreMetaDataOnly];
111 if UseAllSpace.Checked then
112 Options := Options + [IBXServices.UseAllSpace];
113 Report.Lines.Add('Restore Started');
114 RestoreFromFile(SourceArchive.Text,Report.Lines);
115 Report.Lines.Add('Restore Completed');
116 Progressbar1.Visible := false;
117 MessageDlg('Restore Completed',mtInformation,[mbOK],0);
118 end;
119 end;
120
121 procedure TRestoreDlg.DoServerRestore(Data: PtrInt);
122 begin
123 Progressbar1.Visible := true;
124 with IBXServerSideRestoreService1 do
125 begin
126 PageSize := StrToInt(self.PageSize.Text);
127 PageBuffers := StrToInt(self.PageBuffers.Text);
128 Options := [Replace];
129 if DeactivateIndexes.Checked then
130 Options := Options + [IBXServices.DeactivateIndexes];
131 if NoShadow.Checked then
132 Options := Options + [IBXServices.NoShadow];
133 if NoValidityCheck.Checked then
134 Options := Options + [IBXServices.NoValidityCheck];
135 if OneRelationAtATime.Checked then
136 Options := Options + [IBXServices.OneRelationAtATime];
137 if RestoreMetaDataOnly.Checked then
138 Options := Options + [IBXServices.RestoreMetaDataOnly];
139 if UseAllSpace.Checked then
140 Options := Options + [IBXServices.UseAllSpace];
141 BackupFiles.Clear;
142 BackupFiles.Add(SourceArchive.Text);
143 Report.Lines.Add('Restore Started');
144 Execute(Report.Lines);
145 Report.Lines.Add('Restore Completed');
146 Progressbar1.Visible := false;
147 MessageDlg('Restore Completed',mtInformation,[mbOK],0);
148 end;
149 end;
150
151 function TRestoreDlg.ShowModal(DefaultPageSize,
152 DefaultNumBuffers: integer): TModalResult;
153 begin
154 PageSize.Text := IntToStr(DefaultPageSize);
155 PageBuffers.Text := IntToStr(DefaultNumBuffers);
156 Result := inherited ShowModal;
157 end;
158
159 procedure TRestoreDlg.FormShow(Sender: TObject);
160 begin
161 PageControl1.ActivePage := SelectTab;
162 ServerName.Text := IBXClientSideRestoreService1.ServicesConnection.ServerName;
163 DBName.Text := IBXClientSideRestoreService1.DatabaseFiles[0];
164 SourceArchive.SetFocus;
165 end;
166
167 procedure TRestoreDlg.IBXClientSideRestoreService1GetNextLine(Sender: TObject;
168 var Line: string);
169 begin
170 Report.VertScrollBar.Position := (Report.Lines.Count-1)*20;
171 Application.ProcessMessages;
172 end;
173
174 procedure TRestoreDlg.ReportTabShow(Sender: TObject);
175 begin
176 Report.Lines.Clear;
177 end;
178
179 procedure TRestoreDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction);
180 begin
181 if ModalResult <> mrOK then Exit;
182
183 if PageControl1.ActivePage = SelectTab then
184 begin
185 CloseAction := caNone;
186 if SourceArchive.Text = '' then
187 raise Exception.Create('A Backup File Name must be given');
188 if ServerSideBtn.Checked then
189 Application.QueueAsyncCall(@DoServerRestore,0)
190 else
191 Application.QueueAsyncCall(@DoClientRestore,0);
192 PageControl1.ActivePage := ReportTab;
193 end;
194
195 end;
196
197 end.
198