unit srvRecibosProveedor_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, uDAScriptingProvider, uDABusinessProcessor,
  uDAClasses, uDADataTable, uDABINAdapter,

  uDACDSDataTable, uDAInterfaces, DB,
  frxClass, frxDBSet,  frxDCtrl, frxDMPExport, frxGradient,
  frxChBox, frxCross, frxRich, frxChart, frxOLE, frxBarcode;

type
  { TsrvRecibosProveedor }
  TsrvRecibosProveedor = class(TDARemoteService, IsrvRecibosProveedor)
    DABINAdapter: TDABINAdapter;
    bpRecibosProveedor: TDABusinessProcessor;
    bpPagosProveedor: TDABusinessProcessor;
    bpRecibosCompensados: TDABusinessProcessor;
    schRecibosProveedor: TDASchema;
    DADataDictionary: TDADataDictionary;
    procedure DARemoteServiceBeforeAcquireConnection(Sender: TDARemoteService;
      var ConnectionName: string);
    procedure DARemoteServiceBeforeGetDatasetData(const Dataset: IDADataset;
      const IncludeSchema: Boolean; const MaxRecords: Integer);
    procedure DARemoteServiceCreate(Sender: TObject);
  private
  protected
    { IsrvRecibosProveedor methods }
    function GetNextAutoInc(const GeneratorName: String): Integer;
    function GenerateReport(const ID: Integer): Binary;
  end;

implementation

{$R *.dfm}
uses
  Dialogs,
  {Generated:} FactuGES_Invk, uDataModuleServer, uDatabaseUtils,
  schRecibosProveedorClient_Intf, uRestriccionesUsuarioUtils;
//  uRptRecibosProveedor_Server; //, uBizRecibosProveedorServer;

procedure Create_srvRecibosProveedor(out anInstance : IUnknown);
begin
  anInstance := TsrvRecibosProveedor.Create(NIL);
end;

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

procedure TsrvRecibosProveedor.DARemoteServiceBeforeGetDatasetData(
  const Dataset: IDADataset; const IncludeSchema: Boolean;
  const MaxRecords: Integer);
begin
  if DataSet.Name = nme_RecibosProveedor then
  begin
    { Aquí se asegura que el usuario sólo accede a Recibos
      de las empresas a las que tiene permiso para acceder
      filtrando DataSet por ID_EMPRESA. }
    FiltrarAccesoUsuario(Session, Connection, schRecibosProveedor, DataSet, fld_RecibosProveedorID_EMPRESA);
  end;
end;

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

function TsrvRecibosProveedor.GenerateReport(const ID: Integer): Binary;
//var
//  AReportGenerator : TRptRecibosProveedor;
begin
//  AReportGenerator := TRptRecibosProveedor.Create(nil);
//  try
//    Result := AReportGenerator.GenerarRecibo(ID);
//  finally
//    FreeAndNIL(AReportGenerator);
//  end;
  Result := NIL;
end;

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

initialization
  TROClassFactory.Create('srvRecibosProveedor', Create_srvRecibosProveedor, TsrvRecibosProveedor_Invoker);

finalization

end.
