unit main;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs, BMDThread, cxGraphics, cxLookAndFeels,
cxLookAndFeelPainters,
Vcl.Menus, dxSkinsCore, dxSkinBlack, dxSkinBlue,
dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide,
dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray,
dxSkinOffice2013White, dxSkinOffice2016Colorful, dxSkinOffice2016Dark,
dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinValentine,
dxSkinVisualStudio2013Blue, dxSkinVisualStudio2013Dark,
dxSkinVisualStudio2013Light, dxSkinVS2010, dxSkinWhiteprint,
dxSkinXmas2008Blue,
Vcl.StdCtrls, cxButtons,
Vcl.ExtCtrls, cxControls,
cxContainer, cxEdit, cxTextEdit, cxMemo, cxLabel, Uni, MySQLUniProvider,
IdBaseComponent, IdThreadComponent, Data.DB, DBAccess;
type
TForm_Main =
class(TForm)
cxButton1: TcxButton;
Timer_Export_Radius_Accept: TTimer;
Timer_Export_Radius_Deny: TTimer;
cxMemo_Accept: TcxMemo;
cxLabel1: TcxLabel;
cxMemo_Deny: TcxMemo;
cxLabel2: TcxLabel;
idThread_Export_Radius_Accept: TIdThreadComponent;
idThread_Export_Radius_Deny: TIdThreadComponent;
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure Timer_Export_Radius_AcceptTimer(Sender: TObject);
procedure Timer_Export_Radius_DenyTimer(Sender: TObject);
procedure Thread_Export_Radius_DenyTerminate(Sender: TObject;
Thread: TBMDExecuteThread;
var Data: Pointer);
procedure Thread_Export_Radius_AcceptStart(Sender: TObject;
Thread: TBMDExecuteThread;
var Data: Pointer);
procedure Thread_Export_Radius_DenyStart(Sender: TObject;
Thread: TBMDExecuteThread;
var Data: Pointer);
procedure cxButton1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure idThread_Export_Radius_DenyRun(Sender: TIdThreadComponent);
procedure idThread_Export_Radius_AcceptRun(Sender: TIdThreadComponent);
procedure idThread_Export_Radius_AcceptTerminate(
Sender: TIdThreadComponent);
procedure idThread_Export_Radius_DenyTerminate(Sender: TIdThreadComponent);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form_Main: TForm_Main;
MySQL: TMySQLUniProvider;
implementation
{$R *.dfm}
procedure TForm_Main.idThread_Export_Radius_AcceptRun(
Sender: TIdThreadComponent);
var DBConnection: TUniConnection; DBQuery: TUniQuery;
begin
cxMemo_Accept.Lines.Add(FormatDateTime('
dd.mm.yyyy, hh:nn:ss', now) + '
, Thread gestartet');
DBConnection:=TUniConnection.Create(
nil);
DBConnection.Server:='
172.16.6.50';
DBConnection.Port:=3306;
DBConnection.Username:='
root_copy';
DBConnection.Password:='
password';
DBConnection.ProviderName:='
MySQL';
DBConnection.Database:='
xxx';
DBConnection.LoginPrompt:=false;
DBConnection.Pooling:=true;
try
DBConnection.Connect;
except
on E :
Exception do
begin
cxMemo_Accept.Lines.Add('
DBVerbindung Fehler');
cxMemo_Accept.Lines.Add('
Exception message = '+E.
Message);
end;
end;
if DBConnection.Connected
then
begin
try
DBQuery:=TUniQuery.Create(
nil);
DBQuery.Connection:=DBConnection;
DBQuery.SQL.Text:='
SELECT * FROM hotspotstatistik h LIMIT 100;';
DBQuery.Active:=true;
cxMemo_Accept.Lines.Add(inttostr(DBQuery.RecordCount));
DBQuery.Active:=false;
DBQuery.Free;
except
on E :
Exception do
begin
cxMemo_Accept.Lines.Add('
Query Fehler');
cxMemo_Accept.Lines.Add('
Exception message = '+E.
Message);
end;
end;
DBConnection.Close;
end;
DBConnection.Free;
Sender.Stop;
end;
procedure TForm_Main.idThread_Export_Radius_AcceptTerminate(
Sender: TIdThreadComponent);
begin
cxMemo_Accept.Lines.Add(FormatDateTime('
dd.mm.yyyy, hh:nn:ss', now) + '
, Thread beendet');
Timer_Export_Radius_Accept.Enabled:=true;
end;
procedure TForm_Main.Thread_Export_Radius_AcceptStart(Sender: TObject;
Thread: TBMDExecuteThread;
var Data: Pointer);
begin
cxMemo_Accept.Lines.Add('
Thread Start');
end;
procedure TForm_Main.Thread_Export_Radius_DenyStart(Sender: TObject;
Thread: TBMDExecuteThread;
var Data: Pointer);
begin
cxMemo_Deny.Lines.Add('
Thread Start');
end;
procedure TForm_Main.Thread_Export_Radius_DenyTerminate(Sender: TObject;
Thread: TBMDExecuteThread;
var Data: Pointer);
begin
cxMemo_Deny.Lines.Add('
Thread Ende');
Timer_Export_Radius_Deny.Enabled:=true;
end;
procedure TForm_Main.Timer_Export_Radius_AcceptTimer(Sender: TObject);
begin
Timer_Export_Radius_Accept.Enabled:=false;
idThread_Export_Radius_Accept.Start();
end;
procedure TForm_Main.Timer_Export_Radius_DenyTimer(Sender: TObject);
begin
Timer_Export_Radius_Deny.Enabled:=false;
idThread_Export_Radius_Deny.Start();
end;
procedure TForm_Main.cxButton1Click(Sender: TObject);
begin
cxButton1.Enabled:=false;
Timer_Export_Radius_Accept.Enabled:=true;
Timer_Export_Radius_Deny.Enabled:=true;
end;
procedure TForm_Main.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
idThread_Export_Radius_Accept.OnTerminate :=
NIL;
idThread_Export_Radius_Accept.Stop();
idThread_Export_Radius_Deny.OnTerminate :=
NIL;
idThread_Export_Radius_Deny.Stop();
MySQL.Free;
end;
procedure TForm_Main.FormCreate(Sender: TObject);
begin
MySQL:=TMySQLUniProvider.Create(
nil);
end;
procedure TForm_Main.idThread_Export_Radius_DenyRun(Sender: TIdThreadComponent);
var DBConnection: TUniConnection; DBQuery: TUniQuery;
begin
cxMemo_Deny.Lines.Add(FormatDateTime('
dd.mm.yyyy, hh:nn:ss', now) + '
, Thread gestartet');
DBConnection:=TUniConnection.Create(
nil);
DBConnection.Server:='
172.16.6.50';
DBConnection.Port:=3306;
DBConnection.Username:='
root_copy';
DBConnection.Password:='
password';
DBConnection.Database:='
xxx';
DBConnection.ProviderName:='
MySQL';
DBConnection.LoginPrompt:=false;
DBConnection.Pooling:=true;
try
DBConnection.Connect;
except
on E :
Exception do
begin
cxMemo_Deny.Lines.Add('
DBVerbindung Fehler');
cxMemo_Deny.Lines.Add('
Exception message = '+E.
Message);
end;
end;
if DBConnection.Connected
then
begin
try
DBQuery:=TUniQuery.Create(
nil);
DBQuery.Connection:=DBConnection;
DBQuery.SQL.Text:='
SELECT * FROM hotspotstatistik h LIMIT 100;';
DBQuery.Active:=true;
cxMemo_Deny.Lines.Add(inttostr(DBQuery.RecordCount));
DBQuery.Active:=false;
DBQuery.Free;
except
on E :
Exception do
begin
cxMemo_Deny.Lines.Add('
Query Fehler');
cxMemo_Deny.Lines.Add('
Exception message = '+E.
Message);
end;
end;
DBConnection.Close;
end;
DBConnection.Free;
Sender.Stop;
end;
procedure TForm_Main.idThread_Export_Radius_DenyTerminate(
Sender: TIdThreadComponent);
begin
cxMemo_Deny.Lines.Add(FormatDateTime('
dd.mm.yyyy, hh:nn:ss', now) + '
, Thread beendet');
Timer_Export_Radius_Deny.Enabled:=true;
end;
end.