unit srvComisiones_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, uROClient;

type
  { TsrvComisiones }
  TsrvComisiones = class(TDataAbstractService, IsrvComisiones)
    Diagrams: TDADiagrams;
    Bin2DataStreamer: TDABin2DataStreamer;
    bpComisiones: TDABusinessProcessor;
    bpFacturasComision: TDABusinessProcessor;
    schComisiones: TDASchema;
    DataDictionary: TDADataDictionary;
    procedure DARemoteServiceBeforeGetDatasetData(const Dataset: IDADataset;
      const IncludeSchema: Boolean; const MaxRecords: Integer);
    procedure DARemoteServiceCreate(Sender: TObject);
    procedure DataAbstractServiceBeforeAcquireConnection(aSender: TObject; var aConnectionName: string);
  private
  protected
    { IsrvComisiones methods }
    function GenerarInforme(const ListaID: TIntegerArray): Binary;
  end;

implementation

{$R *.dfm}
uses
  {Generated:} FactuGES_Invk, Dialogs, uSistemaFunc, uROClasses,
  uDataModuleServer, uDatabaseUtils, uUsersManager, schComisionesClient_Intf,
  uRestriccionesUsuarioUtils, uBizComisionesServer, uRptComisiones_Server;
// uRptWordFacturaCliente, ;

procedure Create_srvComisiones(out anInstance : IUnknown);
begin
  anInstance := TsrvComisiones.Create(NIL);
end;

{ srvComisones }

procedure TsrvComisiones.DARemoteServiceBeforeGetDatasetData(
  const Dataset: IDADataset; const IncludeSchema: Boolean;
  const MaxRecords: Integer);
begin
{
  if DataSet.Name = nme_FacturasCliente 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, schFacturasCliente, DataSet, fld_FacturasClienteID_EMPRESA);
  end;
}
end;

procedure TsrvComisiones.DARemoteServiceCreate(Sender: TObject);
begin
  //SessionManager := dmServer.SessionManager;
  bpComisiones.BusinessRulesID := BIZ_SERVER_COMISIONES;
end;

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

function TsrvComisiones.GenerarInforme(const ListaID: TIntegerArray): Binary;
var
  AReportGenerator : TRptComisiones;
begin
  AReportGenerator := TRptComisiones.Create(nil);
  try
    Result := AReportGenerator.GenerarInforme(ListaID);
  finally
    FreeAndNIL(AReportGenerator);
  end;
end;


initialization
  TROClassFactory.Create('srvComisiones', Create_srvComisiones, TsrvComisiones_Invoker);

finalization

end.
