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

File Contents

# Content
1 (*
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) 2014 Tony Whyman, MWA Software
19 * (http://www.mwasoftware.co.uk).
20 *
21 * All Rights Reserved.
22 *
23 * Contributor(s): ______________________________________.
24 *
25 *)
26 unit IBXCreateDatabaseDlg;
27
28 {$mode objfpc}{$H+}
29
30 interface
31
32 uses
33 LCLIntf, LCLType, SysUtils, Variants, Classes, Graphics, Controls, Forms,
34 Dialogs, IBXServices, StdCtrls, ExtCtrls;
35
36 type
37
38 { TCreateDatabaseDlg }
39
40 TCreateDatabaseDlg = class(TForm)
41 IBRestoreService1: TIBXServerSideRestoreService;
42 Panel1: TPanel;
43 Status: TLabel;
44 Label1: TLabel;
45 OpenDialog1: TOpenDialog;
46 Timer1: TTimer;
47 procedure FormShow(Sender: TObject);
48 procedure IBRestoreService1GetNextLine(Sender: TObject; var Line: string);
49 procedure Timer1Timer(Sender: TObject);
50 private
51 { Private declarations }
52 procedure DoRestore(Data: PtrInt);
53 public
54 { Public declarations }
55 end;
56
57 var
58 CreateDatabaseDlg: TCreateDatabaseDlg;
59
60 function RestoreDatabaseFromArchive(
61 aRestoreService: TIBXServerSideRestoreService; aFilename: string): boolean;
62
63 function CreateNewDatabase(
64 aRestoreService: TIBXServerSideRestoreService; DBArchive: string): boolean;
65
66 implementation
67
68 function RestoreDatabaseFromArchive(
69 aRestoreService: TIBXServerSideRestoreService; aFilename: string): boolean;
70 begin
71 with TCreateDatabaseDlg.Create(Application) do
72 try
73 if (aFilename = '') or not FileExists(aFileName) then
74 begin
75 OpenDialog1.InitialDir := GetUserDir;
76 if OpenDialog1.Execute then
77 aFilename := OpenDialog1.FileName
78 else
79 Exit;
80 end;
81 IBRestoreService1.Assign(aRestoreService);
82 IBRestoreService1.BackupFiles.Clear;
83 IBRestoreService1.Options := [replace];
84 IBRestoreService1.BackupFiles.Add(aFilename);
85 Result := ShowModal = mrOK;
86 finally
87 Free
88 end;
89 end;
90
91 function CreateNewDatabase(aRestoreService: TIBXServerSideRestoreService;
92 DBArchive: string): boolean;
93 begin
94 with TCreateDatabaseDlg.Create(Application) do
95 try
96 IBRestoreService1.Assign(aRestoreService);
97 IBRestoreService1.BackupFiles.Clear;
98 IBRestoreService1.BackupFiles.Add(DBArchive);
99 IBRestoreService1.Options := [CreateNewDB];
100 Result := ShowModal = mrOK;
101 finally
102 Free
103 end
104 end;
105
106 {$R *.lfm}
107
108 procedure TCreateDatabaseDlg.FormShow(Sender: TObject);
109 begin
110 Status.Caption := '';
111 Application.QueueAsyncCall(@DoRestore,0)
112 end;
113
114 procedure TCreateDatabaseDlg.IBRestoreService1GetNextLine(Sender: TObject;
115 var Line: string);
116 begin
117 Status.Caption := Line;
118 Application.ProcessMessages;
119 end;
120
121 procedure TCreateDatabaseDlg.Timer1Timer(Sender: TObject);
122 begin
123 Timer1.Interval := 0;
124 if FileExists(IBRestoreService1.DatabaseFiles[0]) then
125 begin
126 ModalResult := mrOK
127 end
128 else
129 ModalResult := mrCancel
130 end;
131
132 procedure TCreateDatabaseDlg.DoRestore(Data: PtrInt);
133 begin
134 try
135 IBRestoreService1.Execute(nil);
136 Timer1.Interval := 500;
137 except on E:Exception do
138 raise
139 end;
140 end;
141
142 end.

Properties

Name Value
svn:eol-style native