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

type
  { TsrvComisiones }
  TsrvComisiones = class(TDARemoteService, IsrvComisiones)
    Diagrams: TDADiagrams;
    DABINAdapter: TDABINAdapter;
    bpComisiones: TDABusinessProcessor;
    bpFacturas_Comision: TDABusinessProcessor;
    schComisiones: TDASchema;
    DataDictionary: TDADataDictionary;
    procedure DARemoteServiceBeforeAcquireConnection(Sender: TDARemoteService;
      var ConnectionName: string);
    procedure DARemoteServiceCreate(Sender: TObject);
    { IsrvComisiones methods }
  protected
    function GetNextAutoInc(const GeneratorName: String): Integer;
    function GenerateReport(const AComisionID: Variant; const DesglosadoProv: Boolean; const FechaIni: String; const FechaFin: String; const AAgenteID: Variant): Binary;
  end;

implementation

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

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

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

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

function TsrvComisiones.GenerateReport(const AComisionID: Variant; const DesglosadoProv: Boolean; const FechaIni: String; const FechaFin: String; const AAgenteID: Variant): Binary;
var
  AReportGenerator : TRptComisiones;
begin
  AReportGenerator := TRptComisiones.Create(nil);
  try
    Result := AReportGenerator.GenerarComision(AComisionID, DesglosadoProv, FechaIni, FechaFin, AAgenteID);
  finally
    FreeAndNIL(AReportGenerator);
  end;
end;

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

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

finalization

end.
