DataBaseService.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include <afxwin.h>
  3. #include "stdafx.h"
  4. #include "../sqlite/CppSQLite3.h"
  5. class LOCK_GUARD
  6. {
  7. public:
  8. LOCK_GUARD(RTL_CRITICAL_SECTION&cs) :rcs(cs){ ::EnterCriticalSection(&rcs); }
  9. ~LOCK_GUARD(){ ::LeaveCriticalSection(&rcs); }
  10. private:
  11. RTL_CRITICAL_SECTION& rcs;
  12. };
  13. class CDataBaseService
  14. {
  15. public:
  16. CDataBaseService(void);
  17. ~CDataBaseService(void);
  18. void SetDataBasePath(const wstring& _indexdbpath, const wstring& _batchdbpath,
  19. const wstring& _sharefilename, const wstring& _sharefilepath, const wstring& _workpath);
  20. bool InsertPapers(vector<string>& list_papers);
  21. bool InsertIndex(int total_cnt, int& last_id);
  22. bool InsertBatchFail(int state, int zipfile_cnt);
  23. bool InsertBatchInfo();
  24. void LoadUnhandleBatch(const wstring& _indexdbpath, vector<int>& vct);
  25. void GetBatchCount(const wstring& _indexdbpath, int batch_id, int& cnt);
  26. void UpdateBatchSchemaErro(const wstring& _indexdbpath, int batch_id);
  27. private:
  28. bool OpenIndexDB();
  29. bool OpenBatchDB();
  30. CppSQLite3DB m_indexdb;
  31. CppSQLite3DB m_batchdb;
  32. wstring m_strIndexDBPath;
  33. wstring m_strBatchDBPath;
  34. wstring m_strShareFileName;
  35. wstring m_strShareFilePath;
  36. wstring m_strWorkPath;
  37. RTL_CRITICAL_SECTION db_lock;
  38. };