146 lines
3.6 KiB
ObjectPascal
146 lines
3.6 KiB
ObjectPascal
|
|
unit uFactuGES_App;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
SysUtils, Classes, Forms, uUsuarios, uBizEmpresas,
|
|||
|
|
uEmpresasController, JclFileUtils, uUsuariosController;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TAppFactuGES = class(TObject)
|
|||
|
|
private
|
|||
|
|
FAppInfo : TJclFileVersionInfo;
|
|||
|
|
FEmpresasController : IEmpresasController;
|
|||
|
|
FUsuariosController: IUsuariosController;
|
|||
|
|
FEmpresaActiva: IBizEmpresa;
|
|||
|
|
FUsuarioActivo: TUsuario;
|
|||
|
|
function GetAppForm: TCustomForm;
|
|||
|
|
procedure SetEmpresaActiva(const Value: IBizEmpresa);
|
|||
|
|
procedure SetUsuarioActivo(const Value: TUsuario);
|
|||
|
|
function GetEmpresasController: IEmpresasController;
|
|||
|
|
function GetUsuariosController: IUsuariosController;
|
|||
|
|
function GetAppName: String;
|
|||
|
|
function GetAppVersion: String;
|
|||
|
|
protected
|
|||
|
|
procedure InitializeInstance; virtual;
|
|||
|
|
procedure DestroyInstance; virtual;
|
|||
|
|
public
|
|||
|
|
class function NewInstance: TObject; override;
|
|||
|
|
procedure FreeInstance; override;
|
|||
|
|
class function RefCount: Integer;
|
|||
|
|
property AppVersion : String read GetAppVersion;
|
|||
|
|
property AppName : String read GetAppName;
|
|||
|
|
property AppForm : TCustomForm read GetAppForm;
|
|||
|
|
property EmpresaActiva : IBizEmpresa read FEmpresaActiva write SetEmpresaActiva;
|
|||
|
|
property UsuarioActivo : TUsuario read FUsuarioActivo write SetUsuarioActivo;
|
|||
|
|
property EmpresasController : IEmpresasController read GetEmpresasController;
|
|||
|
|
property UsuariosController : IUsuariosController read GetUsuariosController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
AppFactuGES : TAppFactuGES = nil;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uDataModuleBase, uUsuariosViewRegister;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
Ref_Count : Integer = 0;
|
|||
|
|
|
|||
|
|
procedure TAppFactuGES.DestroyInstance;
|
|||
|
|
begin
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TAppFactuGES.FreeInstance;
|
|||
|
|
begin
|
|||
|
|
Dec(Ref_Count);
|
|||
|
|
if (Ref_Count = 0) then
|
|||
|
|
begin
|
|||
|
|
AppFactuGES := NIL;
|
|||
|
|
// Destroy private variables here
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
inherited FreeInstance;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TAppFactuGES.GetAppForm: TCustomForm;
|
|||
|
|
begin
|
|||
|
|
Result := Application.MainForm;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TAppFactuGES.GetAppName: String;
|
|||
|
|
begin
|
|||
|
|
Result := FAppInfo.ProductName;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TAppFactuGES.GetAppVersion: String;
|
|||
|
|
begin
|
|||
|
|
Result := FAppInfo.ProductVersion;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TAppFactuGES.GetEmpresasController: IEmpresasController;
|
|||
|
|
begin
|
|||
|
|
Result := FEmpresasController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TAppFactuGES.GetUsuariosController: IUsuariosController;
|
|||
|
|
begin
|
|||
|
|
Result := FUsuariosController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TAppFactuGES.InitializeInstance;
|
|||
|
|
begin
|
|||
|
|
FEmpresaActiva := NIL;
|
|||
|
|
FUsuarioActivo := NIL;
|
|||
|
|
FAppInfo := TJclFileVersionInfo.Create(Application.ExeName);
|
|||
|
|
FUsuariosController := TUsuariosController.Create;
|
|||
|
|
FEmpresasController := TEmpresasController.Create;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
class function TAppFactuGES.NewInstance: TObject;
|
|||
|
|
begin
|
|||
|
|
if (not Assigned(AppFactuGES)) then
|
|||
|
|
begin
|
|||
|
|
AppFactuGES := TAppFactuGES(inherited NewInstance);
|
|||
|
|
// Initialize private variables here
|
|||
|
|
AppFactuGES.InitializeInstance;
|
|||
|
|
end;
|
|||
|
|
Result := AppFactuGES;
|
|||
|
|
Inc(Ref_Count);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
class function TAppFactuGES.RefCount: Integer;
|
|||
|
|
begin
|
|||
|
|
Result := Ref_Count;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TAppFactuGES.SetEmpresaActiva(const Value: IBizEmpresa);
|
|||
|
|
begin
|
|||
|
|
FEmpresaActiva := Value;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TAppFactuGES.SetUsuarioActivo(const Value: TUsuario);
|
|||
|
|
begin
|
|||
|
|
if Assigned(FUsuarioActivo) and (FUsuarioActivo <> Value) then
|
|||
|
|
FreeAndNIL(FUsuarioActivo);
|
|||
|
|
FUsuarioActivo := Value;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
initialization
|
|||
|
|
AppFactuGES := TAppFactuGES.Create;
|
|||
|
|
|
|||
|
|
// Pongo esto aqu<71> por ahora
|
|||
|
|
uUsuariosViewRegister.RegisterViews;
|
|||
|
|
|
|||
|
|
finalization
|
|||
|
|
FreeAndNIL(AppFactuGES);
|
|||
|
|
|
|||
|
|
// Pongo esto aqu<71> por ahora
|
|||
|
|
uUsuariosViewRegister.UnregisterViews;
|
|||
|
|
|
|||
|
|
end.
|