try
SP_DOC_QUEUE_PROCESS.Close;
SP_DOC_QUEUE_PROCESS.ParamByName('Id').AsInteger := Id;
SP_DOC_QUEUE_PROCESS.ExecProc; // <--- hier hängt er bei einer
exception
If SP_DOC_QUEUE_PROCESS.ParamByName('Error_Code').AsInteger <> 0 Then
Raise EDatabaseError.Create('ErrorCode: ' + SP_DOC_QUEUE_PROCESS.ParamByName('Error_Code').AsString
+ #13#10 + Trim(SP_DOC_QUEUE_PROCESS.ParamByName('Error_Msg').AsString));
DBConnection.CommitFreeAndNil(TD);
RemoveFromQueue(Id);
QR.Close;
QR.SQL.Text := 'SELECT COUNT(Id) FROM Doc_Queue';
QR.Open;
FbDoCheckQueue := (QR.Fields[0].AsInteger > 0);
DocsInCola := QR.Fields[0].AsInteger;
QR.Close;
DoInformProcessDone(Clase, E, S, Tipo, Numero, TipoOp, DocsInCola); // sends message to mainthread
except
on Ex:
Exception do begin
DBConnection.RollbackFreeAndNil(TD);
CodeSite.Send(csmLevel1, 'Error processing document', Ex.Message);
Inc(CE);
If CE >= 5 Then begin
CreateNotification(E, S, Tipo, Numero, UserId, TipoOp, Ex.Message);
RemoveFromQueue(Id);
DoNotifyUserError(UserId, Ex.Message);
end else begin
RemoveFromQueue(Id); // remove it from the first place
InsertIntoQueue(E, S, Tipo, Numero, TipoOp, UserId, CE, RC); // and insert it at the end again
end;
FbDoCheckQueue := True;
end;