unit EDI_Log_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, uDADataTable, uDABINAdapter;

type
  { TEDI_Log }
  TEDI_Log = class(TDARemoteService, IEDI_Log)
    schEDILog: TDASchema;
    DABINAdapter: TDABINAdapter;
  private
  protected
    { IEDI_Log methods }
    procedure InsertarLog(const Fecha: DateTime; const Report: String; const OK: Boolean; const Error_msg: String);
  end;

implementation

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

procedure Create_EDI_Log(out anInstance : IUnknown);
begin
  anInstance := TEDI_Log.Create(NIL);
end;

{ EDI_Log }
procedure TEDI_Log.InsertarLog(const Fecha: DateTime; const Report: String; const OK: Boolean; const Error_msg: String);
var
  cmd : IDASQLCommand;
  conn : IDAConnection;
begin
  conn := dmServer.ConnectionManager.NewConnection(ConnectionName);
  conn.BeginTransaction;

  cmd := schEDILog.NewCommand(conn, 'Insert_EDILog');
  try
    cmd.ParamByName('FECHA').AsDateTime := Fecha;
    cmd.ParamByName('REPORT').AsString := Report;    
    if OK then
      cmd.ParamByName('OK').AsInteger := 1
    else
      cmd.ParamByName('OK').AsInteger := 0;
    cmd.ParamByName('ERROR_MSG').AsString := Error_msg;
    cmd.Execute;
  finally
    conn.CommitTransaction;
    conn := nil;
  end;
end;

initialization
  TROClassFactory.Create('EDI_Log', Create_EDI_Log, TEDI_Log_Invoker);

finalization

end.
