AdoImpl_2.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /*************************************************************
  2. /* Copyright (C), 2014-2020, lyfz. Co., Ltd.
  3. /* 文件名: AdoImpl.h
  4. /* 作者: Jeff.w
  5. /* 创建日期: 2014-08-16
  6. /* 版本号: V1.0
  7. /* 描述: 核心层底,数据库ADO编程
  8. /* 其它:
  9. /* 主要类模块:
  10. /* 历史修改记录:
  11. /* 作者 时间 版本 描述
  12. /* Jeff.w 14/08/18 1.0 创建这个模块
  13. ***************************************************************/
  14. #ifndef __ADO_IMPL_HEADER__
  15. #define __ADO_IMPL_HEADER__
  16. #pragma once
  17. //#include <list>//随存随取,使用vector比较好;
  18. #include <vector>
  19. using namespace std;
  20. #include "AdoDef.h"
  21. #include "ADODatabase.h"
  22. #include "ADORecordset.h"
  23. #include "ADOCommand.h"
  24. typedef struct tbl_dindan
  25. {
  26. TString _id;
  27. TString _money1;
  28. TString _money2;
  29. TString _money3;
  30. TString _name1;
  31. TString _name2;
  32. TString _taoxiid;
  33. TString _taoxiname;
  34. TString _taoxijiage;
  35. TString _taoxizs;
  36. TString _time1;
  37. TString _time2;
  38. TString _time3;
  39. TString _bm;
  40. TString _ren;
  41. TString _discount;
  42. TString _payed1;
  43. TString _payed2;
  44. TString _payed3;
  45. TString _payed4;
  46. TString _payed5;
  47. TString _time4;
  48. TString _time5;
  49. TString _takezs;
  50. TString _choosezs;
  51. TString _status;
  52. TString _clothescount2;
  53. TString _outside2;
  54. TString _style;
  55. TString _payed3time;
  56. TString _payed4ren;
  57. TString _payed4time;
  58. TString _status2;
  59. TString _status3;
  60. TString _waiter1;
  61. TString _waiter2;
  62. TString _waiter3;
  63. TString _waiter4;
  64. TString _bz;
  65. TString _taketime;
  66. TString _clothescount;
  67. TString _outside;
  68. TString _bz2;
  69. TString _bz3;
  70. TString _urgent;
  71. TString _status4;
  72. TString _status5;
  73. TString _waiter5;
  74. TString _waiter6;
  75. TString _pinyin1;
  76. TString _pinyin2;
  77. TString _waiter7;
  78. TString _status6;
  79. TString _phone1;
  80. TString _phone2;
  81. TString _status7;
  82. TString _memberno;
  83. TString _waiter8;
  84. TString _time6;
  85. TString _status8;
  86. TString _bruncount;
  87. TString _tichenren1;
  88. TString _tichenren2;
  89. TString _tichenren3;
  90. TString _tichenren4;
  91. TString _tichenren5;
  92. TString _send1;
  93. TString _send2;
  94. TString _send3;
  95. TString _datetime4;
  96. TString _datetime5;
  97. TString _datetime6;
  98. TString _waiter12;
  99. TString _waiter13;
  100. TString _waiter14;
  101. TString _waiter22;
  102. TString _waiter23;
  103. TString _waiter24;
  104. TString _waiter1rate;
  105. TString _waiter12rate;
  106. TString _waiter13rate;
  107. TString _waiter14rate;
  108. TString _waiter2rate;
  109. TString _waiter22rate;
  110. TString _waiter23rate;
  111. TString _waiter24rate;
  112. TString _ren2;
  113. TString _renrate;
  114. TString _ren2rate;
  115. TString _txtype;
  116. TString _delphotos;
  117. TString _delphotos2;
  118. TString _growthtxselname;
  119. TString _designno;
  120. TString _designreplaceno;
  121. TString _size;
  122. TString _dindantype;
  123. TString _contractno1;
  124. TString _contractno2;
  125. TString _cfno;
  126. TString _calldate;
  127. TString _from;
  128. TString _reason;
  129. TString _time7;
  130. TString _time8;
  131. TString _time9;
  132. TString _time10;
  133. TString _authorize;
  134. TString _discount2;
  135. TString _authorize2;
  136. TString _bz4;
  137. int _satisfaction1;
  138. int _satisfaction2;
  139. int _satisfaction3;
  140. int _satisfaction4;
  141. int _satisfaction5;
  142. int _satisfaction6;
  143. int _satisfaction7;
  144. TString _bz5;
  145. int _send4;
  146. int _send5;
  147. TString _waiter9;
  148. TString _curno;
  149. TString _xplrr;
  150. TString _xplrtime;
  151. int _satisfaction8;
  152. TString _visitpeople1;
  153. TString _visitpeople2;
  154. TString _visitpeople3;
  155. TString _visitpeople4;
  156. TString _visitpeople5;
  157. TString _visitpeople6;
  158. TString _visitpeople7;
  159. TString _visitpeople8;
  160. TString _visittime1;
  161. TString _visittime2;
  162. TString _visittime3;
  163. TString _visittime4;
  164. TString _visittime5;
  165. TString _visittime6;
  166. TString _visittime7;
  167. TString _visittime8;
  168. }Tbl_dindan, *pTbl_dindan;
  169. typedef struct tbl_IncrementalBackup
  170. {
  171. bool _isbackup;
  172. TString _branchid;
  173. TString _opttime;
  174. TString _order;
  175. int _phototype;
  176. TString _content;
  177. TString _userid;
  178. TString _username;
  179. TString _baktime;
  180. }Tbl_IncrementalBackup,*pTbl_IncrementalBackup;
  181. // 声明回调函数;
  182. typedef int (CALLBACK *RecordsetCallback)(IN const DWORD& dwCallBackType, IN LPVOID lpParamter, IN const int& nRecordCount, IN CADORecordset* pRet);
  183. // Jeff.一个数据库只有一个AdoImpl实例;
  184. // 该类使用线程,监测线程的作用是判断数据库是否断开并重连;
  185. // 未对二进制文件支持操作;
  186. class AdoImpl
  187. {
  188. CString m_strQuery;
  189. CString m_strLastError;
  190. DWORD m_dwLastError;
  191. inline CString GetQuery() {return m_strQuery;};
  192. inline void SetQuery(LPCSTR strQuery) {m_strQuery = strQuery;};
  193. private:
  194. CRITICAL_SECTION m_csAdo;
  195. TCHAR m_szConnectString[1024];// 暂使用1024魔数,后期升级再定义;
  196. CADODatabase *m_pADODatabase;
  197. BOOL OpenADORecordSet(IN CADORecordset *pRSet, IN LPCTSTR lpSQL);
  198. void CloseADORecordSet(IN CADORecordset* pRSet);
  199. void DeleteADORecordSet(IN CADORecordset* pRSet);
  200. public:
  201. AdoImpl(void);
  202. virtual ~AdoImpl(void);
  203. void dump_com_error(_com_error &e);
  204. void SetConnectString(
  205. IN const int &nType,
  206. IN LPCTSTR lpDataSource,
  207. IN LPCTSTR lpDatabaseTCPPort,
  208. IN LPCTSTR lpDatabaseAccount,
  209. IN LPCTSTR lpDatabasePassWord,
  210. IN LPCTSTR lpDatabaseName,
  211. IN LPCTSTR lpDatabaseFile = NULL);
  212. BOOL IsOpen();
  213. BOOL Opendatabase(IN LPCTSTR lpConnectString = NULL);
  214. void Closedatabase();
  215. int Execute(IN LPCTSTR lpSQL);//不返回记录集;
  216. bool GetADODateBaseStatus();
  217. CADODatabase *GetAdoDatabase(){return m_pADODatabase;};
  218. // 应用层接口;
  219. public:
  220. DWORD GetTableRecordCount(IN LPCTSTR lpTableName, IN LPCTSTR lpFilters); // 返回要查询的表的记录数;
  221. // 使用回调函数来处理具体的数据;
  222. int GetFieldValueList(IN LPCTSTR lpTableName, IN LPCTSTR lpFields, IN LPCTSTR lpFilters, IN const DWORD &dwCallBackType,IN LPVOID lpCallBack, IN OUT LPVOID lpParamter);
  223. // 其他类型;
  224. int GetFieldValueList(IN LPCTSTR lpTableName, IN LPCTSTR lpFilters, IN LPCTSTR lpSql, OUT INT &nFieldCount, __out vector<TString>& vtRet); // 此函数不支持2进制文件的select;
  225. int GetFieldValueList(IN LPCTSTR lpTableName, IN LPCTSTR lpSql, OUT int &nFieldCount, OUT CArray<CStringArray,CStringArray>& strArray);
  226. int GetClientServiceViewData(IN LPCTSTR lpSql, OUT CArray<CStringArray,CStringArray>& strArray,IN LPCTSTR lpFilters=NULL);
  227. int GetTbl_dindan_Values(IN LPCTSTR lpTableName, IN LPCTSTR lpFilters, IN LPCTSTR lpSql, INT &nFieldCount, OUT vector<TString>& vtRet);
  228. int GetTbl_dindan_Values(IN LPCTSTR lpTableName, IN LPCTSTR lpFilters, IN LPCTSTR lpSql, INT &nFieldCount, OUT vector<Tbl_dindan>& vtRet);
  229. int GetTbl_IncrementalBackup_Values(IN LPCTSTR lpTableName, IN LPCTSTR lpFilters, IN LPCTSTR lpSql, INT &nFieldCount, OUT vector<Tbl_IncrementalBackup>& vtRet);
  230. };
  231. #endif