unit srvVentasEnProceso_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:} VARELA_Intf, uDAClasses, uDABusinessProcessor,
  uDAInterfaces, uDADataTable, uDABINAdapter;

type
  { TsrvVentasEnProceso }
  TsrvVentasEnProceso = class(TDARemoteService, IsrvVentasEnProceso)
    DABINAdapter: TDABINAdapter;
    schVentasEnProceso: TDASchema;
  private
  protected
    function GetData(const DatasetName: String; const MaxRecords: Integer; const Columns: String; const Params: TDADatasetParamArray): Binary;
    function GetSchema(const DatasetName: String; const Columns: String): Binary;
  end;

implementation

{$R *.dfm}
uses
  {Generated:} VARELA_Invk, uDataModuleServer, uSchemaUtilsServer;

const
  CAMPOS_SUMA = '#INICIO#FINAL#IMPORTE#';

procedure Create_srvVentasEnProceso(out anInstance : IUnknown);
begin
  anInstance := TsrvVentasEnProceso.Create(NIL);
end;

{ srvVentasEnProceso }
{ TsrvVentasEnProceso }

function TsrvVentasEnProceso.GetData(const DatasetName: String;
  const MaxRecords: Integer; const Columns: String;
  const Params: TDADatasetParamArray): Binary;
var
  ds : IDADataset;
  i : integer;
begin
  result := Binary.Create;
  try
    { Prepares the parameter arrays}

    with TReplicarDataSet.Create do
    begin
      SourceDataSetName := DatasetName;
      Service := Self;
      Columnas := Columns;
      ColumnasQueSuman := CAMPOS_SUMA;
      try
        ds := GetNewDataSet;
      finally
        Free;
      end;
    end;

    for i := 0 to (Params.Count-1) do
      ds.ParamByName(Params[i].Name).Value := Params[i].Value;
    ds.Open;
    ServiceAdapter.WriteDataset(Result, ds, [woRows], MaxRecords);
  except
    FreeAndNIl(result);
    raise;
  end;
end;

function TsrvVentasEnProceso.GetSchema(const DatasetName,
  Columns: String): Binary;
var
  ds : IDADataset;
begin
  result := Binary.Create;
  try
    with TReplicarDataSet.Create do
    begin
      SourceDataSetName := DatasetName;
      Service := Self;
      Columnas := Columns;
      ColumnasQueSuman := CAMPOS_SUMA;
      try
        ds := GetNewDataSet;
      finally
        Free;
      end;
    end;
    ServiceAdapter.WriteDataset(result, ds, [woSchema]);
  except
    FreeAndNIl(result);
    raise;
  end;
end;

initialization
  TROClassFactory.Create('srvVentasEnProceso', Create_srvVentasEnProceso, TsrvVentasEnProceso_Invoker);

finalization

end.
