Advertisement
filhotecmail

HorseServicesIInterfaces.HorseSrvIInterfaces

Sep 15th, 2020
646
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.32 KB | None | 0 0
  1. unit LeopardGerenciador.Core.HorseApi.HorseServices.HorseServicesIInterfaces.HorseSrvIInterfaces;
  2.  
  3. interface
  4. uses
  5.   system.Classes,System.SysUtils,Vcl.Forms,Horse,Horse.Jhonson,System.JSON,System.Threading;
  6.  
  7.   Type TOnEventsHorse = procedure(const Arg: String) of object;
  8.   Type
  9.      THorseLogEvent = class
  10.   private
  11.     FOnEventsHorse: TOnEventsHorse;
  12.     FTempoConectado: double;
  13.     FMensagem: string;
  14.     FHeader: string;
  15.     FTipo: string;
  16.     FStringBuilder: TStringBuilder;
  17.     procedure SetOnEventsHorse(const Value: TOnEventsHorse);
  18.     procedure SetMensagem(const Value: string);
  19.     procedure SetTempoConectado(const Value: double);
  20.     procedure SetHeader(const Value: string);
  21.     procedure SetTipo(const Value: string);
  22.   public
  23.     procedure AfterConstruction; override;
  24.     procedure BeforeDestruction; override;
  25.   published
  26.      property Tipo: string read FTipo write SetTipo;
  27.      property Header: string read FHeader write SetHeader;
  28.      property Mensagem: string read FMensagem write SetMensagem;
  29.      property TempoConectado: double read FTempoConectado write SetTempoConectado;
  30.      property OnEventsHorse: TOnEventsHorse read FOnEventsHorse write SetOnEventsHorse;
  31.      function Notificar:THorseLogEvent;
  32.  
  33.   end;
  34.  
  35.   type
  36.       IhorseSrvControlelotes = Interface
  37.         ['{02E5BC80-6D1F-4015-94A6-D3F43ADC14B0}']
  38.      function InjectHorseHttp(var Horse:THorse ):IhorseSrvControlelotes;
  39.      function GetLotesMovimentados:IhorseSrvControlelotes;
  40.      function GetLotesMonth:IhorseSrvControlelotes;
  41.  
  42.   End;
  43.  
  44.   Type IHorseSrvNfe = Interface
  45.     ['{475AAB43-789A-474E-9285-6E0E9A23C4D5}']
  46.     function ConsultarServicoSefaz:IHorseSrvNfe;
  47.     function PostDadosEmitente(Arg: TJSONObject = nil):IHorseSrvNfe;
  48.     function InjectHorseHttp(var Horse:THorse ):IHorseSrvNfe;
  49.     function IniciarNota:IHorseSrvNFe;
  50.     function HelperDocument:IHorseSrvNFe;
  51.     function InjetarEventos(Arg: TProc<THorseLogEvent>):IHorseSrvNFe;
  52.   End;
  53.  
  54.  
  55. implementation
  56.  
  57. uses
  58.   Lib.System.Classes.Helpers.ClassesAppAndObjetcs.Controller, Lib.System.PrimitiveTypes.Helpers.Controller,
  59.   Lib.System.RTTI.Helper.Controller;
  60.  
  61. { THorseLogEvent }
  62.  
  63. procedure THorseLogEvent.AfterConstruction;
  64. begin
  65.   inherited;
  66.  FStringBuilder := TStringBuilder.Create;
  67. end;
  68.  
  69. procedure THorseLogEvent.BeforeDestruction;
  70. begin
  71.   inherited;
  72.  FreeAndNil( FStringBuilder );
  73. end;
  74.  
  75. function THorseLogEvent.Notificar: THorseLogEvent;
  76. begin
  77.  TTask.Run(
  78.   procedure
  79.   begin
  80.     TThread.Queue(TThread.CurrentThread,
  81.     procedure
  82.     begin
  83.        if Assigned(FOnEventsHorse) then
  84.           FOnEventsHorse(FStringBuilder.ToString);
  85.       FStringBuilder.Clear;
  86.     end);
  87.   end);
  88. end;
  89.  
  90. procedure THorseLogEvent.SetHeader(const Value: string);
  91. begin
  92.   FHeader := Value;
  93.   FStringBuilder.Append(Value).AppendLine;
  94. end;
  95.  
  96. procedure THorseLogEvent.SetMensagem(const Value: string);
  97. begin
  98.   FMensagem := Value;
  99.   FStringBuilder.Append(Value).AppendLine;
  100.   Notificar;
  101. end;
  102.  
  103. procedure THorseLogEvent.SetOnEventsHorse(const Value: TOnEventsHorse);
  104. begin
  105.   FOnEventsHorse := Value;
  106.  
  107. end;
  108.  
  109. procedure THorseLogEvent.SetTempoConectado(const Value: double);
  110. begin
  111.   FTempoConectado := Value;
  112. end;
  113.  
  114.  procedure THorseLogEvent.SetTipo(const Value: string);
  115. begin
  116.   FTipo := Value;
  117.   FStringBuilder.Append(Value).AppendLine;
  118. end;
  119.  
  120.  
  121. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement