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,
//  {Required:} uRORemoteDataModule,
  {Ancestor Implementation:} DARemoteService_Impl,
  {Used RODLs:} DataAbstract_Intf,
//  {Generated:} FactuGES_Intf, uDAClasses;
  {Generated:} FactuGES_Intf, uDAClasses, uDAScriptingProvider,
  uDABusinessProcessor, uDADataTable, uDABINAdapter;


type
  { TsrvConfiguracion }
  TsrvConfiguracion = class(TDARemoteService, IsrvConfiguracion)
    DABINAdapter: TDABINAdapter;
    schConfiguracion: TDASchema;
    procedure DARemoteServiceCreate(Sender: TObject);
    procedure DARemoteServiceBeforeAcquireConnection(Sender: TDARemoteService;
      var ConnectionName: string);
  protected
    { IsrvConfiguracion methods }
    function DarValor(const CODIGO: String): String;
  end;

implementation

{$R *.dfm}
uses
  {Generated:} FactuGES_Invk, uDAInterfaces, uDataModuleServer, Variants,
  uROClasses;

procedure Create_srvConfiguracion(out anInstance : IUnknown);
begin
  anInstance := TsrvConfiguracion.Create(NIL);
end;

{ srvConfiguracion }
procedure TsrvConfiguracion.DARemoteServiceBeforeAcquireConnection(
  Sender: TDARemoteService; var ConnectionName: string);
begin
  ConnectionName := dmServer.ConnectionName;
end;

procedure TsrvConfiguracion.DARemoteServiceCreate(Sender: TObject);
begin
  SessionManager := dmServer.SessionManager;
end;

function TsrvConfiguracion.DarValor(const CODIGO: String): String;
var
   ADataSet : IDADataset;
begin
  try
    ADataSet := schConfiguracion.NewDataset(Connection, 'darValor', ['CODIGO'], [CODIGO]);
    ADataSet.Open;
    if ADataSet.Dataset.RecordCount > 0 then
       Result := ADataSet.Dataset.Fields[0].AsVariant
    else
       RaiseError('Falta variable de configuracion: ' + CODIGO);
  finally
    ADataSet.Close;
  end;
end;

initialization
  TROClassFactory.Create('srvConfiguracion', Create_srvConfiguracion, TsrvConfiguracion_Invoker);

finalization

end.
