unit srvInventario_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:} DARemoteService_Impl,
  {Used RODLs:} DataAbstract_Intf,
  {Generated:} FactuGES_Intf, uDAClasses, uDAScriptingProvider,
  uDABusinessProcessor, uDADataTable, uDABINAdapter, uDAInterfaces;

type
  { TsrvInventario }
  TsrvInventario = class(TDARemoteService, IsrvInventario)
    bpInventario: TDABusinessProcessor;
    DABINAdapter: TDABINAdapter;
    schInventario: TDASchema;
    DataDictionary: TDADataDictionary;
    procedure DARemoteServiceAfterGetDatasetData(const Dataset: IDADataset;
      const IncludeSchema: Boolean; const MaxRecords: Integer);
    procedure DARemoteServiceBeforeAcquireConnection(Sender: TDARemoteService;
      var ConnectionName: string);
  private
  protected
    { IsrvInventario methods }
    function GetNextAutoInc(const GeneratorName: String): Integer;
  end;

implementation

{$R *.dfm}
uses
  {Generated:} FactuGES_Invk, uDataModuleServer, uDatabaseUtils,
  schInventarioClient_Intf, uRestriccionesUsuarioUtils;

procedure Create_srvInventario(out anInstance : IUnknown);
begin
  anInstance := TsrvInventario.Create(NIL);
end;

{ srvInventario }
procedure TsrvInventario.DARemoteServiceAfterGetDatasetData(
  const Dataset: IDADataset; const IncludeSchema: Boolean;
  const MaxRecords: Integer);
begin
  if DataSet.Name = nme_Inventario then
  begin
    { Aquí se asegura que el usuario sólo accede a los Articulos
      de las empresas a las que tiene permiso para acceder
      filtrando DataSet por ID_EMPRESA. }
    FiltrarAccesoUsuario(Session, Connection, schInventario, DataSet, fld_InventarioID_EMPRESA);
  end;
end;

procedure TsrvInventario.DARemoteServiceBeforeAcquireConnection(
  Sender: TDARemoteService; var ConnectionName: string);
begin
  ConnectionName := dmServer.ConnectionName;
end;

function TsrvInventario.GetNextAutoInc(const GeneratorName: String): Integer;
begin
  Result := uDatabaseUtils.GetNextAutoInc(GeneratorName)
end;

initialization
  TROClassFactory.Create('srvInventario', Create_srvInventario, TsrvInventario_Invoker);

finalization

end.
