1 |
tony |
37 |
(* |
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, IBServices, StdCtrls, ExtCtrls; |
35 |
|
|
|
36 |
|
|
type |
37 |
|
|
|
38 |
|
|
{ TCreateDatabaseDlg } |
39 |
|
|
|
40 |
|
|
TCreateDatabaseDlg = class(TForm) |
41 |
|
|
IBRestoreService1: TIBRestoreService; |
42 |
|
|
Panel1: TPanel; |
43 |
|
|
Status: TLabel; |
44 |
|
|
Label1: TLabel; |
45 |
|
|
OpenDialog1: TOpenDialog; |
46 |
|
|
Timer1: TTimer; |
47 |
|
|
procedure FormShow(Sender: TObject); |
48 |
|
|
procedure Timer1Timer(Sender: TObject); |
49 |
|
|
private |
50 |
|
|
{ Private declarations } |
51 |
|
|
procedure DoRestore(Data: PtrInt); |
52 |
|
|
public |
53 |
|
|
{ Public declarations } |
54 |
|
|
end; |
55 |
|
|
|
56 |
|
|
var |
57 |
|
|
CreateDatabaseDlg: TCreateDatabaseDlg; |
58 |
|
|
|
59 |
|
|
implementation |
60 |
|
|
|
61 |
|
|
{$R *.lfm} |
62 |
|
|
|
63 |
|
|
procedure TCreateDatabaseDlg.FormShow(Sender: TObject); |
64 |
|
|
begin |
65 |
|
|
Status.Caption := ''; |
66 |
|
|
Application.QueueAsyncCall(@DoRestore,0) |
67 |
|
|
end; |
68 |
|
|
|
69 |
|
|
procedure TCreateDatabaseDlg.Timer1Timer(Sender: TObject); |
70 |
|
|
begin |
71 |
|
|
Timer1.Interval := 0; |
72 |
|
|
if FileExists(IBRestoreService1.DatabaseName[0]) then |
73 |
|
|
begin |
74 |
|
|
ModalResult := mrOK |
75 |
|
|
end |
76 |
|
|
else |
77 |
|
|
ModalResult := mrCancel |
78 |
|
|
end; |
79 |
|
|
|
80 |
|
|
procedure TCreateDatabaseDlg.DoRestore(Data: PtrInt); |
81 |
|
|
begin |
82 |
|
|
try |
83 |
|
|
IBRestoreService1.Active := true; |
84 |
|
|
IBRestoreService1.ServiceStart; |
85 |
|
|
try |
86 |
|
|
while not IBRestoreService1.Eof do |
87 |
|
|
begin |
88 |
|
|
Status.Caption := Trim(IBRestoreService1.GetNextLine); |
89 |
|
|
Application.ProcessMessages |
90 |
|
|
end; |
91 |
|
|
finally |
92 |
|
|
IBRestoreService1.Active := false |
93 |
|
|
end; |
94 |
|
|
Timer1.Interval := 500; |
95 |
|
|
except on E:Exception do |
96 |
|
|
raise |
97 |
|
|
end; |
98 |
|
|
end; |
99 |
|
|
|
100 |
|
|
end. |