Po hlavnich upravach sdileni sponeni a uvolnovani connection poolu
This commit is contained in:
@ -6,6 +6,9 @@ interface
|
||||
uses
|
||||
System.Generics.Collections,
|
||||
System.SysUtils,
|
||||
FireDAC.Stan.Option,
|
||||
FireDAC.Comp.Client,
|
||||
FireDAC.Stan.Param,
|
||||
JsonDataObjects,
|
||||
uSvc_Base,
|
||||
uCommons,
|
||||
@ -36,7 +39,7 @@ type
|
||||
TKmenZboziService = class(TServiceBase)
|
||||
public
|
||||
function GetAll: TObjectList<TKmenZbozi>; virtual;
|
||||
function GetByID (const AID: Integer; params: TDictionary<string, string>=nil): TKmenZbozi; virtual;
|
||||
function GetByID (const AID: Integer; params: TDictionary<string, string>=nil; AConn: TFDConnection = nil): TKmenZbozi; virtual;
|
||||
function GetByParams (params: TDictionary<string, string>): TObjectList<TKmenZbozi>; virtual;
|
||||
function GetMeta: TJSONObject; virtual;
|
||||
function GetPrepocetMJ (idKmen: integer): TObjectList<TPrepocetMJ>; virtual;
|
||||
@ -49,9 +52,6 @@ implementation
|
||||
uses
|
||||
System.StrUtils,
|
||||
System.Variants,
|
||||
FireDAC.Stan.Option,
|
||||
FireDAC.Comp.Client,
|
||||
FireDAC.Stan.Param,
|
||||
Quick.Logger,
|
||||
MVCFramework.Commons,
|
||||
MVCFramework.FireDAC.Utils,
|
||||
@ -211,6 +211,7 @@ uses
|
||||
sqlConnX:= TFDConnection.Create (nil);
|
||||
sqlConnX.ConnectionDefName:= sqlPoolName;
|
||||
|
||||
|
||||
lSQL:= 'SELECT ' + sqlSelKmen + ' FROM ' + tblKZ + ' ORDER BY ID';
|
||||
|
||||
lQry:= TFDQuery.Create (nil);
|
||||
@ -220,10 +221,9 @@ uses
|
||||
lQry.Open (lSQL);
|
||||
result:= lQry.AsObjectList<TKmenZbozi>;
|
||||
finally
|
||||
lQry.Free;
|
||||
end;
|
||||
|
||||
lQry.Free;
|
||||
sqlConnX.Close;
|
||||
sqlConnX.Free;
|
||||
end;
|
||||
|
||||
@ -231,18 +231,25 @@ uses
|
||||
|
||||
|
||||
|
||||
function TKmenZboziService.GetByID (const AID: Integer; params: TDictionary<string, string>=nil): TKmenZbozi;
|
||||
function TKmenZboziService.GetByID (const AID: Integer; params: TDictionary<string, string>=nil; AConn: TFDConnection = nil): TKmenZbozi;
|
||||
{$IFDEF CUSTOM_CTRL_Rootvin}
|
||||
const rtnASOLTrideni = '_ASOL_IdentifTrideni';
|
||||
{$ENDIF}
|
||||
var lSQL, extInfoStr: string;
|
||||
lQry: TFDQuery;
|
||||
sqlConnX: TFDConnection;
|
||||
lokalniConnection: boolean;
|
||||
begin
|
||||
result:= nil;
|
||||
result := nil;
|
||||
|
||||
sqlConnX:= TFDConnection.Create (nil);
|
||||
sqlConnX.ConnectionDefName:= sqlPoolName;
|
||||
lokalniConnection:= (AConn = nil);
|
||||
if (lokalniConnection) then
|
||||
begin
|
||||
sqlConnX:= TFDConnection.Create (nil);
|
||||
sqlConnX.ConnectionDefName:= sqlPoolName;
|
||||
end
|
||||
else
|
||||
sqlConnX:= AConn;
|
||||
|
||||
extInfoStr:= '';
|
||||
if (SQLTableExists ('dbo', tblKZe)) then
|
||||
@ -288,11 +295,11 @@ uses
|
||||
raise EServiceException.Create ('Chyba nacitani kmenove karty: ' + E.Message);
|
||||
end;
|
||||
finally
|
||||
lQry.Free;
|
||||
end;
|
||||
|
||||
lQry.Free;
|
||||
sqlConnX.Close;
|
||||
sqlConnX.Free;
|
||||
if (lokalniConnection) then
|
||||
sqlConnX.Free;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user