UploadManager.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. #include <thread>
  3. #include <atomic>
  4. #include <mutex>
  5. struct UploadProcess;
  6. struct ScanParamInfo
  7. {
  8. std::string bantch_code;
  9. std::string exam_id;
  10. std::string exam_name;
  11. std::string course_name;
  12. std::string subject_id;
  13. };
  14. //type:0,答卷;1,原卷,2,异常
  15. //MY_UPLOAD_REV_INFO*
  16. struct IUploudNotify{
  17. virtual void OnUploadNotify(int type, void*data) = 0;
  18. virtual void OnScanListFilter(int paper_id) = 0;
  19. };
  20. class CBatchService;
  21. class UploadManager
  22. {
  23. public:
  24. UploadManager();
  25. ~UploadManager();
  26. // bEanble 是否启用边扫描变上传模式 bCountiue 是否继续上一次的 pNotify 通知消息回调
  27. bool Init(bool bEanble, bool bCountiue, bool bErrorHanle, bool bOnlineCard, int nSubjectID, IUploudNotify*pNotify, CppSQLite3DB*rst_db, RTL_CRITICAL_SECTION*rst_db_lock);
  28. void ScanListFilter(bool bSuccess, int nUploadState);
  29. int UploadOnScanCmd(int nCmd, const char*param, int nOnlineScanType=-1, void*ret = nullptr);
  30. bool IsEanble(){ return m_bEnable; }
  31. bool IsContinue(){ return m_bCoutinue; }
  32. int GetPaperUploadState(int paper_id,char*szErrorInfo,int nLen);
  33. void OnNetNotify(const char*param);
  34. void OnReConnect(bool bSuccess);
  35. void OnTcpError();
  36. void SetBatchCode(const std::string &code){ m_bantch_code = code; }
  37. bool IsZXHXCreateUploadDBSuccess(){ return m_zxhxCreateUploadDBSuccess; }
  38. void SetNotifyPtr(IUploudNotify*pNotify){ m_pNotify = pNotify; }
  39. CBatchService* m_pBatchService;
  40. protected:
  41. virtual void OnUploadNotify(int type, void*data);
  42. virtual void OnScanListFilter(int paper_id);
  43. bool OpenDB(bool bCountiue);
  44. void Stop();
  45. void Continue();
  46. void Suspend();
  47. void ScanListFilterThread(bool bSuccess, int nUploadState);
  48. void UploadYichangjuan();
  49. void UploadSuccessjuan(int student_paper_id);
  50. void ReUploadUploadError(const char*param);
  51. void NotifyScanProcess(UploadProcess*pRt=nullptr);
  52. void NotifyUploadOnScanStop();
  53. void NotifyEnd();
  54. void SendUploadTaskWhenReConnected();
  55. private:
  56. CppSQLite3DB upload_db;
  57. RTL_CRITICAL_SECTION upload_db_lock;
  58. CppSQLite3DB *result_db;
  59. RTL_CRITICAL_SECTION *result_db_lock;
  60. IUploudNotify*m_pNotify;
  61. std::thread m_thread;
  62. std::atomic<bool> m_bExit;
  63. bool m_bEnable;
  64. std::atomic<bool> m_bScanStopFlag;
  65. std::atomic<bool> m_bScanStartFlag;
  66. bool m_bOnlineCard;
  67. bool m_bCoutinue;
  68. std::mutex m_tx_pre_paperid;
  69. std::vector<int> m_vctPrePaperid;
  70. bool m_bSendUploadRstToZHXH;
  71. int m_nSubjectID;
  72. std::atomic<bool> m_zxhxCreateUploadDBSuccess;
  73. std::string m_bantch_code;
  74. std::string m_strStartParam;
  75. };