41 |
|
private |
42 |
|
FOnLogMessage: TOnLogMessage; |
43 |
|
FOnProgressEvent: TOnProgressEvent; |
44 |
< |
procedure Add2Log(Sender: TObject; Msg: string); |
45 |
< |
procedure DoUpgrade(IBXScript: TIBXScript; TargetVersionNo: integer); |
44 |
> |
function DoUpgrade(IBXScript: TIBXScript; TargetVersionNo: integer): boolean; |
45 |
|
procedure WriteLog(Msg: string); |
46 |
|
procedure HandleOnGetNextLine(Sender: TObject; var Line: string); |
47 |
|
procedure IBXScriptCreateDatabase(Sender: TObject; |
48 |
|
var DatabaseFileName: string); |
49 |
|
protected |
50 |
+ |
procedure Add2Log(Sender: TObject; Msg: string); override; |
51 |
|
procedure Downgrade(DBArchive: string); override; |
52 |
|
function InternalCreateNewDatabase(DBArchive: string): boolean; override; |
53 |
|
function RestoreDatabaseFromArchive(aFilename: string): boolean; override; |
75 |
|
WriteLog(Msg); |
76 |
|
end; |
77 |
|
|
78 |
< |
procedure TIBCMLocalDBSupport.DoUpgrade(IBXScript: TIBXScript; |
79 |
< |
TargetVersionNo: integer); |
78 |
> |
function TIBCMLocalDBSupport.DoUpgrade(IBXScript: TIBXScript; |
79 |
> |
TargetVersionNo: integer): boolean; |
80 |
|
var UpdateAvailable: boolean; |
81 |
|
UpgradeInfo: TUpgradeInfo; |
82 |
|
DBArchive: string; |
96 |
|
end; |
97 |
|
Add2Log(self,UpgradeInfo.UserMessage); |
98 |
|
Add2Log(self,Format(sUpdateMsg,[UpgradeInfo.UpdateSQLFile])); |
99 |
< |
if not IBXScript.RunScript(UpgradeInfo.UpdateSQLFile) then |
99 |
> |
Result := IBXScript.RunScript(UpgradeInfo.UpdateSQLFile); |
100 |
> |
if not Result then |
101 |
|
break; |
102 |
|
UpdateVersionNo; |
103 |
|
end; |
126 |
|
|
127 |
|
procedure TIBCMLocalDBSupport.Downgrade(DBArchive: string); |
128 |
|
begin |
129 |
+ |
inherited; |
130 |
|
RestoreDatabase(DBArchive); |
131 |
+ |
DowngradeDone; |
132 |
|
end; |
133 |
|
|
134 |
|
function TIBCMLocalDBSupport.InternalCreateNewDatabase(DBArchive: string |
173 |
|
begin |
174 |
|
BackupFiles.Clear; |
175 |
|
BackupFiles.Add(aFilename); |
176 |
+ |
DatabaseFiles.Clear; |
177 |
+ |
DatabaseFiles.Add(Database.DatabaseName); |
178 |
|
Options := [Replace]; |
179 |
|
Execute(nil); |
180 |
|
end; |
184 |
|
): boolean; |
185 |
|
var IBXScript: TIBXScript; |
186 |
|
begin |
182 |
– |
Result := true; |
187 |
|
IBXScript := TIBXScript.Create(self); |
188 |
|
try |
189 |
|
IBXScript.Database := Database; |
191 |
|
IBXScript.OnOutputLog := @Add2Log; |
192 |
|
if assigned(UpgradeConf) then |
193 |
|
IBXScript.GetParamValue := @UpgradeConf.GetParamValue; |
194 |
< |
DoUpgrade(IBXScript, TargetVersionNo); |
194 |
> |
Result := DoUpgrade(IBXScript, TargetVersionNo); |
195 |
|
finally |
196 |
|
IBXScript.Free; |
197 |
|
end; |
199 |
|
end; |
200 |
|
|
201 |
|
function TIBCMLocalDBSupport.SaveDatabaseToArchive(aFilename: string): boolean; |
198 |
– |
var Service: TIBXClientSideBackupService; |
202 |
|
begin |
203 |
|
Result := true; |
204 |
|
with BackupService do |
205 |
|
begin |
206 |
+ |
DatabaseName := Database.DatabaseName; |
207 |
+ |
BackupFiles.Clear; |
208 |
+ |
BackupFiles.Add(aFileName); |
209 |
|
Execute(nil); |
210 |
|
WriteLog(Format(sBackupDone,[aFileName])); |
211 |
|
end; |