ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/examples/DBAdmin/dlg/RestoreDlgUnit.pas
(Generate patch)

Comparing ibx/trunk/examples/DBAdmin/dlg/RestoreDlgUnit.pas (file contents):
Revision 208 by tony, Thu Mar 1 11:23:33 2018 UTC vs.
Revision 209 by tony, Wed Mar 14 12:48:51 2018 UTC

# Line 23 | Line 23 | interface
23  
24   uses
25    Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
26 <  StdCtrls, Buttons, ComCtrls, IBServices;
26 >  StdCtrls, Buttons, ComCtrls, IBXServices;
27  
28   type
29  
# Line 33 | Line 33 | type
33      Button1: TButton;
34      Button2: TButton;
35      DeActivateIndexes: TCheckBox;
36 +    IBXClientSideRestoreService1: TIBXClientSideRestoreService;
37 +    IBXServerSideRestoreService1: TIBXServerSideRestoreService;
38      PageBuffers: TEdit;
39      Label6: TLabel;
40      NoShadow: TCheckBox;
# Line 40 | Line 42 | type
42      OneRelationAtATime: TCheckBox;
43      RestoreMetaDataOnly: TCheckBox;
44      UseAllSpace: TCheckBox;
45 <    Edit1: TEdit;
45 >    ServerName: TEdit;
46      DBName: TEdit;
47      SourceArchive: TEdit;
48      PageSize: TEdit;
47    IBRestoreService1: TIBRestoreService;
49      Label1: TLabel;
50      Label2: TLabel;
51      Label3: TLabel;
# Line 53 | Line 54 | type
54      Report: TMemo;
55      OpenDialog1: TOpenDialog;
56      PageControl1: TPageControl;
57 <    RadioButton1: TRadioButton;
58 <    RadioButton2: TRadioButton;
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 DoRestore(Data: PtrInt);
70 >    procedure DoClientRestore(Data: PtrInt);
71 >    procedure DoServerRestore(Data: PtrInt);
72    public
73      { public declarations }
74       function ShowModal(DefaultPageSize, DefaultNumBuffers: integer): TModalResult;
# Line 85 | Line 89 | begin
89      SourceArchive.Text := OpenDialog1.Filename;
90   end;
91  
92 < procedure TRestoreDlg.DoRestore(Data: PtrInt);
93 < var bakfile: TFileStream;
94 <    line: string;
95 < begin
96 <  bakfile := nil;
97 <  if IBRestoreService1.BackupFileLocation = flClientSide then
98 <    bakfile := TFileStream.Create(IBRestoreService1.BackupFile[0],fmOpenRead);
99 <  Report.Lines.Add('Restore Started');
100 <  try
101 <    IBRestoreService1.ServiceStart;
102 <    while not IBRestoreService1.Eof do
103 <    begin
104 <      case IBRestoreService1.BackupFileLocation of
105 <      flServerSide:
106 <        Report.Lines.Add(Trim(IBRestoreService1.GetNextLine));
107 <      flClientSide:
108 <        begin
109 <          IBRestoreService1.SendNextChunk(bakfile,line);
110 <          if line <> '' then
111 <           Report.Lines.Add(line);
112 <        end;
113 <      end;
114 <      Application.ProcessMessages
111 <    end;
112 <  finally
113 <    if bakfile <> nil then
114 <      bakfile.Free;
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 <  while IBRestoreService1.IsServiceRunning do; {flush}
117 <  IBRestoreService1.ACtive := false;
116 > end;
117  
118 <  Report.Lines.Add('Restore Completed');
119 <  MessageDlg('Restore Completed',mtInformation,[mbOK],0);
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, DefaultNumBuffers: integer
147 <  ): TModalResult;
146 > function TRestoreDlg.ShowModal(DefaultPageSize,
147 >  DefaultNumBuffers: integer): TModalResult;
148   begin
149    PageSize.Text := IntToStr(DefaultPageSize);
150    PageBuffers.Text := IntToStr(DefaultNumBuffers);
# Line 131 | Line 154 | end;
154   procedure TRestoreDlg.FormShow(Sender: TObject);
155   begin
156    PageControl1.ActivePage := SelectTab;
157 <  Edit1.Text := IBRestoreService1.ServerName;
158 <  if IBRestoreService1.BackupFileLocation = flServerSide then
136 <    RadioButton1.Checked := true
137 <  else
138 <    RadioButton2.Checked := true;
139 <  DBName.Text := IBRestoreService1.DatabaseName[0];
140 <  IBRestoreService1.BackupFile.Clear;
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;
# Line 155 | Line 179 | begin
179      CloseAction := caNone;
180      if SourceArchive.Text = '' then
181        raise Exception.Create('A Backup File Name must be given');
182 <    with IBRestoreService1 do
183 <    begin
160 <      if RadioButton1.Checked then
161 <         BackupFileLocation := flServerSide
182 >      if ServerSideBtn.Checked then
183 >        Application.QueueAsyncCall(@DoServerRestore,0)
184        else
185 <        BackupFileLocation := flClientSide;
164 <      BackupFile.Add(SourceArchive.Text);
165 <      PageSize := StrToInt(self.PageSize.Text);
166 <      PageBuffers := StrToInt(self.PageBuffers.Text);
167 <      Options := [Replace];
168 <      if DeactivateIndexes.Checked then
169 <        Options := Options + [IBServices.DeactivateIndexes];
170 <      if NoShadow.Checked then
171 <        Options := Options + [IBServices.NoShadow];
172 <      if NoValidityCheck.Checked then
173 <        Options := Options + [IBServices.NoValidityCheck];
174 <      if OneRelationAtATime.Checked then
175 <        Options := Options + [IBServices.OneRelationAtATime];
176 <      if RestoreMetaDataOnly.Checked then
177 <        Options := Options + [IBServices.RestoreMetaDataOnly];
178 <      if UseAllSpace.Checked then
179 <        Options := Options + [IBServices.UseAllSpace];
180 <    end;
181 <
185 >        Application.QueueAsyncCall(@DoClientRestore,0);
186      PageControl1.ActivePage := ReportTab;
183    Application.QueueAsyncCall(@DoRestore,0);
187    end;
188  
189   end;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines