Priprava na init poolingu uz ve WinService + do TBaseController dat jen FConn a na to okazovat dal

This commit is contained in:
2026-04-30 09:23:44 +02:00
parent 1258a27a4e
commit 18081c6bf8
10 changed files with 224 additions and 69 deletions
+37 -2
View File
@@ -10,6 +10,12 @@ uses
MVCFramework.Serializer.Commons,
MVCFramework.Nullables,
MVCFramework.Controllers.Register,
FireDAC.Stan.Intf, FireDAC.Stan.Option,
FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.VCLUI.Wait,
Data.DB, FireDAC.Comp.Client, FireDAC.Comp.UI, FireDAC.Phys.MSSQLDef,
FireDAC.Phys.ODBCBase, FireDAC.Phys.MSSQL, FireDAC.Stan.Param, FireDAC.DatS,
FireDAC.DApt.Intf, FireDAC.DApt, FireDAC.Comp.DataSet, FireDAC.Stan.Consts,
uDataMod,
uCommons,
uSvc_Base,
@@ -35,6 +41,8 @@ const
type
TBaseController = class abstract(TMVCController)
private
FConn: TFDConnection;
strict private
FObecnyService: TObecnyService;
@@ -160,7 +168,11 @@ type
function GetEMPNadobaService: TEMPNadobaService;
function GetEMPVytezeniDoklService: TEMPVytezeniDoklService;
{$ENDIF}
procedure OnBeforeAction (aContext: TWebContext; const aActionName: string; var AHandled: Boolean); override;
procedure OnAfterAction (aContext: TWebContext; const aActionName: string); override;
public
property Conn: TFDConnection read FConn;
constructor Create; override;
destructor Destroy; override;
function sanitizeSQLString (s: string): string;
@@ -209,12 +221,35 @@ implementation
uses
Winapi.ActiveX,
System.SysUtils,
System.DateUtils,
FireDAC.Stan.Consts;
System.DateUtils;
{ TBaseController }
procedure TBaseController.OnBeforeAction (aContext: TWebContext; const aActionName: string; var AHandled: Boolean);
begin
inherited;
AHandled := true;
FConn := TFDConnection.Create (nil);
FConn.ConnectionDefName := sqlPoolName;
FConn.Connected := true;
end;
procedure TBaseController.OnAfterAction (aContext: TWebContext; const aActionName: string);
begin
try
if Assigned(FConn) then
FConn.Close;
finally
FConn.Free;
end;
end;
constructor TBaseController.Create;
begin
inherited;