40 |
|
TIBCMLocalDBSupport = class(TCustomIBLocalDBSupport) |
41 |
|
private |
42 |
|
FOnLogMessage: TOnLogMessage; |
43 |
+ |
FOnProgressEvent: TOnProgressEvent; |
44 |
|
procedure Add2Log(Sender: TObject; Msg: string); |
45 |
|
procedure DoUpgrade(IBXScript: TIBXScript; TargetVersionNo: integer); |
46 |
|
procedure WriteLog(Msg: string); |
47 |
|
procedure HandleOnGetNextLine(Sender: TObject; var Line: string); |
48 |
+ |
procedure IBXScriptCreateDatabase(Sender: TObject; |
49 |
+ |
var DatabaseFileName: string); |
50 |
|
protected |
51 |
|
procedure Downgrade(DBArchive: string); override; |
52 |
|
function InternalCreateNewDatabase(DBArchive: string): boolean; override; |
56 |
|
public |
57 |
|
constructor Create(aOwner: TComponent); override; |
58 |
|
property OnLogMessage: TOnLogMessage read FOnLogMessage write FOnLogMessage; |
59 |
+ |
property OnProgressEvent: TOnProgressEvent read FOnProgressEvent write FOnProgressEvent; {Progress Bar Support} |
60 |
|
end; |
61 |
|
|
62 |
|
implementation |
116 |
|
OnLogMessage(self,Line); |
117 |
|
end; |
118 |
|
|
119 |
+ |
procedure TIBCMLocalDBSupport.IBXScriptCreateDatabase(Sender: TObject; |
120 |
+ |
var DatabaseFileName: string); |
121 |
+ |
begin |
122 |
+ |
DatabaseFileName := (Sender as TIBXScript).Database.Attachment.GetConnectString; |
123 |
+ |
(Sender as TIBXScript).Database.DropDatabase; |
124 |
+ |
end; |
125 |
+ |
|
126 |
|
procedure TIBCMLocalDBSupport.Downgrade(DBArchive: string); |
127 |
|
begin |
128 |
|
RestoreDatabase(DBArchive); |
130 |
|
|
131 |
|
function TIBCMLocalDBSupport.InternalCreateNewDatabase(DBArchive: string |
132 |
|
): boolean; |
122 |
– |
var Ext: string; |
133 |
|
begin |
134 |
|
Result := true; |
135 |
< |
Ext := AnsiUpperCase(ExtractFileExt(DBArchive)); |
126 |
< |
if Ext = '.GBK' then |
135 |
> |
if IsGbakFile(DBArchive) then |
136 |
|
begin |
137 |
|
with RestoreService do |
138 |
|
begin |
149 |
|
end; |
150 |
|
end |
151 |
|
else |
143 |
– |
if (Ext = '.SQL') and Database.Connected then |
152 |
|
with TIBXScript.Create(self) do |
153 |
|
try |
154 |
|
Database := self.Database; |
155 |
< |
IgnoreCreateDatabase := true; |
155 |
> |
OnCreateDatabase := @IBXScriptCreateDatabase; |
156 |
> |
OnProgressEvent := FOnProgressEvent; |
157 |
|
WriteLog(sCreatingDatabase); |
158 |
|
Result := RunScript(DBArchive); |
159 |
+ |
Add2Log(self,''); {ensure EOL sent} |
160 |
|
finally |
161 |
|
Free |
162 |
|
end |
153 |
– |
else |
154 |
– |
raise Exception.CreateFmt('Archive file (%s) has an unknown extension',[DBArchive]); |
163 |
|
end; |
164 |
|
|
165 |
|
function TIBCMLocalDBSupport.RestoreDatabaseFromArchive( |