2011-11-14 17:40:41 +00:00
|
|
|
|
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
|
2013-05-16 17:17:31 +00:00
|
|
|
|
{vcl:} Classes, SysUtils,
|
2011-11-14 17:40:41 +00:00
|
|
|
|
{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 }
|
2013-05-16 17:17:31 +00:00
|
|
|
|
function darValor(const CODIGO: AnsiString; const ValorPorDefecto: String = ''): AnsiString;
|
|
|
|
|
|
function darValorParaEmpresa(const CODIGO: AnsiString; const ID_EMPRESA: Integer; const ValorPorDefecto: String = ''): AnsiString;
|
|
|
|
|
|
procedure guardarValor(const CODIGO: AnsiString; const Valor: String = '');
|
|
|
|
|
|
procedure guardarValorParaEmpresa(const CODIGO: AnsiString; const ID_EMPRESA: Integer; const Valor: String = '');
|
2011-11-14 17:40:41 +00:00
|
|
|
|
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' 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;
|
|
|
|
|
|
|
2013-05-16 17:17:31 +00:00
|
|
|
|
function TsrvConfiguracion.darValorParaEmpresa(const CODIGO: AnsiString;
|
|
|
|
|
|
const ID_EMPRESA: Integer; const ValorPorDefecto: String): AnsiString;
|
|
|
|
|
|
var
|
|
|
|
|
|
ADataSet : IDADataset;
|
|
|
|
|
|
ACurrentConn : IDAConnection;
|
|
|
|
|
|
ACommand : IDASQLCommand;
|
|
|
|
|
|
begin
|
|
|
|
|
|
try
|
|
|
|
|
|
ADataSet := schConfiguracion.NewDataset(Connection, 'darValorParaEmpresa', ['CODIGO','ID_EMPRESA'], [CODIGO, ID_EMPRESA]);
|
|
|
|
|
|
ADataSet.Open;
|
|
|
|
|
|
if ADataSet.Dataset.RecordCount > 0 then
|
|
|
|
|
|
Result := ADataSet.Dataset.Fields[0].AsVariant
|
|
|
|
|
|
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 := ID_EMPRESA;
|
|
|
|
|
|
Execute;
|
|
|
|
|
|
ACurrentConn.CommitTransaction;
|
|
|
|
|
|
end;
|
|
|
|
|
|
except
|
|
|
|
|
|
ACurrentConn.RollbackTransaction;
|
|
|
|
|
|
end;
|
|
|
|
|
|
ACommand := NIL;
|
|
|
|
|
|
// RaiseError('Falta variable de configuracion: ' + CODIGO);
|
|
|
|
|
|
end;
|
|
|
|
|
|
finally
|
|
|
|
|
|
ADataSet.Close;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2011-11-14 17:40:41 +00:00
|
|
|
|
procedure TsrvConfiguracion.DataAbstractServiceBeforeAcquireConnection(
|
|
|
|
|
|
aSender: TObject; var aConnectionName: string);
|
|
|
|
|
|
begin
|
|
|
|
|
|
ConnectionName := dmServer.ConnectionName;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2013-05-16 17:17:31 +00:00
|
|
|
|
procedure TsrvConfiguracion.GuardarValor(const CODIGO: AnsiString; const Valor: String = '');
|
2011-11-14 17:40:41 +00:00
|
|
|
|
var
|
|
|
|
|
|
ACurrentConn : IDAConnection;
|
|
|
|
|
|
ACommand : IDASQLCommand;
|
2013-05-30 14:11:35 +00:00
|
|
|
|
// st: TStringStream;
|
|
|
|
|
|
// st2: IROStream;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
if CODIGO = 'CONDICIONES_COCINA' then
|
|
|
|
|
|
begin
|
|
|
|
|
|
// st := TStringStream.Create(Valor);
|
|
|
|
|
|
// st.Position := 0;
|
|
|
|
|
|
// st2 := TROStream.create(st, true);
|
|
|
|
|
|
//
|
|
|
|
|
|
//
|
|
|
|
|
|
// ParamByName('VALOR_BLOB').LoadFromStream(st2);
|
|
|
|
|
|
|
|
|
|
|
|
ParamByName('VALOR_BLOB').Value := Valor;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
// ParamByName('ID_EMPRESA').Value := Null;
|
|
|
|
|
|
Execute;
|
|
|
|
|
|
ACurrentConn.CommitTransaction;
|
|
|
|
|
|
end;
|
|
|
|
|
|
except
|
|
|
|
|
|
ACurrentConn.RollbackTransaction;
|
|
|
|
|
|
end;
|
|
|
|
|
|
ACommand := NIL;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2013-05-16 17:17:31 +00:00
|
|
|
|
procedure TsrvConfiguracion.guardarValorParaEmpresa(const CODIGO: AnsiString;
|
|
|
|
|
|
const ID_EMPRESA: Integer; const Valor: String);
|
|
|
|
|
|
var
|
|
|
|
|
|
ACurrentConn : IDAConnection;
|
|
|
|
|
|
ACommand : IDASQLCommand;
|
|
|
|
|
|
begin
|
|
|
|
|
|
//Creamos la variable de configuraci<63>n con su valor por defecto
|
|
|
|
|
|
ACurrentConn := dmServer.ConnectionManager.NewConnection(dmServer.ConnectionManager.GetDefaultConnectionName);
|
|
|
|
|
|
ACommand := schConfiguracion.NewCommand(ACurrentConn, 'UpdateValorParaEmpresa');
|
|
|
|
|
|
try
|
|
|
|
|
|
with ACommand do
|
|
|
|
|
|
begin
|
|
|
|
|
|
ParamByName('CODIGO').Value := CODIGO;
|
|
|
|
|
|
ParamByName('ID_EMPRESA').Value := ID_EMPRESA;
|
|
|
|
|
|
ParamByName('VALOR').Value := Valor;
|
|
|
|
|
|
Execute;
|
|
|
|
|
|
ACurrentConn.CommitTransaction;
|
|
|
|
|
|
end;
|
|
|
|
|
|
except
|
|
|
|
|
|
ACurrentConn.RollbackTransaction;
|
|
|
|
|
|
end;
|
|
|
|
|
|
ACommand := NIL;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2011-11-14 17:40:41 +00:00
|
|
|
|
initialization
|
|
|
|
|
|
TROClassFactory.Create('srvConfiguracion', Create_srvConfiguracion, TsrvConfiguracion_Invoker);
|
|
|
|
|
|
|
|
|
|
|
|
finalization
|
|
|
|
|
|
|
|
|
|
|
|
end.
|