2011-11-14 17:40:41 +00:00
|
|
|
unit uDataModuleConfiguracion;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
SysUtils, Classes, uRORemoteService, uDADataTable,
|
|
|
|
|
uDABINAdapter, uROClient, IniFiles, Variants,
|
|
|
|
|
uDADataStreamer, uROTypes;
|
|
|
|
|
|
|
|
|
|
const
|
|
|
|
|
SERVER_URL = 'http://localhost:8099/bin';
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
TdmConfiguracion = class(TDataModule)
|
|
|
|
|
RORemoteService: TRORemoteService;
|
|
|
|
|
private
|
|
|
|
|
FIniFile : TIniFile;
|
|
|
|
|
public
|
|
|
|
|
function DarValor(const CODIGO: String; const ValorPorDefecto: String = ''): Variant;
|
2013-05-16 17:17:31 +00:00
|
|
|
function DarValorParaEmpresa(const CODIGO: String; const ID_EMPRESA: Integer; const ValorPorDefecto: String = ''): Variant;
|
2011-11-14 17:40:41 +00:00
|
|
|
procedure GuardarValor(const CODIGO: String; const Valor: Variant);
|
|
|
|
|
procedure LeerConfiguracion;
|
|
|
|
|
procedure SalvarConfiguracion;
|
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
dmConfiguracion: TdmConfiguracion;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
Forms, FactuGES_Intf, uDataModuleConexion,
|
|
|
|
|
uSistemaFunc, SHFolder, uAppInfoUtils;
|
|
|
|
|
|
|
|
|
|
const
|
|
|
|
|
CONFIG_INI_FILE = 'config.ini';
|
|
|
|
|
|
|
|
|
|
{ TdmConfiguracion }
|
|
|
|
|
|
|
|
|
|
constructor TdmConfiguracion.Create(AOwner: TComponent);
|
|
|
|
|
var
|
|
|
|
|
AIniFile : String;
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
AIniFile := GetSpecialFolderPath(CSIDL_COMMON_APPDATA); //[All Users]\Application Data
|
|
|
|
|
AIniFile := AIniFile + PathDelim + GetAppName + PathDelim;
|
|
|
|
|
|
|
|
|
|
if not DirectoryExists(AIniFile) then
|
|
|
|
|
CreateDir(AIniFile);
|
|
|
|
|
|
|
|
|
|
FIniFile := TIniFile.Create(AIniFile + CONFIG_INI_FILE);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TdmConfiguracion.DarValor(const CODIGO: String; const ValorPorDefecto: String = ''): Variant;
|
|
|
|
|
begin
|
|
|
|
|
RORemoteService.Channel := dmConexion.ROChannel;
|
|
|
|
|
RORemoteService.Message := dmConexion.ROMessage;
|
|
|
|
|
Result := (RORemoteService as IsrvConfiguracion).DarValor(CODIGO, ValorPorDefecto);
|
|
|
|
|
end;
|
|
|
|
|
|
2013-05-16 17:17:31 +00:00
|
|
|
function TdmConfiguracion.DarValorParaEmpresa(const CODIGO: String;
|
|
|
|
|
const ID_EMPRESA: Integer; const ValorPorDefecto: String): Variant;
|
|
|
|
|
begin
|
|
|
|
|
RORemoteService.Channel := dmConexion.ROChannel;
|
|
|
|
|
RORemoteService.Message := dmConexion.ROMessage;
|
|
|
|
|
Result := (RORemoteService as IsrvConfiguracion).DarValorParaEmpresa(CODIGO, ID_EMPRESA, ValorPorDefecto);
|
|
|
|
|
end;
|
|
|
|
|
|
2011-11-14 17:40:41 +00:00
|
|
|
destructor TdmConfiguracion.Destroy;
|
|
|
|
|
begin
|
|
|
|
|
FreeAndNIL(FIniFile);
|
|
|
|
|
inherited;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TdmConfiguracion.GuardarValor(const CODIGO: String; const Valor: Variant);
|
|
|
|
|
begin
|
|
|
|
|
RORemoteService.Channel := dmConexion.ROChannel;
|
|
|
|
|
RORemoteService.Message := dmConexion.ROMessage;
|
|
|
|
|
(RORemoteService as IsrvConfiguracion).GuardarValor(CODIGO, Valor);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TdmConfiguracion.LeerConfiguracion;
|
|
|
|
|
begin
|
|
|
|
|
with FIniFile do
|
|
|
|
|
dmConexion.TargetURL := ReadString('Server', 'URL', SERVER_URL);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TdmConfiguracion.SalvarConfiguracion;
|
|
|
|
|
begin
|
|
|
|
|
with FIniFile do
|
|
|
|
|
WriteString('Server', 'URL', dmConexion.TargetURL);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|