unit srvMontajes_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, uDADataTable, uDABINAdapter, uDAClasses,
  uDAScriptingProvider, uDABusinessProcessor, uDAInterfaces;

type
  { TsrvMontajes }
  TsrvMontajes = class(TDARemoteService, IsrvMontajes)
    Diagrams: TDADiagrams;
    DABINAdapter: TDABINAdapter;
    bpMontajes: TDABusinessProcessor;
    bpDetallesMontajes: TDABusinessProcessor;
    bpGastosMontajes: TDABusinessProcessor;
    schMontajes: TDASchema;
    DataDictionary: TDADataDictionary;
    procedure DARemoteServiceBeforeAcquireConnection(Sender: TDARemoteService;
      var ConnectionName: string);
    procedure DARemoteServiceAfterGetDatasetData(const Dataset: IDADataset;
      const IncludeSchema: Boolean; const MaxRecords: Integer);
    procedure DARemoteServiceCreate(Sender: TObject);
  private
  protected
    { IsrvMontajes methods }
    function GetNextAutoInc(const GeneratorName: String): Integer;
  end;

implementation

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

procedure Create_srvMontajes(out anInstance : IUnknown);
begin
  anInstance := TsrvMontajes.Create(NIL);
end;

{ srvMontajes }
procedure TsrvMontajes.DARemoteServiceAfterGetDatasetData(
  const Dataset: IDADataset; const IncludeSchema: Boolean;
  const MaxRecords: Integer);
begin
  if DataSet.Name = nme_Montajes then
  begin
    { Aquí se asegura que el usuario sólo accede a facturas
      de las empresas a las que tiene permiso para acceder
      filtrando DataSet por ID_EMPRESA. }
    FiltrarAccesoUsuario(Session, Connection, schMontajes, DataSet, fld_MontajesID_EMPRESA);
  end;
end;

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

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

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

initialization
  TROClassFactory.Create('srvMontajes', Create_srvMontajes, TsrvMontajes_Invoker);

finalization

end.
