This commit is contained in:
Алексей Заблоцкий 2023-10-19 10:37:55 +03:00
commit 2df92e04a1
3 changed files with 13 additions and 3 deletions

View File

@ -80,7 +80,7 @@ type
nCommandReceived: integer; nCommandReceived: integer;
nCommandReady: integer; nCommandReady: integer;
nErrors: integer; nErrors: integer;
fCheckConnect: boolean;
procedure CleanDone; procedure CleanDone;
public public
Host: string; Host: string;
@ -109,6 +109,7 @@ type
function RunCommand(ACommand: TCommand): boolean; function RunCommand(ACommand: TCommand): boolean;
function FindCommand(IDCommand: string): TCommand; function FindCommand(IDCommand: string): TCommand;
procedure Idle; procedure Idle;
procedure SetIdle;
procedure Execute; override; procedure Execute; override;
function ProcessOptionValues(ReportName,ParamName: string; ParamValues: TStrings; out Answer: string; out RetValue: QWORD; out OptionValues: TStrings): boolean; function ProcessOptionValues(ReportName,ParamName: string; ParamValues: TStrings; out Answer: string; out RetValue: QWORD; out OptionValues: TStrings): boolean;
class function newID: string; class function newID: string;
@ -232,6 +233,7 @@ procedure TBaseConnection.Idle;
var var
d: TDateTime; d: TDateTime;
begin begin
fCheckConnect:=false;
d := Created; d := Created;
if LastAccess>d then d := LastAccess; if LastAccess>d then d := LastAccess;
if (now()-d)*24*60>fTimeout then if (now()-d)*24*60>fTimeout then
@ -243,6 +245,11 @@ begin
fProcessor.ExecuteSQL('SELECT 1'); fProcessor.ExecuteSQL('SELECT 1');
end; end;
procedure TBaseConnection.SetIdle;
begin
fCheckConnect:=true;
end;
procedure TBaseConnection.CleanDone; procedure TBaseConnection.CleanDone;
var var
i: integer; i: integer;
@ -286,7 +293,8 @@ begin
end; end;
end; end;
CleanDone; CleanDone;
sleep(100); if fCheckConnect then Idle;
sleep(200);
end; end;
log(self,'finished'); log(self,'finished');
end; end;

View File

@ -537,7 +537,7 @@ begin
MainCon.ExecuteSQL('select 1'); MainCon.ExecuteSQL('select 1');
for i := conlist.Count-1 downto 0 do for i := conlist.Count-1 downto 0 do
if not TBaseConnection(conList[i]).Finished then if not TBaseConnection(conList[i]).Finished then
TBaseConnection(conList[i]).Idle; TBaseConnection(conList[i]).SetIdle;
end; end;
initialization initialization

View File

@ -76,7 +76,9 @@
<Unit> <Unit>
<Filename Value="connectionsdmunit.pas"/> <Filename Value="connectionsdmunit.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="ConnectionsDM"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="DataModule"/>
<UnitName Value="ConnectionsDmUnit"/> <UnitName Value="ConnectionsDmUnit"/>
</Unit> </Unit>
<Unit> <Unit>