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

Comparing ibx/trunk/examples/DBAdmin/dlg/BackupDlgUnit.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, StdCtrls,
26 <  Buttons, ExtCtrls, ComCtrls, IBServices;
26 >  Buttons, ExtCtrls, ComCtrls, IBXServices;
27  
28   type
29  
# Line 32 | Line 32 | type
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 <    Edit1: TEdit;
43 <    Edit2: TEdit;
44 <    Edit3: TEdit;
43 <    IBBackupService1: TIBBackupService;
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 <    RadioButton1: TRadioButton;
51 <    RadioButton2: TRadioButton;
50 >    ServerSideBtn: TRadioButton;
51 >    ClientSideBtn: TRadioButton;
52      SaveDialog1: TSaveDialog;
53      SpeedButton1: TSpeedButton;
54      SelectTab: TTabSheet;
# Line 58 | Line 59 | type
59      procedure SpeedButton1Click(Sender: TObject);
60    private
61      { private declarations }
62 <    procedure DoBackup(Data: PtrInt);
62 >    procedure DoClientBackup(Data: PtrInt);
63 >    procedure DoServerBackup(Data: PtrInt);
64    public
65      { public declarations }
66   end;
# Line 75 | Line 77 | implementation
77   procedure TBackupDlg.SpeedButton1Click(Sender: TObject);
78   begin
79    if SaveDialog1.Execute then
80 <    Edit3.Text := SaveDialog1.Filename;
80 >    BackupFileName.Text := SaveDialog1.Filename;
81   end;
82  
83 < procedure TBackupDlg.DoBackup(Data: PtrInt);
84 < var bakfile: TFileStream;
83 <    BackupCount: integer;
83 > procedure TBackupDlg.DoClientBackup(Data: PtrInt);
84 > var BackupCount: integer;
85   begin
86 <  bakfile := nil;
86 <  with IBBackupService1 do
86 >  with IBXClientSideBackupService1 do
87    begin
88 <  Options := [];
89 <  if IgnoreChecksums.Checked then
90 <    Options := Options + [IBServices.IgnoreChecksums];
91 <  if IgnoreLimboTransactions.Checked then
92 <    Options := Options + [IgnoreLimbo];
93 <  if MetadataOnly.Checked then
94 <    Options := Options + [IBServices.MetadataOnly];
95 <  if NoGarbageCollection.Checked then
96 <    Options := Options + [IBServices.NoGarbageCollection];
97 <  if NoDBTriggers.Checked then
98 <    Options := Options + [IBServices.NoDBTriggers];
99 <  end;
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 <  if IBBackupService1.BackupFileLocation = flClientSide then
103 <    bakfile := TFileStream.Create(IBBackupService1.BackupFile[0],fmCreate);
104 <  try
105 <    IBBackupService1.ServiceStart;
106 <    while not IBBackupService1.Eof do
107 <    begin
108 <      case IBBackupService1.BackupFileLocation of
109 <      flServerSide:
110 <        Report.Lines.Add(IBBackupService1.GetNextLine);
111 <      flClientSide:
112 <        IBBackupService1.WriteNextChunk(bakfile);
113 <      end;
114 <      Application.ProcessMessages;
115 <    end;
116 <    if bakfile <> nil then
117 <      BackupCount := bakfile.Size;
118 <  finally
119 <    if bakfile <> nil then
120 <      bakfile.Free;
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 <  while IBBackupService1.IsServiceRunning do; {flush}
108 <
109 <  {Report completion}
110 <  case IBBackupService1.BackupFileLocation of
111 <  flServerSide:
112 <    begin
113 <      Report.Lines.Add('Backup Completed');
114 <      MessageDlg('Backup Completed',mtInformation,[mbOK],0);
115 <    end;
116 <  flClientSide:
117 <    begin
118 <      Report.Lines.Add(Format('Backup Completed - File Size = %d bytes',[BackupCount]));
119 <      MessageDlg(Format('Backup Completed - File Size = %d bytes',[BackupCount]),mtInformation,[mbOK],0);
120 <    end;
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;
138  IBBackupService1.Active := false;
129   end;
130  
131   procedure TBackupDlg.FormShow(Sender: TObject);
132   begin
133    PageControl1.ActivePage := SelectTab;
134 <  Edit1.Text := IBBackupService1.ServerName;
135 <  if IBBackupService1.BackupFileLocation = flServerSide then
136 <    RadioButton1.Checked := true
147 <  else
148 <    RadioButton2.Checked := true;
149 <  Edit2.Text := IBBackupService1.DatabaseName;
150 <  IBBackupService1.BackupFile.Clear;
134 >  ServerName.Text := IBXClientSideBackupService1.ServicesConnection.ServerName;
135 >  DBName.Text := IBXClientSideBackupService1.DatabaseName;
136 >  BackupFileName.Text := '';
137   end;
138  
139   procedure TBackupDlg.ReportTabShow(Sender: TObject);
# Line 162 | Line 148 | begin
148    if PageControl1.ActivePage = SelectTab then
149    begin
150      CloseAction := caNone;
151 <    if Edit3.Text = '' then
151 >    if BackupFileName.Text = '' then
152        raise Exception.Create('A Backup File Name must be given');
167    IBBackupService1.BackupFile.Add(Edit3.Text);
168    if RadioButton1.Checked then
169       IBBackupService1.BackupFileLocation := flServerSide
170    else
171      IBBackupService1.BackupFileLocation := flClientSide;
153      PageControl1.ActivePage := ReportTab;
154 <    Application.QueueAsyncCall(@DoBackup,0);
154 >    if ServerSideBtn.Checked then
155 >      Application.QueueAsyncCall(@DoServerBackup,0)
156 >    else
157 >      Application.QueueAsyncCall(@DoClientBackup,0);
158    end;
159   end;
160  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines