Priprava na init poolingu uz ve WinService + do TBaseController dat jen FConn a na to okazovat dal
This commit is contained in:
@@ -59,53 +59,54 @@ uses
|
||||
w: TStreamWriter;
|
||||
jo: System.JSON.TJsonObject;
|
||||
begin
|
||||
idJSON:= 0;
|
||||
respString:= '[';
|
||||
idJSON := 0;
|
||||
respString := '[';
|
||||
|
||||
jo:= System.JSON.TJsonObject.Create;
|
||||
jo := System.JSON.TJsonObject.Create;
|
||||
|
||||
jsonData:= jsonData.Trim;
|
||||
jsonData := jsonData.Trim;
|
||||
if (jsonData<>'') then
|
||||
begin
|
||||
lQry:= TFDQuery.Create(nil);
|
||||
lQry := TFDQuery.Create(nil);
|
||||
try
|
||||
lQry.Connection:= FDM.sqlConn;
|
||||
lQry.Connection := FDM.sqlConn;
|
||||
try
|
||||
CoCreateGuid(guid);
|
||||
if (System.SysUtils.CreateGUID(guid)=S_OK) then
|
||||
guidIdent:= System.SysUtils.GUIDToString(guid)
|
||||
guidIdent := System.SysUtils.GUIDToString(guid)
|
||||
else
|
||||
guidIdent:= self.NewUUID32;
|
||||
lSQL:= 'INSERT ' + tblPrijataJsonData + ' (IdPHIdent, GUIDIdent, JSONData) SELECT 0, CONVERT(uniqueidentifier, N' + guidIdent.QuotedString + '), N' + jsonData.QuotedString;
|
||||
FDM.sqlConn.ExecSQL(lSQL);
|
||||
lSQL:= 'SELECT ID FROM ' + tblPrijataJsonData + ' WHERE GUIDIdent=CONVERT(uniqueidentifier, N' + guidIdent.QuotedString + ')';
|
||||
lQry.Open(lSQL);
|
||||
guidIdent := self.NewUUID32;
|
||||
lSQL := 'INSERT ' + tblPrijataJsonData + ' (IdPHIdent, GUIDIdent, JSONData) SELECT 0, CONVERT(uniqueidentifier, N' + guidIdent.QuotedString + '), N' + jsonData.QuotedString;
|
||||
FDM.sqlConn.ExecSQL (lSQL);
|
||||
lSQL := 'SELECT ID FROM ' + tblPrijataJsonData + ' WHERE GUIDIdent=CONVERT(uniqueidentifier, N' + guidIdent.QuotedString + ')';
|
||||
lQry.Open (lSQL);
|
||||
if (lQry.RecordCount=1) then
|
||||
begin
|
||||
idJSON:= lQry.FieldByName('ID').AsInteger;
|
||||
respString:= 'OK';
|
||||
jo.AddPair('heliosid', idJSON.ToString);
|
||||
idJSON := lQry.FieldByName('ID').AsInteger;
|
||||
respString := 'OK';
|
||||
jo.AddPair ('heliosid', idJSON.ToString);
|
||||
end;
|
||||
except on E:Exception do
|
||||
begin
|
||||
respString:= 'NOT OK';
|
||||
respString := 'NOT OK';
|
||||
raise EServiceException.Create('Chyba zápisu JSON dat: ' + E.Message);
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
FreeAndNil(lQry);
|
||||
lQry.Close;
|
||||
lQry.Free;
|
||||
end;
|
||||
|
||||
|
||||
CoInitialize(nil);
|
||||
j:= TJsonObject.Parse(jsonData) as JsonDataObjects.TJsonObject;
|
||||
CoInitialize (nil);
|
||||
j := TJsonObject.Parse(jsonData) as JsonDataObjects.TJsonObject;
|
||||
try
|
||||
if (j<>nil) then
|
||||
if (j.Contains('akce')) then
|
||||
begin
|
||||
akce:= j.S['akce'].Trim;
|
||||
akce := j.S['akce'].Trim;
|
||||
if (idJSON>0) and (akce<>'') then
|
||||
FDM.sqlConn.ExecSQL('UPDATE ' + tblPrijataJsonData + ' SET Akce=N' + akce.QuotedString + ' WHERE ID=' + idJSON.ToString);
|
||||
FDM.sqlConn.ExecSQL ('UPDATE ' + tblPrijataJsonData + ' SET Akce=N' + akce.QuotedString + ' WHERE ID=' + idJSON.ToString);
|
||||
{
|
||||
for i:=0 to j['tasks'].Count-1 do
|
||||
begin
|
||||
@@ -125,12 +126,12 @@ uses
|
||||
|
||||
end
|
||||
else
|
||||
respString:= 'NO input data';
|
||||
respString := 'NO input data';
|
||||
|
||||
jo.AddPair('status', respString);
|
||||
respString:= '[' +respString + ']';
|
||||
jo.AddPair ('status', respString);
|
||||
respString := '[' +respString + ']';
|
||||
|
||||
respString:= jo.ToString;
|
||||
respString := jo.ToString;
|
||||
|
||||
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user