ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/examples/DBAdmin/dlg/RestoreDlgUnit.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: 5881 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 RestoreMetaDataOnly: TCheckBox;
44 UseAllSpace: TCheckBox;
45 ServerName: TEdit;
46 DBName: TEdit;
47 SourceArchive: TEdit;
48 PageSize: TEdit;
49 Label1: TLabel;
50 Label2: TLabel;
51 Label3: TLabel;
52 Label4: TLabel;
53 Label5: TLabel;
54 Report: TMemo;
55 OpenDialog1: TOpenDialog;
56 PageControl1: TPageControl;
57 ServerSideBtn: TRadioButton;
58 ClientSideBtn: TRadioButton;
59 SpeedButton1: TSpeedButton;
60 SelectTab: TTabSheet;
61 ReportTab: TTabSheet;
62 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
63 procedure FormShow(Sender: TObject);
64 procedure IBXClientSideRestoreService1GetNextLine(Sender: TObject;
65 var Line: string);
66 procedure ReportTabShow(Sender: TObject);
67 procedure SpeedButton1Click(Sender: TObject);
68 private
69 { private declarations }
70 procedure DoClientRestore(Data: PtrInt);
71 procedure DoServerRestore(Data: PtrInt);
72 public
73 { public declarations }
74 function ShowModal(DefaultPageSize, DefaultNumBuffers: integer): TModalResult;
75 end;
76
77 var
78 RestoreDlg: TRestoreDlg;
79
80 implementation
81
82 {$R *.lfm}
83
84 { TRestoreDlg }
85
86 procedure TRestoreDlg.SpeedButton1Click(Sender: TObject);
87 begin
88 if OpenDialog1.Execute then
89 SourceArchive.Text := OpenDialog1.Filename;
90 end;
91
92 procedure TRestoreDlg.DoClientRestore(Data: PtrInt);
93 begin
94 with IBXClientSideRestoreService1 do
95 begin
96 PageSize := StrToInt(self.PageSize.Text);
97 PageBuffers := StrToInt(self.PageBuffers.Text);
98 Options := [Replace];
99 if DeactivateIndexes.Checked then
100 Options := Options + [IBXServices.DeactivateIndexes];
101 if NoShadow.Checked then
102 Options := Options + [IBXServices.NoShadow];
103 if NoValidityCheck.Checked then
104 Options := Options + [IBXServices.NoValidityCheck];
105 if OneRelationAtATime.Checked then
106 Options := Options + [IBXServices.OneRelationAtATime];
107 if RestoreMetaDataOnly.Checked then
108 Options := Options + [IBXServices.RestoreMetaDataOnly];
109 if UseAllSpace.Checked then
110 Options := Options + [IBXServices.UseAllSpace];
111 Report.Lines.Add('Restore Started');
112 RestoreFromFile(SourceArchive.Text,Report.Lines);
113 Report.Lines.Add('Restore Completed');
114 MessageDlg('Restore Completed',mtInformation,[mbOK],0);
115 end;
116 end;
117
118 procedure TRestoreDlg.DoServerRestore(Data: PtrInt);
119 begin
120 with IBXServerSideRestoreService1 do
121 begin
122 PageSize := StrToInt(self.PageSize.Text);
123 PageBuffers := StrToInt(self.PageBuffers.Text);
124 Options := [Replace];
125 if DeactivateIndexes.Checked then
126 Options := Options + [IBXServices.DeactivateIndexes];
127 if NoShadow.Checked then
128 Options := Options + [IBXServices.NoShadow];
129 if NoValidityCheck.Checked then
130 Options := Options + [IBXServices.NoValidityCheck];
131 if OneRelationAtATime.Checked then
132 Options := Options + [IBXServices.OneRelationAtATime];
133 if RestoreMetaDataOnly.Checked then
134 Options := Options + [IBXServices.RestoreMetaDataOnly];
135 if UseAllSpace.Checked then
136 Options := Options + [IBXServices.UseAllSpace];
137 BackupFiles.Clear;
138 BackupFiles.Add(SourceArchive.Text);
139 Report.Lines.Add('Restore Started');
140 Execute(Report.Lines);
141 Report.Lines.Add('Restore Completed');
142 MessageDlg('Restore Completed',mtInformation,[mbOK],0);
143 end;
144 end;
145
146 function TRestoreDlg.ShowModal(DefaultPageSize,
147 DefaultNumBuffers: integer): TModalResult;
148 begin
149 PageSize.Text := IntToStr(DefaultPageSize);
150 PageBuffers.Text := IntToStr(DefaultNumBuffers);
151 Result := inherited ShowModal;
152 end;
153
154 procedure TRestoreDlg.FormShow(Sender: TObject);
155 begin
156 PageControl1.ActivePage := SelectTab;
157 ServerName.Text := IBXClientSideRestoreService1.ServicesConnection.ServerName;
158 DBName.Text := IBXClientSideRestoreService1.DatabaseFiles[0];
159 SourceArchive.SetFocus;
160 end;
161
162 procedure TRestoreDlg.IBXClientSideRestoreService1GetNextLine(Sender: TObject;
163 var Line: string);
164 begin
165 Application.ProcessMessages;
166 end;
167
168 procedure TRestoreDlg.ReportTabShow(Sender: TObject);
169 begin
170 Report.Lines.Clear;
171 end;
172
173 procedure TRestoreDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction);
174 begin
175 if ModalResult <> mrOK then Exit;
176
177 if PageControl1.ActivePage = SelectTab then
178 begin
179 CloseAction := caNone;
180 if SourceArchive.Text = '' then
181 raise Exception.Create('A Backup File Name must be given');
182 if ServerSideBtn.Checked then
183 Application.QueueAsyncCall(@DoServerRestore,0)
184 else
185 Application.QueueAsyncCall(@DoClientRestore,0);
186 PageControl1.ActivePage := ReportTab;
187 end;
188
189 end;
190
191 end.
192