-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from dliocode/v2
versão 2
- Loading branch information
Showing
34 changed files
with
3,773 additions
and
563 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
program Model5; | ||
|
||
uses | ||
Vcl.Forms, | ||
Unit2 in 'Unit2.pas' {Form2}, | ||
DataLogger in '..\..\src\Core\DataLogger.pas', | ||
DataLogger.Provider in '..\..\src\Core\DataLogger.Provider.pas', | ||
DataLogger.Types in '..\..\src\Core\DataLogger.Types.pas', | ||
DataLogger.Utils in '..\..\src\Core\DataLogger.Utils.pas', | ||
DataLogger.Provider.Memo in '..\..\src\Providers\DataLogger.Provider.Memo.pas'; | ||
|
||
{$R *.res} | ||
|
||
begin | ||
ReportMemoryLeaksOnShutdown := True; | ||
|
||
Application.Initialize; | ||
Application.MainFormOnTaskbar := True; | ||
Application.CreateForm(TForm2, Form2); | ||
Application.Run; | ||
end. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
object Form2: TForm2 | ||
Left = 0 | ||
Top = 0 | ||
Caption = 'Form2' | ||
ClientHeight = 443 | ||
ClientWidth = 923 | ||
Color = clBtnFace | ||
Font.Charset = DEFAULT_CHARSET | ||
Font.Color = clWindowText | ||
Font.Height = -12 | ||
Font.Name = 'Segoe UI' | ||
Font.Style = [] | ||
FormStyle = fsStayOnTop | ||
OnCreate = FormCreate | ||
TextHeight = 15 | ||
object btn1: TButton | ||
Left = 8 | ||
Top = 8 | ||
Width = 75 | ||
Height = 25 | ||
Caption = 'Iniciar' | ||
TabOrder = 0 | ||
OnClick = btn1Click | ||
end | ||
object Panel1: TPanel | ||
Left = 0 | ||
Top = 41 | ||
Width = 923 | ||
Height = 402 | ||
Align = alBottom | ||
Anchors = [akLeft, akTop, akRight, akBottom] | ||
Caption = 'Panel1' | ||
TabOrder = 1 | ||
ExplicitLeft = 8 | ||
ExplicitTop = 39 | ||
ExplicitWidth = 624 | ||
object Memo1: TMemo | ||
Left = 457 | ||
Top = 1 | ||
Width = 465 | ||
Height = 400 | ||
Align = alClient | ||
TabOrder = 0 | ||
ExplicitLeft = 311 | ||
ExplicitWidth = 304 | ||
end | ||
object Memo2: TMemo | ||
Left = 1 | ||
Top = 1 | ||
Width = 456 | ||
Height = 400 | ||
Align = alLeft | ||
TabOrder = 1 | ||
end | ||
end | ||
object btnParar: TButton | ||
Left = 89 | ||
Top = 8 | ||
Width = 75 | ||
Height = 25 | ||
Caption = 'Parar' | ||
TabOrder = 2 | ||
OnClick = btnPararClick | ||
end | ||
object btnLimpar: TButton | ||
Left = 378 | ||
Top = 15 | ||
Width = 75 | ||
Height = 25 | ||
Caption = 'Limpar' | ||
TabOrder = 3 | ||
OnClick = btnLimparClick | ||
end | ||
object btnLimpar2: TButton | ||
Left = 463 | ||
Top = 15 | ||
Width = 75 | ||
Height = 25 | ||
Caption = 'Limpar' | ||
TabOrder = 4 | ||
OnClick = btnLimpar2Click | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
unit Unit2; | ||
|
||
interface | ||
|
||
uses | ||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, | ||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls; | ||
|
||
type | ||
TForm2 = class(TForm) | ||
btn1: TButton; | ||
Panel1: TPanel; | ||
Memo1: TMemo; | ||
Memo2: TMemo; | ||
btnParar: TButton; | ||
btnLimpar: TButton; | ||
btnLimpar2: TButton; | ||
procedure btn1Click(Sender: TObject); | ||
procedure FormCreate(Sender: TObject); | ||
procedure btnLimparClick(Sender: TObject); | ||
procedure btnLimpar2Click(Sender: TObject); | ||
procedure btnPararClick(Sender: TObject); | ||
private | ||
{ Private declarations } | ||
LStop: Boolean; | ||
public | ||
{ Public declarations } | ||
end; | ||
|
||
var | ||
Form2: TForm2; | ||
|
||
implementation | ||
|
||
uses | ||
DataLogger, | ||
DataLogger.Provider.Memo; | ||
|
||
var | ||
M1: TDataLoggerProvider; | ||
M2: TDataLoggerProvider; | ||
|
||
{$R *.dfm} | ||
|
||
procedure TForm2.btn1Click(Sender: TObject); | ||
begin | ||
LStop := False; | ||
|
||
TThread.CreateAnonymousThread( | ||
procedure | ||
var | ||
I: Integer; | ||
begin | ||
for I := 1 to 100 do | ||
begin | ||
if LStop then | ||
Break; | ||
|
||
Sleep(100); | ||
|
||
if (I = 5) or (I = 70) then | ||
begin | ||
Logger.Warn('StartTransaction'); | ||
Logger.StartTransaction; // 1 | ||
end; | ||
|
||
try | ||
Logger.Info('Teste ' + I.ToString); | ||
finally | ||
if I = 50 then | ||
begin | ||
Logger.CommitTransaction; // 1 | ||
Logger.Warn('CommitTransaction'); | ||
end; | ||
|
||
if I = 90 then | ||
begin | ||
Logger.RollbackTransaction; | ||
Logger.Warn('RollbackTransaction'); | ||
end; | ||
end; | ||
end; | ||
end).Start; | ||
end; | ||
|
||
procedure TForm2.btnLimpar2Click(Sender: TObject); | ||
begin | ||
Memo2.Clear; | ||
end; | ||
|
||
procedure TForm2.btnLimparClick(Sender: TObject); | ||
begin | ||
Memo1.Clear; | ||
end; | ||
|
||
procedure TForm2.btnPararClick(Sender: TObject); | ||
begin | ||
LStop := True; | ||
end; | ||
|
||
procedure TForm2.FormCreate(Sender: TObject); | ||
begin | ||
M1 := TProviderMemo.Create(Memo2).UseTransaction(True); | ||
M2 := TProviderMemo.Create(Memo1); | ||
|
||
Logger.SetProvider([M1, M2]); | ||
Logger.SetLogFormat(TLoggerFormat.LOG_TIMESTAMP + ': ' + TLoggerFormat.LOG_MESSAGE); | ||
end; | ||
|
||
end. |
Oops, something went wrong.