Po hlavnich upravach sdileni sponeni a uvolnovani connection poolu

This commit is contained in:
2026-04-13 12:20:09 +02:00
parent a62b608cfd
commit 1258a27a4e
16 changed files with 2006 additions and 1324 deletions

Binary file not shown.

View File

@ -133,7 +133,7 @@ IF (@genDokladMat=1) OR (@genDokladFin=1)
IF (@@FETCH_STATUS<>0) BREAK IF (@@FETCH_STATUS<>0) BREAK
SET @cnt = (SELECT COUNT(d.ID) FROM dbo.TabDokladyZbozi d JOIN dbo.TabDokladyZbozi_EXT de ON (de.ID=d.ID) WHERE d.IDSklad=@cilovySklad AND d.RadaDokladu=@radaDokl SET @cnt = (SELECT COUNT(d.ID) FROM dbo.TabDokladyZbozi d JOIN dbo.TabDokladyZbozi_EXT de ON (de.ID=d.ID) WHERE d.IDSklad=@cilovySklad AND d.RadaDokladu=@radaDokl
AND CAST(d.DatPorizeni AS DATE)=IIF(@material=0, CAST(@datumDokladuMat AS DATE), CAST(@datumDokladuFin AS DATE)) AND s.BlokovaniEditoru IS NULL AND CAST(d.DatPorizeni AS DATE)=IIF(@material=0, CAST(@datumDokladuMat AS DATE), CAST(@datumDokladuFin AS DATE)) AND d.BlokovaniEditoru IS NULL
AND d.DruhPohybuZbo=@druhPohybuZbo AND d.Realizovano=0 AND de._Vyroba_ObjednavkaMat_Typ=(@material+1) AND d.DruhPohybuZbo=@druhPohybuZbo AND d.Realizovano=0 AND de._Vyroba_ObjednavkaMat_Typ=(@material+1)
) )
IF (@cnt<=1) IF (@cnt<=1)

View File

@ -794,6 +794,7 @@ uses
var lQry: TFDQuery; var lQry: TFDQuery;
sqlConnX: TFDConnection; sqlConnX: TFDConnection;
lSQL, where, errMsg: string; lSQL, where, errMsg: string;
lokIDcka: TList<integer>;
cnt, rNo, idVPr: integer; cnt, rNo, idVPr: integer;
typPrikazu: integer; typPrikazu: integer;
operace, material, spustene: boolean; operace, material, spustene: boolean;
@ -804,311 +805,346 @@ uses
p: TVyrobniPrikaz; p: TVyrobniPrikaz;
vpSvr: TVyrobniPrikazService; vpSvr: TVyrobniPrikazService;
locParams: TDictionary<string, string>; locParams: TDictionary<string, string>;
lokIDcko: TObject;
begin begin
cisOper:= ''; cisOper:= '';
locParams:= TDictionary<string, string>.Create; locParams:= TDictionary<string, string>.Create;
operace:= false;
if (params.ContainsKey('operace')) then
if (params.Items['operace']='1') then
begin
operace:= true;
locParams.Add('operace', params.Items['operace']);
end;
material:= false;
if (params.ContainsKey('material')) then
if (params.Items['material']='1') then
begin
material:= true;
locParams.Add('material', params.Items['material']);
end;
spustene:= false;
if (params.ContainsKey('spustene')) then
if (params.Items['spustene']='1') then
begin
spustene:= true;
locParams.Add('spustene', params.Items['spustene']);
end;
where:= '';
lSQL:= 'SELECT DISTINCT(main.ID) AS ID FROM ' + tblVPr + ' main';
if (spustene) then
where:= where + IfThen(where<>'', ' AND ', '') + 'EXISTS (SELECT 1 FROM ' + tblPrPost + ' pp INNER JOIN ' + tblRozpracOperR
+ ' r ON (r.DokladPrPostup=pp.Doklad AND r.AltPrPostup=pp.Alt AND r.IDPrikaz=pp.IDPrikaz)'
+ ' INNER JOIN ' + tblRozpracOper + ' h ON (h.ID=r.IDEvidRozpracOper)'
+ ' WHERE pp.IDOdchylkyDo IS NULL AND pp.IDPrikaz=main.ID AND h.DatumUzavreni IS NULL)';
typPrikazu:= 0;
if (params.ContainsKey('typ')) then
if not(TryStrToInt(params.Items['typ'], typPrikazu)) then
typPrikazu:= 0;
locParams.Add('rtn', '1');
locParams.Add('typPrikazu', typPrikazu.ToString);
if (typPrikazu=0) then // obecny
where:= where + IfThen(where<>'', ' AND ', '') + 'main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0)';
if (typPrikazu=1) then // pro micharnu se nacitaji vyssi prikazy, tj. kde testo skonci
begin
locParams.Add('nazevOp', 'michani');
where:= where + IfThen(where<>'', ' AND ', '') + 'main.Rada=N''003'' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Blokovano=0 AND SkupZbo=N''701'')';
if (params.ContainsKey('idstroj')) then
begin
if (params.Items['idstroj']<>'') then
where:= where + ' AND (main.IDPrikazVyssi IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.IDOdchylkyDo IS NULL'
+ ' AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje=' + params.Items['idstroj'] + ')'
+ ' OR main.IDPrikazVyssi IN (SELECT ID FROM ' + tblPrikaz
+ ' WHERE IDPrikazVyssi IN (SELECT px.ID FROM ' + tblPrPost + ' ppx'
+ ' INNER JOIN dbo.TabPrikaz px ON (px.ID=ppx.IDPrikaz)'
+ ' WHERE ppx.IDOdchylkyDo IS NULL'
+ ' AND px.StavPrikazu IN (30,40)'
+ ' AND ppx.IDStroje=' + params.Items['idstroj'] + '))'
+ ')';
{
where:= where + IfThen(where<>'', ' AND ', '') + 'main.IDPrikazVyssi IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.IDOdchylkyDo IS NULL'
+ ' AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje=' + params.Items['idstroj'] + ')'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Blokovano=0 AND SkupZbo=N''701'')'
}
end;
{
else
where:= where + IfThen(where<>'', ' AND ', '') + 'main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo=N''701'')';
}
if (params.ContainsKey('idstroju')) then
begin
if (params.Items['idstroju']<>'') then
where:= where + ' AND (main.IDPrikazVyssi IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.IDOdchylkyDo IS NULL'
+ ' AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje IN ' + params.Items['idstroju'] + ')'
+ ' OR main.IDPrikazVyssi IN (SELECT ID FROM ' + tblPrikaz
+ ' WHERE IDPrikazVyssi IN (SELECT px.ID FROM ' + tblPrPost + ' ppx'
+ ' INNER JOIN dbo.TabPrikaz px ON (px.ID=ppx.IDPrikaz)'
+ ' WHERE ppx.IDOdchylkyDo IS NULL'
+ ' AND px.StavPrikazu IN (30,40)'
+ ' AND ppx.IDStroje IN ' + params.Items['idstroju'] + '))'
+ ')';
{
where:= where + IfThen(where<>'', ' AND ', '') + 'main.IDPrikazVyssi IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.IDOdchylkyDo IS NULL'
+ ' AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje IN (' + params.Items['idstroju'] + '))'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo=N''701'')'
}
end;
end;
if (typPrikazu=2) then // pro macirnu
begin
locParams.Add('nazevOp', 'máčení');
where:= where + IfThen(where<>'', ' AND ', '') + 'main.Rada IN (N''004'', N''002'') AND EXISTS (SELECT 1 FROM ' + tblPrPost + ' pp INNER JOIN ' + tblCisStroj + ' cs'
+ ' ON (cs.ID=pp.IDStroje) INNER JOIN ' + tblCisStrojE + ' cse ON (cse.ID=cs.ID) WHERE pp.IDPrikaz=main.ID'
+ ' AND pp.IDOdchylkyDo IS NULL AND pp.priorita=0 AND cse._MaceciStroj=1)';
{
where:= where + IfThen(where<>'', ' AND ', '') + 'main.Rada=N''004'' AND main.IDZakazModif IN (SELECT ID FROM '
+ tblZakazModif + ' WHERE Schvaleno=1 AND Kod LIKE N''COKO%'')';
}
{
if (params.ContainsKey('idpracovist')) then
if (params.Items['idpracovist']<>'') then
begin
where:= where + IfThen(where<>'', ' AND ', '') + 'main.ID IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.IDOdchylkyDo IS NULL'
+ ' AND p.StavPrikazu IN (30,40)'
+ ' AND pp.pracoviste IN (' + params.Items['idpracovist'] + '))'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo<>N''701'')'
end;
}
if (params.ContainsKey('idstroju')) then
begin
if (params.Items['idstroju']<>'') then
where:= where + IfThen(where<>'', ' AND ', '') + 'main.ID IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.Typ=1 AND pp.IDOdchylkyDo IS NULL AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje IN (' + params.Items['idstroju'] + '))'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo<>N''701'')'
end;
if (params.ContainsKey('idstroj')) then
begin
if (params.Items['idstroj']<>'') then
where:= where + IfThen(where<>'', ' AND ', '') + 'main.ID IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.Typ=1 AND pp.IDOdchylkyDo IS NULL AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje IN (' + params.Items['idstroj'] + '))'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo<>N''701'')'
end;
{
else
where:= where + IfThen(where<>'', ' AND ', '') + 'main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo<>N''701'')';
}
end;
if (typPrikazu=3) then // pro baleni (interni)
begin
locParams.Add('nazevOp', 'balení');
where:= where + IfThen(where<>'', ' AND ', '') + 'EXISTS (SELECT 1 FROM dbo.TabPrPostup WHERE IDPrikaz=main.ID AND IdOdchylkyDo IS NULL'
+ ' AND LOWER(Nazev) LIKE N''%balení%'' AND IDStroje NOT IN (SELECT ID FROM ' + tblCisStroj
+ ' WHERE Blokovano=0 AND Kod LIKE N''BAL-%'') AND priorita=0)'; // main.Rada=N''004''
{
if (params.ContainsKey('idstroj')) then
begin
if (params.Items['idstroj']<>'') then
where:= where + IfThen(where<>'', ' AND ', '') + 'main.ID IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.Typ=1 AND pp.IDOdchylkyDo IS NULL AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje IN (' + params.Items['idstroj'] + '))'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Blokovano=0 AND SkupZbo<>N''701'')'
end;
if (params.ContainsKey('idstroju')) then
begin
if (params.Items['idstroju']<>'') then
where:= where + IfThen(where<>'', ' AND ', '') + 'main.ID IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.Typ=1 AND pp.IDOdchylkyDo IS NULL AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje IN (' + params.Items['idstroju'] + '))'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo<>N''701'')';
end;
}
end;
if (typPrikazu=4) then // pro balicku finalu
begin
locParams.Add('nazevOp', 'balení');
where:= where + IfThen(where<>'', ' AND ', '') + 'EXISTS (SELECT 1 FROM dbo.TabPrPostup WHERE IDPrikaz=main.ID AND IdOdchylkyDo IS NULL'
+ ' AND IDStroje IN (SELECT ID FROM ' + tblCisStroj + ' WHERE Blokovano=0 AND Kod LIKE N''BAL-%''))';
end;
if (typPrikazu=5) then // pro EWB
begin
locParams.Add('nazevOp', 'balení');
where:= where + IfThen(where<>'', ' AND ', '') + 'EXISTS (SELECT 1 FROM dbo.TabPrPostup WHERE IDPrikaz=main.ID AND IdOdchylkyDo IS NULL'
+ ' AND IDStroje IN (SELECT ID FROM ' + tblCisStroj + ' WHERE Blokovano=0 AND Kod LIKE N''EWB%''))';
end;
if (params.ContainsKey('odDatum')) then
if (params.Items['odDatum']<>'') then
odDatum:= params.Items['odDatum'];
if (odDatum<>'') then
begin
if (Length(odDatum)=8) then
odDatum:= odDatum + '000000';
if (Length(odDatum)=10) then
odDatum:= odDatum + '00';
odDatum:= MidStr(odDatum, 7, 2) + '.' + MidStr(odDatum, 5, 2) + '.' + LeftStr(odDatum, 4) + ' ' + MidStr(odDatum, 9, 2) + ':' + MidStr(odDatum, 11, 2) + ':' + MidStr(odDatum, 13, 2);
if not(TryStrToDateTime(odDatum, datOd)) then
datOd:= IncDay(Now, -180)
end
else
datOd:= IncDay(Now, -180);
if (params.ContainsKey('doDatum')) then
if (params.Items['doDatum']<>'') then
odDatum:= params.Items['doDatum'];
if (doDatum<>'') then
begin
if (Length(doDatum)=8) then
doDatum:= doDatum + '235959';
if (Length(doDatum)=10) then
doDatum:= doDatum + '59';
doDatum:= MidStr(doDatum, 7, 2) + '.' + MidStr(doDatum, 5, 2) + '.' + LeftStr(doDatum, 4) + ' ' + MidStr(doDatum, 9, 2) + ':' + MidStr(doDatum, 11, 2) + ':' + MidStr(doDatum, 13, 2);
if not(TryStrToDateTime(doDatum, datDo)) then
datDo:= Now
end
else
datDo:= Now;
if (odDatum<>'') then
begin
strTemp:= 'CONVERT(datetime, N' + FormatDateTime('dd.mm.yyyy', datOd).QuotedString + ',104)';
where:= where + IfThen(where<>'', ' AND ', '') + 'main.DatPorizeni>=' + strTemp;
end;
if (doDatum<>'') then
begin
strTemp:= 'CONVERT(datetime, N' + FormatDateTime('dd.mm.yyyy', datDo).QuotedString + ',104)';
where:= where + IfThen(where<>'', ' AND ', '') + 'main.DatPorizeni<=' + strTemp;
end;
// pro micharnu nejsou prikazy pozastavovany
where:= where + IfThen(where<>'', ' AND ', '') + 'main.StavPrikazu IN (30' + IfThen(typPrikazu<>1, ',40', '') + ')';
where:= where + IfThen(where<>'', ' AND ', '') + 'main.Rada<>N''009''';
where:= where + IfThen(where<>'', ' AND ', '') + 'main.Rada LIKE N''0%''';
if (where<>'') then
lSQL:= lSQL + ' WHERE ' + where;
lSQL:= lSQL + ' GROUP BY main.ID ORDER BY main.ID';
vpSvr:= TVyrobniPrikazService.Create (self.FDM);
sqlConnX:= TFDConnection.Create(nil);
sqlConnX.ConnectionDefName:= sqlPoolName;
lQry:= TFDQuery.Create(nil);
try try
lQry.Connection:= sqlConnX;
lQry.FetchOptions.Mode:= fmAll; operace:= false;
lQry.Open(lSQL); if (params.ContainsKey('operace')) then
cnt:= lQry.RecordCount; if (params.Items['operace']='1') then
vpList:= TObjectList<TVyrobniPrikaz>.Create;
try
if not(lQry.Active) then
lQry.Open(lSQL);
lQry.First;
rNo:= 1;
while (rNo<=cnt) do
begin
lQry.RecNo:= rNo;
idVPr:= lQry.FieldByName('ID').AsInteger;
p:= vpSvr.GetByID (idVPr, locParams);
vpList.Add(p);
if not(lQry.Active) then
lQry.Open;
Inc(rNo);
end;
result:= vpList;
except on E:Exception do
begin begin
errMsg:= e.Message; operace:= true;
raise EServiceException.Create('Chyba načítání naskenované položky/položek dokladu: ' + E.Message); locParams.Add('operace', params.Items['operace']);
end; end;
material:= false;
if (params.ContainsKey('material')) then
if (params.Items['material']='1') then
begin
material:= true;
locParams.Add('material', params.Items['material']);
end;
spustene:= false;
if (params.ContainsKey('spustene')) then
if (params.Items['spustene']='1') then
begin
spustene:= true;
locParams.Add('spustene', params.Items['spustene']);
end;
where:= '';
lSQL:= 'SELECT DISTINCT(main.ID) AS ID FROM ' + tblVPr + ' main';
if (spustene) then
where:= where + IfThen(where<>'', ' AND ', '') + 'EXISTS (SELECT 1 FROM ' + tblPrPost + ' pp INNER JOIN ' + tblRozpracOperR
+ ' r ON (r.DokladPrPostup=pp.Doklad AND r.AltPrPostup=pp.Alt AND r.IDPrikaz=pp.IDPrikaz)'
+ ' INNER JOIN ' + tblRozpracOper + ' h ON (h.ID=r.IDEvidRozpracOper)'
+ ' WHERE pp.IDOdchylkyDo IS NULL AND pp.IDPrikaz=main.ID AND h.DatumUzavreni IS NULL)';
typPrikazu:= 0;
if (params.ContainsKey('typ')) then
if not(TryStrToInt(params.Items['typ'], typPrikazu)) then
typPrikazu:= 0;
locParams.Add('rtn', '1');
locParams.Add('typPrikazu', typPrikazu.ToString);
if (typPrikazu=0) then // obecny
where:= where + IfThen(where<>'', ' AND ', '') + 'main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0)';
if (typPrikazu=1) then // pro micharnu se nacitaji vyssi prikazy, tj. kde testo skonci
begin
locParams.Add('nazevOp', 'michani');
where:= where + IfThen(where<>'', ' AND ', '') + 'main.Rada=N''003'' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Blokovano=0 AND SkupZbo=N''701'')';
if (params.ContainsKey('idstroj')) then
begin
if (params.Items['idstroj']<>'') then
where:= where + ' AND (main.IDPrikazVyssi IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.IDOdchylkyDo IS NULL'
+ ' AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje=' + params.Items['idstroj'] + ')'
+ ' OR main.IDPrikazVyssi IN (SELECT ID FROM ' + tblPrikaz
+ ' WHERE IDPrikazVyssi IN (SELECT px.ID FROM ' + tblPrPost + ' ppx'
+ ' INNER JOIN dbo.TabPrikaz px ON (px.ID=ppx.IDPrikaz)'
+ ' WHERE ppx.IDOdchylkyDo IS NULL'
+ ' AND px.StavPrikazu IN (30,40)'
+ ' AND ppx.IDStroje=' + params.Items['idstroj'] + '))'
+ ')';
{
where:= where + IfThen(where<>'', ' AND ', '') + 'main.IDPrikazVyssi IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.IDOdchylkyDo IS NULL'
+ ' AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje=' + params.Items['idstroj'] + ')'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Blokovano=0 AND SkupZbo=N''701'')'
}
end;
{
else
where:= where + IfThen(where<>'', ' AND ', '') + 'main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo=N''701'')';
}
if (params.ContainsKey('idstroju')) then
begin
if (params.Items['idstroju']<>'') then
where:= where + ' AND (main.IDPrikazVyssi IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.IDOdchylkyDo IS NULL'
+ ' AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje IN ' + params.Items['idstroju'] + ')'
+ ' OR main.IDPrikazVyssi IN (SELECT ID FROM ' + tblPrikaz
+ ' WHERE IDPrikazVyssi IN (SELECT px.ID FROM ' + tblPrPost + ' ppx'
+ ' INNER JOIN dbo.TabPrikaz px ON (px.ID=ppx.IDPrikaz)'
+ ' WHERE ppx.IDOdchylkyDo IS NULL'
+ ' AND px.StavPrikazu IN (30,40)'
+ ' AND ppx.IDStroje IN ' + params.Items['idstroju'] + '))'
+ ')';
{
where:= where + IfThen(where<>'', ' AND ', '') + 'main.IDPrikazVyssi IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.IDOdchylkyDo IS NULL'
+ ' AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje IN (' + params.Items['idstroju'] + '))'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo=N''701'')'
}
end;
end;
if (typPrikazu=2) then // pro macirnu
begin
locParams.Add('nazevOp', 'máčení');
where:= where + IfThen(where<>'', ' AND ', '') + 'main.Rada IN (N''004'', N''002'') AND EXISTS (SELECT 1 FROM ' + tblPrPost + ' pp INNER JOIN ' + tblCisStroj + ' cs'
+ ' ON (cs.ID=pp.IDStroje) INNER JOIN ' + tblCisStrojE + ' cse ON (cse.ID=cs.ID) WHERE pp.IDPrikaz=main.ID'
+ ' AND pp.IDOdchylkyDo IS NULL AND pp.priorita=0 AND cse._MaceciStroj=1)';
{
where:= where + IfThen(where<>'', ' AND ', '') + 'main.Rada=N''004'' AND main.IDZakazModif IN (SELECT ID FROM '
+ tblZakazModif + ' WHERE Schvaleno=1 AND Kod LIKE N''COKO%'')';
}
{
if (params.ContainsKey('idpracovist')) then
if (params.Items['idpracovist']<>'') then
begin
where:= where + IfThen(where<>'', ' AND ', '') + 'main.ID IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.IDOdchylkyDo IS NULL'
+ ' AND p.StavPrikazu IN (30,40)'
+ ' AND pp.pracoviste IN (' + params.Items['idpracovist'] + '))'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo<>N''701'')'
end;
}
if (params.ContainsKey('idstroju')) then
begin
if (params.Items['idstroju']<>'') then
where:= where + IfThen(where<>'', ' AND ', '') + 'main.ID IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.Typ=1 AND pp.IDOdchylkyDo IS NULL AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje IN (' + params.Items['idstroju'] + '))'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo<>N''701'')'
end;
if (params.ContainsKey('idstroj')) then
begin
if (params.Items['idstroj']<>'') then
where:= where + IfThen(where<>'', ' AND ', '') + 'main.ID IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.Typ=1 AND pp.IDOdchylkyDo IS NULL AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje IN (' + params.Items['idstroj'] + '))'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo<>N''701'')'
end;
{
else
where:= where + IfThen(where<>'', ' AND ', '') + 'main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo<>N''701'')';
}
end;
if (typPrikazu=3) then // pro baleni (interni)
begin
locParams.Add('nazevOp', 'balení');
where:= where + IfThen(where<>'', ' AND ', '') + 'EXISTS (SELECT 1 FROM dbo.TabPrPostup WHERE IDPrikaz=main.ID AND IdOdchylkyDo IS NULL'
+ ' AND LOWER(Nazev) LIKE N''%balení%'' AND IDStroje NOT IN (SELECT ID FROM ' + tblCisStroj
+ ' WHERE Blokovano=0 AND Kod LIKE N''BAL-%'') AND priorita=0)'; // main.Rada=N''004''
{
if (params.ContainsKey('idstroj')) then
begin
if (params.Items['idstroj']<>'') then
where:= where + IfThen(where<>'', ' AND ', '') + 'main.ID IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.Typ=1 AND pp.IDOdchylkyDo IS NULL AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje IN (' + params.Items['idstroj'] + '))'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Blokovano=0 AND SkupZbo<>N''701'')'
end;
if (params.ContainsKey('idstroju')) then
begin
if (params.Items['idstroju']<>'') then
where:= where + IfThen(where<>'', ' AND ', '') + 'main.ID IN (SELECT p.ID FROM ' + tblPrPost + ' pp INNER JOIN dbo.TabPrikaz p ON (p.ID=pp.IDPrikaz)'
+ ' WHERE pp.Typ=1 AND pp.IDOdchylkyDo IS NULL AND p.StavPrikazu IN (30,40)'
+ ' AND pp.IDStroje IN (' + params.Items['idstroju'] + '))'
+ ' AND main.IDTabKmen IN (SELECT ID FROM ' + tblKZ + ' WHERE Dilec=1 AND Blokovano=0 AND SkupZbo<>N''701'')';
end;
}
end;
if (typPrikazu=4) then // pro balicku finalu
begin
locParams.Add('nazevOp', 'balení');
where:= where + IfThen(where<>'', ' AND ', '') + 'EXISTS (SELECT 1 FROM dbo.TabPrPostup WHERE IDPrikaz=main.ID AND IdOdchylkyDo IS NULL'
+ ' AND IDStroje IN (SELECT ID FROM ' + tblCisStroj + ' WHERE Blokovano=0 AND Kod LIKE N''BAL-%''))';
end;
if (typPrikazu=5) then // pro EWB
begin
locParams.Add('nazevOp', 'balení');
where:= where + IfThen(where<>'', ' AND ', '') + 'EXISTS (SELECT 1 FROM dbo.TabPrPostup WHERE IDPrikaz=main.ID AND IdOdchylkyDo IS NULL'
+ ' AND IDStroje IN (SELECT ID FROM ' + tblCisStroj + ' WHERE Blokovano=0 AND Kod LIKE N''EWB%''))';
end;
if (params.ContainsKey('odDatum')) then
if (params.Items['odDatum']<>'') then
odDatum:= params.Items['odDatum'];
if (odDatum<>'') then
begin
if (Length(odDatum)=8) then
odDatum:= odDatum + '000000';
if (Length(odDatum)=10) then
odDatum:= odDatum + '00';
odDatum:= MidStr(odDatum, 7, 2) + '.' + MidStr(odDatum, 5, 2) + '.' + LeftStr(odDatum, 4) + ' ' + MidStr(odDatum, 9, 2) + ':' + MidStr(odDatum, 11, 2) + ':' + MidStr(odDatum, 13, 2);
if not(TryStrToDateTime(odDatum, datOd)) then
datOd:= IncDay(Now, -180)
end
else
datOd:= IncDay(Now, -180);
if (params.ContainsKey('doDatum')) then
if (params.Items['doDatum']<>'') then
doDatum:= params.Items['doDatum'];
if (doDatum<>'') then
begin
if (Length(doDatum)=8) then
doDatum:= doDatum + '235959';
if (Length(doDatum)=10) then
doDatum:= doDatum + '59';
doDatum:= MidStr(doDatum, 7, 2) + '.' + MidStr(doDatum, 5, 2) + '.' + LeftStr(doDatum, 4) + ' ' + MidStr(doDatum, 9, 2) + ':' + MidStr(doDatum, 11, 2) + ':' + MidStr(doDatum, 13, 2);
if not(TryStrToDateTime(doDatum, datDo)) then
datDo:= Now
end
else
datDo:= Now;
if (odDatum<>'') then
begin
strTemp:= 'CONVERT(datetime, N' + FormatDateTime('dd.mm.yyyy', datOd).QuotedString + ',104)';
where:= where + IfThen(where<>'', ' AND ', '') + 'main.DatPorizeni>=' + strTemp;
end;
if (doDatum<>'') then
begin
strTemp:= 'CONVERT(datetime, N' + FormatDateTime('dd.mm.yyyy', datDo).QuotedString + ',104)';
where:= where + IfThen(where<>'', ' AND ', '') + 'main.DatPorizeni<=' + strTemp;
end;
// pro micharnu nejsou prikazy pozastavovany
where:= where + IfThen(where<>'', ' AND ', '') + 'main.StavPrikazu IN (30' + IfThen(typPrikazu<>1, ',40', '') + ')';
where:= where + IfThen(where<>'', ' AND ', '') + 'main.Rada<>N''009''';
where:= where + IfThen(where<>'', ' AND ', '') + 'main.Rada LIKE N''0%''';
if (where<>'') then
lSQL:= lSQL + ' WHERE ' + where;
lSQL:= lSQL + ' GROUP BY main.ID ORDER BY main.ID';
vpSvr := TVyrobniPrikazService.Create (self.FDM);
try
sqlConnX := TFDConnection.Create (nil);
try
sqlConnX.ConnectionDefName := sqlPoolName;
sqlConnX.Open;
lokIDcka := TList<Integer>.Create;
try
lQry := TFDQuery.Create (nil);
try
lQry.Connection := sqlConnX;
lQry.FetchOptions.Mode := fmAll;
lQry.Open (lSQL);
cnt := lQry.RecordCount;
if not lQry.Active then
lQry.Open (lSQL);
lQry.First;
rNo := 1;
try
while (rNo <= cnt) do
begin
lQry.RecNo := rNo;
idVPr := lQry.FieldByName('ID').AsInteger;
lokIDcka.Add (idVPr);
if not lQry.Active then
lQry.Open (lSQL);
Inc(rNo);
end;
except
on E: Exception do
begin
{$IF CompilerVersion >= 37.0} // Delphi 13+
raise EServiceException.Create ('Chyba načítání naskenované položky/položek dokladu') from E;
{$ELSE}
raise EServiceException.Create ('Chyba načítání naskenované položky/položek dokladu: ' + E.Message) at ExceptAddr;
{$ENDIF}
end;
end;
finally
lQry.Free;
end;
vpList := TObjectList<TVyrobniPrikaz>.Create;
try
for idVPr in lokIDcka do
begin
p := vpSvr.GetByID (idVPr, locParams, sqlConnX);
vpList.Add (p);
end;
result := vpList;
vpList := nil; // zabrani uvolneni v finally
finally
vpList.Free;
end;
finally
lokIDcka.Free;
end;
finally
sqlConnX.Free;
end;
finally
vpSvr.Free;
end; end;
finally finally
begin locParams.Free;
vpSvr.Free;
FreeAndNil(lQry);
end;
end; end;
locParams.Free;
sqlConnX.Close;
sqlConnX.Free;
end; end;

View File

@ -55,7 +55,7 @@
var lSQL, errMsg, url, outData, fName, loopCasTyp: string; var lSQL, errMsg, url, outData, fName, loopCasTyp: string;
lLoop, idDigiFile, cnt, idx: Integer; lLoop, idDigiFile, cnt, idx: Integer;
lLoopMax, koefProCas: integer; lLoopMax, koefProCas: integer;
logRunCnt: integer; logRunCnt, intTemp: integer;
Msg: TMsg; Msg: TMsg;
firstRun, inProg, inDL: boolean; firstRun, inProg, inDL: boolean;
lQry: TFDQuery; lQry: TFDQuery;
@ -95,137 +95,140 @@
attrIdx:= attribs.IndexOf('zapisObjMatExpPrIntMins'); attrIdx:= attribs.IndexOf('zapisObjMatExpPrIntMins');
if (attrIdx>-1) then if (attrIdx>-1) then
if (attribs.Get(attrIdx).NodeValue<>null) then if TryStrToInt(VarToStr(attribs.Get(attrIdx).NodeValue), intTemp) then
lLoopMax:= attribs.Get(attrIdx).NodeValue; lLoopMax:= intTemp;
end; // n1 = config end; // n1 = config
end; // specCfgXML.DocumentElement<>nil end; // specCfgXML.DocumentElement<>nil
end; // not specCfgXML.IsEmptyDoc end; // not specCfgXML.IsEmptyDoc
end; // FileExists(cfgFile) end; // FileExists(cfgFile)
except except
on E: Exception do
datMod.LogInfo (Quick.Logger.etError, 'Chyba cteni konfigu THeoRTNZapisObjMatThread: ' + E.Message);
end; end;
finally finally
begin begin
if (specCfgXML<>nil) then if (specCfgXML<>nil) then
specCfgXML:= nil; specCfgXML := nil;
CoUninitialize; CoUninitialize;
end; end;
end; end;
datMod.LogInfo (Quick.Logger.etInfo, 'Zapis Objednavek materialu do ExpPr - interval: ' + lLoopMax.ToString + ' min.'); datMod.LogInfo (Quick.Logger.etInfo, 'Zapis Objednavek materialu do ExpPr - interval: ' + lLoopMax.ToString + ' min.');
lLoopMax:= lLoopMax * 60; // minuty na vteriny lLoopMax := lLoopMax * 60; // minuty na vteriny
firstRun:= true; firstRun := true;
inProg:= false; inProg := false;
FRunning:= true; FRunning := true;
if (1=1) then // pro rychle vypnuti if (1=1) then // pro rychle vypnuti
begin begin
FTimer:= CreateWaitableTimer (nil, true, 'RTNZapisObjMatExpPrWaitableTimer'); FTimer := CreateWaitableTimer (nil, true, 'RTNZapisObjMatExpPrWaitableTimer');
liDueTime.QuadPart:= -1*_Second; liDueTime.QuadPart := -1*_Second;
sqlConnX:= TFDConnection.Create (nil); while not(Terminated) and FRunning do
sqlConnX.Params.SetStrings (datMod.sqlConnParams); begin
lSQL:= 'DECLARE @errMsg NVARCHAR(500)=N''''' + CRLF +'IF OBJECT_ID(N''dbo.ep_Vyroba_GenObjednavkuMatDoVyrobyNew'', N''P'') IS NOT NULL' + CRLF if (HDCDZApiService<>nil) then
+ ' EXEC dbo.ep_Vyroba_GenObjednavkuMatDoVyrobyNew @errMsg OUT' + CRLF + 'SELECT @errMsg AS ErrMsg'; if (HDCDZApiService.Terminated) then
lQry:= TFDQuery.Create(nil);
try
lQry.Connection:= sqlConnX;
while not(Terminated) or not(FRunning) do
begin
if (HDCDZApiService<>nil) then
if (HDCDZApiService.Terminated) then
begin
Terminate;
FRunning:= false;
end;
PeekMessage (&Msg, 0, 0, 0, PM_NOREMOVE); { Create message queue }
if (lLoop=lLoopMax) or (firstRun) then // pri startu a pak kazdou minutu
begin begin
idDigiFile:= 0; Terminate;
firstRun:= false; FRunning:= false;
end;
if (logRunCnt<4) then PeekMessage (&Msg, 0, 0, 0, PM_NOREMOVE); { Create message queue }
datMod.LogInfo (Quick.Logger.etInfo, 'Spoustim zapis Objednavky materialu do ExpPr c.' + logRunCnt.toString + '...');
if (logRunCnt=4) then
datMod.LogInfo (Quick.Logger.etInfo, 'Spoustim zapis Objednavky - bezi, ale dal neloguju');
try if (lLoop=lLoopMax) or (firstRun) then // pri startu a pak kazdou minutu
if not(inProg) then // nebezi uz ? begin
begin
if (1=1) then // pro rychle vypnuti sqlConnX := TFDConnection.Create (nil);
try
sqlConnX.Params.SetStrings (datMod.sqlConnParams);
lQry := TFDQuery.Create(nil);
try
lQry.Connection := sqlConnX;
idDigiFile:= 0;
firstRun:= false;
if (logRunCnt<4) then
datMod.LogInfo (Quick.Logger.etInfo, 'Spoustim zapis Objednavky materialu do ExpPr c.' + logRunCnt.toString + '...');
if (logRunCnt=4) then
datMod.LogInfo (Quick.Logger.etInfo, 'Spoustim zapis Objednavky - bezi, ale dal neloguju');
try
if not(inProg) then // nebezi uz ?
begin
if (1=1) then // pro rychle vypnuti
begin
sqlConnX.Open;
if (sqlConnX.Connected) then
begin
inProg:= true;
lSQL:= 'DECLARE @errMsg NVARCHAR(500)=N''''' + CRLF +'IF OBJECT_ID(N''dbo.ep_Vyroba_GenObjednavkuMatDoVyrobyNew'', N''P'') IS NOT NULL' + CRLF
+ ' EXEC dbo.ep_Vyroba_GenObjednavkuMatDoVyrobyNew @errMsg OUT' + CRLF + 'SELECT @errMsg AS ErrMsg';
lQry.Open(lSQL);
if (lQry.RecordCount>0) then
begin
lQry.First;
errMsg:= lQry.FieldByName('ErrMsg').AsString;
if (errMsg<>'') then
begin
datMod.LogInfo (Quick.Logger.etInfo, 'Zapis Objednavky materialu do ExpPr - chyba: ' + errMsg);
{$IFDEF DEBUG}
WriteLn('Zapis Objednavky materialu do ExpPr - chyba: ' + errMsg);
{$ENDIF}
end;
end;
inProg:= false;
end; // sql Connected
end; // 1=1
end;
except on E:Exception do
begin begin
sqlConnX.Open; inProg:= false;
if (sqlConnX.Connected) then errMsg:= E.Message; // datMod.sqlQry11.FieldByName('ErrMsg').AsString;
if (mamTabPrijataData) then
begin begin
inProg:= true; datMod.LogInfo (Quick.Logger.etError, 'Zapis Objednavky materialu do ExpPr - chyba: ' + errMsg);
lQry.Open(lSQL); {$IFDEF DEBUG}
if (lQry.RecordCount>0) then WriteLn('Zapis Objednavky materialu do ExpPr - chyba: ' + errMsg);
begin {$ENDIF}
lQry.First; end;
errMsg:= lQry.FieldByName('ErrMsg').AsString;
if (errMsg<>'') then
begin
datMod.LogInfo (Quick.Logger.etInfo, 'Zapis Objednavky materialu do ExpPr - chyba: ' + errMsg);
{$IFDEF DEBUG}
WriteLn('Zapis Objednavky materialu do ExpPr - chyba: ' + errMsg);
{$ENDIF}
end;
end;
lQry.Close;
inProg:= false;
end; // sql Connected
end; end;
end; end;
finally
lQry.Free;
end;
except on E:Exception do finally
begin sqlConnX.Free;
inProg:= false;
errMsg:= E.Message; // datMod.sqlQry11.FieldByName('ErrMsg').AsString;
if (mamTabPrijataData) then
begin
datMod.LogInfo (Quick.Logger.etError, 'Zapis Objednavky materialu do ExpPr - chyba: ' + errMsg);
{$IFDEF DEBUG}
WriteLn('Zapis Objednavky materialu do ExpPr - chyba: ' + errMsg);
{$ENDIF}
end;
end;
end;
lLoop:= 0;
if (logRunCnt<5) then
Inc (logRunCnt);
end; end;
Inc (lLoop);
if (FTimer<>0) then lLoop:= 0;
SetWaitableTimer (FTimer, TLargeInteger(liDueTime), 0, nil, nil, false); if (logRunCnt<5) then
repeat Inc (logRunCnt);
lBusy:= MsgWaitForMultipleObjects (1, FTimer, false, INFINITE, QS_ALLINPUT); end; // if lLoop=lLoopMax...
until lBusy = WAIT_OBJECT_0;
Inc (lLoop);
if (FTimer<>0) then
SetWaitableTimer (FTimer, TLargeInteger(liDueTime), 0, nil, nil, false);
repeat
lBusy:= MsgWaitForMultipleObjects (1, FTimer, false, INFINITE, QS_ALLINPUT);
until lBusy = WAIT_OBJECT_0;
// Sleep (998); // Sleep (998);
end; end; // while not(Terminated) and FRunning
finally
end;
if (lQry<>nil) then if (FTimer<>0) then
begin CloseHandle (FTimer);
lQry.Close;
FreeAndNil (lQry);
end;
if (sqlConnX<>nil) then
begin
sqlConnX.Close;
FreeAndNil (sqlConnX);
end;
end; // 1=1 end; // 1=1

Binary file not shown.

View File

@ -13,9 +13,7 @@ uses
Winapi.Windows, Winapi.Windows,
System.Classes, System.Classes,
{$IFDEF DEBUG}
Web.WebReq, Web.WebReq,
{$ENDIF}
MVCFramework.Middleware.Swagger, MVCFramework.Middleware.Swagger,
MVCFramework.Swagger.Commons, MVCFramework.Swagger.Commons,

View File

@ -5,7 +5,7 @@
<FrameworkType>VCL</FrameworkType> <FrameworkType>VCL</FrameworkType>
<MainSource>hdcDZApi.dpr</MainSource> <MainSource>hdcDZApi.dpr</MainSource>
<Base>True</Base> <Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config> <Config Condition="'$(Config)'==''">Release</Config>
<Platform Condition="'$(Platform)'==''">Win64</Platform> <Platform Condition="'$(Platform)'==''">Win64</Platform>
<TargetedPlatforms>2</TargetedPlatforms> <TargetedPlatforms>2</TargetedPlatforms>
<AppType>Application</AppType> <AppType>Application</AppType>
@ -131,9 +131,9 @@
<DCC_ImageBase>700000</DCC_ImageBase> <DCC_ImageBase>700000</DCC_ImageBase>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo> <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_MajorVer>3</VerInfo_MajorVer> <VerInfo_MajorVer>3</VerInfo_MajorVer>
<VerInfo_Release>2025</VerInfo_Release> <VerInfo_Release>2026</VerInfo_Release>
<VerInfo_Build>1205</VerInfo_Build> <VerInfo_Build>412</VerInfo_Build>
<VerInfo_Keys>CompanyName=HD Consulting s.r.o. Strakonice;FileDescription=HDC x Pro Holding DataZone komunikator (API);FileVersion=3.0.2025.1205;InternalName=;LegalCopyright=(c) 2022-25 HD Consulting s.r.o. / Tomas Buzin;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=XE12.3.1;LastCompiledTime=2025.12.05 12:42:18</VerInfo_Keys> <VerInfo_Keys>CompanyName=HD Consulting s.r.o. Strakonice;FileDescription=HDC x Pro Holding DataZone komunikator (API);FileVersion=3.0.2026.412;InternalName=;LegalCopyright=(c) 2022-25 HD Consulting s.r.o. / Tomas Buzin;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=XE12.3.1;LastCompiledTime=2026.04.12 16:03:18</VerInfo_Keys>
<Icon_MainIcon>api2-5.ico</Icon_MainIcon> <Icon_MainIcon>api2-5.ico</Icon_MainIcon>
<DCC_MapFile>3</DCC_MapFile> <DCC_MapFile>3</DCC_MapFile>
<DCC_DebugInformation>2</DCC_DebugInformation> <DCC_DebugInformation>2</DCC_DebugInformation>
@ -251,7 +251,7 @@
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\SVGIconImageList290.bpl">Ethea SVGIconImageList VCL components</Excluded_Packages> <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\SVGIconImageList290.bpl">Ethea SVGIconImageList VCL components</Excluded_Packages>
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\EssentialsDR290.bpl">TurboPack Essentials Delphi Runtime package</Excluded_Packages> <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\EssentialsDR290.bpl">TurboPack Essentials Delphi Runtime package</Excluded_Packages>
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\PngComponentsD290.bpl">Png Components for Delphi</Excluded_Packages> <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\PngComponentsD290.bpl">Png Components for Delphi</Excluded_Packages>
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\dmvcframeworkRT120.bpl">DMVCFramework - CopyRight (2010-2024) Daniele Teti and the DMVCFramework Team</Excluded_Packages> <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\dmvcframeworkRT120.bpl">DMVCFramework - CopyRight (2010-2025) Daniele Teti and the DMVCFramework Team</Excluded_Packages>
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\JvAppFrmDesign290.bpl">JVCL Application and Form Components</Excluded_Packages> <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\JvAppFrmDesign290.bpl">JVCL Application and Form Components</Excluded_Packages>
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\JvBandsDesign290.bpl">JVCL Band Objects</Excluded_Packages> <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\JvBandsDesign290.bpl">JVCL Band Objects</Excluded_Packages>
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\JvCmpDesign290.bpl">JVCL Non-Visual Components</Excluded_Packages> <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\JvCmpDesign290.bpl">JVCL Non-Visual Components</Excluded_Packages>
@ -282,6 +282,7 @@
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\dclunidac290.bpl">Devart Universal Data Access Components</Excluded_Packages> <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\dclunidac290.bpl">Devart Universal Data Access Components</Excluded_Packages>
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\dclSVGIconImageListFMX290.bpl">Ethea SVGIconImageList FMX components</Excluded_Packages> <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\dclSVGIconImageListFMX290.bpl">Ethea SVGIconImageList FMX components</Excluded_Packages>
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\dcldxIconLibraryRS29.bpl">Express Cross Platform Library Icon Library by Developer Express Inc.</Excluded_Packages> <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\dcldxIconLibraryRS29.bpl">Express Cross Platform Library Icon Library by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\ColorButton.bpl">(untitled)</Excluded_Packages>
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\VirtualTreesDD290.bpl">File C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\VirtualTreesDD290.bpl not found</Excluded_Packages> <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\VirtualTreesDD290.bpl">File C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\VirtualTreesDD290.bpl not found</Excluded_Packages>
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\Vyvoj12_0.bpl">Helios Orange Components</Excluded_Packages> <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\Vyvoj12_0.bpl">Helios Orange Components</Excluded_Packages>
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\LockBox3DR290.bpl">TurboPack LockBox 3 Delphi runtime package</Excluded_Packages> <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\LockBox3DR290.bpl">TurboPack LockBox 3 Delphi runtime package</Excluded_Packages>

Binary file not shown.

View File

@ -246,7 +246,7 @@ uses
try try
Render(ObjectDict().Add('data', GetStavSkladuService.GetByParams(params))); // viz uSvc_ObehZbozi.pas Render(ObjectDict().Add('data', GetStavSkladuService.GetByParams(params, FDM.sqlConn))); // viz uSvc_ObehZbozi.pas
except except
{$IFDEF NORENDER400} {$IFDEF NORENDER400}
RenderStatusMessage (200); RenderStatusMessage (200);
@ -343,7 +343,7 @@ uses
try try
Render(ObjectDict().Add('data', GetDokladOZService.GetByParams (params))); // viz uSvc_ObehZbozi.pas Render(ObjectDict().Add('data', GetDokladOZService.GetByParams (params, FDM.sqlConn))); // viz uSvc_ObehZbozi.pas
except except
{$IFDEF NORENDER400} {$IFDEF NORENDER400}
RenderStatusMessage (200); RenderStatusMessage (200);
@ -410,7 +410,7 @@ uses
begin begin
params.Add('id', iId.ToString); params.Add('id', iId.ToString);
try try
Render(ObjectDict().Add('data', GetDokladOZService.GetByParams (params))); // viz uSvc_ObehZbozi.pas Render(ObjectDict().Add('data', GetDokladOZService.GetByParams (params, FDM.sqlConn))); // viz uSvc_ObehZbozi.pas
except except
{$IFDEF NORENDER400} {$IFDEF NORENDER400}
RenderStatusMessage (200); RenderStatusMessage (200);
@ -550,7 +550,7 @@ uses
params.Add('iddoklad', iIdDoklad.ToString); params.Add('iddoklad', iIdDoklad.ToString);
try try
Render(ObjectDict().Add('data', GetPolozkaOZService.GetByParams(params))); // viz uSvc_ObehZbozi.pas Render(ObjectDict().Add('data', GetPolozkaOZService.GetByParams(params, FDM.sqlConn))); // viz uSvc_ObehZbozi.pas
except except
{$IFDEF NORENDER400} {$IFDEF NORENDER400}
RenderStatusMessage (200); RenderStatusMessage (200);

View File

@ -854,7 +854,7 @@ uses
try try
Render(ObjectDict().Add('data', GetVyrobaEvidRozpracOperaciService.GetByParams (params))); Render(ObjectDict().Add('data', GetVyrobaEvidRozpracOperaciService.GetByParams (params, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -886,7 +886,7 @@ uses
params.Add('id', iId.ToString); params.Add('id', iId.ToString);
try try
Render(ObjectDict().Add('data', GetVyrobaEvidRozpracOperaciService.GetByParams (params))); Render(ObjectDict().Add('data', GetVyrobaEvidRozpracOperaciService.GetByParams (params, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -974,7 +974,7 @@ uses
if (iId>0) then if (iId>0) then
begin begin
try try
Render(ObjectDict().Add('data', GetVyrobaEvidenceOperaciService.GetByID (iId))); Render(ObjectDict().Add('data', GetVyrobaEvidenceOperaciService.GetByID (iId, nil, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -1040,7 +1040,7 @@ uses
params.Add('id', iId.ToString); params.Add('id', iId.ToString);
try try
Render(ObjectDict().Add('data', GetTPVCisKoopService.GetByParams (params))); Render(ObjectDict().Add('data', GetTPVCisKoopService.GetByParams (params, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -1122,7 +1122,7 @@ uses
params.Add('spustene', '1'); params.Add('spustene', '1');
try try
Render(ObjectDict().Add('data', GetVyrobniPrikazService.GetByParams (params) )); Render(ObjectDict().Add('data', GetVyrobniPrikazService.GetByParams (params, FDM.sqlConn) ));
except on E:Exception do except on E:Exception do
begin begin
RenderStatusMessage (200); RenderStatusMessage (200);
@ -1161,7 +1161,7 @@ uses
params.Add('jenId', '1'); params.Add('jenId', '1');
try try
Render(ObjectDict().Add('data', GetVyrobniPrikazService.GetByParams (params))); Render(ObjectDict().Add('data', GetVyrobniPrikazService.GetByParams (params, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
end; end;
@ -1204,7 +1204,7 @@ uses
try try
Render(ObjectDict().Add('data', GetVyrobniPrikazService.GetByID (iId, params))); Render(ObjectDict().Add('data', GetVyrobniPrikazService.GetByID (iId, params, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -1330,7 +1330,7 @@ uses
try try
Render(ObjectDict().Add('data', GetDokladOZService.GetByParams (params))); Render(ObjectDict().Add('data', GetDokladOZService.GetByParams (params, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -1420,7 +1420,7 @@ uses
mnReq:= 0; mnReq:= 0;
try try
Render(ObjectDict().Add('data', GetVyrobniPrikazService.GetKusovnik (idVPr, mnReq, jenPlatne, 0))); Render(ObjectDict().Add('data', GetVyrobniPrikazService.GetKusovnik (idVPr, mnReq, jenPlatne, 0, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -1477,7 +1477,7 @@ uses
params.Add('stavPrikazu', iStav.ToString); params.Add('stavPrikazu', iStav.ToString);
try try
Render(ObjectDict().Add('data', GetMaterialPrikazuService.GetByParams (params))); Render(ObjectDict().Add('data', GetMaterialPrikazuService.GetByParams (params, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -1570,7 +1570,7 @@ uses
try try
Render(ObjectDict().Add('data', GetMaterialPrikazuService.GetByParams (params))); Render(ObjectDict().Add('data', GetMaterialPrikazuService.GetByParams (params, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -1680,7 +1680,7 @@ uses
try try
Render(ObjectDict().Add('data', GetVyrobniOperaceService.GetByParams (p))); // viz uSvc_Vyroba.pas Render(ObjectDict().Add('data', GetVyrobniOperaceService.GetByParams (p, FDM.sqlConn))); // viz uSvc_Vyroba.pas
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -1721,7 +1721,7 @@ uses
params.Add ('kontrolnipostupy', '1'); params.Add ('kontrolnipostupy', '1');
try try
Render(ObjectDict().Add('data', GetVyrobniOperaceService.GetByID (iid, params))); Render(ObjectDict().Add('data', GetVyrobniOperaceService.GetByID (iid, params, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -1840,7 +1840,7 @@ uses
try try
Render(ObjectDict().Add('data', GetKooperacniObjednavkaService.GetByParams(params))); Render(ObjectDict().Add('data', GetKooperacniObjednavkaService.GetByParams(params, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -1876,7 +1876,7 @@ uses
bPol:= (p=1); bPol:= (p=1);
try try
Render(ObjectDict().Add('data', GetKooperacniObjednavkaService.GetByID(iId, bPol))); Render(ObjectDict().Add('data', GetKooperacniObjednavkaService.GetByID(iId, bPol, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -2100,7 +2100,7 @@ uses
params.Add('dilec', idDilce.ToString); params.Add('dilec', idDilce.ToString);
try try
Render(ObjectDict().Add('data', GetTPVOperaceDilceService.GetByParams (params))); Render(ObjectDict().Add('data', GetTPVOperaceDilceService.GetByParams (params, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
end; end;
@ -2176,7 +2176,7 @@ uses
params.Add('id', iId.ToString); params.Add('id', iId.ToString);
try try
Render(ObjectDict().Add('data', GetMaterialPrikazuService.GetByParams (params))); Render(ObjectDict().Add('data', GetMaterialPrikazuService.GetByParams (params, FDM.sqlConn)));
except except
RenderStatusMessage (200); RenderStatusMessage (200);
{ {
@ -2382,7 +2382,7 @@ uses
params.Add ('id', iId.ToString); params.Add ('id', iId.ToString);
try try
Render(ObjectDict().Add('data', GetTPVPrednastaveniOperaciService.GetByID (iId, params))); Render(ObjectDict().Add('data', GetTPVPrednastaveniOperaciService.GetByID (iId, params, FDM.sqlConn)));
except except
// RenderStatusMessage (200); // RenderStatusMessage (200);
{ {
@ -2424,7 +2424,7 @@ uses
{$ENDIF} {$ENDIF}
try try
Render(ObjectDict().Add('data', GetTPVPrednastaveniOperaciService.GetByParams (params))); Render(ObjectDict().Add('data', GetTPVPrednastaveniOperaciService.GetByParams (params, FDM.sqlConn)));
except except
// RenderStatusMessage (200); // RenderStatusMessage (200);
{ {

View File

@ -9,7 +9,7 @@ uses
Data.DB, FireDAC.Comp.Client, FireDAC.Comp.UI, FireDAC.Phys.MSSQLDef, Data.DB, FireDAC.Comp.Client, FireDAC.Comp.UI, FireDAC.Phys.MSSQLDef,
FireDAC.Phys.ODBCBase, FireDAC.Phys.MSSQL, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.Phys.ODBCBase, FireDAC.Phys.MSSQL, FireDAC.Stan.Param, FireDAC.DatS,
FireDAC.DApt.Intf, FireDAC.DApt, FireDAC.Comp.DataSet, FireDAC.Stan.Consts, FireDAC.DApt.Intf, FireDAC.DApt, FireDAC.Comp.DataSet, FireDAC.Stan.Consts,
Winapi.ActiveX, Winapi.ActiveX, System.RegularExpressions,
MVCFramework.Logger, MVCFramework.Logger,
Quick.Logger, Quick.Threads, Quick.Logger.Provider.Files; Quick.Logger, Quick.Threads, Quick.Logger.Provider.Files;
@ -44,6 +44,7 @@ type
function SQLRecordExists (sqlText: string): Boolean; function SQLRecordExists (sqlText: string): Boolean;
function SQLColumnExists (const tabName: string; const colName: string): Boolean; function SQLColumnExists (const tabName: string; const colName: string): Boolean;
function SQLIDsToString (const tabName: string=''; where: string=''): string; function SQLIDsToString (const tabName: string=''; where: string=''): string;
function SQLIsSafe (const S: string): boolean;
function SQLGetString (sqlCmd: string=''; sqlConnLoc: TFDConnection=nil): string; function SQLGetString (sqlCmd: string=''; sqlConnLoc: TFDConnection=nil): string;
function StreamToString (const M: TStream): string; function StreamToString (const M: TStream): string;
@ -57,6 +58,8 @@ type
var var
datMod: TdatMod; datMod: TdatMod;
ConnDef: IFDStanConnectionDef; ConnDef: IFDStanConnectionDef;
ConnInit: Boolean = false;
ConnInitLock: TObject;
implementation implementation
@ -91,7 +94,7 @@ uses System.StrUtils, Data.Win.ADODB,
procedure TdatMod.DataModuleDestroy(Sender: TObject); procedure TdatMod.DataModuleDestroy (Sender: TObject);
begin begin
if (sqlConnParams<>nil) then if (sqlConnParams<>nil) then
sqlConnParams.Free; sqlConnParams.Free;
@ -156,90 +159,13 @@ uses System.StrUtils, Data.Win.ADODB,
dbConnOleDB:= false; dbConnOleDB:= false;
{
drvList:= TStringList.Create;
try
GetProviderNames(drvList);
{$IFDEF DEBUG}
{
if (drvList.Count>0) then
begin
Writeln(CRLF+'Registrovane drivery:');
for idx:=0 to drvList.Count-1 do
Writeln(drvList.Strings[idx]);
end;
Writeln('');
{$ENDIF}
{
if (drvList.IndexOf('MSOLEDBSQL') >= 0) then
mamOleDb:= true;
if (drvList.IndexOf('MSOLEDBSQL19') >= 0) then
dbEncConn:= true;
if not(mamOleDb) or (odbc) then
begin
mamOleDb:= false;
idx:= -1;
if (drvList.Find('ODBC Driver 17', idx)) then
drvName2:= drvList.Strings[idx];
if (drvList.Find('ODBC Driver 18', idx)) then
begin
drvName2:= drvList.Strings[idx];
dbEncConn:= true;
end;
if (drvList.Find('ODBC Driver 19', idx)) then
begin
drvName2:= drvList.Strings[idx];
dbEncConn:= true;
end;
end;
sqlMSSQLDrv.ODBCDriver:= drvName2;
if (drvName.Contains('ODBC')) then
drvName:= 'ODBC';
// sqlMSSQLDrv.DriverID:= drvName;
dbConnOleDB:= mamOleDb;
{$IFDEF DEBUG}
{ Writeln('Vybrany driver: ' + sqlMSSQLDrv.ODBCDriver);
{$ENDIF}
{
finally
drvList.Free;
end;
}
if not(sqlConn.Connected) and (dbServer<>'') and (dbName<>'') then if not(sqlConn.Connected) and (dbServer<>'') and (dbName<>'') then
begin begin
try try
sqlConnParams:= TStringList.Create;
sqlConnParams.Clear;
oPars:= TStringList.Create; oPars:= TStringList.Create;
try try
// sqlConn.Params.Clear; // oPars.Add(S_FD_ConnParam_Common_DriverID + '=MSSQL'); // je definovan v AddConnectionDef
// sqlConn.DriverName:= drvName;
// sqlConn.Params.Add(S_FD_ConnParam_Common_DriverID + '=' + drvName);
sqlConnParams.Add(S_FD_ConnParam_Common_DriverID + '=MSSQL');
sqlConnParams.Add(S_FD_ConnParam_Common_Server + '=' + dbServer);
sqlConnParams.Add(S_FD_ConnParam_Common_Port + '=' + dbPort.ToString);
sqlConnParams.Add(S_FD_ConnParam_Common_Database + '=' + dbName);
sqlConnParams.Add(S_FD_ConnParam_Common_UserName + '=' + dbUser);
sqlConnParams.Add(S_FD_ConnParam_Common_Password + '=' + dbPwd);
sqlConnParams.Add(S_FD_ConnParam_Common_OSAuthent + '=No');
sqlConnParams.Add(S_FD_ConnParam_Common_MetaDefSchema + '=dbo');
sqlConnParams.Add(S_FD_ConnParam_Common_LoginTimeout + '=15');
sqlConnParams.Add(S_FD_ConnParam_MSSQL_MARS + '=Yes');
// sqlConnParams.Add(S_FD_ConnParam_Common_Pooled + '=True');
// sqlConnParams.Add(S_FD_ConnParam_Common_Pool_MaximumItems + '=100');
sqlConnParams.Add(S_FD_ConnParam_Common_ExtendedMetadata + '=True');
sqlConnParams.Add(S_FD_ConnParam_Common_ApplicationName + '=hdcdzAPIsvc2');
sqlConnParams.Add(S_FD_ConnParam_ODBC_ODBCAdvanced + '=TrustServerCertificate=yes');
oPars.Add(S_FD_ConnParam_Common_DriverID + '=MSSQL');
oPars.Add(S_FD_ConnParam_Common_Server + '=' + dbServer); oPars.Add(S_FD_ConnParam_Common_Server + '=' + dbServer);
oPars.Add(S_FD_ConnParam_Common_Port + '=' + dbPort.ToString); oPars.Add(S_FD_ConnParam_Common_Port + '=' + dbPort.ToString);
oPars.Add(S_FD_ConnParam_Common_Database + '=' + dbName); oPars.Add(S_FD_ConnParam_Common_Database + '=' + dbName);
@ -249,42 +175,58 @@ uses System.StrUtils, Data.Win.ADODB,
oPars.Add(S_FD_ConnParam_Common_MetaDefSchema + '=dbo'); oPars.Add(S_FD_ConnParam_Common_MetaDefSchema + '=dbo');
oPars.Add(S_FD_ConnParam_Common_LoginTimeout + '=15'); oPars.Add(S_FD_ConnParam_Common_LoginTimeout + '=15');
oPars.Add(S_FD_ConnParam_MSSQL_MARS + '=Yes'); oPars.Add(S_FD_ConnParam_MSSQL_MARS + '=Yes');
oPars.Add(S_FD_ConnParam_Common_ExtendedMetadata + '=True'); oPars.Add(S_FD_ConnParam_Common_ExtendedMetadata + '=False'); // True jen pri pouziti AutoGenerate SQL / CachedUpdates / UpdateObject
oPars.Add(S_FD_ConnParam_Common_ApplicationName + '=hdcdzAPIsvc'); oPars.Add(S_FD_ConnParam_Common_ApplicationName + '=hdcdzAPIsvc');
oPars.Add(S_FD_ConnParam_Common_Pooled + '=True'); oPars.Add(S_FD_ConnParam_Common_Pooled + '=True');
oPars.Add(S_FD_ConnParam_Common_Pool_MaximumItems + '=100'); oPars.Add(S_FD_ConnParam_Common_Pool_MaximumItems + '=300');
oPars.Add(S_FD_ConnParam_Common_Pool_ExpireTimeout + '=30000'); // FireDAC v intervalu 30 sekund testuje platnost spojeni, jestli to SQL server neukoncil
oPars.Add(S_FD_ConnParam_Common_Pool_CleanupTimeout + '=90000'); // FireDAC v intervalu 90 sekund cisti nepouzivana spojeni
oPars.Add(S_FD_ConnParam_ODBC_ODBCAdvanced + '=TrustServerCertificate=yes'); oPars.Add(S_FD_ConnParam_ODBC_ODBCAdvanced + '=TrustServerCertificate=yes');
// oPars.Add('CommandTimeout=120');
if (dbEncConn) then
oPars.Add(S_FD_ConnParam_MSSQL_Encrypt + '=Yes');
if (FDManager.FindConnection(sqlPoolName)=nil) then if not(ConnInit) then
begin begin
FDManager.AddConnectionDef (sqlPoolName, 'MSSQL', oPars, true); TMonitor.Enter(ConnInitLock);
if (FDManager.State<>dmsInactive) then try
Sleep(0); if not(ConnInit) then
begin
if (FDManager.ConnectionDefs.FindConnectionDef(sqlPoolName) = nil) then
FDManager.AddConnectionDef(sqlPoolName, 'MSSQL', oPars);
if (FDManager.State = dmsInactive) then
FDManager.Open;
ConnInit := True;
end;
finally
TMonitor.Exit (ConnInitLock);
end;
end; end;
FDManager.Open;
// sqlConn.Params.SetStrings(oPars); // sqlConn.Params.SetStrings(oPars);
sqlConn.ConnectionDefName:= sqlPoolName; sqlConn.ConnectionDefName:= sqlPoolName;
sqlQry1.ConnectionName:= sqlConn.ConnectionDefName; sqlQry1.Connection:= sqlConn;
sqlQry2.ConnectionName:= sqlConn.ConnectionDefName; sqlQry2.Connection:= sqlConn;
sqlQry3.ConnectionName:= sqlConn.ConnectionDefName; sqlQry3.Connection:= sqlConn;
sqlQry10.ConnectionName:= sqlConn.ConnectionDefName; sqlQry10.Connection:= sqlConn;
sqlQry11.ConnectionName:= sqlConn.ConnectionDefName; sqlQry11.Connection:= sqlConn;
// if (dbConnOleDB) then // if (dbConnOleDB) then
// sqlMSSQLDrv.ODBCDriver:= ''; // sqlMSSQLDrv.ODBCDriver:= '';
connStr:= '';
if (dbEncConn) then if (dbEncConn) then
begin begin
if (dbConnOleDB) then if (dbConnOleDB) then
connStr:= 'Encrypt=True;TrustServerCertificate=True;UseEncryptionForData=True' connStr:= ';Encrypt=True;TrustServerCertificate=True;UseEncryptionForData=True'
else else
connStr:= 'Encrypt=yes;TrustServerCertificate=yes;Encrypt=yes'; connStr:= ';Encrypt=yes;TrustServerCertificate=yes;Encrypt=yes';
// sqlConn.Params.Add(S_FD_ConnParam_ODBC_ODBCAdvanced + '=' + connStr); // sqlConn.Params.Add(S_FD_ConnParam_ODBC_ODBCAdvanced + '=' + connStr);
end; end;
connStr:= FDManager.ConnectionDefs.ConnectionDefByName(sqlPoolName).Params.Text + connStr;
connStr:= sqlConn.Params.DelimitedText;
sqlConn.Open; sqlConn.Open;
sqlConn.ExecSQL('SET LOCK_TIMEOUT 60000'); // čekej max 60 sekund na lock, ne nekonecne jako je default (-1)
except on E:Exception do except on E:Exception do
begin begin
result:= E.Message; result:= E.Message;
@ -294,8 +236,8 @@ uses System.StrUtils, Data.Win.ADODB,
end; end;
end; // try end; // try
finally finally
if (oPars<>nil) then // sqlConnParams.Free;
oPars.Free; oPars.Free;
end; // try end; // try
end; end;
end; end;
@ -458,19 +400,37 @@ uses System.StrUtils, Data.Win.ADODB,
function TdatMod.SQLIsSafe (const S: string): boolean;
var UpperS: string;
begin
result:= TRegEx.IsMatch (S, '^[A-Za-z0-9_ \(\)=<>!\.,]+$', [roIgnoreCase]);
if not result then
Exit;
UpperS := UpperCase(S);
// zakázaná klíčová slova
if TRegEx.IsMatch(UpperS, '\b(SELECT|INSERT|UPDATE|DELETE|DROP|EXEC|UNION)\b') then
Exit (False);
result := True;
end;
function TdatMod.SQLIDsToString (const tabName: string = ''; where: string = ''): string; function TdatMod.SQLIDsToString (const tabName: string = ''; where: string = ''): string;
var lSQL, s, t: string; var lSQL, s, t: string;
c: boolean; c: boolean;
lQry: TFDQuery; lQry: TFDQuery;
sqlConnX: TFDConnection; sqlConnX: TFDConnection;
begin begin
result:= ''; result := '';
try try
if (self.sqlConn.Connected) then if (self.sqlConn.Connected) then
begin begin
s:= ''; s := '';
t:= tabName; t := tabName;
if not(t.Contains('dbo.')) and not(t.Contains('dbo].')) then if not(t.Contains('dbo.')) and not(t.Contains('dbo].')) then
t:= '[' + t; t:= '[' + t;
if not(t.EndsWith(']')) then if not(t.EndsWith(']')) then
@ -479,8 +439,8 @@ uses System.StrUtils, Data.Win.ADODB,
t:= '[dbo].' + t; t:= '[dbo].' + t;
sqlConnX:= TFDConnection.Create(nil); sqlConnX := TFDConnection.Create(nil);
sqlConnX.ConnectionDefName:= sqlPoolName; sqlConnX.ConnectionDefName := sqlPoolName;
try try
sqlConnX.Open; sqlConnX.Open;
finally finally
@ -491,15 +451,23 @@ uses System.StrUtils, Data.Win.ADODB,
begin begin
lQry:= TFDQuery.Create(nil); lQry:= TFDQuery.Create(nil);
try try
lQry.Connection:= sqlConnX; result := '';
lQry.Connection := sqlConnX;
where:= where.Replace(';', '').Replace('--', '').Trim; // sanitace podminky where:= where.Replace(';', '').Replace('--', '').Trim; // sanitace podminky
lSQL:= 'SELECT STRING_AGG(ID,'','') AS IDs FROM ' + t + IfThen(where<>'', ' WHERE ' + where, ''); lSQL:= 'SELECT STRING_AGG(ID,'','') AS IDs FROM ' + t + IfThen(where<>'', ' WHERE ' + where, '');
try
lQry.Open(lSQL); if not(SQLIsSafe(where)) then
result:= lQry.FieldByName('IDs').AsString; lSQL:= '';
except on E:Exception do
result:= ''; if (lSQL<>'') then
end; begin
try
lQry.Open (lSQL);
result := lQry.FieldByName('IDs').AsString;
except on E:Exception do
result := '';
end;
end;
finally finally
lQry.Free; lQry.Free;
end; end;
@ -608,10 +576,12 @@ uses System.StrUtils, Data.Win.ADODB,
initialization initialization
ConnInitLock := TObject.Create;
// CoInitialize(nil); // CoInitialize(nil);
finalization finalization
ConnInitLock.Free;
// CoUninitialize; // CoUninitialize;
end. end.

View File

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

View File

@ -7,6 +7,9 @@ interface
uses uses
System.Generics.Collections, System.Generics.Collections,
System.SysUtils, System.SysUtils,
FireDAC.Stan.Option,
FireDAC.Comp.Client,
FireDAC.Stan.Param,
JsonDataObjects, JsonDataObjects,
uSvc_Base, uSvc_Base,
uCommons, uCommons,
@ -40,7 +43,7 @@ type
TSerioveCisloPohybOZService = class(TServiceBase) TSerioveCisloPohybOZService = class(TServiceBase)
public public
function GetMeta: TJSONObject; virtual; function GetMeta: TJSONObject; virtual;
function GetByParams (params: TDictionary<string, string>): TObjectList<TSerioveCisloPohybOZ>; virtual; function GetByParams (params: TDictionary<string, string>; AConn: TFDConnection = nil): TObjectList<TSerioveCisloPohybOZ>; virtual;
end; end;
@ -48,15 +51,15 @@ type
TStavSkladuService = class(TServiceBase) TStavSkladuService = class(TServiceBase)
public public
function GetMeta: TJSONObject; virtual; function GetMeta: TJSONObject; virtual;
function GetByParams (params: TDictionary<string, string>): TObjectList<TStavSkladu>; virtual; function GetByParams (params: TDictionary<string, string>; AConn: TFDConnection = nil): TObjectList<TStavSkladu>; virtual;
end; end;
TDokladOZService = class(TServiceBase) TDokladOZService = class(TServiceBase)
public public
function GetByID (const AID: integer; sdServer: boolean=false; params: TDictionary<string, string>=nil): TDokladOZ; virtual;
function GetMeta: TJSONObject; virtual; function GetMeta: TJSONObject; virtual;
function GetByParams (params: TDictionary<string, string>): TObjectList<TDokladOZ>; virtual; function GetByID (const AID: integer; sdServer: boolean=false; params: TDictionary<string, string>=nil; AConn: TFDConnection = nil): TDokladOZ; virtual;
function GetByParams (params: TDictionary<string, string>; AConn: TFDConnection = nil): TObjectList<TDokladOZ>; virtual;
function GetDruhyDokladu (druhpohybu: string): TObjectList<TDruhDokZbo>; virtual; function GetDruhyDokladu (druhpohybu: string): TObjectList<TDruhDokZbo>; virtual;
end; end;
@ -64,8 +67,8 @@ type
TPolozkaOZService = class(TServiceBase) TPolozkaOZService = class(TServiceBase)
public public
function GetMeta: TJSONObject; virtual; function GetMeta: TJSONObject; virtual;
function GetByID (const AID: integer; sdServer: boolean=false): TPohybOZ; virtual; function GetByID (const AID: integer; sdServer: boolean=false; AConn: TFDConnection = nil): TPohybOZ; virtual;
function GetByParams (params: TDictionary<string, string>): TObjectList<TPohybOZ>; virtual; function GetByParams (params: TDictionary<string, string>; AConn: TFDConnection = nil): TObjectList<TPohybOZ>; virtual;
end; end;
@ -76,9 +79,6 @@ implementation
uses uses
System.StrUtils, System.StrUtils,
System.DateUtils, System.DateUtils,
FireDAC.Stan.Option,
FireDAC.Comp.Client,
FireDAC.Stan.Param,
MVCFramework.FireDAC.Utils, MVCFramework.FireDAC.Utils,
MVCFramework.DataSet.Utils, MVCFramework.DataSet.Utils,
MVCFramework.Serializer.Commons; MVCFramework.Serializer.Commons;
@ -90,15 +90,26 @@ uses
{ TStavSkladuService } { TStavSkladuService }
function TStavSkladuService.GetByParams (params: TDictionary<string, string>): TObjectList<TStavSkladu>; function TStavSkladuService.GetByParams (params: TDictionary<string, string>; AConn: TFDConnection = nil): TObjectList<TStavSkladu>;
var lSQL, where, odDatum, doDatum, strTemp: string; var lSQL, where, odDatum, doDatum, strTemp: string;
datOd, datDo: TDateTime; datOd, datDo: TDateTime;
id: integer; id: integer;
lQry: TFDQuery; lQry: TFDQuery;
sqlConnX: TFDConnection; sqlConnX: TFDConnection;
lokalniConnection: boolean;
begin begin
result:= nil; result:= nil;
lokalniConnection := (AConn = nil);
if (lokalniConnection) then
begin
sqlConnX:= TFDConnection.Create(nil);
sqlConnX.ConnectionDefName:= sqlPoolName;
end
else
sqlConnX := AConn;
lSQL:= 'SELECT ' + GetTabCols('dbo', tblSS) + ' FROM ' + tblSS; lSQL:= 'SELECT ' + GetTabCols('dbo', tblSS) + ' FROM ' + tblSS;
where:= ''; where:= '';
@ -129,14 +140,14 @@ uses
lQry:= TFDQuery.Create(nil); lQry:= TFDQuery.Create(nil);
sqlConnX:= TFDConnection.Create(nil);
sqlConnX.ConnectionDefName:= sqlPoolName;
try try
sqlConnX.Connected := true;
lQry.Connection:= sqlConnX; lQry.Connection:= sqlConnX;
try try
lQry.Open(lSQL); lQry.Open(lSQL);
result:= lQry.AsObjectList<TStavSkladu>; result:= lQry.AsObjectList<TStavSkladu>;
lQry.Close;
except on E:Exception do except on E:Exception do
raise EServiceException.Create('Chyba na<6E><61>t<EFBFBD>n<EFBFBD> dokladu: ' + E.Message); raise EServiceException.Create('Chyba na<6E><61>t<EFBFBD>n<EFBFBD> dokladu: ' + E.Message);
end; end;
@ -144,9 +155,11 @@ uses
lQry.Free; lQry.Free;
end; end;
sqlConnX.Close; if (lokalniConnection) then
sqlConnX.Free; begin
sqlConnX.Close;
sqlConnX.Free;
end;
end; end;
@ -245,21 +258,33 @@ uses
function TDokladOZService.GetByParams (params: TDictionary<string, string>): TObjectList<TDokladOZ>; function TDokladOZService.GetByParams (params: TDictionary<string, string>; AConn: TFDConnection = nil): TObjectList<TDokladOZ>;
var lSQL, lSQLmin, where, odDatum, doDatum, sklad, strTemp: string; var lSQL, lSQLmin, where, odDatum, doDatum, sklad, strTemp: string;
lQry: TFDQuery; lQry: TFDQuery;
sqlConnX: TFDConnection; sqlConnX: TFDConnection;
datOd, datDo: TDateTime; datOd, datDo: TDateTime;
id, iDZ, idPrikaz, cnt, rNo: integer; id, iDZ, idPrikaz, cnt, rNo: integer;
jenSeznam, polozky, minimum: Boolean; jenSeznam, polozky, minimum: Boolean;
d: TDokladOZ; resList: TObjectList<TDokladOZ>;
dList: TObjectList<TDokladOZ>; resObj: TDokladOZ;
noDatum, snZSDServeru: boolean; noDatum, snZSDServeru: boolean;
radyD, sklady, dpz: string; radyD, sklady, dpz: string;
p: TDictionary<string, string>; p: TDictionary<string, string>;
lokalniConnection: boolean;
lokIDcka: TList<integer>;
begin begin
result:= nil; result:= nil;
lokalniConnection := (AConn = nil);
if (lokalniConnection) then
begin
sqlConnX:= TFDConnection.Create(nil);
sqlConnX.ConnectionDefName:= sqlPoolName;
end
else
sqlConnX := AConn;
p:= TDictionary<string, string>.Create; p:= TDictionary<string, string>.Create;
radyD:= ''; radyD:= '';
dpz:= ''; dpz:= '';
@ -421,20 +446,19 @@ uses
end; end;
{$ENDIF} {$ENDIF}
sqlConnX:= TFDConnection.Create(nil);
sqlConnX.ConnectionDefName:= sqlPoolName;
lQry:= TFDQuery.Create(nil); lQry:= TFDQuery.Create(nil);
try try
lQry.FetchOptions.Mode:= fmAll; sqlConnX.Connected := true;
lQry.Connection:= sqlConnX; lQry.FetchOptions.Mode := fmAll;
lQry.Open(lSQL); lQry.Connection := sqlConnX;
cnt:= lQry.RecordCount; lQry.Open (lSQL);
cnt := lQry.RecordCount;
if (cnt>0) then if (cnt>0) then
begin begin
lQry.Close;
lokIDcka:= TList<integer>.Create;
try try
d:= TDokladOZ.Create;
dList:= TObjectList<TDokladOZ>.Create;
try try
rNo:= 1; rNo:= 1;
lQry.First; lQry.First;
@ -442,44 +466,71 @@ uses
begin begin
lQry.RecNo:= rNo; lQry.RecNo:= rNo;
iDZ:= lQry.FieldByName('ID').AsInteger; iDZ:= lQry.FieldByName('ID').AsInteger;
d:= self.GetByID (iDZ, snZSDServeru, p); lokIDcka.Add (iDZ);
dList.Add(d);
if not(lQry.Active) then if not(lQry.Active) then
lQry.Open; lQry.Open;
Inc(rNo); Inc(rNo);
end; end;
result:= dList; // FDM.sqlQry1.AsObjectList<TDokladOZ>; lQry.Close;
except on E:Exception do except on E:Exception do
raise EServiceException.Create('Chyba na<6E><61>t<EFBFBD>n<EFBFBD> dokladu: ' + E.Message); raise EServiceException.Create('Chyba na<6E><61>t<EFBFBD>n<EFBFBD> dokladu: ' + E.Message);
end; end;
// FreeAndNil(dList); // FreeAndNil(dList);
resList:= TObjectList<TDokladOZ>.Create;
try
for iDZ in lokIDcka do
begin
resObj:= self.GetByID (iDZ, snZSDServeru, p, sqlConnX);
resList.Add (resObj);
end;
result:= resList;
resList:= nil;
finally
resList.Free;
end;
finally finally
lokIDcka.Free;
end; end;
end end
else else
raise EServiceException.Create('Vybran<61>m podm<64>nk<6E>m neodpov<6F>d<EFBFBD> <20><>dn<64> doklad'); raise EServiceException.Create('Vybran<61>m podm<64>nk<6E>m neodpov<6F>d<EFBFBD> <20><>dn<64> doklad');
finally finally
p.Free;
lQry.Close; lQry.Close;
FreeAndNil(lQry); lQry.Free;
if (lokalniConnection) then
begin
sqlConnX.Close;
sqlConnX.Free;
end;
end; end;
p.Free;
sqlConnX.Close;
sqlConnX.Free;
end; end;
function TDokladOZService.GetByID (const AID: Integer; sdServer: boolean=false; params: TDictionary<string, string>=nil): TDokladOZ; function TDokladOZService.GetByID (const AID: Integer; sdServer: boolean=false; params: TDictionary<string, string>=nil; AConn: TFDConnection = nil): TDokladOZ;
var lSQL, extInfoStr, errMsg: string; var lSQL, extInfoStr, errMsg: string;
minimumDat, polozky: boolean; minimumDat, polozky: boolean;
p: TDictionary<string, string>; p: TDictionary<string, string>;
ps: TPolozkaOZService; ps: TPolozkaOZService;
lQry: TFDQuery; lQry: TFDQuery;
sqlConnX: TFDConnection; sqlConnX: TFDConnection;
lokalniConnection: boolean;
begin begin
result:= nil; result := nil;
lokalniConnection := (AConn = nil);
if (lokalniConnection) then
begin
sqlConnX:= TFDConnection.Create(nil);
sqlConnX.ConnectionDefName:= sqlPoolName;
end
else
sqlConnX:= AConn;
extInfoStr:= ''; extInfoStr:= '';
if (SQLTableExists ('dbo', tblDZe)) then if (SQLTableExists ('dbo', tblDZe)) then
@ -491,6 +542,7 @@ uses
lQry.Open(lSQL, [AID]); lQry.Open(lSQL, [AID]);
if (lQry.RecordCount>0) then if (lQry.RecordCount>0) then
extInfoStr:= lQry.AsJSONObject; extInfoStr:= lQry.AsJSONObject;
lQry.Close;
finally finally
lQry.Free; lQry.Free;
end; end;
@ -532,11 +584,9 @@ uses
lSQL:= lSQL + ' FROM ' + tblDZ + ' WHERE ID=:ID'; lSQL:= lSQL + ' FROM ' + tblDZ + ' WHERE ID=:ID';
sqlConnX:= TFDConnection.Create(nil);
sqlConnX.ConnectionDefName:= sqlPoolName;
lQry:= TFDQuery.Create(nil); lQry:= TFDQuery.Create(nil);
try try
sqlConnX.Connected := true;
lQry.FetchOptions.Mode:= fmAll; lQry.FetchOptions.Mode:= fmAll;
lQry.Connection:= sqlConnX; lQry.Connection:= sqlConnX;
lQry.Open(lSQL, [AID]); lQry.Open(lSQL, [AID]);
@ -550,16 +600,19 @@ uses
result.PohybyOZ:= ps.GetByParams (p); result.PohybyOZ:= ps.GetByParams (p);
end end
else else
raise EServiceException.Create('Doklad ob<6F>hu zbo<62><6F> s ID ' + AID.ToString + ' nebyl nalezen.'); raise EServiceException.Create('Doklad ob<6F>hu zbo<62><6F> s ID ' + AID.ToString + ' nebyl nalezen.');
finally finally
p.Free; p.Free;
ps.Free; ps.Free;
FreeAndNil(lQry); lQry.Close;
lQry.Free;
if (lokalniConnection) then
begin
sqlConnX.Close;
sqlConnX.Free;
end;
end; end;
sqlConnX.Close;
sqlConnX.Free;
end; end;
@ -589,19 +642,28 @@ uses
{ TPolozkaOZService } { TPolozkaOZService }
function TPolozkaOZService.GetByParams (params: TDictionary<string, string>): TObjectList<TPohybOZ>; function TPolozkaOZService.GetByParams (params: TDictionary<string, string>; AConn: TFDConnection = nil): TObjectList<TPohybOZ>;
var lSQL, where: string; var lSQL, where: string;
id, AID, cnt, rNo: integer; id, AID, cnt, rNo: integer;
lQry: TFDQuery; lQry: TFDQuery;
sqlConnX: TFDConnection; sqlConnX: TFDConnection;
pList: TObjectList<TPohybOZ>; resList: TObjectList<TPohybOZ>;
p: TPohybOZ; resObj: TPohybOZ;
sdServer: boolean; sdServer: boolean;
lokalniConnection: boolean;
lokIDcka: TList<integer>;
begin begin
result:= nil; result:= nil;
p:= TPohybOZ.Create; lokalniConnection := (AConn = nil);
// pList:= TObjectList<TPohybOZ>.Create; if (lokalniConnection) then
begin
sqlConnX:= TFDConnection.Create(nil);
sqlConnX.ConnectionDefName:= sqlPoolName;
end
else
sqlConnX := AConn;
lSQL:= 'SELECT ' + GetTabCols('dbo', tblPZ, '', false) + ' FROM ' + tblPZ; lSQL:= 'SELECT ' + GetTabCols('dbo', tblPZ, '', false) + ' FROM ' + tblPZ;
@ -634,48 +696,61 @@ uses
// lSQL:= lSQL.Replace('TabPohybyZbozi.', 'main.'); // lSQL:= lSQL.Replace('TabPohybyZbozi.', 'main.');
sqlConnX:= TFDConnection.Create(nil); sqlConnX.Connected := true;
sqlConnX.ConnectionDefName:= sqlPoolName;
lQry:= TFDQuery.Create(nil); lQry:= TFDQuery.Create(nil);
try try
lQry.FetchOptions.Mode:= fmAll; lQry.FetchOptions.Mode := fmAll;
lQry.Connection:= sqlConnX; lQry.Connection := sqlConnX;
lQry.Open(lSQL); lQry.Open (lSQL);
cnt:= lQry.RecordCount; cnt := lQry.RecordCount;
pList:= TObjectList<TPohybOZ>.Create; lokIDcka := TList<integer>.Create;
try try
lQry.First; lQry.First;
rNo:= 1; rNo := 1;
while (rNo<=cnt) do while (rNo<=cnt) do
begin begin
lQry.RecNo:= rNo; lQry.RecNo := rNo;
AID:= lQry.FieldByName('ID').AsInteger; AID := lQry.FieldByName('ID').AsInteger;
p:= self.GetByID (AID, sdServer); lokIDcka.Add (AID);
pList.Add(p);
if not(lQry.Active) then if not(lQry.Active) then
lQry.Open; lQry.Open;
Inc(rNo); Inc (rNo);
end; end;
result:= pList;
except on E:Exception do except on E:Exception do
raise EServiceException.Create('Chyba na<6E><61>t<EFBFBD>n<EFBFBD> polo<6C>ky/polo<6C>ek dokladu: ' + E.Message); raise EServiceException.Create('Chyba na<6E><61>t<EFBFBD>n<EFBFBD> polo<6C>ky/polo<6C>ek dokladu: ' + E.Message);
end; end;
// pList.Free; // pList.Free;
resList := TObjectList<TPohybOZ>.Create;
try
for AID in lokIDcka do
begin
resObj := self.GetByID (AID, sdServer, sqlConnX);
resList.Add (resObj);
end;
result := resList;
resList := nil;
finally
resList.Free;
end;
finally finally
lokIDcka.Free;
lQry.Close; lQry.Close;
FreeAndNil(lQry); FreeAndNil (lQry);
end; end;
sqlConnX.Close; if (lokalniConnection) then
sqlConnX.Free; begin
sqlConnX.Close;
sqlConnX.Free;
end;
end; end;
function TPolozkaOZService.GetByID (const AID: Integer; sdServer: boolean=false): TPohybOZ; function TPolozkaOZService.GetByID (const AID: Integer; sdServer: boolean=false; AConn: TFDConnection = nil): TPohybOZ;
var lSQL, lSQL2, sz, rDokl, dpz, skl, sTemp: string; var lSQL, lSQL2, sz, rDokl, dpz, skl, sTemp: string;
p: TDictionary<string, string>; p: TDictionary<string, string>;
pds: TSerioveCisloPohybOZService; pds: TSerioveCisloPohybOZService;
@ -684,6 +759,8 @@ uses
lQry, lQry2: TFDQuery; lQry, lQry2: TFDQuery;
sqlConnX, sqlConnX2: TFDConnection; sqlConnX, sqlConnX2: TFDConnection;
extInfoStr: string; extInfoStr: string;
lokalniConnection: boolean;
lokIDcka: TList<integer>;
{$IFDEF CUSTOM_CTRL_Rootvin} {$IFDEF CUSTOM_CTRL_Rootvin}
silo: string; silo: string;
siloInt, idMzdy: integer; siloInt, idMzdy: integer;
@ -691,12 +768,21 @@ uses
begin begin
result:= nil; result:= nil;
lokalniConnection := (AConn = nil);
if (lokalniConnection) then
begin
sqlConnX:= TFDConnection.Create(nil);
sqlConnX.ConnectionDefName:= sqlPoolName;
end
else
sqlConnX := AConn;
{$IFDEF CUSTOM_CTRL_Rootvin} {$IFDEF CUSTOM_CTRL_Rootvin}
silo:= ''; silo:= '';
{$ENDIF} {$ENDIF}
sqlConnX:= TFDConnection.Create(nil); sqlConnX.Connected := true;
sqlConnX.ConnectionDefName:= sqlPoolName;
lQry:= TFDQuery.Create(nil); lQry:= TFDQuery.Create(nil);
lQry.FetchOptions.Mode:= fmAll; lQry.FetchOptions.Mode:= fmAll;
lQry.Connection:= sqlConnX; lQry.Connection:= sqlConnX;
@ -757,48 +843,53 @@ uses
{$IFDEF CUSTOM_CTRL_Rootvin} {$IFDEF CUSTOM_CTRL_Rootvin}
lQry2:= TFDQuery.Create(nil); lQry2:= TFDQuery.Create(nil);
try try
lQry2.FetchOptions.Mode:= fmAll; lQry2.FetchOptions.Mode := fmAll;
lQry2.Connection:= sqlConnX; lQry2.Connection := sqlConnX;
if (sz='101') and (dpz='0') and ((rDokl='251') or (rDokl='261')) then if (sz='101') and (dpz='0') and ((rDokl='251') or (rDokl='261')) then
if (silo='') then if (silo='') then
begin begin
lSQL:= 'SELECT TOP(1) p.IDUmisteni, u.Kod FROM ' + tblPuvodniVC + ' p INNER JOIN ' + tblUmisteni + ' u ON (u.ID=p.IDUmisteni) WHERE p.IDPohybZbozi=:ID'; lSQL := 'SELECT TOP(1) p.IDUmisteni, u.Kod FROM ' + tblPuvodniVC + ' p INNER JOIN ' + tblUmisteni + ' u ON (u.ID=p.IDUmisteni) WHERE p.IDPohybZbozi=:ID';
lQry2.Open (lSQL, [AID]); lQry2.Open (lSQL, [AID]);
lQry2.First; lQry2.First;
u:= lQry2.FieldByName('IDUmisteni').AsInteger; u := lQry2.FieldByName('IDUmisteni').AsInteger;
silo:= lQry2.FieldByName('Kod').AsString; silo := lQry2.FieldByName('Kod').AsString;
if (silo<>'') then if (silo<>'') then
begin begin
TryStrToInt (silo, siloInt); TryStrToInt (silo, siloInt);
if (siloInt>0) then if (siloInt>0) then
begin begin
lSQL:= 'IF NOT EXISTS (SELECT 1 FROM ' + tblPZe + ' WHERE ID=:ID) INSERT ' + tblPZe + ' (ID) SELECT :ID' + CRLF; lSQL := 'IF NOT EXISTS (SELECT 1 FROM ' + tblPZe + ' WHERE ID=:ID) INSERT ' + tblPZe + ' (ID) SELECT :ID' + CRLF;
lSQL:= lSQL + 'UPDATE ' + tblPZe + ' SET _Mouka_Silo=' + siloInt.ToString + ' WHERE ID=:ID'; lSQL := lSQL + 'UPDATE ' + tblPZe + ' SET _Mouka_Silo=' + siloInt.ToString + ' WHERE ID=:ID';
sqlConnX.ExecSQL (lSQL, [AID]); sqlConnX.ExecSQL (lSQL, [AID]);
end; end;
end; end;
end; end;
lSQL:= 'SELECT IDMzdy FROM ' + tblPMZGenPZ + ' WHERE IDPohybu=:ID'; lSQL := 'SELECT IDMzdy FROM ' + tblPMZGenPZ + ' WHERE IDPohybu=:ID';
lQry2.Open (lSQL, [AID]); lQry2.Open (lSQL, [AID]);
if (lQry2.RecordCount=1) then if (lQry2.RecordCount=1) then
result.IDMzdy:= lQry2.FieldByName('IDMzdy').AsInteger; result.IDMzdy := lQry2.FieldByName('IDMzdy').AsInteger;
finally finally
lQry2.Close; lQry2.Close;
FreeAndNil(lQry2); FreeAndNil (lQry2);
end; end;
{$ENDIF} {$ENDIF}
if (lokalniConnection) then
begin
sqlConnX2 := TFDConnection.Create(nil);
sqlConnX2.ConnectionDefName := sqlPoolName;
end
else
sqlConnX2 := AConn;
sqlConnX2:= TFDConnection.Create(nil); sqlConnX2.Connected := true;
lQry2:= TFDQuery.Create (nil); lQry2 := TFDQuery.Create (nil);
try try
sqlConnX2.ConnectionDefName:= sqlPoolName;
lQry2.Connection:= sqlConnX2; lQry2.Connection:= sqlConnX2;
@ -880,13 +971,16 @@ uses
finally finally
lQry2.Free; lQry2.Free;
sqlConnX2.Close; if (lokalniConnection) then
sqlConnX2.Free; begin
sqlConnX2.Close;
sqlConnX2.Free;
end;
end; end;
if (extInfoStr<>'') then if (extInfoStr<>'') then
result.ExtInfo:= ExtInfoStr; result.ExtInfo:= ExtInfoStr;
result.SerialNums:= pds.GetByParams (p); result.SerialNums:= pds.GetByParams (p, sqlConnX);
if (u>0) then if (u>0) then
begin begin
Result.Umisteni:= us.GetByID (u); Result.Umisteni:= us.GetByID (u);
@ -905,15 +999,18 @@ uses
else else
raise EServiceException.Create('Polo<6C>ka dokladu ob<6F>hu zbo<62><6F> s ID ' + AID.ToString + ' nebyla nalezena.'); raise EServiceException.Create('Polo<6C>ka dokladu ob<6F>hu zbo<62><6F> s ID ' + AID.ToString + ' nebyla nalezena.');
finally finally
lokIDcka.Free;
p.Free; p.Free;
pds.Free; pds.Free;
lQry.Close; lQry.Close;
FreeAndNil(lQry); FreeAndNil (lQry);
end; end;
sqlConnX.Close; if (lokalniConnection) then
sqlConnX.Free; begin
sqlConnX.Close;
sqlConnX.Free;
end;
end; end;
@ -1021,15 +1118,16 @@ uses
lSQL:= 'SELECT ' + GetTabCols('dbo', tblVyrCP, '', false) + IfThen(sp<>'', ', ' + sp, '') + ' FROM ' + tblVyrCP + ' WHERE 1=0'; lSQL:= 'SELECT ' + GetTabCols('dbo', tblVyrCP, '', false) + IfThen(sp<>'', ', ' + sp, '') + ' FROM ' + tblVyrCP + ' WHERE 1=0';
sqlConnX:= TFDConnection.Create(nil); sqlConnX := TFDConnection.Create(nil);
sqlConnX.ConnectionDefName:= sqlPoolName; sqlConnX.ConnectionDefName := sqlPoolName;
lQry:= TFDQuery.Create(nil); lQry:= TFDQuery.Create(nil);
try try
lQry.FetchOptions.Mode:= fmAll; lQry.FetchOptions.Mode := fmAll;
lQry.Connection:= sqlConnX; lQry.Connection := sqlConnX;
lQry.Open(lSQL); lQry.Open (lSQL);
Result:= lQry.MetadataAsJSONObject(); Result := lQry.MetadataAsJSONObject();
lQry.Close;
finally finally
lQry.Free; lQry.Free;
end; end;
@ -1043,54 +1141,62 @@ uses
function TSerioveCisloPohybOZService.GetByParams (params: TDictionary<string, string>): TObjectList<TSerioveCisloPohybOZ>; function TSerioveCisloPohybOZService.GetByParams (params: TDictionary<string, string>; AConn: TFDConnection = nil): TObjectList<TSerioveCisloPohybOZ>;
var lSQL, lSQL2, where: string; var lSQL, lSQL2, where: string;
lQry: TFDQuery; lQry: TFDQuery;
sqlConnX: TFDConnection; sqlConnX: TFDConnection;
id, idPZ: integer; id, idPZ: integer;
s: TSerioveCisloPohybOZ; s: TSerioveCisloPohybOZ;
sdServer: boolean; sdServer: boolean;
lokalniConnection: boolean;
lokIDcka: TList<integer>;
begin begin
result:= nil; result:= nil;
lSQL:= 'SELECT ' + GetTabCols('', tblVyrCP, 'main') + IfThen(selSpecVyrCP<>'', ', ' + selSpecVyrCP.Replace('#', ''), '') lokalniConnection := (AConn = nil);
+ ', 0 AS ZdrojSD, 0 AS IDDokladGSD FROM ' + tblVyrCP + ' main'; if (lokalniConnection) then
where:= ''; begin
sqlConnX := TFDConnection.Create(nil);
sqlConnX.ConnectionDefName := sqlPoolName;
end
else
sqlConnX := AConn;
sdServer:= false;
lSQL := 'SELECT ' + GetTabCols('', tblVyrCP, 'main') + IfThen(selSpecVyrCP<>'', ', ' + selSpecVyrCP.Replace('#', ''), '')
+ ', 0 AS ZdrojSD, 0 AS IDDokladGSD FROM ' + tblVyrCP + ' main';
where := '';
sdServer := false;
if (params.ContainsKey('sdServer')) then if (params.ContainsKey('sdServer')) then
if (params.Items['sdServer']='1') then if (params.Items['sdServer']='1') then
sdServer:= true; sdServer := true;
id:= 0; id := 0;
if (params.ContainsKey('id')) then if (params.ContainsKey('id')) then
if (params.Items['id']<>'') then if (params.Items['id']<>'') then
if (params.Items['id']<>'0') then if (params.Items['id']<>'0') then
id:= params.Items['id'].ToInteger; id := params.Items['id'].ToInteger;
idPZ:= 0; idPZ := 0;
if (params.ContainsKey('idPolozkaOZ')) then if (params.ContainsKey('idPolozkaOZ')) then
if (params.Items['idPolozkaOZ']<>'') then if (params.Items['idPolozkaOZ']<>'') then
if (params.Items['idPolozkaOZ']<>'0') then if (params.Items['idPolozkaOZ']<>'0') then
begin begin
idPZ:= params.Items['idPolozkaOZ'].ToInteger; idPZ := params.Items['idPolozkaOZ'].ToInteger;
where:= where + IfThen(where<>'', ' AND ', '') + 'main.IDPolozkaDokladu=' + idPZ.ToString; where := where + IfThen(where<>'', ' AND ', '') + 'main.IDPolozkaDokladu=' + idPZ.ToString;
end; end;
if (where<>'') then if (where<>'') then
lSQL:= lSQL + ' WHERE ' + IfThen(id>0, 'main.ID=' + id.ToString, where); lSQL := lSQL + ' WHERE ' + IfThen(id>0, 'main.ID=' + id.ToString, where);
lSQL:= lSQL + ' ORDER BY main.ID'; lSQL := lSQL + ' ORDER BY main.ID';
lSQL:= lSQL.Replace('TabVyrCP.', 'main.'); lSQL := lSQL.Replace('TabVyrCP.', 'main.');
if (selSpecVyrCP='') then if (selSpecVyrCP='') then
lSQL:= lSQL.Replace('main.', ''); lSQL := lSQL.Replace('main.', '');
sqlConnX:= TFDConnection.Create(nil);
sqlConnX.ConnectionDefName:= sqlPoolName;
lQry:= TFDQuery.Create(nil);
lQry := TFDQuery.Create(nil);
{$IF DEFINED(CUSTOM_CTRL_Rootvin) or DEFINED(CUSTOM_CTRL_GatemaSD)} {$IF DEFINED(CUSTOM_CTRL_Rootvin) or DEFINED(CUSTOM_CTRL_GatemaSD)}
// test zda polozky pochazi z SD serveru // test zda polozky pochazi z SD serveru
@ -1102,7 +1208,7 @@ uses
// typ 510=prijemka (potvrzeni/kontrola) // typ 510=prijemka (potvrzeni/kontrola)
lSQL2:= 'SELECT 1 AS A FROM ' + tblGSDScanData + ' p INNER JOIN ' + tblGSDDoklady + ' h ON (h.Id=p.IDDokladSD) WHERE h.DatGenerovani IS NOT NULL AND h.TypDokladu IN (500,510) AND p.IDPohZbo_New=' + idPZ.ToString; lSQL2:= 'SELECT 1 AS A FROM ' + tblGSDScanData + ' p INNER JOIN ' + tblGSDDoklady + ' h ON (h.Id=p.IDDokladSD) WHERE h.DatGenerovani IS NOT NULL AND h.TypDokladu IN (500,510) AND p.IDPohZbo_New=' + idPZ.ToString;
lSQL2:= lSQL2 + ' ORDER BY p.ID'; lSQL2:= lSQL2 + ' ORDER BY p.ID';
lQry.Open(lSQL2); lQry.Open (lSQL2);
if (lQry.RecordCount>0) then if (lQry.RecordCount>0) then
lSQL:= lSQL2.Replace(' 1 AS A ', ' 1000000000+p.ID AS ID, p.IDPohZbo_New AS IDPolozkaDokladu, 0 AS IDVyrCis, p.VyrCislo AS VyrCis, p.PopisSarze AS Nazev, p.Mnozstvi' lSQL:= lSQL2.Replace(' 1 AS A ', ' 1000000000+p.ID AS ID, p.IDPohZbo_New AS IDPolozkaDokladu, 0 AS IDVyrCis, p.VyrCislo AS VyrCis, p.PopisSarze AS Nazev, p.Mnozstvi'
+ ', p.MnozstviEvidence AS MnozstviEvid, p.DatPorizeni AS DatVstup, p.DatumExpirace AS DatExpirace, 1 AS ZdrojSD, h.ID AS IDDokladGSD '); + ', p.MnozstviEvidence AS MnozstviEvid, p.DatPorizeni AS DatVstup, p.DatumExpirace AS DatExpirace, 1 AS ZdrojSD, h.ID AS IDDokladGSD ');
@ -1112,19 +1218,22 @@ uses
end; end;
{$ENDIF} {$ENDIF}
try try
lQry.FetchOptions.Mode:= fmAll; sqlConnX.Connected:= true;
lQry.Connection:= sqlConnX; lQry.FetchOptions.Mode := fmAll;
lQry.Open(lSQL); lQry.Connection := sqlConnX;
result:= lQry.AsObjectList<TSerioveCisloPohybOZ>; lQry.Open (lSQL);
result := lQry.AsObjectList<TSerioveCisloPohybOZ>;
lQry.Close;
finally finally
lQry.Free; lQry.Free;
end; end;
sqlConnX.Close; if (lokalniConnection) then
sqlConnX.Free; begin
sqlConnX.Close;
sqlConnX.Free;
end;
end; end;
end. end.

File diff suppressed because it is too large Load Diff

View File

@ -451,7 +451,7 @@ uses
logRun: Int64; logRun: Int64;
Msg: TMsg; Msg: TMsg;
mamTabPrijataData, firstRun, inProg, canCont: boolean; mamTabPrijataData, firstRun, inProg, canCont: boolean;
lQry, lQry2: TFDQuery; lQry, lQry2, lQry3: TFDQuery;
sqlConnX: TFDConnection; sqlConnX: TFDConnection;
begin begin
lLoop:= 0; lLoop:= 0;
@ -507,49 +507,49 @@ uses
{$ENDIF} {$ENDIF}
begin begin
sqlConnX:= TFDConnection.Create(nil); // sqlConnX:= TFDConnection.Create(nil);
sqlConnX.ConnectionDefName:= sqlPoolName; // sqlConnX.ConnectionDefName:= sqlPoolName;
sqlConnX.Open; // sqlConnX.Open;
if (sqlConnX.Connected) then if (1=1) then // (sqlConnX.Connected)
begin begin
lSQL:= 'SELECT d.ID FROM ' + tblPrijataJsonData + ' d WITH(NOLOCK) WHERE d.Blokovano=0 AND d.DatZpracovani IS NULL'; lSQL := 'SELECT d.ID FROM ' + tblPrijataJsonData + ' d WITH(NOLOCK) WHERE d.Blokovano=0 AND d.DatZpracovani IS NULL';
lSQL:= lSQL + ' AND ISNULL(d.PosledniChyba,N'''')=N'''''; lSQL := lSQL + ' AND ISNULL(d.PosledniChyba,N'''')=N'''' AND d.Nezpracovat=0';
lSQL:= lSQL + ' AND d.Blokovano=0 '; // AND ISNULL( (SELECT COUNT(ID) FROM dbo._hdc_ph_Log WHERE LogText=N''Zpracovani API json'' AND IntValue=d.ID), 0)<4'; lSQL := lSQL + ' AND d.Blokovano=0 '; // AND ISNULL( (SELECT COUNT(ID) FROM dbo._hdc_ph_Log WHERE LogText=N''Zpracovani API json'' AND IntValue=d.ID), 0)<4';
lSQL:= lSQL + ' ORDER BY d.ID'; lSQL := lSQL + ' ORDER BY d.ID';
lQry:= TFDQuery.Create(nil); lQry := TFDQuery.Create(nil);
lQry2:= TFDQuery.Create(nil);
// lQry2.Connection:= sqlConnX;
try try
lQry.Connection:= sqlConnX; // lQry.Connection:= sqlConnX;
lQry.ConnectionName := sqlPoolName;
lQry2.ConnectionName := sqlPoolName;
lQry.Open(lSQL); lQry.Open(lSQL);
lQry.First; lQry.First;
inProg:= true; inProg := true;
while not(lQry.EOF) do while not(lQry.EOF) do
begin begin
idTask:= lQry.FieldByName('ID').asInteger; idTask := lQry.FieldByName('ID').asInteger;
canCont:= true; canCont := true;
lQry2:= TFDQuery.Create(nil); lQry2.Open ('SELECT COUNT(ID) AS Pocet FROM dbo._hdc_ph_Log WITH(NOLOCK) WHERE IntValue=' + idTask.ToString + ' AND LogText LIKE N''%Zpracova%''');
lQry2.Connection:= sqlConnX;
lQry2.Open('SELECT COUNT(ID) AS Pocet FROM dbo._hdc_ph_Log WITH(NOLOCK) WHERE IntValue=' + idTask.ToString + ' AND LogText LIKE N''%Zpracova%''');
lQry2.First; lQry2.First;
cnt:= lQry2.FieldByName('Pocet').AsInteger; cnt := lQry2.FieldByName('Pocet').AsInteger;
FreeAndNil(lQry2);
if (cnt>3) then if (cnt>3) then
canCont:= false; canCont:= false;
if (canCont) then if (canCont) then
begin begin
lQry2.ExecSQL('INSERT dbo._hdc_ph_Log (IntValue, LogText) SELECT ' + idTask.ToString + ', N''Zpracovani API json''');
sqlConnX.ExecSQL('INSERT dbo._hdc_ph_Log (IntValue, LogText) SELECT ' + idTask.ToString + ', N''Zpracovani API json''');
datMod.LogInfo (Quick.Logger.etInfo, 'Zpracovani prijatych JSON dat - idTask ' + idTask.ToString); datMod.LogInfo (Quick.Logger.etInfo, 'Zpracovani prijatych JSON dat - idTask ' + idTask.ToString);
// LogInfo(Quick.Logger.etError, 'Zpracovani PrijataJSONData ID ' + idTask.ToString); // LogInfo(Quick.Logger.etError, 'Zpracovani PrijataJSONData ID ' + idTask.ToString);
try try
sqlConnX.ExecSQL('UPDATE ' + tblPrijataJsonData + ' SET Blokovano=1 WHERE ID=' + idTask.ToString); lQry2.ExecSQL('UPDATE ' + tblPrijataJsonData + ' SET Blokovano=1 WHERE ID=' + idTask.ToString);
lSQL:= ''; lSQL:= '';
{$IFDEF DEBUG} {$IFDEF DEBUG}
Write ('Zpracovani prijateho JSON id ' + idTask.ToString); Write ('Zpracovani prijateho JSON id ' + idTask.ToString);
@ -559,8 +559,8 @@ uses
{$ELSE} {$ELSE}
lSQL:= lSQL + 'IF OBJECT_ID(N''dbo.ep_HDCDZApi_ZpracujPrijataData'', N''P'') IS NOT NULL' + CRLF + ' EXEC dbo.ep_HDCDZApi_ZpracujPrijataData @idJson=' + idTask.ToString; lSQL:= lSQL + 'IF OBJECT_ID(N''dbo.ep_HDCDZApi_ZpracujPrijataData'', N''P'') IS NOT NULL' + CRLF + ' EXEC dbo.ep_HDCDZApi_ZpracujPrijataData @idJson=' + idTask.ToString;
{$ENDIF} {$ENDIF}
sqlConnX.ExecSQL(lSQL); lQry2.ExecSQL(lSQL);
sqlConnX.ExecSQL('UPDATE ' + tblPrijataJsonData + ' SET PosledniChyba=NULL WHERE ID=' + idTask.ToString); lQry2.ExecSQL('UPDATE ' + tblPrijataJsonData + ' SET PosledniChyba=NULL WHERE ID=' + idTask.ToString);
{$IFDEF DEBUG} {$IFDEF DEBUG}
Writeln(' - OK'); Writeln(' - OK');
@ -572,7 +572,7 @@ uses
{$IFDEF DEBUG} {$IFDEF DEBUG}
WriteLn ('Chyba zpracovani prijateho JSON id ' + idTask.ToString + ' >> ' + errMsg); WriteLn ('Chyba zpracovani prijateho JSON id ' + idTask.ToString + ' >> ' + errMsg);
{$ENDIF} {$ENDIF}
sqlConnX.ExecSQL('UPDATE ' + tblPrijataJsonData + ' SET PosledniChyba=N' + errMsg.QuotedString + ' WHERE ID=' + idTask.ToString); lQry2.ExecSQL('UPDATE ' + tblPrijataJsonData + ' SET PosledniChyba=N' + errMsg.QuotedString + ' WHERE ID=' + idTask.ToString);
{$IFDEF CUSTOM_CTRL_Rootvin} {$IFDEF CUSTOM_CTRL_Rootvin}
datMod.LogInfo (Quick.Logger.etError, 'Chyba evidence start/stop operace PrijataJSONData ID ' + idTask.ToString + ' : ' + errMsg); datMod.LogInfo (Quick.Logger.etError, 'Chyba evidence start/stop operace PrijataJSONData ID ' + idTask.ToString + ' : ' + errMsg);
{$ELSE} {$ELSE}
@ -580,19 +580,21 @@ uses
{$ENDIF} {$ENDIF}
end; end;
end; end;
sqlConnX.ExecSQL('UPDATE ' + tblPrijataJsonData + ' SET Blokovano=0 WHERE ID=' + idTask.ToString); lQry2.ExecSQL('UPDATE ' + tblPrijataJsonData + ' SET Blokovano=0 WHERE ID=' + idTask.ToString);
end; end;
lQry.Next; lQry.Next;
end; end;
finally finally
lQry2.Close;
FreeAndNil (lQry2);
lQry.Close; lQry.Close;
FreeAndNil (lQry); FreeAndNil (lQry);
end; end;
inProg:= false; inProg:= false;
end; // sql Connected end; // sql Connected
sqlConnX.Close; if Assigned(sqlConnx) then
FreeAndNil (sqlConnX); sqlConnX.Free;
end; end;
end; end;

2
ukazBlokovanePorty.cmd Normal file
View File

@ -0,0 +1,2 @@
@echo off
netsh interface ipv4 show excludedportrange protocol=tcp