Advertisement
filhotecmail

HorseServicesIInterfaces.HorseSrvIInterfaces

Sep 15th, 2020
636
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.37 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.   End;
  52.  
  53.   var _EVentos:THorseLogEvent;
  54.  
  55.  
  56. implementation
  57.  
  58. uses
  59.   Lib.System.Classes.Helpers.ClassesAppAndObjetcs.Controller, Lib.System.PrimitiveTypes.Helpers.Controller,
  60.   Lib.System.RTTI.Helper.Controller;
  61.  
  62. { THorseLogEvent }
  63.  
  64. procedure THorseLogEvent.AfterConstruction;
  65. begin
  66.   inherited;
  67.  FStringBuilder := TStringBuilder.Create;
  68. end;
  69.  
  70. procedure THorseLogEvent.BeforeDestruction;
  71. begin
  72.   inherited;
  73.  FreeAndNil( FStringBuilder );
  74. end;
  75.  
  76. function THorseLogEvent.Notificar: THorseLogEvent;
  77. begin
  78.  TTask.Run(
  79.   procedure
  80.   begin
  81.     TThread.Queue(TThread.CurrentThread,
  82.     procedure
  83.     begin
  84.        if Assigned(FOnEventsHorse) then
  85.           FOnEventsHorse(FStringBuilder.ToString);
  86.       FStringBuilder.Clear;
  87.     end);
  88.   end);
  89. end;
  90.  
  91. procedure THorseLogEvent.SetHeader(const Value: string);
  92. begin
  93.   FHeader := Value;
  94.   FStringBuilder.Append(Value).AppendLine;
  95. end;
  96.  
  97. procedure THorseLogEvent.SetMensagem(const Value: string);
  98. begin
  99.   FMensagem := Value;
  100.   FStringBuilder.Append(Value).AppendLine;
  101.   Notificar;
  102. end;
  103.  
  104. procedure THorseLogEvent.SetOnEventsHorse(const Value: TOnEventsHorse);
  105. begin
  106.   FOnEventsHorse := Value;
  107.  
  108. end;
  109.  
  110. procedure THorseLogEvent.SetTempoConectado(const Value: double);
  111. begin
  112.   FTempoConectado := Value;
  113. end;
  114.  
  115.  procedure THorseLogEvent.SetTipo(const Value: string);
  116. begin
  117.   FTipo := Value;
  118.   FStringBuilder.Append(Value).AppendLine;
  119. end;
  120.  
  121. initialization
  122.   _EVentos := THorseLogEvent.Create;
  123.  finalization
  124.    FreeAndNil( _EVentos );
  125. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement