RunHttpPost_insertIsException.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "RunHttpPost_insertIsException.h"
  2. #include "../user/config.h"
  3. extern config *pconfig;
  4. RunHttpPost_insertIsException::RunHttpPost_insertIsException(InteractiveTask *task, QMutex *mutex)
  5. :RunAbstract(task, mutex)
  6. {
  7. }
  8. void RunHttpPost_insertIsException::run()
  9. {
  10. InteractiveData *pSingletonData = SINGLETON_CREATE(InteractiveData)();
  11. QReadLocker locker(&pSingletonData->m_dataCacheLock);
  12. QString inData = getRequest().toString();
  13. QJsonParseError error;
  14. QJsonDocument jsonDocRead = QJsonDocument::fromJson(inData.toUtf8());
  15. QJsonDocument jsonDocWrite;
  16. if (error.error == QJsonParseError::NoError)
  17. {
  18. QJsonObject jsonObjRoot = jsonDocRead.object();
  19. QString exceptionTypeName = jsonObjRoot.value("exceptionTypeName").toString();
  20. QString exceptionLevelName = jsonObjRoot.value("exceptionLevelName").toString();
  21. QString exceptionDescription = jsonObjRoot.value("exceptionDescription").toString();
  22. jsonObjRoot.insert("exceptionCategory", "2");
  23. jsonObjRoot.insert("raiser", pconfig->userId.toInt());
  24. for (auto it = pSingletonData->m_dataCacheExceptionTypeDictLabel.begin(); it != pSingletonData->m_dataCacheExceptionTypeDictLabel.end(); ++it)
  25. {
  26. if (it.value() == exceptionTypeName)
  27. {
  28. jsonObjRoot.insert("exceptionType", pSingletonData->m_dataCacheExceptionTypeDictValue[it.key()]);
  29. }
  30. }
  31. for (auto it = pSingletonData->m_dataCacheSeverityLevelDictLabel.begin(); it != pSingletonData->m_dataCacheSeverityLevelDictLabel.end(); ++it)
  32. {
  33. if (it.value() == exceptionLevelName)
  34. {
  35. jsonObjRoot.insert("exceptionLevel", pSingletonData->m_dataCacheSeverityLevelDictValue[it.key()]);
  36. }
  37. }
  38. if (!pconfig->devId.isEmpty())
  39. {
  40. jsonObjRoot.insert("sourceId", pconfig->devId);
  41. }
  42. jsonDocWrite.setObject(jsonObjRoot);
  43. }
  44. QByteArray json = jsonDocWrite.toJson(QJsonDocument::Compact);
  45. QByteArray outData = InteractiveHttp::http_post_insertIsException(json);
  46. setRespond(outData);
  47. }