ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/examples/services/BackupDlgUnit.pas
Revision: 380
Committed: Mon Jan 10 10:13:17 2022 UTC (2 years, 11 months ago) by tony
Content type: text/x-pascal
File size: 3828 byte(s)
Log Message:
propset for eol-style

File Contents

# User Rev Content
1 tony 143 (*
2     * IBX For Lazarus (Firebird Express)
3     *
4     * The contents of this file are subject to the Initial Developer's
5     * Public License Version 1.0 (the "License"); you may not use this
6     * file except in compliance with the License. You may obtain a copy
7     * of the License here:
8     *
9     * http://www.firebirdsql.org/index.php?op=doc&id=idpl
10     *
11     * Software distributed under the License is distributed on an "AS
12     * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13     * implied. See the License for the specific language governing rights
14     * and limitations under the License.
15     *
16     * The Initial Developer of the Original Code is Tony Whyman.
17     *
18     * The Original Code is (C) 2015 Tony Whyman, MWA Software
19     * (http://www.mwasoftware.co.uk).
20     *
21     * All Rights Reserved.
22     *
23     * Contributor(s): ______________________________________.
24     *
25     *)
26    
27     unit BackupDlgUnit;
28    
29     {$mode objfpc}{$H+}
30    
31     interface
32    
33     uses
34 tony 209 Classes, SysUtils, FileUtil, IBXServices, Forms, Controls, Graphics, Dialogs, ExtCtrls,
35     StdCtrls, Buttons;
36 tony 143
37     type
38    
39     { TBackupDlg }
40    
41     TBackupDlg = class(TForm)
42     Bevel1: TBevel;
43     Button1: TButton;
44     Button2: TButton;
45 tony 209 CSBackupService1: TIBXClientSideBackupService;
46     SSBackupService1: TIBXServerSideBackupService;
47     ServerName: TEdit;
48     DBName: TEdit;
49     BackupFilename: TEdit;
50 tony 143 Label1: TLabel;
51     Label2: TLabel;
52     Label3: TLabel;
53 tony 209 ServerSideBtn: TRadioButton;
54     ClientSideBtn: TRadioButton;
55 tony 143 SaveDialog1: TSaveDialog;
56     SpeedButton1: TSpeedButton;
57     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
58     procedure FormShow(Sender: TObject);
59     procedure SpeedButton1Click(Sender: TObject);
60 tony 209 procedure SSBackupService1GetNextLine(Sender: TObject; var Line: string);
61 tony 143 private
62     { private declarations }
63 tony 209 FOutputLog: TStrings;
64     procedure RunBackup;
65 tony 143 public
66     { public declarations }
67 tony 209 function ShowModal(var aDBName: string; OutputLog: TStrings): TModalResult;
68 tony 143 end;
69    
70     var
71     BackupDlg: TBackupDlg;
72    
73     implementation
74    
75     {$R *.lfm}
76    
77     { TBackupDlg }
78    
79     procedure TBackupDlg.SpeedButton1Click(Sender: TObject);
80     begin
81     if SaveDialog1.Execute then
82 tony 209 BackupFilename.Text := SaveDialog1.Filename;
83 tony 143 end;
84    
85 tony 209 procedure TBackupDlg.SSBackupService1GetNextLine(Sender: TObject;
86     var Line: string);
87 tony 143 begin
88 tony 209 Application.ProcessMessages;
89     end;
90    
91     function TBackupDlg.ShowModal(var aDBName: string; OutputLog: TStrings): TModalResult;
92     begin
93     DBName.Text := aDBName;
94     FOutputLog := OutputLog;
95     Result := inherited ShowModal;
96     if Result = mrOK then
97     begin
98     RunBackup;
99     aDBName := DBName.Text;
100 tony 143 end;
101 tony 209 end;
102 tony 143
103 tony 209 procedure TBackupDlg.RunBackup;
104     var BackupCount: integer;
105     begin
106     FOutputLog.Add('Starting Backup');
107     if ClientSideBtn.Checked then
108     begin
109     CSBackupService1.BackupToFile(BackupFilename.Text,BackupCount);
110     FOutputLog.Add(Format('Backup Completed - File Size = %d bytes',[BackupCount]));
111     MessageDlg(Format('Backup Completed - File Size = %d bytes',[BackupCount]),mtInformation,[mbOK],0);
112     end
113     else
114     begin
115     SSBackupService1.Execute(FOutputLog);
116     FOutputLog.Add('Backup Completed');
117     MessageDlg('Backup Completed',mtInformation,[mbOK],0);
118 tony 143 end;
119     end;
120    
121     procedure TBackupDlg.FormShow(Sender: TObject);
122     begin
123 tony 209 ServerName.Text := CSBackupService1.ServicesConnection.ServerName;
124     SSBackupService1.BackupFiles.Clear;
125 tony 143 end;
126    
127     procedure TBackupDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction);
128     begin
129     if ModalResult <> mrOK then Exit;
130 tony 209 if DBName.Text = '' then
131 tony 143 raise Exception.Create('A Database Name must be given');
132 tony 209 if BackupFilename.Text = '' then
133 tony 143 raise Exception.Create('A Backup File Name must be given');
134 tony 209 CSBackupService1.DatabaseName := DBName.Text;
135     SSBackupService1.DatabaseName := DBName.Text;
136     if ServerSideBtn.Checked then
137     SSBackupService1.BackupFiles.Add(BackupFilename.Text);
138 tony 143 end;
139    
140     end.
141    

Properties

Name Value
svn:eol-style native