ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/iblocaldb/nongui/IBCMLocalDBSupport.pas
(Generate patch)

Comparing ibx/trunk/iblocaldb/nongui/IBCMLocalDBSupport.pas (file contents):
Revision 271 by tony, Wed Mar 14 12:48:51 2018 UTC vs.
Revision 272 by tony, Mon Feb 4 13:34:37 2019 UTC

# Line 40 | Line 40 | type
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;
# Line 53 | Line 56 | type
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
# Line 112 | Line 116 | begin
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);
# Line 119 | Line 130 | end;
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
# Line 140 | Line 149 | 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(

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines