ImgUploader.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include "scan_common.h"
  3. #include "DataBaseManagerHolder.h"
  4. #include "basic_struct.h"
  5. #include "ImageUploadWorker.h"
  6. using namespace std;
  7. class CImgUploader : public IService, public CDataBaseManagerHolder
  8. {
  9. enum IMG_UPLOAD_STATE{
  10. //正在打开下一个批次的数据库
  11. IMG_UPLOAD_STATE_OPENNING,
  12. //正在准备
  13. IMG_UPLOAD_STATE_READYING,
  14. //正在上传
  15. IMG_UPLOAD_STATE_UPLOADING,
  16. //正在关闭当前打开的数据库
  17. IMG_UPLOAD_STATE_CLOSING,
  18. //当前数据库已经关闭
  19. IMG_UPLOAD_STATE_CLOSED,
  20. };
  21. struct paper_info{
  22. string file_name;
  23. int paper_id;
  24. string paper_code;
  25. string student_code;
  26. int student_id;
  27. string student_name;
  28. };
  29. enum{
  30. UPLOAD_WORKER_COUNT = 6,
  31. UPLOAD_TASK_BUFFER_COUNT = (UPLOAD_WORKER_COUNT + 1)
  32. };
  33. public:
  34. CImgUploader(void);
  35. ~CImgUploader(void);
  36. int QueryUploadePaperImg(vector<IMG_UPLOAD_TASK>& tasks);
  37. int SetHandlerWnd(HWND hwnd);
  38. int ClearUploadedPaperImg();
  39. int GetCurrentUploadTaskInfo(IMG_UPLOAD_TASK& task);
  40. protected:
  41. virtual ServiceState OnStarting(void);
  42. virtual ServiceState OnRunning(void);
  43. void handleCompleteTask();
  44. private:
  45. CString m_url;
  46. CString m_urlDeletePaperBatch;
  47. IMG_UPLOAD_STATE m_current_database_state;
  48. //表示上传线程是否在上传
  49. BOOL m_uploading;
  50. CppSQLite3DB bantch_db;
  51. int m_last_paper_id;
  52. BOOL m_current_has_more;
  53. HWND m_hwnd;
  54. IMG_UPLOAD_TASK m_task_info;
  55. CString m_school_id;
  56. CString m_bantch_dir;
  57. CImageUploadWorker worker[UPLOAD_WORKER_COUNT];
  58. CUploadTask taskBuffer[UPLOAD_TASK_BUFFER_COUNT];
  59. // Logger pTestLogger;
  60. };