#pragma once #include #include #include struct UploadProcess; struct ScanParamInfo { std::string bantch_code; std::string exam_id; std::string exam_name; std::string course_name; std::string subject_id; }; //type:0,答卷;1,原卷,2,异常 //MY_UPLOAD_REV_INFO* struct IUploudNotify{ virtual void OnUploadNotify(int type, void*data) = 0; virtual void OnScanListFilter(int paper_id) = 0; }; class CBatchService; class UploadManager { public: UploadManager(); ~UploadManager(); // bEanble 是否启用边扫描变上传模式 bCountiue 是否继续上一次的 pNotify 通知消息回调 bool Init(bool bEanble, bool bCountiue, bool bErrorHanle, bool bOnlineCard, int nSubjectID, IUploudNotify*pNotify, CppSQLite3DB*rst_db, RTL_CRITICAL_SECTION*rst_db_lock); void ScanListFilter(bool bSuccess, int nUploadState); int UploadOnScanCmd(int nCmd, const char*param, int nOnlineScanType=-1, void*ret = nullptr); bool IsEanble(){ return m_bEnable; } bool IsContinue(){ return m_bCoutinue; } int GetPaperUploadState(int paper_id,char*szErrorInfo,int nLen); void OnNetNotify(const char*param); void OnReConnect(bool bSuccess); void OnTcpError(); void SetBatchCode(const std::string &code){ m_bantch_code = code; } bool IsZXHXCreateUploadDBSuccess(){ return m_zxhxCreateUploadDBSuccess; } void SetNotifyPtr(IUploudNotify*pNotify){ m_pNotify = pNotify; } CBatchService* m_pBatchService; protected: virtual void OnUploadNotify(int type, void*data); virtual void OnScanListFilter(int paper_id); bool OpenDB(bool bCountiue); void Stop(); void Continue(); void Suspend(); void ScanListFilterThread(bool bSuccess, int nUploadState); void UploadYichangjuan(); void UploadSuccessjuan(int student_paper_id); void ReUploadUploadError(const char*param); void NotifyScanProcess(UploadProcess*pRt=nullptr); void NotifyUploadOnScanStop(); void NotifyEnd(); void SendUploadTaskWhenReConnected(); private: CppSQLite3DB upload_db; RTL_CRITICAL_SECTION upload_db_lock; CppSQLite3DB *result_db; RTL_CRITICAL_SECTION *result_db_lock; IUploudNotify*m_pNotify; std::thread m_thread; std::atomic m_bExit; bool m_bEnable; std::atomic m_bScanStopFlag; std::atomic m_bScanStartFlag; bool m_bOnlineCard; bool m_bCoutinue; std::mutex m_tx_pre_paperid; std::vector m_vctPrePaperid; bool m_bSendUploadRstToZHXH; int m_nSubjectID; std::atomic m_zxhxCreateUploadDBSuccess; std::string m_bantch_code; std::string m_strStartParam; };