Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {*******************************************************}
- { }
- { FrentePDV }
- { }
- { Copyright (C) 2017 Leopard report }
- { C:\Leopard\Pdv\CentralDeConfiguracao\SourceProj\ }
- {- CentraldeConfiguracao 1.0.0.244 }
- { 08/09/2017 16:39:20 }
- { Devenvolvedor: Carlos Alberto Dias da Silva Filho }
- {*******************************************************}
- unit CentralConfigFactory;
- interface
- uses Vcl.Forms,FrmConfigSat, SatModelEngine,Dialogs,JvExComCtrls, JvComCtrls, JvDialogs,Types,Windows,
- JvComponentBase, JvComputerInfoEx, FrmMiscelanias, Sistema.Model,FireDAC.Phys.FBDef, FireDAC.UI.Intf, FireDAC.VCLUI.Wait, FireDAC.Comp.UI,
- FireDAC.Stan.Intf, FireDAC.Phys, FireDAC.Phys.IBBase, FireDAC.Phys.FB, FireDAC.Stan.Option, FireDAC.Stan.Param,
- FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.Stan.Async, FireDAC.DApt,
- FireDAC.Stan.Def, FireDAC.Stan.Pool, Data.DB, FireDAC.Comp.Client, FireDAC.Comp.DataSet,System.SysUtils,System.Generics.Collections;
- type
- ICentral = interface
- ['{21BC9C81-9302-4029-B46B-25E28070463F}']
- function CreateConfigSatForm:TForm;
- function CreateFrmMisc: TForm;
- function CreateSat:TObject;
- function CarregaDllSat: String;
- function RetornaNomedoComputador:string;
- function CriaInformacoesCpu: TJvComputerInfoEx;
- function CriaConfigSistemas: TObject;
- procedure LimpaMemoriaResidual;
- procedure CreateConexaoBaseDados;
- end;
- IAbstractCentral = interface
- ['{3530B3E6-14C0-4C9E-B5F6-C76B28229A5D}']
- function CreateIAbstractProduct: ICentral;
- end;
- TCentralFactory = class(TInterfacedObject, ICentral)
- private
- published
- function CreateConfigSatForm:TForm;
- function CreateFrmMisc: TForm;
- function CreateSat:TObject;
- function CarregaDllSat: String;
- function RetornaNomedoComputador:string;
- function CriaInformacoesCpu: TJvComputerInfoEx;
- function CriaConfigSistemas: TObject;
- procedure LimpaMemoriaResidual;
- procedure CreateConexaoBaseDados;
- end;
- TConcreteCentral = class(TInterfacedObject, IAbstractCentral)
- public
- function CreateIAbstractProduct: ICentral;
- end;
- type TGlobals = class
- FrmConfigSatParam: TTfrmConfigSat;
- CentralFactory: TConcreteCentral;
- Central: TCentralFactory;
- Sat: TSatTableDaoModel;
- FInfoCpu: TJvComputerInfoEx;
- FrmMisc: TTfrmMiscelanias;
- SistemaConfig: TSistema;
- FConnectionPdv: TFDConnection;
- End;
- type Obj = class Function Global: TObjectList<TGlobals>;
- end;
- var FrmConfigSatParam: TTfrmConfigSat;
- CentralFactory: TConcreteCentral;
- Central: TCentralFactory;
- Sat: TSatTableDaoModel;
- FInfoCpu: TJvComputerInfoEx;
- FrmMisc: TTfrmMiscelanias;
- SistemaConfig: TSistema;
- FConnectionPdv: TFDConnection;
- implementation
- uses
- FuncoesLibraryClass;
- { TCentralFactory }
- function TCentralFactory.CarregaDllSat: String;
- var aopen: TJvOpenDialog;
- begin
- aopen:= TJvOpenDialog.Create(nil);
- try
- if aopen.Execute then
- Result:= aopen.FileName;
- finally
- aopen.DisposeOf;
- end;
- end;
- procedure TCentralFactory.CreateConexaoBaseDados;
- begin
- CarregaWait('Preparando Carregamento dos dados',200);
- FConnectionPdv:= TFDConnection.Create(Nil);
- FConnectionPdv.Params.Clear;
- CarregaWait('Tentando se conectar ao banco de dados',200);
- FConnectionPdv.DriverName := 'FB';
- FConnectionPdv.Params.Values['Server'] := '127.0.0.1';
- FConnectionPdv.Params.Values['Database'] := 'C:\Leopard\PDV\PDV.FDB';
- FConnectionPdv.Params.Values['User_Name'] := 'SYSDBA';
- FConnectionPdv.Params.Values['Password'] := '1234';
- FConnectionPdv.Params.Values['Port'] := '3050';
- FConnectionPdv.Params.Values['DriveId'] := 'FB';
- FConnectionPdv.LoginPrompt:= False;
- CarregaWait('Tentando se conectar ao banco de dados',200);
- try
- try
- FConnectionPdv.Connected:= True;
- finally
- CarregaWait('Conexao criada com sucesso!',200);
- end;
- except
- on E: Exception do begin
- raise Exception.Create('Não consegui conectar a base de dados do PDV, por favor revise as configurações ou'
- +' verifique se o Arquivo PDV.FDB se encontra na pasta.');
- end;
- end;
- end;
- function TCentralFactory.CreateConfigSatForm: TForm;
- begin
- CarregaWait('Carregando e criando dados do SAT',200);
- FrmConfigSatParam:= TTfrmConfigSat.Create(Application);
- Result:= FrmConfigSatParam;
- FrmConfigSatParam.ShowModal;
- end;
- function TCentralFactory.CreateFrmMisc: TForm;
- begin
- CarregaWait('Carregando as Configurações da aplicação',500);
- FrmMisc:= TTfrmMiscelanias.Create(Application);
- Result := FrmMisc;
- FrmMisc.ShowModal;
- end;
- function TCentralFactory.CreateSat: TObject;
- begin
- Sat:= TSatTableDaoModel.Create;
- Result:= Sat;
- end;
- function TCentralFactory.CriaConfigSistemas: TObject;
- begin
- SistemaConfig:= TSistema.Create;
- result:= SistemaConfig;
- end;
- function TCentralFactory.CriaInformacoesCpu: TJvComputerInfoEx;
- begin
- Result:= TJvComputerInfoEx.Create(Nil);
- FInfoCpu:= Result;
- end;
- procedure TCentralFactory.LimpaMemoriaResidual;
- var
- MainHandle : THandle;
- begin
- try
- MainHandle := OpenProcess(PROCESS_ALL_ACCESS, false, GetCurrentProcessID) ;
- SetProcessWorkingSetSize(MainHandle, $FFFFFFFF, $FFFFFFFF) ;
- CloseHandle(MainHandle) ;
- except
- end;
- Application.ProcessMessages;
- end;
- function TCentralFactory.RetornaNomedoComputador: string;
- var ipbuffer : string;
- nsize : dword;
- begin
- nsize := 255;
- SetLength(ipbuffer,nsize);
- if GetComputerName(pchar(ipbuffer),nsize) then
- result := ipbuffer;
- end;
- { TConcreteCentral }
- function TConcreteCentral.CreateIAbstractProduct: ICentral;
- begin
- Result := TCentralFactory.Create();
- end;
- { Obj }
- function Obj.Global: TObjectList<TGlobals>;
- var Objeto: TObjectList<TGlobals>; I: Integer;
- begin
- Objeto:= TObjectList<TGlobals>.Create();
- result:= Objeto;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement