#pragma once #include #include "stdafx.h" #include "../sqlite/CppSQLite3.h" class LOCK_GUARD { public: LOCK_GUARD(RTL_CRITICAL_SECTION&cs) :rcs(cs){ ::EnterCriticalSection(&rcs); } ~LOCK_GUARD(){ ::LeaveCriticalSection(&rcs); } private: RTL_CRITICAL_SECTION& rcs; }; class CDataBaseService { public: CDataBaseService(void); ~CDataBaseService(void); void SetDataBasePath(const wstring& _indexdbpath, const wstring& _batchdbpath, const wstring& _sharefilename, const wstring& _sharefilepath, const wstring& _workpath); bool InsertPapers(vector& list_papers); bool InsertIndex(int total_cnt, int& last_id); bool InsertBatchFail(int state, int zipfile_cnt); bool InsertBatchInfo(); void LoadUnhandleBatch(const wstring& _indexdbpath, vector& vct); void GetBatchCount(const wstring& _indexdbpath, int batch_id, int& cnt); void UpdateBatchSchemaErro(const wstring& _indexdbpath, int batch_id); private: bool OpenIndexDB(); bool OpenBatchDB(); CppSQLite3DB m_indexdb; CppSQLite3DB m_batchdb; wstring m_strIndexDBPath; wstring m_strBatchDBPath; wstring m_strShareFileName; wstring m_strShareFilePath; wstring m_strWorkPath; RTL_CRITICAL_SECTION db_lock; };