Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit BkpModel;
- interface
- uses Classes,SysUtils,System.Generics.Collections,windows,Forms;
- type TServiceProgressEvent = procedure (ASender: TObject; const AMessage: String) of object;
- type
- TBkpservicesthread = class(TThread)
- private
- protected
- procedure Execute(const User, password, Host, Banco, LocalBkp,Formato,output: string); overload;
- procedure CmdPromptcommand(const User, password, Host, Banco, LocalBkp,Formato,output: string);
- procedure BackupDossier;
- public
- end;
- type TbkpServicesOptions = class
- private
- FCaminhoBkp: string;
- FPageSize: LongWord;
- FPageBuffers: LongWord;
- {Private declaration}
- protected
- {Protected declaration}
- public
- {Public declaration declaration}
- property CaminhoBkp: string read FCaminhoBkp write FCaminhoBkp;
- property PageSize: LongWord read FPageSize write FPageSize default 0;
- property PageBuffers: LongWord read FPageBuffers write FPageBuffers default 0;
- constructor Create; (*Metodos do Constructor*)
- destructor Destroy; override;
- published
- {Protected declaration}
- end;
- type TBkpServices = class( TComponent )
- private
- FDatabase: String;
- FEUAPassword: String;
- FEUAUserName: String;
- FEUAPort: String;
- FTBkpservicesthread: TBkpservicesthread;
- FTbkpServicesOptions: TbkpServicesOptions;
- FOnProgress: TServiceProgressEvent;
- FTstringList: TstringList;
- FHost: string;
- FCaminhoBkp: string;
- {Private declaration}
- protected
- {Protected declaration}
- public
- constructor Create(AOwner: TComponent); override;
- {Public declaration declaration}
- property Database: String read FDatabase write FDatabase;
- property UserName: String read FEUAUserName write FEUAUserName;
- property Password: String read FEUAPassword write FEUAPassword;
- property Port: String read FEUAPort write FEUAPort;
- property Host: string read FHost write FHost;
- property CaminhoBkp: string read FCaminhoBkp write FCaminhoBkp;
- property RetornoGbk: TstringList read FTstringList write FTstringList;
- property Options: TbkpServicesOptions read FTbkpServicesOptions write FTbkpServicesOptions;
- property OnProgress: TServiceProgressEvent read FOnProgress write FOnProgress;
- procedure ExecuteBackup;
- destructor Destroy; override;
- procedure AfterConstruction; override;
- procedure BeforeDestruction; override;
- published
- {Protected declaration}
- end;
- { TBkpServices }
- implementation
- procedure TBkpServices.AfterConstruction;
- begin
- inherited AfterConstruction;
- end;
- procedure TBkpServices.BeforeDestruction;
- begin
- inherited BeforeDestruction;
- end;
- constructor TBkpServices.Create(AOwner: TComponent);
- begin
- inherited Create(aowner);
- FTbkpServicesOptions:= TbkpServicesOptions.Create;
- end;
- destructor TBkpServices.Destroy;
- begin
- inherited;
- end;
- procedure TBkpServices.ExecuteBackup;
- begin
- FTBkpservicesthread := TBkpservicesthread.Create;
- FTBkpservicesthread.CmdPromptcommand(FEUAUserName,FEUAPassword,FHost,FDatabase,FCaminhoBkp,'.Fkb',ExtractFilePath(Application.ExeName));
- end;
- { TbkpServicesOptions }
- constructor TbkpServicesOptions.Create;
- begin
- end;
- destructor TbkpServicesOptions.Destroy;
- begin
- inherited;
- end;
- { TBkpservicesthread }
- procedure TBkpservicesthread.BackupDossier;
- begin
- end;
- procedure TBkpservicesthread.CmdPromptcommand(const User, password, Host, Banco, LocalBkp,Formato,output: string);
- var T: TstringBuilder;
- begin
- T:= TStringBuilder.Create;
- T.Append('cmd /c gbak ')
- .Append( '-user ')
- .Append(user)
- .Append(' -pas ')
- .Append(password)
- .Append(Host)
- .Append(':')
- .Append(Banco)
- .Append(LocalBkp)
- .Append('.'+Formato)
- .Append('>')
- .Append(output)
- .Append(',0');
- WinExec(PAnsiChar(T.ToString),SW_HIDE);
- end;
- procedure TBkpservicesthread.Execute(const User, password, Host, Banco, LocalBkp, Formato, output: string);
- begin
- inherited Execute;
- CmdPromptcommand(User, password, Host, Banco, LocalBkp, Formato, output);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement