123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- /*************************************************************
- /* Copyright (C), 2008-2010, StoneU Tech. Co., Ltd.
- /* 文件名: DBInterface.h
- /* 作者: Jesse
- /* 创建日期: 2010-08-02
- /* 版本号: V1.0
- /* 描述: 实现多种数据库的支持
- /* 其它:
- /* 主要类模块: CDBInterface
- /* 历史修改记录:
- 作者 时间 版本 描述
- Jesse 10/08/02 1.0 创建这个模块
- ***************************************************************/
- #ifndef _DB_INTERFACE_H
- #define _DB_INTERFACE_H
- namespace DBInterface
- {
- const int MAX_DB_TYPE = 255;
- /*************************************************
- /* 类名
- /* {
- /* 构造函数;
- /* 析构函数;
- /* 提供全局访问函数;
- /* 静态类指针变量;
- /* 数据库类型成员变量;
- /*
- /* }
- **************************************************/
- class CDBInterface
- {
- public:
- CDBInterface()
- {
-
- };
- ~CDBInterface()
- {
- };
- void Release();
- // 静态成员函数,提供全局访问的接口
- static CDBInterface* GetInstancePtr();
- // 设置数据库类型
- void SetDBType(char *pDBType);
- //插入设备资料
- INT InsertDevInfo(int nID, CHAR *pUid, int nPort, int nAddr, CHAR *pDevName, int nDevTypeID,
- int nRate, int nDataBit, int nStopBit, int nParityBit, int nRsMode,
- CHAR *pIPAddr, int nIPPort, int nCommMode, int nDevFlag, int nSpecialDev,
- int nTimeout, int nIsuse, CHAR *pProtocalName, CHAR *pIniName,
- CHAR *pReserved1, CHAR *pReserved2, CHAR *pReserved3, CHAR *pReserved4, CHAR *pReserved5,
- CHAR *pReserved6, CHAR *pReserved7, CHAR *pReserved8, CHAR *pReserved9, CHAR *pReserved10,
- int nReserved1, int nReserved2, int nReserved3, int nReserved4, int nReserved5,
- int nReserved6, int nReserved7, int nReserved8, int nReserved9, int nReserved10,
- int bReserved1, int bReserved2, int bReserved3, int bReserved4, int bReserved5,
- int bReserved6, int bReserved7, int bReserved8, int bReserved9, int bReserved10);
- //修改设备资料
- INT EditDevInfo(CHAR *pOldUid, CHAR *pNewUid, int nPort, int nAddr, CHAR *pDevName, int nDevTypeID,
- int nRate, int nDataBit, int nStopBit, int nParityBit, int nRsMode,
- CHAR *pIPAddr, int nIPPort, int nCommMode, int nDevFlag, int nSpecialDev,
- int nTimeout, int nIsuse, CHAR *pProtocalName, CHAR *pIniName,
- CHAR *pReserved1, CHAR *pReserved2, CHAR *pReserved3, CHAR *pReserved4, CHAR *pReserved5,
- CHAR *pReserved6, CHAR *pReserved7, CHAR *pReserved8, CHAR *pReserved9, CHAR *pReserved10,
- int nReserved1, int nReserved2, int nReserved3, int nReserved4, int nReserved5,
- int nReserved6, int nReserved7, int nReserved8, int nReserved9, int nReserved10,
- int bReserved1, int bReserved2, int bReserved3, int bReserved4, int bReserved5,
- int bReserved6, int bReserved7, int bReserved8, int bReserved9, int bReserved10);
- //删除设备资料
- INT DeleteDevInfo(CHAR *pUid);
- //插入变量信息
- INT InsertVarInfo(int nID, int nDevTypeID,CHAR *pVarName,CHAR *pVarDesc,int nVarTypeID,int nMinValues,int nMaxValues,int nMaxConvtRate,int nMinConvtRate,
- int nCollectFreq,int bIsDDE,int nRegStartAddr,int nWaringLevel,CHAR *pSetValue,CHAR *pUnit,CHAR *pUid,CHAR *pRelatepage,int bRecCurve,int nRegNum,
- CHAR *pOnDesc,CHAR *pOffDesc,int nUpperLimit,int nLowerLimit,int nChildid,int nVarItemID,int nNormalState,CHAR *pFields,CHAR *pSnmpOid,int nRearm,
- int nOffset,int nFuncCode,int nDataLen,float fCoef,int bRealtimeFlag,int bIsSave,CHAR *pRs232Cmd,CHAR *pRs232Type,int nRs232Index,int nIdentifyTime,
- int nRedetectTime,int bIsNormalAlarm,int nPurview,
- CHAR *pReserved1,CHAR *pReserved2,CHAR *pReserved3,CHAR *pReserved4,CHAR *pReserved5,
- CHAR *pReserved6,CHAR *pReserved7,CHAR *pReserved8,CHAR *pReserved9,CHAR *pReserved10,
- int nReserved1,int nReserved2,int nReserved3,int nReserved4,int nReserved5,
- int nReserved6,int nReserved7,int nReserved8,int nReserved9,int nReserved10,
- int bReserved1,int bReserved2,int bReserved3,int bReserved4,int bReserved5,
- int bReserved6,int bReserved7,int bReserved8,int bReserved9,int bReserved10 );
- //插入数据记录
- INT InsertDataRecord(
- CHAR* pDevName, // 设备名称
- CHAR* pHappenTime, // 发生时间
- CHAR* pVarName, // 变量名称
- CHAR *pVarDesc, // 变量描述
- double dbCurrValue // 当前值
- );
- //获取设备类型ID
- INT GetDevTypeID( CHAR *pDevTypeName, CHAR *pDevTypeID );
- //获取指定厂家的设备型号ID
- INT GetDevTypeID( int nDriverID, int nFactoryID, CHAR *pDevTypeName, CHAR *pDevTypeID );
- //获取设备名称
- INT GetDevName( CHAR *pDevUID, CHAR *pDevName );
- //获取设备UID
- INT GetDevUID( CHAR *pDevName, CHAR *pDevUID );
- //获取表最大的ID, 通用函数
- INT GetMaxID( CHAR *pTableName, CHAR *pFieldName, CHAR *pMaxID );
- //获取驱动ID
- INT GetDevDriveID( CHAR *pDevDriverName, CHAR *pDevDriverID );
- //获取指定驱动的厂家ID
- INT GetDevFactoryID( int nDriverID, CHAR *pDevFactoryName, CHAR *pDevFactoryID );
- //根据UID查找同一类型设备的个数
- INT FindDevInfoByUID( CHAR *pUID, CHAR *pDevNum );
- //得到可以用的设备名称
- INT FindDevNameByName( CHAR *pName, CString &sDevName,int &nDevIndex );
- //得到时间计划
- INT GetDatePlan( int nPlanType, CHAR *pPlanID, unsigned char nBufDate[7][24] );
- //得到时间计划
- INT GetDatePlan( int nPlanType, CHAR *pUid, int nVarID, unsigned char nBufDate[7][24] );
- //删除原有的时间计划
- INT DeleteDatePlan( int nPlanType, CHAR *pPlanID );
- //删除原有的时间计划
- INT DeleteDatePlan( int nPlanType, CString strUid, int nVarID );
- //插入时间计划
- INT InsertDatePlan( int nPlanType, CHAR *pPlanID, int nStartHours, int nEndHours, int nStartWeek, int nEndWeek );
- //插入时间计划
- INT InsertDatePlan( int nPlanType, CString strUid, int nVarID, int nStartHours, int nEndHours, int nStartWeek, int nEndWeek );
- //获取系统支持所有的驱动类型
- INT GetDevDriveList( list<string>& list1, list<string>& list2 );
- //获取指定驱动的厂家资料
- INT GetDevFactoryList( int nDriverID, list<string>& list1, list<string>& list2 );
- //获取指定厂家的设备型号列表
- INT GetDevTypeList( int nDriverID, int nFactoryID, list<string>& list1, list<string>& list2 );
- //获取变量状态列表
- INT GetVarStatusList( CHAR *pVarUID, int nVarID, list<string>& list1, list<string>& list2 );
- //获取变量bit位的ID
- INT GetVarBitID( CHAR *pVarUID, int nStartBit, int nEndBit, CHAR *pVarBitID );
- //设置变量bit位的ID
- INT SetVarBitID( CHAR *pVarUID, int nStartBit, int nEndBit, int &nBitID );
- //获取变量类型
- INT GetVarTypeName( int nVarTypeID, CHAR *pVarTypeName );
- //获取功能码
- INT GetFuncCodeName( int nFuncID, CHAR *pFuncName );
- //获取变量ID
- INT GetVarID( CHAR *pVarName, CHAR *pVarID );
- //获取变量ID
- INT GetVarID( int nStartAddr, int nFuncCode, int nRegNum, CHAR *pVarID );
- //获取变量类型ID
- INT GetVarTypeID( CHAR *pVarTypeName, CHAR *pVarTypeID );
- //获取功能码ID
- INT GetFuncCodeID( CHAR *pFuncName, CHAR *pFuncID );
- //获取设备名称
- INT GetDevInfo( CHAR *pDevUID, CHAR *pDllName, CHAR *pIniName, CHAR *pDevProtocolType );
- //修改密码
- INT ModifyPwd(CHAR *pUserID, CHAR *pUserPwd);
- //验证用户名、密码是否合法
- INT ValidateUser(CHAR *pUserID, CHAR *pUserPwd);
- //验证用户是否启用
- INT ValidateUserEnable(CHAR *pUserID, CHAR *pStatus);
- //得到用户信息ID
- INT GetUserID( CHAR *pID, CHAR *pUserID );
- //判断用户是否管理设备权限
- INT HasDevAlloc( int iGroupID, CHAR *pUid );
- //删除设备权限信息
- INT DelUserDevInfo( int iGroupID );
- //添加设备权限信息
- INT AddUserDevInfo(int nID, int iGroupID, CHAR *pUid);
- //获取变量状态表ID
- INT GetVarStatusID( CHAR *pVarUID, int nVarID, int nStatusID, CHAR *pStatusDesc, CHAR *pID );
- //设置变量状态表ID
- INT SetVarStatusID( CHAR *pVarUID, int nVarID, int nStatusID, CHAR *pStatusDesc );
- INT AddGroupToDll();
- INT GetAllGroupToTree( CTreeCtrl *pTreeCtrl,HTREEITEM hRoot );
- INT AddGroup(int iID, CString sGroupName, CString sGroupDesc);
- INT ModifyGroup(CString sGroupName, CString sGroupDesc);
- INT DelGroup(int iGroupID);
- //得到組的ID通過組名稱
- INT GetGroupIDByName( CString sGroupName,int &iGroupID );
- // 根據權限名得到ID
- INT GetPermitIDByName( CString sPermitName,int &iPermitID );
- // 根據組的ID得到該組的所有權限
- INT GetGroupPermitByID( CListBox *pListBox,int iGroupID );
- // 如果2中有則1沒
- INT GetGroupPermitByID( CListBox *pListBox1,CListBox *pListBox2 );
- // 根據組的ID得到該組的所有设备
- INT GetGroupDeviceByID( CListBox *pListBox,int iGroupID );
- // 如果2中有則1沒
- INT GetGroupDeviceByID( CListBox *pListBox1,CListBox *pListBox2 );
- // 根據組的ID得到該組的所有用户
- INT GetGroupUserByID( CListBox *pListBox,int iGroupID );
- // 如果2中有則1沒
- INT GetGroupUserByID( CListBox *pListBox1,CListBox *pListBox2 );
- INT FindGroupByName(CString sGroupName);
- // 根據用戶名得到ID
- INT GetUserIDByName( CString sUserName,int &iUserID );
- INT AddUserToDll();
- //得到用戶所屬的組
- INT GetAllGroupByUserID( CListBox *pListBox,CHAR * pUserID );
- INT GetAllGroupByUserID( CListBox *pListBox1,CListBox *pListBox2 );
- //添加用户所属组信息
- INT AddUserToGroup(int iID, CHAR * pUserID, int iGroupID, CHAR *pUserName);
- //刪除用戶所屬組
- INT DeleteUserGroup(CHAR * pUserID, int iGroupID );
- //刪除組的用戶
- INT DeleteGroupUser( int iGroupID );
- // 插入日志记录
- INT InsertLogRecord( int LogType, int ModuleType, CHAR *pHappenTime, CHAR *pContent );
- // 根據權限ID得到名
- INT GetPermitNameByID( CString &sPermitName,int iPermitID );
- //根据指定内容删除表内容, 通用函数
- 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 );
- //判断是否有电话,短信,EMAIL功能
- INT JudgeIsTSE( bool &bTel,bool &bSms,bool &bEmail );
- INT GetAllActionWithAlarm( CListCtrl *pListCtrl );
- INT AddActionWithAlarm( CString sDoSet, CString sDoStatus,int iAlarmData,int iResumeData,CString sDoPlanTime );
- INT AddActionWithAlarm( CString sDoSet,CString sDoStatus,int iAlarmData,int iResumeData,CString sDoPlanTime,CStringArray &SA );
- INT ModifyActionWithAlarm( CString sOldDoSet,CString sDoSet, CString sDoStatus,int iAlarmData,int iResumeData,CString sDoPlanTime );
- INT DelActionWithAlarm( CString sDosetVarName );
- INT GetActionWithAlarmVar( CListBox *pListBox,CString sDoSet );
- INT GetActionWithAlarmVar( CListBox *pListBox1,CListBox *pListBox2 );
- INT GetAWAPlanTime( CString sDoSet,CString &sPlanTime );
- INT SetAWAPlanTime( CString sDoSet,CString sPlanTime );
- INT UpDownUserInfo( int iID1,int iID2 );
- //获取指定驱动ID的驱动名称
- INT GetDriverName( int nDriverID, CString &sDriverName );
- //获取指定驱动ID和厂家ID的厂家名称
- INT GetFactoryName( int nDriverID, int nFactoryID, CString &sFactoryName );
- //获取指定驱动ID,厂家ID和设备类型ID的名称
- INT GetDevicesName( int nDriverID, int nFactoryID, int nDevicesID,CString &spDevicesName );
- //当编辑用户时要更新其它表的对应用户的帐号
- INT UpdateOtherTableUserName( CHAR *pUserID_Old,CHAR *pUserID_New );
- private:
- static CDBInterface* m_pDBInterface;
- char m_chDBType[MAX_DB_TYPE];
- };
- };
- #endif
|