2007-10-03 16:03:28 +00:00
|
|
|
unit uDataModuleConfiguracion;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
SysUtils, Classes, uRORemoteService, uDADataTable,
|
2008-02-29 18:55:32 +00:00
|
|
|
uDABINAdapter, uROClient, IniFiles,
|
2007-10-03 16:03:28 +00:00
|
|
|
uDADataStreamer;
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
TdmConfiguracion = class(TDataModule)
|
|
|
|
|
RORemoteService: TRORemoteService;
|
|
|
|
|
private
|
|
|
|
|
FIniFile : TIniFile;
|
|
|
|
|
public
|
2008-08-28 09:04:03 +00:00
|
|
|
function DarValor(const CODIGO: String; const ValorPorDefecto: String = ''): Variant;
|
2007-10-03 16:03:28 +00:00
|
|
|
procedure LeerConfiguracion;
|
|
|
|
|
procedure SalvarConfiguracion;
|
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
dmConfiguracion: TdmConfiguracion;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
uses
|
2008-03-27 17:01:26 +00:00
|
|
|
Forms, FactuGES_Intf, Variants, uDataModuleConexion,
|
|
|
|
|
uSistemaFunc, SHFolder, uAppInfoUtils;
|
2007-10-03 16:03:28 +00:00
|
|
|
|
2008-03-27 17:01:26 +00:00
|
|
|
const
|
|
|
|
|
CONFIG_INI_FILE = 'config.ini';
|
2007-10-03 16:03:28 +00:00
|
|
|
|
|
|
|
|
{ TdmConfiguracion }
|
|
|
|
|
|
|
|
|
|
constructor TdmConfiguracion.Create(AOwner: TComponent);
|
2008-03-27 17:01:26 +00:00
|
|
|
var
|
|
|
|
|
AIniFile : String;
|
2007-10-03 16:03:28 +00:00
|
|
|
begin
|
|
|
|
|
inherited;
|
2008-03-27 17:01:26 +00:00
|
|
|
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);
|
2007-10-03 16:03:28 +00:00
|
|
|
end;
|
|
|
|
|
|
2008-08-28 09:04:03 +00:00
|
|
|
function TdmConfiguracion.DarValor(const CODIGO: String; const ValorPorDefecto: String = ''): Variant;
|
2007-10-03 16:03:28 +00:00
|
|
|
begin
|
2008-02-29 18:55:32 +00:00
|
|
|
RORemoteService.Channel := dmConexion.ROChannel;
|
|
|
|
|
RORemoteService.Message := dmConexion.ROMessage;
|
2008-08-28 09:04:03 +00:00
|
|
|
Result := (RORemoteService as IsrvConfiguracion).DarValor(CODIGO, ValorPorDefecto);
|
2007-10-03 16:03:28 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
destructor TdmConfiguracion.Destroy;
|
|
|
|
|
begin
|
|
|
|
|
FreeAndNIL(FIniFile);
|
|
|
|
|
inherited;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TdmConfiguracion.LeerConfiguracion;
|
2012-06-11 14:31:03 +00:00
|
|
|
var
|
|
|
|
|
AStream : TMemoryStream;
|
2007-10-03 16:03:28 +00:00
|
|
|
begin
|
2012-06-11 14:31:03 +00:00
|
|
|
AStream := TMemoryStream.Create();
|
|
|
|
|
try
|
|
|
|
|
if (FIniFile.ReadBinaryStream('Server', 'URLs', AStream) > 0) then
|
|
|
|
|
dmConexion.ListaConexiones.LoadFromStream(AStream);
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNIL(AStream);
|
|
|
|
|
end;
|
2007-10-03 16:03:28 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TdmConfiguracion.SalvarConfiguracion;
|
2012-06-11 14:31:03 +00:00
|
|
|
var
|
|
|
|
|
AStream : TMemoryStream;
|
2007-10-03 16:03:28 +00:00
|
|
|
begin
|
2012-06-11 14:31:03 +00:00
|
|
|
AStream := TMemoryStream.Create();
|
|
|
|
|
try
|
|
|
|
|
dmConexion.ListaConexiones.SaveToStream(AStream);
|
|
|
|
|
AStream.Position := 0;
|
|
|
|
|
FIniFile.WriteBinaryStream('Server', 'URLs', AStream);
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
end;
|
2007-10-03 16:03:28 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|