32 |
|
|
33 |
|
uses |
34 |
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, |
35 |
< |
StdCtrls, Buttons, IBServices; |
35 |
> |
StdCtrls, Buttons, IBXServices; |
36 |
|
|
37 |
|
type |
38 |
|
|
42 |
|
Bevel1: TBevel; |
43 |
|
Button1: TButton; |
44 |
|
Button2: TButton; |
45 |
< |
CheckBox1: TCheckBox; |
46 |
< |
Edit1: TEdit; |
47 |
< |
Edit2: TEdit; |
48 |
< |
Edit3: TEdit; |
49 |
< |
IBRestoreService1: TIBRestoreService; |
45 |
> |
CSRestoreService1: TIBXClientSideRestoreService; |
46 |
> |
SSRestoreService1: TIBXServerSideRestoreService; |
47 |
> |
ReplaceExisting: TCheckBox; |
48 |
> |
ServerName: TEdit; |
49 |
> |
DBName: TEdit; |
50 |
> |
BackupFileName: TEdit; |
51 |
|
Label1: TLabel; |
52 |
|
Label2: TLabel; |
53 |
|
Label3: TLabel; |
54 |
|
OpenDialog1: TOpenDialog; |
55 |
< |
RadioButton1: TRadioButton; |
56 |
< |
RadioButton2: TRadioButton; |
55 |
> |
ServerSideBtn: TRadioButton; |
56 |
> |
ClientSideBtn: TRadioButton; |
57 |
|
SpeedButton1: TSpeedButton; |
58 |
|
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); |
59 |
|
procedure FormShow(Sender: TObject); |
60 |
+ |
procedure IBRestoreService1GetNextLine(Sender: TObject; var Line: string); |
61 |
|
procedure SpeedButton1Click(Sender: TObject); |
62 |
|
private |
63 |
|
{ private declarations } |
64 |
+ |
FOutputLog: TStrings; |
65 |
+ |
procedure RunRestore; |
66 |
|
public |
67 |
|
{ public declarations } |
68 |
< |
procedure RunRestore; |
68 |
> |
function ShowModal(var aDBName: string; OutputLog: TStrings): TModalResult; |
69 |
|
end; |
70 |
|
|
71 |
|
var |
75 |
|
|
76 |
|
{$R *.lfm} |
77 |
|
|
74 |
– |
uses MainFormUnit; |
75 |
– |
|
78 |
|
{ TRestoreDlg } |
79 |
|
|
80 |
|
procedure TRestoreDlg.SpeedButton1Click(Sender: TObject); |
81 |
|
begin |
82 |
|
if OpenDialog1.Execute then |
83 |
< |
Edit3.Text := OpenDialog1.Filename; |
83 |
> |
BackupFileName.Text := OpenDialog1.Filename; |
84 |
|
end; |
85 |
|
|
86 |
|
procedure TRestoreDlg.RunRestore; |
85 |
– |
var bakfile: TFileStream; |
86 |
– |
line: string; |
87 |
|
begin |
88 |
< |
bakfile := nil; |
89 |
< |
if IBRestoreService1.BackupFileLocation = flClientSide then |
90 |
< |
bakfile := TFileStream.Create(IBRestoreService1.BackupFile[0],fmOpenRead); |
91 |
< |
MainForm.Memo1.Lines.Add('Restore Started'); |
92 |
< |
try |
93 |
< |
IBRestoreService1.ServiceStart; |
94 |
< |
while not IBRestoreService1.Eof do |
95 |
< |
begin |
96 |
< |
case IBRestoreService1.BackupFileLocation of |
97 |
< |
flServerSide: |
98 |
< |
MainForm.Memo1.Lines.Add(Trim(IBRestoreService1.GetNextLine)); |
99 |
< |
flClientSide: |
100 |
< |
begin |
101 |
< |
IBRestoreService1.SendNextChunk(bakfile,line); |
102 |
< |
if line <> '' then |
103 |
< |
MainForm. Memo1.Lines.Add(line); |
104 |
< |
end; |
105 |
< |
end; |
106 |
< |
Application.ProcessMessages |
107 |
< |
end; |
108 |
< |
finally |
109 |
< |
if bakfile <> nil then |
110 |
< |
bakfile.Free; |
111 |
< |
end; |
112 |
< |
while IBRestoreService1.IsServiceRunning do; {flush} |
88 |
> |
FOutputLog.Add('Restore Started'); |
89 |
> |
if ClientSideBtn.Checked then |
90 |
> |
CSRestoreService1.RestoreFromFile(BackupFilename.Text,FOutputLog) |
91 |
> |
else |
92 |
> |
SSRestoreService1.Execute(FOutputLog); |
93 |
|
|
94 |
< |
MainForm.Memo1.Lines.Add('Restore Completed'); |
94 |
> |
FOutputLog.Add('Restore Completed'); |
95 |
|
MessageDlg('Restore Completed',mtInformation,[mbOK],0); |
96 |
|
end; |
97 |
|
|
98 |
+ |
function TRestoreDlg.ShowModal(var aDBName: string; OutputLog: TStrings |
99 |
+ |
): TModalResult; |
100 |
+ |
begin |
101 |
+ |
DBName.Text := aDBName; |
102 |
+ |
FOutputLog := OutputLog; |
103 |
+ |
Result := inherited ShowModal; |
104 |
+ |
if Result = mrOK then |
105 |
+ |
begin |
106 |
+ |
RunRestore; |
107 |
+ |
aDBName := DBName.Text; |
108 |
+ |
end; |
109 |
+ |
end; |
110 |
+ |
|
111 |
|
procedure TRestoreDlg.FormShow(Sender: TObject); |
112 |
|
begin |
113 |
< |
Edit1.Text := IBRestoreService1.ServerName; |
114 |
< |
if IBRestoreService1.BackupFileLocation = flServerSide then |
115 |
< |
RadioButton1.Checked := true |
116 |
< |
else |
117 |
< |
RadioButton2.Checked := true; |
118 |
< |
Edit2.Text := IBRestoreService1.DatabaseName[0]; |
119 |
< |
IBRestoreService1.BackupFile.Clear; |
113 |
> |
ServerName.Text := CSRestoreService1.ServicesConnection.ServerName; |
114 |
> |
end; |
115 |
> |
|
116 |
> |
procedure TRestoreDlg.IBRestoreService1GetNextLine(Sender: TObject; |
117 |
> |
var Line: string); |
118 |
> |
begin |
119 |
> |
Application.ProcessMessages; |
120 |
|
end; |
121 |
|
|
122 |
|
procedure TRestoreDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction); |
123 |
|
begin |
124 |
|
if ModalResult <> mrOK then Exit; |
125 |
< |
if Edit2.Text = '' then |
125 |
> |
if DBName.Text = '' then |
126 |
|
raise Exception.Create('A Database Name must be given'); |
127 |
< |
if Edit3.Text = '' then |
127 |
> |
if BackupFileName.Text = '' then |
128 |
|
raise Exception.Create('A Backup File Name must be given'); |
129 |
< |
IBRestoreService1.DatabaseName.Clear; |
130 |
< |
IBRestoreService1.DatabaseName.Add(Edit2.Text); |
131 |
< |
IBRestoreService1.BackupFile.Add(Edit3.Text); |
132 |
< |
if RadioButton1.Checked then |
133 |
< |
IBRestoreService1.BackupFileLocation := flServerSide |
134 |
< |
else |
135 |
< |
IBRestoreService1.BackupFileLocation := flClientSide; |
136 |
< |
if CheckBox1.Checked then |
137 |
< |
IBRestoreService1.Options := IBRestoreService1.Options + [Replace] - [CreateNewDB] |
129 |
> |
CSRestoreService1.DatabaseFiles.Clear; |
130 |
> |
CSRestoreService1.DatabaseFiles.Add(DBName.Text); |
131 |
> |
SSRestoreService1.DatabaseFiles.Clear; |
132 |
> |
SSRestoreService1.DatabaseFiles.Add(DBName.Text); |
133 |
> |
SSRestoreService1.BackupFiles.Clear; |
134 |
> |
SSRestoreService1.BackupFiles.Add(BackupFileName.Text); |
135 |
> |
if ReplaceExisting.Checked then |
136 |
> |
begin |
137 |
> |
CSRestoreService1.Options := CSRestoreService1.Options + [Replace] - [CreateNewDB]; |
138 |
> |
SSRestoreService1.Options := SSRestoreService1.Options + [Replace] - [CreateNewDB]; |
139 |
> |
end |
140 |
|
else |
141 |
< |
IBRestoreService1.Options := IBRestoreService1.Options - [Replace] + [CreateNewDB] |
142 |
< |
|
141 |
> |
begin |
142 |
> |
CSRestoreService1.Options := CSRestoreService1.Options - [Replace] + [CreateNewDB]; |
143 |
> |
SSRestoreService1.Options := SSRestoreService1.Options - [Replace] + [CreateNewDB]; |
144 |
> |
end; |
145 |
|
end; |
146 |
|
|
147 |
|
end. |