DBInterface.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. /*************************************************************
  2. /* Copyright (C), 2008-2010, StoneU Tech. Co., Ltd.
  3. /* 文件名: DBInterface.h
  4. /* 作者: Jesse
  5. /* 创建日期: 2010-08-02
  6. /* 版本号: V1.0
  7. /* 描述: 实现多种数据库的支持
  8. /* 其它:
  9. /* 主要类模块: CDBInterface
  10. /* 历史修改记录:
  11. 作者 时间 版本 描述
  12. Jesse 10/08/02 1.0 创建这个模块
  13. ***************************************************************/
  14. #ifndef _DB_INTERFACE_H
  15. #define _DB_INTERFACE_H
  16. namespace DBInterface
  17. {
  18. const int MAX_DB_TYPE = 255;
  19. /*************************************************
  20. /* 类名
  21. /* {
  22. /* 构造函数;
  23. /* 析构函数;
  24. /* 提供全局访问函数;
  25. /* 静态类指针变量;
  26. /* 数据库类型成员变量;
  27. /*
  28. /* }
  29. **************************************************/
  30. class CDBInterface
  31. {
  32. public:
  33. CDBInterface()
  34. {
  35. };
  36. ~CDBInterface()
  37. {
  38. };
  39. void Release();
  40. // 静态成员函数,提供全局访问的接口
  41. static CDBInterface* GetInstancePtr();
  42. // 设置数据库类型
  43. void SetDBType(char *pDBType);
  44. //插入设备资料
  45. INT InsertDevInfo(int nID, CHAR *pUid, int nPort, int nAddr, CHAR *pDevName, int nDevTypeID,
  46. int nRate, int nDataBit, int nStopBit, int nParityBit, int nRsMode,
  47. CHAR *pIPAddr, int nIPPort, int nCommMode, int nDevFlag, int nSpecialDev,
  48. int nTimeout, int nIsuse, CHAR *pProtocalName, CHAR *pIniName,
  49. CHAR *pReserved1, CHAR *pReserved2, CHAR *pReserved3, CHAR *pReserved4, CHAR *pReserved5,
  50. CHAR *pReserved6, CHAR *pReserved7, CHAR *pReserved8, CHAR *pReserved9, CHAR *pReserved10,
  51. int nReserved1, int nReserved2, int nReserved3, int nReserved4, int nReserved5,
  52. int nReserved6, int nReserved7, int nReserved8, int nReserved9, int nReserved10,
  53. int bReserved1, int bReserved2, int bReserved3, int bReserved4, int bReserved5,
  54. int bReserved6, int bReserved7, int bReserved8, int bReserved9, int bReserved10);
  55. //修改设备资料
  56. INT EditDevInfo(CHAR *pOldUid, CHAR *pNewUid, int nPort, int nAddr, CHAR *pDevName, int nDevTypeID,
  57. int nRate, int nDataBit, int nStopBit, int nParityBit, int nRsMode,
  58. CHAR *pIPAddr, int nIPPort, int nCommMode, int nDevFlag, int nSpecialDev,
  59. int nTimeout, int nIsuse, CHAR *pProtocalName, CHAR *pIniName,
  60. CHAR *pReserved1, CHAR *pReserved2, CHAR *pReserved3, CHAR *pReserved4, CHAR *pReserved5,
  61. CHAR *pReserved6, CHAR *pReserved7, CHAR *pReserved8, CHAR *pReserved9, CHAR *pReserved10,
  62. int nReserved1, int nReserved2, int nReserved3, int nReserved4, int nReserved5,
  63. int nReserved6, int nReserved7, int nReserved8, int nReserved9, int nReserved10,
  64. int bReserved1, int bReserved2, int bReserved3, int bReserved4, int bReserved5,
  65. int bReserved6, int bReserved7, int bReserved8, int bReserved9, int bReserved10);
  66. //删除设备资料
  67. INT DeleteDevInfo(CHAR *pUid);
  68. //插入变量信息
  69. INT InsertVarInfo(int nID, int nDevTypeID,CHAR *pVarName,CHAR *pVarDesc,int nVarTypeID,int nMinValues,int nMaxValues,int nMaxConvtRate,int nMinConvtRate,
  70. int nCollectFreq,int bIsDDE,int nRegStartAddr,int nWaringLevel,CHAR *pSetValue,CHAR *pUnit,CHAR *pUid,CHAR *pRelatepage,int bRecCurve,int nRegNum,
  71. CHAR *pOnDesc,CHAR *pOffDesc,int nUpperLimit,int nLowerLimit,int nChildid,int nVarItemID,int nNormalState,CHAR *pFields,CHAR *pSnmpOid,int nRearm,
  72. int nOffset,int nFuncCode,int nDataLen,float fCoef,int bRealtimeFlag,int bIsSave,CHAR *pRs232Cmd,CHAR *pRs232Type,int nRs232Index,int nIdentifyTime,
  73. int nRedetectTime,int bIsNormalAlarm,int nPurview,
  74. CHAR *pReserved1,CHAR *pReserved2,CHAR *pReserved3,CHAR *pReserved4,CHAR *pReserved5,
  75. CHAR *pReserved6,CHAR *pReserved7,CHAR *pReserved8,CHAR *pReserved9,CHAR *pReserved10,
  76. int nReserved1,int nReserved2,int nReserved3,int nReserved4,int nReserved5,
  77. int nReserved6,int nReserved7,int nReserved8,int nReserved9,int nReserved10,
  78. int bReserved1,int bReserved2,int bReserved3,int bReserved4,int bReserved5,
  79. int bReserved6,int bReserved7,int bReserved8,int bReserved9,int bReserved10 );
  80. //插入数据记录
  81. INT InsertDataRecord(
  82. CHAR* pDevName, // 设备名称
  83. CHAR* pHappenTime, // 发生时间
  84. CHAR* pVarName, // 变量名称
  85. CHAR *pVarDesc, // 变量描述
  86. double dbCurrValue // 当前值
  87. );
  88. //获取设备类型ID
  89. INT GetDevTypeID( CHAR *pDevTypeName, CHAR *pDevTypeID );
  90. //获取指定厂家的设备型号ID
  91. INT GetDevTypeID( int nDriverID, int nFactoryID, CHAR *pDevTypeName, CHAR *pDevTypeID );
  92. //获取设备名称
  93. INT GetDevName( CHAR *pDevUID, CHAR *pDevName );
  94. //获取设备UID
  95. INT GetDevUID( CHAR *pDevName, CHAR *pDevUID );
  96. //获取表最大的ID, 通用函数
  97. INT GetMaxID( CHAR *pTableName, CHAR *pFieldName, CHAR *pMaxID );
  98. //获取驱动ID
  99. INT GetDevDriveID( CHAR *pDevDriverName, CHAR *pDevDriverID );
  100. //获取指定驱动的厂家ID
  101. INT GetDevFactoryID( int nDriverID, CHAR *pDevFactoryName, CHAR *pDevFactoryID );
  102. //根据UID查找同一类型设备的个数
  103. INT FindDevInfoByUID( CHAR *pUID, CHAR *pDevNum );
  104. //得到可以用的设备名称
  105. INT FindDevNameByName( CHAR *pName, CString &sDevName,int &nDevIndex );
  106. //得到时间计划
  107. INT GetDatePlan( int nPlanType, CHAR *pPlanID, unsigned char nBufDate[7][24] );
  108. //得到时间计划
  109. INT GetDatePlan( int nPlanType, CHAR *pUid, int nVarID, unsigned char nBufDate[7][24] );
  110. //删除原有的时间计划
  111. INT DeleteDatePlan( int nPlanType, CHAR *pPlanID );
  112. //删除原有的时间计划
  113. INT DeleteDatePlan( int nPlanType, CString strUid, int nVarID );
  114. //插入时间计划
  115. INT InsertDatePlan( int nPlanType, CHAR *pPlanID, int nStartHours, int nEndHours, int nStartWeek, int nEndWeek );
  116. //插入时间计划
  117. INT InsertDatePlan( int nPlanType, CString strUid, int nVarID, int nStartHours, int nEndHours, int nStartWeek, int nEndWeek );
  118. //获取系统支持所有的驱动类型
  119. INT GetDevDriveList( list<string>& list1, list<string>& list2 );
  120. //获取指定驱动的厂家资料
  121. INT GetDevFactoryList( int nDriverID, list<string>& list1, list<string>& list2 );
  122. //获取指定厂家的设备型号列表
  123. INT GetDevTypeList( int nDriverID, int nFactoryID, list<string>& list1, list<string>& list2 );
  124. //获取变量状态列表
  125. INT GetVarStatusList( CHAR *pVarUID, int nVarID, list<string>& list1, list<string>& list2 );
  126. //获取变量bit位的ID
  127. INT GetVarBitID( CHAR *pVarUID, int nStartBit, int nEndBit, CHAR *pVarBitID );
  128. //设置变量bit位的ID
  129. INT SetVarBitID( CHAR *pVarUID, int nStartBit, int nEndBit, int &nBitID );
  130. //获取变量类型
  131. INT GetVarTypeName( int nVarTypeID, CHAR *pVarTypeName );
  132. //获取功能码
  133. INT GetFuncCodeName( int nFuncID, CHAR *pFuncName );
  134. //获取变量ID
  135. INT GetVarID( CHAR *pVarName, CHAR *pVarID );
  136. //获取变量ID
  137. INT GetVarID( int nStartAddr, int nFuncCode, int nRegNum, CHAR *pVarID );
  138. //获取变量类型ID
  139. INT GetVarTypeID( CHAR *pVarTypeName, CHAR *pVarTypeID );
  140. //获取功能码ID
  141. INT GetFuncCodeID( CHAR *pFuncName, CHAR *pFuncID );
  142. //获取设备名称
  143. INT GetDevInfo( CHAR *pDevUID, CHAR *pDllName, CHAR *pIniName, CHAR *pDevProtocolType );
  144. //修改密码
  145. INT ModifyPwd(CHAR *pUserID, CHAR *pUserPwd);
  146. //验证用户名、密码是否合法
  147. INT ValidateUser(CHAR *pUserID, CHAR *pUserPwd);
  148. //验证用户是否启用
  149. INT ValidateUserEnable(CHAR *pUserID, CHAR *pStatus);
  150. //得到用户信息ID
  151. INT GetUserID( CHAR *pID, CHAR *pUserID );
  152. //判断用户是否管理设备权限
  153. INT HasDevAlloc( int iGroupID, CHAR *pUid );
  154. //删除设备权限信息
  155. INT DelUserDevInfo( int iGroupID );
  156. //添加设备权限信息
  157. INT AddUserDevInfo(int nID, int iGroupID, CHAR *pUid);
  158. //获取变量状态表ID
  159. INT GetVarStatusID( CHAR *pVarUID, int nVarID, int nStatusID, CHAR *pStatusDesc, CHAR *pID );
  160. //设置变量状态表ID
  161. INT SetVarStatusID( CHAR *pVarUID, int nVarID, int nStatusID, CHAR *pStatusDesc );
  162. INT AddGroupToDll();
  163. INT GetAllGroupToTree( CTreeCtrl *pTreeCtrl,HTREEITEM hRoot );
  164. INT AddGroup(int iID, CString sGroupName, CString sGroupDesc);
  165. INT ModifyGroup(CString sGroupName, CString sGroupDesc);
  166. INT DelGroup(int iGroupID);
  167. //得到組的ID通過組名稱
  168. INT GetGroupIDByName( CString sGroupName,int &iGroupID );
  169. // 根據權限名得到ID
  170. INT GetPermitIDByName( CString sPermitName,int &iPermitID );
  171. // 根據組的ID得到該組的所有權限
  172. INT GetGroupPermitByID( CListBox *pListBox,int iGroupID );
  173. // 如果2中有則1沒
  174. INT GetGroupPermitByID( CListBox *pListBox1,CListBox *pListBox2 );
  175. // 根據組的ID得到該組的所有设备
  176. INT GetGroupDeviceByID( CListBox *pListBox,int iGroupID );
  177. // 如果2中有則1沒
  178. INT GetGroupDeviceByID( CListBox *pListBox1,CListBox *pListBox2 );
  179. // 根據組的ID得到該組的所有用户
  180. INT GetGroupUserByID( CListBox *pListBox,int iGroupID );
  181. // 如果2中有則1沒
  182. INT GetGroupUserByID( CListBox *pListBox1,CListBox *pListBox2 );
  183. INT FindGroupByName(CString sGroupName);
  184. // 根據用戶名得到ID
  185. INT GetUserIDByName( CString sUserName,int &iUserID );
  186. INT AddUserToDll();
  187. //得到用戶所屬的組
  188. INT GetAllGroupByUserID( CListBox *pListBox,CHAR * pUserID );
  189. INT GetAllGroupByUserID( CListBox *pListBox1,CListBox *pListBox2 );
  190. //添加用户所属组信息
  191. INT AddUserToGroup(int iID, CHAR * pUserID, int iGroupID, CHAR *pUserName);
  192. //刪除用戶所屬組
  193. INT DeleteUserGroup(CHAR * pUserID, int iGroupID );
  194. //刪除組的用戶
  195. INT DeleteGroupUser( int iGroupID );
  196. // 插入日志记录
  197. INT InsertLogRecord( int LogType, int ModuleType, CHAR *pHappenTime, CHAR *pContent );
  198. // 根據權限ID得到名
  199. INT GetPermitNameByID( CString &sPermitName,int iPermitID );
  200. //根据指定内容删除表内容, 通用函数
  201. INT DelTableData( CHAR *pTableName, CHAR *pFieldName1="",CHAR *pContent1="",int iType1=0,CHAR *pFieldName2="",CHAR *pContent2="",int iType2=0,CHAR *pFieldName3="",CHAR *pContent3="",int iType3=0 );
  202. //判断是否有电话,短信,EMAIL功能
  203. INT JudgeIsTSE( bool &bTel,bool &bSms,bool &bEmail );
  204. INT GetAllActionWithAlarm( CListCtrl *pListCtrl );
  205. INT AddActionWithAlarm( CString sDoSet, CString sDoStatus,int iAlarmData,int iResumeData,CString sDoPlanTime );
  206. INT AddActionWithAlarm( CString sDoSet,CString sDoStatus,int iAlarmData,int iResumeData,CString sDoPlanTime,CStringArray &SA );
  207. INT ModifyActionWithAlarm( CString sOldDoSet,CString sDoSet, CString sDoStatus,int iAlarmData,int iResumeData,CString sDoPlanTime );
  208. INT DelActionWithAlarm( CString sDosetVarName );
  209. INT GetActionWithAlarmVar( CListBox *pListBox,CString sDoSet );
  210. INT GetActionWithAlarmVar( CListBox *pListBox1,CListBox *pListBox2 );
  211. INT GetAWAPlanTime( CString sDoSet,CString &sPlanTime );
  212. INT SetAWAPlanTime( CString sDoSet,CString sPlanTime );
  213. INT UpDownUserInfo( int iID1,int iID2 );
  214. //获取指定驱动ID的驱动名称
  215. INT GetDriverName( int nDriverID, CString &sDriverName );
  216. //获取指定驱动ID和厂家ID的厂家名称
  217. INT GetFactoryName( int nDriverID, int nFactoryID, CString &sFactoryName );
  218. //获取指定驱动ID,厂家ID和设备类型ID的名称
  219. INT GetDevicesName( int nDriverID, int nFactoryID, int nDevicesID,CString &spDevicesName );
  220. //当编辑用户时要更新其它表的对应用户的帐号
  221. INT UpdateOtherTableUserName( CHAR *pUserID_Old,CHAR *pUserID_New );
  222. private:
  223. static CDBInterface* m_pDBInterface;
  224. char m_chDBType[MAX_DB_TYPE];
  225. };
  226. };
  227. #endif