unit schEDILogServer_Intf;

interface

uses
  Classes, DB, SysUtils, uROClasses, uDADataTable, uDABusinessProcessor, schEDILogClient_Intf;

const
  { Delta rules ids 
       Feel free to change them to something more human readable
       but make sure they are unique in the context of your application }
  RID_EDILogDelta = '{6BA63DE2-08BB-4D9F-8C99-EBE412CE6FEC}';

type
  { IEDILogDelta }
  IEDILogDelta = interface(IEDILog)
  ['{6BA63DE2-08BB-4D9F-8C99-EBE412CE6FEC}']
    { Property getters and setters }
    function GetOldIDValue : Integer;
    function GetOldREPORTValue : String;
    function GetOldFECHAValue : DateTime;
    function GetOldOKValue : Boolean;
    function GetOldERROR_MSGValue : String;

    { Properties }
    property OldID : Integer read GetOldIDValue;
    property OldREPORT : String read GetOldREPORTValue;
    property OldFECHA : DateTime read GetOldFECHAValue;
    property OldOK : Boolean read GetOldOKValue;
    property OldERROR_MSG : String read GetOldERROR_MSGValue;
  end;

  { TEDILogBusinessProcessorRules }
  TEDILogBusinessProcessorRules = class(TDABusinessProcessorRules, IEDILog, IEDILogDelta)
  private
  protected
    { Property getters and setters }
    function GetIDValue: Integer; virtual;
    function GetOldIDValue: Integer; virtual;
    procedure SetIDValue(const aValue: Integer); virtual;
    function GetREPORTValue: String; virtual;
    function GetOldREPORTValue: String; virtual;
    procedure SetREPORTValue(const aValue: String); virtual;
    function GetFECHAValue: DateTime; virtual;
    function GetOldFECHAValue: DateTime; virtual;
    procedure SetFECHAValue(const aValue: DateTime); virtual;
    function GetOKValue: Boolean; virtual;
    function GetOldOKValue: Boolean; virtual;
    procedure SetOKValue(const aValue: Boolean); virtual;
    function GetERROR_MSGValue: String; virtual;
    function GetOldERROR_MSGValue: String; virtual;
    procedure SetERROR_MSGValue(const aValue: String); virtual;

    { Properties }
    property ID : Integer read GetIDValue write SetIDValue;
    property OldID : Integer read GetOldIDValue;
    property REPORT : String read GetREPORTValue write SetREPORTValue;
    property OldREPORT : String read GetOldREPORTValue;
    property FECHA : DateTime read GetFECHAValue write SetFECHAValue;
    property OldFECHA : DateTime read GetOldFECHAValue;
    property OK : Boolean read GetOKValue write SetOKValue;
    property OldOK : Boolean read GetOldOKValue;
    property ERROR_MSG : String read GetERROR_MSGValue write SetERROR_MSGValue;
    property OldERROR_MSG : String read GetOldERROR_MSGValue;

  public
    constructor Create(aBusinessProcessor: TDABusinessProcessor); override;
    destructor Destroy; override;

  end;

implementation

uses
  Variants, uROBinaryHelpers;

{ TEDILogBusinessProcessorRules }
constructor TEDILogBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
begin
  inherited;
end;

destructor TEDILogBusinessProcessorRules.Destroy;
begin
  inherited;
end;

function TEDILogBusinessProcessorRules.GetIDValue: Integer;
begin
  result := BusinessProcessor.CurrentChange.NewValueByName[fld_EDILogID];
end;

function TEDILogBusinessProcessorRules.GetOldIDValue: Integer;
begin
  result := BusinessProcessor.CurrentChange.OldValueByName[fld_EDILogID];
end;

procedure TEDILogBusinessProcessorRules.SetIDValue(const aValue: Integer);
begin
  BusinessProcessor.CurrentChange.NewValueByName[fld_EDILogID] := aValue;
end;

function TEDILogBusinessProcessorRules.GetREPORTValue: String;
begin
  result := BusinessProcessor.CurrentChange.NewValueByName[fld_EDILogREPORT];
end;

function TEDILogBusinessProcessorRules.GetOldREPORTValue: String;
begin
  result := BusinessProcessor.CurrentChange.OldValueByName[fld_EDILogREPORT];
end;

procedure TEDILogBusinessProcessorRules.SetREPORTValue(const aValue: String);
begin
  BusinessProcessor.CurrentChange.NewValueByName[fld_EDILogREPORT] := aValue;
end;

function TEDILogBusinessProcessorRules.GetFECHAValue: DateTime;
begin
  result := BusinessProcessor.CurrentChange.NewValueByName[fld_EDILogFECHA];
end;

function TEDILogBusinessProcessorRules.GetOldFECHAValue: DateTime;
begin
  result := BusinessProcessor.CurrentChange.OldValueByName[fld_EDILogFECHA];
end;

procedure TEDILogBusinessProcessorRules.SetFECHAValue(const aValue: DateTime);
begin
  BusinessProcessor.CurrentChange.NewValueByName[fld_EDILogFECHA] := aValue;
end;

function TEDILogBusinessProcessorRules.GetOKValue: Boolean;
begin
  result := BusinessProcessor.CurrentChange.NewValueByName[fld_EDILogOK];
end;

function TEDILogBusinessProcessorRules.GetOldOKValue: Boolean;
begin
  result := BusinessProcessor.CurrentChange.OldValueByName[fld_EDILogOK];
end;

procedure TEDILogBusinessProcessorRules.SetOKValue(const aValue: Boolean);
begin
  BusinessProcessor.CurrentChange.NewValueByName[fld_EDILogOK] := aValue;
end;

function TEDILogBusinessProcessorRules.GetERROR_MSGValue: String;
begin
  result := BusinessProcessor.CurrentChange.NewValueByName[fld_EDILogERROR_MSG];
end;

function TEDILogBusinessProcessorRules.GetOldERROR_MSGValue: String;
begin
  result := BusinessProcessor.CurrentChange.OldValueByName[fld_EDILogERROR_MSG];
end;

procedure TEDILogBusinessProcessorRules.SetERROR_MSGValue(const aValue: String);
begin
  BusinessProcessor.CurrentChange.NewValueByName[fld_EDILogERROR_MSG] := aValue;
end;


initialization
  RegisterBusinessProcessorRules(RID_EDILogDelta, TEDILogBusinessProcessorRules);

end.
