AlonsoYSal_FactuGES2/Source/Servidor/Configuracion/srvConfiguracion_Impl.pas
2019-11-18 10:36:42 +00:00

149 lines
4.9 KiB
ObjectPascal
Raw Blame History

unit srvConfiguracion_Impl;
{----------------------------------------------------------------------------}
{ This unit was automatically generated by the RemObjects SDK after reading }
{ the RODL file associated with this project . }
{ }
{ This is where you are supposed to code the implementation of your objects. }
{----------------------------------------------------------------------------}
interface
uses
{vcl:} Classes, SysUtils,
{RemObjects:} uROClientIntf, uROTypes, uROServer, uROServerIntf, uROSessions,
{Ancestor Implementation:} DataAbstractService_Impl,
{Used RODLs:} DataAbstract4_Intf,
{Generated:} uDABusinessProcessor, uDABin2DataStreamer, uDADataStreamer,
uDAScriptingProvider, uDAClasses,
FactuGES_Intf, uDAInterfaces;
type
{ TsrvConfiguracion }
TsrvConfiguracion = class(TDataAbstractService, IsrvConfiguracion)
Bin2DataStreamer: TDABin2DataStreamer;
schConfiguracion: TDASchema;
procedure DARemoteServiceCreate(Sender: TObject);
procedure DataAbstractServiceBeforeAcquireConnection(aSender: TObject; var aConnectionName: string);
protected
{ IsrvConfiguracion methods }
function DarValor(const CODIGO: String; Const ValorPorDefecto: String = ''): String;
procedure GuardarValor(const CODIGO: AnsiString; const Valor: AnsiString);
end;
implementation
{$R *.dfm}
uses
{Generated:} FactuGES_Invk, uDataModuleServer, Variants, uROClasses;
procedure Create_srvConfiguracion(out anInstance : IUnknown);
begin
anInstance := TsrvConfiguracion.Create(NIL);
end;
{ srvConfiguracion }
procedure TsrvConfiguracion.DARemoteServiceCreate(Sender: TObject);
begin
//SessionManager := dmServer.SessionManager;
end;
function TsrvConfiguracion.DarValor(const CODIGO: String; const ValorPorDefecto: String = ''): String;
var
ADataSet : IDADataset;
ACurrentConn : IDAConnection;
ACommand : IDASQLCommand;
begin
try
ADataSet := schConfiguracion.NewDataset(Connection, 'darValor', ['CODIGO'], [CODIGO]);
ADataSet.Open;
if ADataSet.Dataset.RecordCount > 0 then
begin
if ((CODIGO = 'CONDICIONES_COCINA') OR
(CODIGO = 'CONDICIONES_ARMARIO') OR
(CODIGO = 'CONDICIONES_BANO') OR
(CODIGO = 'CONDICIONES_ELECTRODOMESTICO') OR
(CODIGO = 'CONDICIONES_OBRA') OR
(CODIGO = 'CONDICIONES_VARIOS')) then
Result := ADataSet.Dataset.Fields[1].AsVariant
else
Result := ADataSet.Dataset.Fields[0].AsVariant
end
else
begin
Result := ValorPorDefecto;
//Creamos la variable de configuraci<63>n con su valor por defecto
ACurrentConn := dmServer.ConnectionManager.NewConnection(dmServer.ConnectionManager.GetDefaultConnectionName);
ACommand := schConfiguracion.NewCommand(ACurrentConn, 'InsertarValor');
try
with ACommand do
begin
ParamByName('CODIGO').Value := CODIGO;
ParamByName('VALOR').Value := ValorPorDefecto;
ParamByName('ID_EMPRESA').Value := Null;
Execute;
ACurrentConn.CommitTransaction;
end;
except
ACurrentConn.RollbackTransaction;
end;
ACommand := NIL;
// RaiseError('Falta variable de configuracion: ' + CODIGO);
end;
finally
ADataSet.Close;
end;
end;
procedure TsrvConfiguracion.DataAbstractServiceBeforeAcquireConnection(
aSender: TObject; var aConnectionName: string);
begin
ConnectionName := dmServer.ConnectionName;
end;
procedure TsrvConfiguracion.GuardarValor(const CODIGO: AnsiString; const Valor: AnsiString);
var
ACurrentConn : IDAConnection;
ACommand : IDASQLCommand;
st: TStringStream;
st2: IROStream;
begin
//Creamos la variable de configuraci<63>n con su valor por defecto
ACurrentConn := dmServer.ConnectionManager.NewConnection(dmServer.ConnectionManager.GetDefaultConnectionName);
ACommand := schConfiguracion.NewCommand(ACurrentConn, 'UpdateValor');
try
with ACommand do
begin
ParamByName('CODIGO').Value := CODIGO;
ParamByName('VALOR').Value := Valor;
//Las condiciones se guardan en el valor bolb en lugar del varchar
if ((CODIGO = 'CONDICIONES_COCINA') OR
(CODIGO = 'CONDICIONES_ARMARIO') OR
(CODIGO = 'CONDICIONES_BANO') OR
(CODIGO = 'CONDICIONES_ELECTRODOMESTICO') OR
(CODIGO = 'CONDICIONES_OBRA') OR
(CODIGO = 'CONDICIONES_VARIOS')) then
begin
ParamByName('VALOR').Value := Null;
ParamByName('VALOR_BLOB').Value := Valor;
end;
Execute;
ACurrentConn.CommitTransaction;
end;
except
ACurrentConn.RollbackTransaction;
end;
ACommand := NIL;
end;
initialization
TROClassFactory.Create('srvConfiguracion', Create_srvConfiguracion, TsrvConfiguracion_Invoker);
finalization
end.