unit srvObras_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
  { TsrvObras }
  TsrvObras = class(TDataAbstractService, IsrvObras)
    Diagrams: TDADiagrams;
    Bin2DataStreamer: TDABin2DataStreamer;
    bpObras: TDABusinessProcessor;
    schObras: TDASchema;
    DataDictionary: TDADataDictionary;
    procedure DARemoteServiceAfterGetDatasetData(const Dataset: IDADataset;
      const IncludeSchema: Boolean; const MaxRecords: Integer);
    procedure DARemoteServiceCreate(Sender: TObject);
    procedure DataAbstractServiceBeforeAcquireConnection(aSender: TObject;
      var aConnectionName: string);
  end;

implementation

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

procedure Create_srvObras(out anInstance : IUnknown);
begin
  anInstance := TsrvObras.Create(NIL);
end;

{ srvObras }
procedure TsrvObras.DARemoteServiceAfterGetDatasetData(
  const Dataset: IDADataset; const IncludeSchema: Boolean;
  const MaxRecords: Integer);
begin
  if Assigned(Dataset.FindField(fld_ObrasID_EMPRESA)) then
  begin
    { Aquí se asegura que el usuario sólo accede a los Obras
      de las empresas a las que tiene permiso para acceder
      filtrando DataSet por ID_EMPRESA. }
    FiltrarAccesoUsuario(Session, Connection, schObras, DataSet, fld_ObrasID_EMPRESA);
  end;
end;

procedure TsrvObras.DARemoteServiceCreate(Sender: TObject);
begin
  SessionManager := dmServer.SessionManager;
  bpObras.BusinessRulesID := BIZ_SERVER_OBRA;
end;

procedure TsrvObras.DataAbstractServiceBeforeAcquireConnection(
  aSender: TObject; var aConnectionName: string);
begin
  ConnectionName := dmServer.ConnectionName;
end;

initialization
  TROClassFactory.Create('srvObras', Create_srvObras, TsrvObras_Invoker);

finalization

end.
