//****************************************************************** // // AUTHOR : LMJ // // FUNCTION : 复制动态库头文件 // // TIME : 2003.08.30 // // HISTORY : // Datetime Action Author Reason // ------------------------------------------------------------------- // 2003.08.30 Creation LMJ // 2004.05.26 Add ZHANGKH Add LOB interface // 2004.12.20 Modify ZhangKeHeng Modify Function for Time Seq // 2005.12.28 Add ZhangKeHeng 部分复制 //****************************************************************** #ifndef __CREPSET_H #define __CREPSET_H #ifdef _WINDOWS64 #ifdef DB_REP_LIB_EXPORTS #define DB_REP_LIB_API __declspec(dllexport) #else #define DB_REP_LIB_API __declspec(dllimport) #endif #else #define DB_REP_LIB_API #endif #include "db_rep_lib_define.h" #include "database_rep_m.h" #ifndef BIND_CHR #define BIND_CHR 1 /* 字符型 unsigned char */ #endif #ifndef BIND_INT #define BIND_INT 3 /* 短整型short 整形int 长整型long */ #endif #ifndef BIND_FLT #define BIND_FLT 4 /* 浮点数float double */ #endif #ifndef BIND_STR #define BIND_STR 5 /* 字符串string */ #endif #ifndef BIND_ODT #define BIND_ODT 156 /* 日期型date*/ #endif const int PARTLY_REP_POLICY_NOREP = 1; const int PARTLY_REP_POLICY_ALLREP = 2; const int PARTLY_REP_POLICY_LIST_REP = 3; const int PARTLY_REP_POLICY_LIST_NOREP = 4; //进程复制策略 const int PARTLY_REP_POLICY_NOREP_EXCEPT_PROC = 5; const int PARTLY_REP_POLICY_ALLREP_EXCEPT_PROC = 6; const int PARTLY_REP_POLICY_LIST_REP_EXCEPT_PROC = 7; const int PARTLY_REP_POLICY_LIST_NOREP_EXCEPT_PROC = 8; //进程中可被重新设定的策略(如果进程策略被设定为以下四种,则可以调用SetProcRepList重新设定进程复制策略和复制列表) const int PARTLY_REP_POLICY_NOREP_SET = 9;//norep_set const int PARTLY_REP_POLICY_ALLREP_SET = 10;//allrep_set const int PARTLY_REP_POLICY_LIST_REP_SET = 11;//list_rep_set const int PARTLY_REP_POLICY_LIST_NOREP_SET = 12;//list_norep_set const int PARTLY_REP_PROCESS_MODEL = 1; const int PARTLY_REP_PROCESS_WARN = 2; const int PARTLY_REP_PROCESS_LOB_EXE = 3; const int PARTLY_REP_PROCESS_LOB = 4; const int PARTLY_REP_PROCESS_STATICS = 5; const int PARTLY_REP_PROCESS_HISDB = 6; struct ProcessRepInfo { int process_list_policy; string process_name; vector process_table_list_vec; }; struct PartlyRepInfo { string db_service_describe; int sample_list_policy; int warn_list_policy; int model_list_policy; int statics_list_policy; //add jihy 20130328 vector warn_list_vec; vector model_list_vec; vector statics_list_vec;//add jihy 20130328' vector sample_process_repinfo;//进程信息集合 vector warn_process_repinfo; vector model_process_repinfo; vector statics_process_repinfo; }; class DB_REP_LIB_API CDbRepSet { public: CDbRepSet(); ~CDbRepSet(); public: //初始化复制动态库 (proc_alias_name为进程别名,需要与db_partly_rep.sys中名称一致) int InitReplicateSet (string proc_alias_name = ""); //设置进程复制列表(设置进程复制策略和哪些表的语句需要复制) (默认为列表复制策略) (proc_alias_name为进程别名,需要与db_partly_rep.sys中名称一致) int SetProcRepList (const string &proc_alias_name, vector &tablename_vec, const string & strUserName = "d5000", int rep_policy = PARTLY_REP_POLICY_LIST_REP_SET); //时序要求复制(例如模型)strDbName 为 db_config_ext.sys中的db_service_describe int ReplicateSql (const vector &strSqlVec , const string &strDbName, const string & strUserName = "d5000"); //非时序要求复制(例如告警)strDbName 为 db_config_ext.sys中的db_service_describe int ReplicateSqlWithNoTimeSeq (const vector &strSqlVec , const string &strDbName , const string & strUserName = "alarm"); //非时序要求复制(例如采样)strDbName 为 db_config_ext.sys中的db_service_describe int ReplicateSqlWithNoTimeSeqSample (const vector &strSqlVec , const string &strDbName , const string & strUserName = "hisdb"); //大字段复制 int ReplicateLOB (const string &strSql , const string &strDbName, const string & strUserName = "d5000"); int ReplicateLOB (const string &strSql , const string &strSqlSelect , const vector &lobVec, bool is_insert, const string &strDbName, const string & strUserName = "d5000"); //绑定变量复制 add by shihaoqiu 20130313 int ReplicateBind (const TRepBindStru &bind_stru, const string &strDbName, const string & strUserName = "d5000"); private: int m_nPid; string m_strProcName; //当前进程名 string m_strPubPath; vector m_strDbNameVec; //所有数据库名 map m_bPartlyRepMap; //所有数据库是否部分复制,1部分 bool m_bRepFlag; map m_PartlyRepInfoMap; //部分复制信息MAP vector m_strPartlyRepPolicyVec; //部分复制策略字符串 private: int GetPubPath(); int GetAllDbName(); int GetAllPartlyRepInfo(); int GetReplicatePath (vector &strPathVec, vector &strDbNameVec, string strDbName, string strUserName); string IntToStr (int nVal); //int WriteRepSql(const vector &strSql,const vector &strPathVec, const vector &strDbNameVec); int WriteRepSql (const vector &strSql, const vector &strPathVec, const vector &strDbNameVec, string strUserName); int WriteRepSqlWithNoTimeSeq (const vector &strSql, const vector &strPathVec, const vector &strDbNameVec); int WriteRepSqlWithNoTimeSeqSample (const vector &strSql, const vector &strPathVec, const vector &strDbNameVec); int MoveInFileToOutFile (const string strInFileName); int GetOutFileName (const string strInFileName , string &strOutFileName); int WriteRepLOB (const string &strSql , const vector &strPathVec, const vector &strDbNameVec); int WriteRepLOB (const string &strSql , const string &strSqlSelect , const vector &lobVec, bool is_insert, const vector &strPathVec, const vector &strDbNameVec); int GetLOBReplicatePath ( vector &strPathVec, vector &strDbNameVec, string strDbName, string strUserName); int MoveLOBInFileToOutFile (const string strInFileName); int GetLOBOutFileName (const string strInFileName , string &strOutFileName); int GetBindReplicatePath ( vector &strPathVec, vector &strDbNameVec, string strDbName, string strUserName); int MoveBindInFileToOutFile (const string strInFileName); int GetBindOutFileName (const string strInFileName , string &strOutFileName); int WriteRepBind (const TRepBindStru &bind_stru, const vector &strPathVec, const vector &strDbNameVec); int GetPartlyRepSql (const vector &strSqlVec, vector &strPartlyRepSqlVec, const string &strDbName, const int &flag); int GetRepSqlByList (const vector &strSqlVec, vector &strPartlyRepSqlVec, vector &tablename_list_vec, const int &rep_policy); void gUsleep (const int usec); }; #endif