[Issue #2 ] 南瑞郭海龙交接最终版2.0

1.由于郭海龙修改了提供的库,导致增加了大量南瑞的头文件,
  所以新建include目录用于存放所有的南瑞提供的同文件。

2. 修复sys_nicmonitor进程重启后,调用接口告警问题。

3. 增加USER_NUSP宏,用于nusp用户。

4. 由于新增了许多头文件且需交接给郭海龙,所以独立了一版2.0版本以用于区分。

	修改:     code/README
	新文件:   code/dep/42/dotconf#1.0.13-1.pkg.tar.gz
	新文件:   code/dep/42/run.sh
	新文件:   code/dep/90/libdotconf-dev_1.3-0.2_amd64.deb
	新文件:   code/dep/90/libdotconf-dev_1.3-0.2_arm64.deb
	新文件:   code/dep/90/libdotconf0_1.3-0.2_amd64.deb
	新文件:   code/dep/90/libdotconf0_1.3-0.2_arm64.deb
	新文件:   code/dep/90/run.sh
	新文件:   code/dep/libproc_common.so
	新文件:   code/dep/old/libman.so
	新文件:   code/dep/proc_common.cpp
	新文件:   code/sys_nicmonitor-code.tar.gz
	修改:     code/sys_nicmonitor/Makefile
	修改:     code/sys_nicmonitor/README
	新文件:   code/sys_nicmonitor/include/common_types.h
	新文件:   code/sys_nicmonitor/include/d5000_err.h
	新文件:   code/sys_nicmonitor/include/db_api/DeleteRecorder.h
	新文件:   code/sys_nicmonitor/include/db_api/codb_net.h
	新文件:   code/sys_nicmonitor/include/db_api/mc_rtdb_m.h
	新文件:   code/sys_nicmonitor/include/db_api/mc_rtdb_mng.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_apinet.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_apinet_rtdb_key.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_apiop.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_apiop.h.old
	新文件:   code/sys_nicmonitor/include/db_api/odb_app2id.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_autolock.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_baseindex.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_ckeymanager.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_common.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_define.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_double_overflow_hashindex.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_field.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_hashindex.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_hashpk.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_intel_ptr.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_lock.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_net.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_net_m.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_netfactory.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_nooverflow_pk.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_orbmgr.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_profile.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_prv_struct.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_public.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_rtdbbase.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_rtdbfactory.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_rtdbop.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_rtdbtable.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_struct.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_system.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_table.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_tablebase.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_tablemgr.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_tablenet.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_tableop.h
	新文件:   code/sys_nicmonitor/include/db_api/odb_where.h
	新文件:   code/sys_nicmonitor/include/db_api/pub_buf.h
	新文件:   code/sys_nicmonitor/include/db_api/rtdb_graph_name_list.h
	新文件:   code/sys_nicmonitor/include/db_api/server2proto.h
	新文件:   code/sys_nicmonitor/include/db_api/tab2idx.h
	新文件:   code/sys_nicmonitor/include/db_api/vl_get_data.h
	新文件:   code/sys_nicmonitor/include/db_api/vl_struct.h
	新文件:   code/sys_nicmonitor/include/db_api/vl_struct_m.cpp
	新文件:   code/sys_nicmonitor/include/db_api/vl_struct_m.h
	新文件:   code/sys_nicmonitor/include/db_com/CAppNo.h
	新文件:   code/sys_nicmonitor/include/db_com/CCharArray.h
	新文件:   code/sys_nicmonitor/include/db_com/CDataStream.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbCommitClient.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbMonitorClient.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbMonitorLocal.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbMonitorShm.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbRepSet.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbSem.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbSemUse.h
	新文件:   code/sys_nicmonitor/include/db_com/CDbShm.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyCfgLocal.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyCommitClient.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyMonitorClient.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyMonitorLocal.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyMonitorShm.h
	新文件:   code/sys_nicmonitor/include/db_com/CDySem.h
	新文件:   code/sys_nicmonitor/include/db_com/CDySemUse.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyShm.h
	新文件:   code/sys_nicmonitor/include/db_com/CDyTagShmInfo.h
	新文件:   code/sys_nicmonitor/include/db_com/CErrorLog.h
	新文件:   code/sys_nicmonitor/include/db_com/CFindFile.h
	新文件:   code/sys_nicmonitor/include/db_com/CPrecTime.h
	新文件:   code/sys_nicmonitor/include/db_com/CRecordSet.h
	新文件:   code/sys_nicmonitor/include/db_com/CRedisAccess.h
	新文件:   code/sys_nicmonitor/include/db_com/CRepSet.h
	新文件:   code/sys_nicmonitor/include/db_com/CSaveReCommitSql.h
	新文件:   code/sys_nicmonitor/include/db_com/CSqlResultAlign.h
	新文件:   code/sys_nicmonitor/include/db_com/CSqlResultAlignClient.h
	新文件:   code/sys_nicmonitor/include/db_com/CSqlResultAlignClient2.h
	新文件:   code/sys_nicmonitor/include/db_com/DBAccess.h
	新文件:   code/sys_nicmonitor/include/db_com/DBCipher.h
	新文件:   code/sys_nicmonitor/include/db_com/DBConnectPool.h
	新文件:   code/sys_nicmonitor/include/db_com/DbFileNetIf.h
	新文件:   code/sys_nicmonitor/include/db_com/Hbase.h
	新文件:   code/sys_nicmonitor/include/db_com/Hbase_constants.h
	新文件:   code/sys_nicmonitor/include/db_com/Hbase_types.h
	新文件:   code/sys_nicmonitor/include/db_com/MyMutex.h
	新文件:   code/sys_nicmonitor/include/db_com/cross_region_sync_client.h
	新文件:   code/sys_nicmonitor/include/db_com/database_rep_m.h
	新文件:   code/sys_nicmonitor/include/db_com/db_commit_define.h
	新文件:   code/sys_nicmonitor/include/db_com/db_commit_m.h
	新文件:   code/sys_nicmonitor/include/db_com/db_error_define.h
	新文件:   code/sys_nicmonitor/include/db_com/db_extern.h
	新文件:   code/sys_nicmonitor/include/db_com/db_global.h
	新文件:   code/sys_nicmonitor/include/db_com/db_micro_define.h
	新文件:   code/sys_nicmonitor/include/db_com/db_monitor_define.h
	新文件:   code/sys_nicmonitor/include/db_com/db_monitor_define.h.old
	新文件:   code/sys_nicmonitor/include/db_com/db_monitor_extern.h
	新文件:   code/sys_nicmonitor/include/db_com/db_monitor_global.h
	新文件:   code/sys_nicmonitor/include/db_com/db_monitor_m.h
	新文件:   code/sys_nicmonitor/include/db_com/db_monitor_m.h.old
	新文件:   code/sys_nicmonitor/include/db_com/db_rep_lib_define.h
	新文件:   code/sys_nicmonitor/include/db_com/db_stat_m.h
	新文件:   code/sys_nicmonitor/include/db_com/db_stat_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/ds_log.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_commit_m.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_monitor_define.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_monitor_m.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_public_m.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_sample_define_m.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_sample_define_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_stat_m.h
	新文件:   code/sys_nicmonitor/include/db_com/dy_stat_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/hiredis.h
	新文件:   code/sys_nicmonitor/include/db_com/interpreter_define.h
	新文件:   code/sys_nicmonitor/include/db_com/interpreter_struct.h
	新文件:   code/sys_nicmonitor/include/db_com/lexical_anls.h
	新文件:   code/sys_nicmonitor/include/db_com/public_m.h
	新文件:   code/sys_nicmonitor/include/db_com/query_sample_m.h
	新文件:   code/sys_nicmonitor/include/db_com/query_sample_pi.h
	新文件:   code/sys_nicmonitor/include/db_com/query_sample_pi_m.h
	新文件:   code/sys_nicmonitor/include/db_com/query_sample_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/query_sample_service_pi_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/query_stat_m.h
	新文件:   code/sys_nicmonitor/include/db_com/query_stat_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/rdb_commit_client.h
	新文件:   code/sys_nicmonitor/include/db_com/rdb_commit_m.h
	新文件:   code/sys_nicmonitor/include/db_com/rdb_define.pb.h
	新文件:   code/sys_nicmonitor/include/db_com/read.h
	新文件:   code/sys_nicmonitor/include/db_com/rtdbkey_defs.h
	新文件:   code/sys_nicmonitor/include/db_com/sample_data_client_base.h
	新文件:   code/sys_nicmonitor/include/db_com/sample_data_m.h
	新文件:   code/sys_nicmonitor/include/db_com/sample_define_m.h
	新文件:   code/sys_nicmonitor/include/db_com/sample_define_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/sample_modify_m.h
	新文件:   code/sys_nicmonitor/include/db_com/sample_modify_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/sds.h
	新文件:   code/sys_nicmonitor/include/db_com/server_define.h
	新文件:   code/sys_nicmonitor/include/db_com/sheetdataclient.h
	新文件:   code/sys_nicmonitor/include/db_com/sheetdataclient.h0604
	新文件:   code/sys_nicmonitor/include/db_com/sql_sp_client_base.h
	新文件:   code/sys_nicmonitor/include/db_com/sql_sp_define.h
	新文件:   code/sys_nicmonitor/include/db_com/sql_sp_m.h
	新文件:   code/sys_nicmonitor/include/db_com/sql_sp_send_client_base.h
	新文件:   code/sys_nicmonitor/include/db_com/sql_syntax_anls.h
	新文件:   code/sys_nicmonitor/include/db_com/sql_to_cime.h
	新文件:   code/sys_nicmonitor/include/db_com/sqlite_access.h
	新文件:   code/sys_nicmonitor/include/db_com/sqlite_server_client.h
	新文件:   code/sys_nicmonitor/include/db_com/sqlite_srv_m.h
	新文件:   code/sys_nicmonitor/include/db_com/store_access_client.h
	新文件:   code/sys_nicmonitor/include/db_com/trigger_sample_m.h
	新文件:   code/sys_nicmonitor/include/db_com/trigger_sample_service_interface.h
	新文件:   code/sys_nicmonitor/include/db_com/wholepubtools.h
	新文件:   code/sys_nicmonitor/include/db_com/wholesampledata.h
	新文件:   code/sys_nicmonitor/include/db_com/wholesqlsp.h
	新文件:   code/sys_nicmonitor/include/log_api.h
	新文件:   code/sys_nicmonitor/include/log_define.h
	新文件:   code/sys_nicmonitor/include/logclient.h
	新文件:   code/sys_nicmonitor/include/port_def.h
	新文件:   code/sys_nicmonitor/include/proc_common.h
	新文件:   code/sys_nicmonitor/include/scn_common.h
	新文件:   code/sys_nicmonitor/include/sysadm/proc_define.h
	新文件:   code/sys_nicmonitor/include/sysadm/scn_define.h
	新文件:   code/sys_nicmonitor/include/system.h
	修改:     code/sys_nicmonitor/mnic.c
	修改:     code/sys_nicmonitor/nicinfo_shm.c
	修改:     code/sys_nicmonitor/test.c
	修改:     code/sys_nicmonitor/version.h
	新文件:   code/test/test_nic
	新文件:   code/test/test_nic.cpp
	新文件:   packages/sys_nicmonitor-2.0-linx90-aarch64-bin-d5000.tar.gz
	新文件:   packages/sys_nicmonitor-2.0-linx90-aarch64-bin-nusp.tar.gz
	新文件:   packages/sys_nicmonitor-2.0-linx90-x86_64-bin-d5000.tar.gz
	新文件:   packages/sys_nicmonitor-2.0-linx90-x86_64-bin-nusp.tar.gz
	重命名:   sys_nicmonitor-arm-bin.tar.gz -> packages/sys_nicmonitor-arm-bin.tar.gz
	重命名:   sys_nicmonitor-arm.tar.gz -> packages/sys_nicmonitor-arm.tar.gz
	新文件:   packages/sys_nicmonitor-mips64-bin.tar.gz
	新文件:   packages/sys_nicmonitor-mips64.tar.gz

Signed-off-by: Wei, Jing <jwei@linx-info.com>
This commit is contained in:
Wei, Jing
2020-10-22 19:15:38 +08:00
parent 78444a27f8
commit 5c462e7adb
193 changed files with 38570 additions and 243 deletions

View File

@@ -0,0 +1,63 @@
#ifndef _CAPPNO_H_
#define _CAPPNO_H_
#ifdef _WINDOWS64
#ifdef CAPP_NO_EXPORTS
#define CAPP_NO_API __declspec(dllexport)
#else
#define CAPP_NO_API __declspec(dllimport)
#endif
#else
#define CAPP_NO_API
#endif
#include <iostream>
#include "system.h"
using namespace std;
class CAPP_NO_API CAppNo
{
public:
unsigned int value_array[4];
public:
CAppNo( unsigned int value1, unsigned int value2 = 0, unsigned int value3 = 0, unsigned int value4 = 0);
CAppNo();
~CAppNo();
// 重载操作符位与&、位或|、取反~、判等==(!=)、赋值(常数)、取余、整除、输出
CAppNo operator&(const CAppNo value);
CAppNo operator&=(const CAppNo value);
CAppNo operator|(const CAppNo value);
CAppNo operator|=(const CAppNo value);
CAppNo operator~();
bool operator==(const CAppNo value);
bool operator ==(const unsigned int value);
bool operator!=(const CAppNo value);
bool operator!=(const unsigned int value);
int operator=(const unsigned int value);
CAppNo operator+(const CAppNo value);
CAppNo operator+=(const CAppNo value);
CAppNo operator-(const CAppNo value);
CAppNo operator%(const unsigned int value);
CAppNo operator/(const unsigned int value);
CAppNo operator*(const unsigned int value);
friend CAPP_NO_API ostream& operator<<(ostream&,const CAppNo&);
bool any();//存在某一位为1,返回true
bool none();//全部为0,返回true
int count();//被设置成1的位的个数
CAppNo NoToCApp(int index_no);//应用号转为CAppNo
int CAppToNo();//CAppNo转为应用号,返回最小号
//int CAppToNo(vector<int> &appno_vec);//CAppNo转为应用号,返回最大号,appno_vec为其中所有应用号
int AppColIndex();//返回应用号所在域
static bool isAppExt();//判断当前是否应用号扩展
private:
//static bool m_is_ext;
};
#endif

View File

@@ -0,0 +1,72 @@
// CCharArray.h: interface for the CCharArray class.
//
//////////////////////////////////////////////////////////////////////
#ifndef _CCharArray_H_
#define _CCharArray_H_
#ifdef _WINDOWS64
#ifdef PUB_TOOLS_EXPORTS
#define PUB_TOOLS_API __declspec(dllexport)
#else
#define PUB_TOOLS_API __declspec(dllimport)
#endif
#else
#define PUB_TOOLS_API
#endif
class PUB_TOOLS_API CCharArray
{
public:
// CCharArray();
CCharArray(char *pChar, int nLen, bool bAutoDel = false);
~CCharArray();
private:
char *m_pChar; // 数据缓冲区
int m_nCharLen; // m_pChar数组的长度
int m_nCharIndex; // m_pChar数组中当前有效位置
bool m_bAutoDelete; // 是否删除缓冲区的数据
private:
void SetLen(int nIndex)
{
m_nCharLen = nIndex;
}
void SetIndex(int nIndex)
{
m_nCharIndex = nIndex;
}
int GetIndex()
{
return m_nCharIndex;
}
int CheckLen(int nLen);
bool GetIsAutoDelete()
{
return m_bAutoDelete;
}
public:
int GetLen()
{
return m_nCharLen;
}
char *GetChar()
{
return m_pChar;
}
void IsAutoDelete(bool bAutoDelete = true)
{
m_bAutoDelete = bAutoDelete;
}
/*
bool PutChar(char *pChar,int nLen);
bool GetChar(char *pChar,int nLen);
bool Skip(int nLen);
*/
};
#endif // _CCharArray_H_

View File

@@ -0,0 +1,141 @@
// CDataStream.h: interface for the CDataStream class.
//
//////////////////////////////////////////////////////////////////////
#ifndef _CDATASTREAM_H_
#define _CDATASTREAM_H_
#ifdef _WINDOWS64
#ifdef PUB_TOOLS_EXPORTS
#define PUB_TOOLS_API __declspec(dllexport)
#else
#define PUB_TOOLS_API __declspec(dllimport)
#endif
#else
#define PUB_TOOLS_API
#endif
#include "common_types.h"
#include "CCharArray.h"
#include <stdlib.h>
struct Keyid
{
int record_id;
short column_id;
};
typedef unsigned char byte;
const int DATASTREAM_NOT_CHECK = -1; //不检查传入串的长度
const int DEFAULT_DATASTREAM_LENGTH = 255; //默认数据的长度应该大于零
typedef struct Keyid TKEYID;
#define ERRMSG_LENGTH 255
class PUB_TOOLS_API CDataStream
{
public:
CDataStream();
~CDataStream();
bool Init(int nMode, bool bAutoDel = true, char *pDataStream = NULL, int nDataStreamLen = 0, int nDefaultDataStreamLen = DEFAULT_DATASTREAM_LENGTH);
enum
{
load = 0, store = 1
};
CDataStream& operator=(const CDataStream & strobj);
CDataStream(const CDataStream & strobj);
private:
int m_nMode;
char *m_pDataStream;
int m_nDataStreamLen;
int m_nDataStreamIndex;
int m_nDefaultDataStreanLen; //默认的数据缓冲区的长度
bool m_bAutoDelete; //是否删除缓冲区的数据
bool m_bChangeOrder;
char m_chMsg[ERRMSG_LENGTH + 1];
private:
bool GetIsAutoDelete()
{
return m_bAutoDelete;
}
bool IsOutofBound(int nLen);
int GetDataLen();
bool SetData(void *pData, int nLen);
bool GetData(void *pData, int nLen);
//exception * GetException(char *pMsg);
void SetErrMsg(char * pMsg);
char * GetErrMsg();
void ChangeOrder(short &s);
void ChangeOrder(unsigned short &s);
void ChangeOrder(int &i);
void ChangeOrder(cmnInt64 &l);
void ChangeOrder(float &f);
void ChangeOrder(double &d);
void ChangeOrder(cmnUint64 &dw);
public:
bool IsChangeOrder()
{
return m_bChangeOrder;
}
int GetDataStreamLen()
{
return m_nDataStreamIndex;
}
void IsAutoDelete(bool bAutoDelete = true)
{
m_bAutoDelete = bAutoDelete;
}
void Skip(int nLen);
void SkipTo(int nLen);
operator char *();
CDataStream & operator <<(char ch);
CDataStream & operator <<(byte by);
CDataStream & operator <<(bool b);
CDataStream & operator <<(short s);
CDataStream & operator <<(unsigned short s);
CDataStream & operator <<(int Integer);
CDataStream & operator <<(cmnInt64 l);
CDataStream & operator <<(float f);
CDataStream & operator <<(double d);
CDataStream & operator <<(cmnUint64 dw);
CDataStream & operator <<(CCharArray & CharArray);
CDataStream & operator <<(TKEYID & keyid);
CDataStream & operator >>(char &ch);
CDataStream & operator >>(byte &by);
CDataStream & operator >>(bool &b);
CDataStream & operator >>(short &s);
CDataStream & operator >>(unsigned short &s);
CDataStream & operator >>(int &Integer);
CDataStream & operator >>(cmnInt64 &l);
CDataStream & operator >>(float &f);
CDataStream & operator >>(double &d);
CDataStream & operator >>(cmnUint64 &dw);
CDataStream & operator >>(CCharArray & CharArray);
CDataStream & operator >>(TKEYID & keyid);
};
#endif // _CDataStream_H_

View File

@@ -0,0 +1,93 @@
#ifndef __CDBCOMMITCLIENT_H__
#define __CDBCOMMITCLIENT_H__
#ifdef _WINDOWS64
#ifdef DB_COMMIT_DLL_EXPORTS
#define DB_COMMIT_DLL_API __declspec(dllexport)
#else
#define DB_COMMIT_DLL_API __declspec(dllimport)
#endif
#else
#define DB_COMMIT_DLL_API
#endif
#ifndef _WINDOWS64
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include <iostream>
#include "db_commit_m.h"
#include "servicemanage.h"
#include "sysadm/scn_service.h"
#include "pub_ctx.h"
#include "system.h"
#include "port_def.h"
#include "logclient.h"
using namespace std;
using namespace NS_SYSADMIN;
const int HIGH = 1;
const int MIDDLE = 2;
const int LOW = 3;
const int NO_SQL_DUP = 0;
const int SQL_DUP = 1;
#define OP_BIND_INSERT 1
#define OP_BIND_UPDATE 2
#define OP_BIND_DELETE 3
#define BIND_COMMIT_DATATYPE_CHR 1 /* 字符型 unsigned char */
#define BIND_COMMIT_DATATYPE_INT 3 /* 短整型short 整形int 长整型long */
#define BIND_COMMIT_DATATYPE_FLT 4 /* 浮点数float double */
#define BIND_COMMIT_DATATYPE_STR 5 /* 字符串string */
#define BIND_COMMIT_DATATYPE_ODT 156 /* 日期型date*/
class DB_COMMIT_DLL_API CDbCommitClient
{
public:
CDbCommitClient();
CDbCommitClient(int sys_port);
CDbCommitClient(int sys_port, int seconds);
~CDbCommitClient();
public:
void SetRequestTimeout(int seconds);
short SqlCommit(TCommitStru CommitSqlStru); //1
short SqlCommitWithNoDup(TCommitStru CommitSqlStru); //2
short RsSqlCommit(TCommitStru CommitSqlStru); //3
short WarnSqlCommit(TCommitStru CommitSqlStru); //4
short LOBInsertCommit(char* sql_insert, char* sql_select, SEQCommitLOBValueType seq_lob_value); //5
short LOBUpdateCommit(char* sql_update, char* sql_select, SEQCommitLOBValueType seq_lob_value); //6
short SqlCommitWithBind(TCommitBindStru CommitBindStru); //7
#ifdef _DATASRV_DIVERSION
//DATA_SRV分模式下指定访问的应用
//app_name = data_srv_dms 访问配网data_srv
//其余取值访问主网data_srv
void SetServiceApp(const char* app_name);
void ClearServiceApp();
#endif
private:
ServiceInfo m_Serviceinfo;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
CScnService* m_ServicesManage;
int m_RequestTimeoutSeconds;
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
int SetServiceHost();
};
#endif

View File

@@ -0,0 +1,71 @@
//******************************************************************
//
// AUTHOR : ShiHaoQiu
//
// FUNCTION : db_monitor 进程的客户端类公用类定义
//
// TIME : 2011.04.09
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2011.04.09 Creation ShiHaoQiu
//
//******************************************************************
#ifndef __CDBMONITORCLIENT_H__
#define __CDBMONITORCLIENT_H__
#include "db_monitor_m.h"
//#include "servicesclient.h"
#include "sysadm/scn_service.h"
#include "system.h"
#include "pub_ctx.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
//#include "serviceglobal.h"
#include "servicemanage.h"
class CDbMonitorClient
{
public:
CDbMonitorClient();
CDbMonitorClient(int seconds);
~CDbMonitorClient();
void SetRequestTimeout(int seconds);
short GetMasterDbInfo(TDbLoginInfo & masterDbInfo);
short GetMasterDbInfo(const char* user_name,TDbLoginInfo & masterDbInfo);
//short MasterDbSwitchByDbName(const char* strDbName);
short MasterDbSwitchByDbService(const char* strDbService);
short GetRepDbLoginInfo(const char* strDbName , TDbLoginInfo & repDbLoginInfo);
short GetDbNum(int & nSize);
short GetAllDbServerInfo(TDbServiceInfo & dbServerInfoSec);
void SetLocalServiceFlag(bool flag);
//add for remote access
int SetDomainInfo(const DomainInfo& domain_info); //设置远程信息(通用)
int SetDomainInfo(const char* domain_name, const tSecLabel& sec_label, const int app_no = AP_DATA_SRV, const int ctx_no = AC_REALTIME_NO);
int SetDomainName(const char* domain_name); //设置域名
int SetSecLabel(tSecLabel& sec_label); //设置标签
void ClearDomainName(); //清除域名m_DomainName设为local_domain
private:
DomainInfo m_DomainInfo;
ServiceInfo m_Serviceinfo;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
int SetServiceHost();
bool m_localserviceflag;
int m_RequestTimeoutSeconds;
};
#endif

View File

@@ -0,0 +1,44 @@
#ifndef ___CDBMONITORLOCAL_H__
#define ___CDBMONITORLOCAL_H__
#ifdef _WINDOWS64
#ifdef DB_MONITOR_DLL_LOCAL_EXPORTS
#define DB_MONITOR_DLL_LOCAL_API __declspec(dllexport)
#else
#define DB_MONITOR_DLL_LOCAL_API __declspec(dllimport)
#endif
#else
#define DB_MONITOR_DLL_LOCAL_API
#endif
#include "db_com/db_monitor_define.h"
#include "CDbMonitorShm.h"
class DB_MONITOR_DLL_LOCAL_API CDbMonitorLocal
{
public:
CDbMonitorLocal();
~CDbMonitorLocal();
int InitDbMonitorLocal();
int GetMasterDbInfo(TLoginInfo &masterDbInfo);
int GetMasterDbInfo(const string user_name,TLoginInfo &masterDbInfo);
int GetRepDbLoginInfo(const string &strDbDesc , TLoginInfo &repDbLoginInfo);
int GetRepDbLoginInfo(const string & strUserName,const string &strDbDesc , TLoginInfo &repDbLoginInfo);
int GetDbNum(int &nSize);
int GetAllDbServerInfo(vector<TLoginInfo> &dbServerInfoVec);
int GetAllDbServerInfoExt(vector<TLoginInfo> & dbServerInfoVec);
int GetUserPassword(string strUserName,string & strUserPassword);
int GetAllUserInfo(vector<TLoginUserInfo> & userLoginVec);
//Add for db_warn_server by ZhangKeHeng
int GetDbInfoByDbService(TLoginInfo &dbServiceInfo , const string strDbService);
int GetDbInfoByDbService(TLoginInfo &dbServiceInfo , const string strDbService,const string user_name);
//int GetDbInfoByDbName(TLoginInfo &dbServiceInfo , const string strDbName);
int GetDbInfoByDbServiceDesc(TLoginInfo &dbServiceInfo , const string strDbDesc);
int GetDbInfoByDbServiceDesc(TLoginInfo &dbServiceInfo , const string strDbDesc,const string user_name);
//add fro db_warn_server db_config_ext.sys ¶ÁÈ¡
int ReadDbConfigInfoFromFile(vector<TLoginInfo> & loginfo_vec);
};
#endif

View File

@@ -0,0 +1,77 @@
//******************************************************************
//
// AUTHOR : LMJ
//
// FUNCTION : 数据库监视进程中操作共享内存 类方法定义
//
// TIME : 2003.12.8
//
// HISTORY :
// Datetime Action Author Reason
// -----------------------------------------------------------------
// 2003.12.16 Creation LMJ
// 2004.09.18 Modify ZhangKeHeng add interface for db_warn_server
//******************************************************************
#ifndef __CDBMONITORSHM_H_
#define __CDBMONITORSHM_H_
#include "db_com/db_monitor_define.h"
class CDbMonitorShm
{
protected:
CDbMonitorShm();
public:
static CDbMonitorShm & getInstance()
{
static CDbMonitorShm gCDbMonitorShm;
return gCDbMonitorShm;
}
~CDbMonitorShm();
private:
CDbShm m_DbShm;
TLoginInfo * m_pAllDbInfo;
int m_nDbNum;
static int m_nDbAppStatusOffset;
static int m_nMasterDbInfoOffset;
static int m_nDbNumOffset;
static int m_nAllDbInfoOffset;
int m_TotalShmSize;
public:
int InitDbMonitorShm();
int SetDbAppStatusInfo(const int nStatus);
int GetDbAppStatusInfo(int &nStatus);
int SetMasterDbLoginInfo(const TLoginInfo &DbLoginInfo);
int GetMasterDbLoginInfo(TLoginInfo &DbLoginInfo);
int SetDbNum(const int nDbNum);
int GetDbNum(int &nDbNum);
int SetDbServiceInfo(const TLoginInfo &dbServiceInfo , int nDbSerialNo);
int GetDbServiceInfo(TLoginInfo &dbServiceInfo , int nDbSerialNo);
int GetDbServiceInfoByDbService(TLoginInfo &dbServiceInfo , string strDbService);
//int GetDbServiceInfoByDbName(TLoginInfo &dbServiceInfo , string strDbName);
int GetDbServiceInfoByDbServiceDesc(TLoginInfo &dbServiceInfo , string strDbDesc);
int GetAllDbServiceInfo(vector<TLoginInfo> &dbServiceInfo);
int SetAllDbServiceInfo(const vector<TLoginInfo> &dbServiceInfo);
//int GetDbSerialNoFromDbName(vector<int> &dbSerialNoVec , string strDbName);
int GetDbSerialNoFromDbServiceDesc(vector<int> &dbSerialNoVec,string strDbDesc);
int GetDbSerialNoFromDbService(int &nDbSerialNo , string strDbService);
//Add for db_warn_server by ZhangKeHeng
int GetDbInfoByDbService(TLoginInfo &dbServiceInfo , string strDbService);
//int GetDbInfoByDbName(TLoginInfo &dbServiceInfo , string strDbName);
int GetDbInfoByDbServiceDesc(TLoginInfo &dbServiceInfo , string strDbDesc);
};
#endif

View File

@@ -0,0 +1,192 @@
//******************************************************************
//
// 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<string> 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<string> warn_list_vec;
vector<string> model_list_vec;
vector<string> statics_list_vec;//add jihy 20130328'
vector<ProcessRepInfo> sample_process_repinfo;//进程信息集合
vector<ProcessRepInfo> warn_process_repinfo;
vector<ProcessRepInfo> model_process_repinfo;
vector<ProcessRepInfo> 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<string> &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<string> &strSqlVec , const string &strDbName,
const string & strUserName = "d5000");
//非时序要求复制例如告警strDbName 为 db_config_ext.sys中的db_service_describe
int ReplicateSqlWithNoTimeSeq (const vector<string> &strSqlVec ,
const string &strDbName , const string & strUserName = "alarm");
//非时序要求复制例如采样strDbName 为 db_config_ext.sys中的db_service_describe
int ReplicateSqlWithNoTimeSeqSample (const vector<string> &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<TLOBContent> &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<string> m_strDbNameVec; //所有数据库名
map<string, int>
m_bPartlyRepMap; //所有数据库是否部分复制1部分
bool m_bRepFlag;
map<string, PartlyRepInfo> m_PartlyRepInfoMap; //部分复制信息MAP
vector<string> m_strPartlyRepPolicyVec; //部分复制策略字符串
private:
int GetPubPath();
int GetAllDbName();
int GetAllPartlyRepInfo();
int GetReplicatePath (vector<string> &strPathVec, vector<string> &strDbNameVec,
string strDbName, string strUserName);
string IntToStr (int nVal);
//int WriteRepSql(const vector<string> &strSql,const vector<string> &strPathVec, const vector<string> &strDbNameVec);
int WriteRepSql (const vector<string> &strSql, const vector<string> &strPathVec,
const vector<string> &strDbNameVec, string strUserName);
int WriteRepSqlWithNoTimeSeq (const vector<string> &strSql,
const vector<string> &strPathVec, const vector<string> &strDbNameVec);
int WriteRepSqlWithNoTimeSeqSample (const vector<string> &strSql,
const vector<string> &strPathVec, const vector<string> &strDbNameVec);
int MoveInFileToOutFile (const string strInFileName);
int GetOutFileName (const string strInFileName , string &strOutFileName);
int WriteRepLOB (const string &strSql , const vector<string> &strPathVec,
const vector<string> &strDbNameVec);
int WriteRepLOB (const string &strSql , const string &strSqlSelect ,
const vector<TLOBContent> &lobVec, bool is_insert,
const vector<string> &strPathVec, const vector<string> &strDbNameVec);
int GetLOBReplicatePath ( vector<string> &strPathVec,
vector<string> &strDbNameVec, string strDbName, string strUserName);
int MoveLOBInFileToOutFile (const string strInFileName);
int GetLOBOutFileName (const string strInFileName , string &strOutFileName);
int GetBindReplicatePath ( vector<string> &strPathVec,
vector<string> &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<string> &strPathVec, const vector<string> &strDbNameVec);
int GetPartlyRepSql (const vector<string> &strSqlVec,
vector<string> &strPartlyRepSqlVec, const string &strDbName, const int &flag);
int GetRepSqlByList (const vector<string> &strSqlVec,
vector<string> &strPartlyRepSqlVec, vector<string> &tablename_list_vec,
const int &rep_policy);
void gUsleep (const int usec);
};
#endif

View File

@@ -0,0 +1,67 @@
#ifndef __CDBSEM_H_
#define __CDBSEM_H_
#ifdef _WINDOWS64
#ifdef PUB_TOOLS_EXPORTS
#define PUB_TOOLS_API __declspec(dllexport)
#else
#define PUB_TOOLS_API __declspec(dllimport)
#endif
#else
#define PUB_TOOLS_API
#endif
#include <iostream>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef _WINDOWS64
#include <unistd.h>
#include <sys/ipc.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <algorithm>
#include <errno.h>
#include <sys/sem.h>
#include <ctype.h>
#include <vector>
#else
#include <windows.h>
#endif
using namespace std;
union db_semun
{
int val;
struct semid_ds *buf;
unsigned short *array;
};
class PUB_TOOLS_API CDbSem
{
#ifndef _WINDOWS64
int m_nSemId;
#else
char m_pSemName[64];
#endif
public:
CDbSem();
~CDbSem();
#ifndef _WINDOWS64
int InitSem(key_t key, int nsems, int initval);
int GetSemValue(int sem_id, int sem_num);
int ClearSemValue(int sem_id, int sem_num);
#else
int InitSem(const char *sem_name);
#endif
int p();
int v();
};
#endif

View File

@@ -0,0 +1,35 @@
#ifndef __CDBSEMUSE_H_
#define __CDBSEMUSE_H_
#include "CDbSem.h"
#ifdef _WINDOWS64
#ifdef PUB_TOOLS_EXPORTS
#define PUB_TOOLS_API __declspec(dllexport)
#else
#define PUB_TOOLS_API __declspec(dllimport)
#endif
#else
#define PUB_TOOLS_API
#endif
class PUB_TOOLS_API CDbSemUse
{
public:
CDbSemUse(CDbSem &sem);
~CDbSemUse();
private:
CDbSem &m_Sem;
int m_nPflag;
int m_nVflag;
public:
int GetPflag();
int GetVflag();
};
#endif

View File

@@ -0,0 +1,96 @@
#ifndef __CDBSHM_H
#define __CDBSHM_H
#ifdef _WINDOWS64
#ifdef PUB_TOOLS_EXPORTS
#define PUB_TOOLS_API __declspec(dllexport)
#else
#define PUB_TOOLS_API __declspec(dllimport)
#endif
#else
#define PUB_TOOLS_API
#endif
#include <sys/types.h>
#ifndef _WINDOWS64
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/utsname.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <algorithm>
#include <errno.h>
#include <sys/sem.h>
#include <ctype.h>
#include <vector>
#include <math.h>
#include <sys/mman.h>
#include <assert.h>
#ifdef _HPUX
#include <sys/pthread.h>
#else
#include <pthread.h>
#endif
#include <signal.h>
#include <dirent.h>
#include <malloc.h>
#else
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <direct.h>
#include <io.h>
#include <windows.h>
#include <errno.h>
#endif
class PUB_TOOLS_API CDbShm
{
public:
CDbShm();
~CDbShm();
private:
static int m_TotalShmSize;
static char * m_pShm;
public:
#ifndef _WINDOWS64
int InitShm(key_t key, int size);
#else
int InitShm(const char* file_name, const int size);
#endif
static int SetShmSize(int nSize);
static int GetShmSize(int &nSize);
int WriteShm(char * inShm, int inSize, int ptrOffset);
int ReadShm(char * &outShm, int outSize, int ptrOffset);
char* MapFile(const char* file_name, const int stab_total_size);
int ReadShmEx(char * outShm, int outSize, int ptrOffset);
};
#endif

View File

@@ -0,0 +1,130 @@
#ifndef ___CDY_CFG_LOCAL_H__
#define ___CDY_CFG_LOCAL_H__
#ifdef _WINDOWS64
#ifdef DY_READ_CONFIG_LOCAL_EXPORTS
#define DY_READ_CONFIG_LOCAL_API __declspec(dllexport)
#else
#define DY_READ_CONFIG_LOCAL_API __declspec(dllimport)
#endif
#else
#define DY_READ_CONFIG_LOCAL_API
#endif
#include <iostream>
#include <map>
#include <vector>
using namespace std;
class DY_READ_CONFIG_LOCAL_API CDyCfgLocal
{
public:
CDyCfgLocal();
~CDyCfgLocal();
//从dy_config.sys读取
/************************************************************
Description:根据dy_name获取dy应用注册应用名
Input: dy_name
Output:app_name
************************************************************/
int GetDyAppNameByDyName (const string dy_name , string& app_name);
/************************************************************
Description:根据dy_name获取dy应用注册应用号
Input: dy_name
Output:app_no
************************************************************/
int GetDyAppNoByDyName (const string dy_name , int& app_no);
/************************************************************
Description:根据dy_name、proc_name,分配当前进程端口号
is_control只对dy_commit,dy_query_sample_server有效
Input: dy_name,proc_name,is_control
Output:app_no
************************************************************/
int GetAppPortPosByDyName (const string dy_name , const string proc_name ,
int& proc_port, bool is_control = true);
/************************************************************
Description:根据dy_name获取dy应用所服务的应用名,如dy_iscada为iscada应用服务
Input: dy_name
Output:app_name
************************************************************/
int GetServedAppNameByDyName (const string dy_name , string& app_name);
/************************************************************
Description:根据dy_name获取dy应用所服务的应用号
Input: dy_name
Output:app_no
************************************************************/
int GetServedAppNoByDyName (const string dy_name, int& app_no);
/************************************************************
Description:获取所有dy_name
Input:
Output:vec_dy_names
************************************************************/
int GetAllDyNameFromCfg (vector<string>& vec_dy_names);
/************************************************************
Description:获取dy_name下的所有dys_name
Input:dy_name
Output:vec_dys_names
************************************************************/
int GetAllDysNameByDyNameFromCfg (const string dy_name,
vector<string>& vec_dys_names);
/************************************************************
Description:获取所有使用DY应用的应用号
Input:
Output:vec_app_no
************************************************************/
int GetAllDyAppNo (vector<int>& vec_app_no);
/************************************************************
Description:检查app_no应用是否使用DY
Input:app_no
Output:-1:读取dy_config.sys配置文件出错;0:未使用DY;1:使用DY
************************************************************/
int CheckDyAppNo (const int app_no);
/************************************************************
Description:根据应用号获取dy_name,对应dy_config.sys中dy_app
Input:app_no
Output:dy_name
************************************************************/
int GetDyNameByAppNo (const int app_no, string &dy_name);
/************************************************************
Description:根据app_no、proc_name,分配当前进程端口号
is_control只对dy_commit,dy_query_sample_server有效
Input:app_no,proc_name,is_control
Output:proc_port
************************************************************/
int GetAppPortPosByAppNo (const int app_no , const string proc_name ,
int& proc_port, bool is_control = true);
/************************************************************
Description:根据dy应用所服务的应用号获取dy应用应用号
Input:app_no
Output:register_app
************************************************************/
int GetDyAppByServedApp (const int app_no, int &register_app);
private:
int getIndexByServiceName (string service_name) ;
int getIndexByDyName (const string dy_name) ;
string gDyIntToStr (int nVal);
int ReadDyConfigInfoLocal();
int StringCopy (char *des, const char *src, int max_len);
vector<string> m_vec_dy_names;
map<string, vector<string> > m_dy_dys_vec_map;
vector<string> m_vec_app_name;
vector<int> m_vec_port_pos;
map<string, int> m_dyname_app_map;
map<int, string> m_app_dyname_map;
//app_name->app_no from mng_app_num_name.ini
map<string, int> m_mng_app_name_map;
map<int, int> m_app_dyapp_map;
map<string, int> m_procname_port_map;
bool m_read_cfg;//配置文件读取成功标识
// void gUsleep(const int usec);
};
#endif

View File

@@ -0,0 +1,85 @@
#ifndef ___CDYCOMMITCLIENT_H__
#define ___CDYCOMMITCLIENT_H__
#ifdef _WINDOWS64
#ifdef DY_COMMIT_DLL_EXPORTS
#define DY_COMMIT_DLL_API __declspec(dllexport)
#else
#define DY_COMMIT_DLL_API __declspec(dllimport)
#endif
#else
#define DY_COMMIT_DLL_API
#endif
#ifndef _WINDOWS64
#include <arpa/inet.h>
#include <netdb.h>
//#include <unistd.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include "dy_commit_m.h"
//#include "common_service_interface.h"
//#include <OB/common_service_interface.h>
#include "msg_api/message_inv.h"
#include "sysadm/scn_service.h"
#include "servicemanage.h"
#include "pub_ctx.h"
#include "system.h"
#include "port_def.h"
#include "db_com/CDyCfgLocal.h"
using namespace NS_SYSADMIN;
//#include <sys/types.h>
//#include <sys/socket.h>
/*#ifndef SERVEICE_CLASS_H
#define SERVEICE_CLASS_H
class CServicesManage servicesman;
#endif*/
struct TDyReCommitProp //扩展用,暂不使用
{
int app_no;
};
class DY_COMMIT_DLL_API CDyCommitClient
{
public:
CDyCommitClient (int sys_port);
CDyCommitClient (int sys_port, int seconds);
CDyCommitClient();//用于图形修改SCADA数据
~CDyCommitClient();
//void SetAppNo(const int app_no);
void SetRequestTimeout (int seconds);
short VSCommit (TDyCommitVS DyCommitVSStru);
short KVSCommit (TDyCommitKVS DyCommitKVSStru);
private:
ServiceInfo m_Serviceinfo;
CDyCfgLocal m_dy_cfg_read;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
CScnService* m_ServicesManage;
int m_RequestTimeoutSeconds;
int GetHostByAppNo (char* host_name, const int app_no, const short context_no);
int SetServiceHost(int app_no);
bool print_env;//是否输出打印语句
//记录应用是否需要调用总控服务
map<int,bool> map_app_is_ctrl;
//是否需要自动获取端口号,CDyCommitClient()下生效
bool m_is_port_auto_set;
short GetIsCtrlByApp(const int app_no,bool &is_ctrl);
};
#endif

View File

@@ -0,0 +1,80 @@
#ifndef __CDYMONITORCLIENT_H__
#define __CDYMONITORCLIENT_H__
/*
#ifdef _WINDOWS64
#ifdef DY_MONITOR_DLL_EXPORTS
#define DY_MONITOR_DLL_API __declspec(dllexport)
#else
#define DY_MONITOR_DLL_API __declspec(dllimport)
#endif
#else
#define DY_MONITOR_DLL_API
#endif
*/
#include "dy_monitor_m.h"
#include "sysadm/scn_service.h"
#include "system.h"
#include "pub_ctx.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "servicemanage.h"
//#include "common_service_interface.h"
//#include <OB/common_service_interface.h>
using namespace NS_SYSADMIN;
class CDyMonitorClient// : virtual public common_service_interface
{
public:
//CDyMonitor_var m_Specify_GenerInvoke;
//CDyMonitor_var m_GenerInvoke;
public:
/*CDyMonitorClient(int app_id, char * specify_host_name, int specify_port, char * specify_server_object, short context =0 , char * orb_name = NULL)
:common_service_interface(app_id, specify_host_name, specify_port, specify_server_object, context, orb_name){}
CDyMonitorClient(int app_id, int policy, int sys_port,char * server_object, short context = 0, char * orb_name = NULL)
:common_service_interface(app_id, policy,sys_port, server_object, context , orb_name){}
CDyMonitorClient(int app_id, int policy, int sys_port, char * server_object,const vector<T_Corba_Props> &props_vec, short context =0, char * orb_name = NULL)
:common_service_interface( app_id, policy, sys_port, server_object, props_vec , context , orb_name){}
CDyMonitorClient(int app_id, char * specify_host_name, int specify_port, char * specify_server_object, const vector<T_Corba_Props> &props_vec, short context = 0, char * orb_name = NULL)
:common_service_interface( app_id, specify_host_name, specify_port, specify_server_object, props_vec, context , orb_name){}
*/
CDyMonitorClient();
CDyMonitorClient(int port);
CDyMonitorClient(int port, int seconds);
~CDyMonitorClient();
void SetRequestTimeout(int seconds);
//设置应访问的服务所属应用,默认AP_DATA_SRV_DY
void SetAppNo(const int app_no);
//调用的接口函数声明在下面增加根据IDL映射后的头文件中定义设置
short GetMasterDyInfo(const char* strDyName,TDyLoginInfo &masterDyInfo);
short MasterDySwitchByDyServiceName(const char* strDyName);
short GetDyNum(int &nSize);
short GetAllDyServerInfo(TDyServiceInfo &dyServerInfoSec);
private:
ServiceInfo m_Serviceinfo;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
CScnService *m_ServicesManage;//modify by wuhan
int m_RequestTimeoutSeconds;
int m_app_no;
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
int SetServiceHost();
};
#endif

View File

@@ -0,0 +1,64 @@
#ifndef ___CDYMONITORLOCAL_H__
#define ___CDYMONITORLOCAL_H__
/*
#ifdef _WINDOWS64
#ifdef DY_MONITOR_DLL_LOCAL_EXPORTS
#define DY_MONITOR_DLL_LOCAL_API __declspec(dllexport)
#else
#define DY_MONITOR_DLL_LOCAL_API __declspec(dllimport)
#endif
#else
#define DY_MONITOR_DLL_LOCAL_API
#endif
*/
#include "dy_monitor_define.h"
#include "CDyMonitorShm.h"
class CDyMonitorLocal
{
public:
CDyMonitorLocal();
~CDyMonitorLocal();
//初始化信号量,读取dy_config.sys
int InitDyMonitorLocal();
//不初始化信号量,仅为读取dy_config.sys用,与InitDyMonitorLocal()只能2选1
int InitDyLoginParaInfo();
//get info from shm
int GetMasterDyInfo (string strDysName, TLoginDyInfo &masterDyInfo);
int GetMasterDyInfo (string dy_name,string strDysName, TLoginDyInfo &masterDyInfo);
int GetDyNum (int &nSize);
int GetAllDyServerInfo (vector<TLoginDyInfo> &dyServerInfoVec);
int GetAllDyServerInfo (const string strDyName,vector<TLoginDyInfo> &dyServerInfoVec);
int getIndexByServiceName (string service_name) ;
int getIndexByServiceName (const string dy_name,const string service_name) ;
//get info from dy_config.sys
int GetAllDySNameFromCfg(string strDyName,vector<string>& dySNameVec);
int GetAllDyNameFromCfg (vector<string>& vec_dy_names);
int GetDyNumFromCfg(int &nSize);
int GetDyServerInfoByIndex (const int index,TLoginDyInfo& dyServerInfo);
private:
int getIndexByDyName (const string dy_name) ;
string gDyIntToStr (int nVal);
int ReadDyConfigInfoLocal();
int StringCopy (char *des, const char *src, int max_len);
vector<TLoginDyInfo> m_dy_config_info;
vector<string> m_vec_dy_names;//按配置顺序记录所有dy_name
vector<int> m_vec_dy_pos;//记录dy_name在m_dy_config_info中对应的起始位置,对应m_vec_dy_names
map<string,vector<string> > m_app_dys_map;
// void gUsleep(const int usec);
};
#endif

View File

@@ -0,0 +1,63 @@
//******************************************************************
//
// AUTHOR : JiXueChun
//
// FUNCTION : 数据库监视进程中操作共享内存 类方法定义
//
// TIME : 2006.11.20
//
// HISTORY :
// Datetime Action Author Reason
// -----------------------------------------------------------------
// 2006.11.20 Creation JiXueChun
// 2008.07.29 Modify JiXueChun add support to distributed dys
//******************************************************************
#ifndef __CDYMONITORSHM_H_
#define __CDYMONITORSHM_H_
#include "dy_monitor_define.h"
class CDyMonitorShm
{
protected:
CDyMonitorShm();
public:
static CDyMonitorShm & getInstance()
{
static CDyMonitorShm gCDyMonitorShm;
return gCDyMonitorShm;
}
~CDyMonitorShm();
private:
CDyShm m_DbShm;
TLoginDyInfo * m_pAllDyInfo;
int m_nDyNum;
static int m_nDyNumOffset;
static int m_nAllDyAppStatusOffset;
static int m_nAllDyInfoOffset;
int m_TotalShmSize;
public:
int InitDyMonitorShm();
int SetDyAppStatusInfoByIndex (int index, int nStatus);
int GetDyAppStatusInfoByIndex (int index, int &nStatus);
int SetDyNum (int nDyNum);
int GetDyNum (int &nDyNum);
int SetDyServiceInfoByIndex (int index, const TLoginDyInfo &dyServiceInfo);
int GetDyServiceInfoByIndex (int index, TLoginDyInfo &dyServiceInfo);
private:
string gDyIntToStr (int nVal);
};
#endif

View File

@@ -0,0 +1,67 @@
#ifndef __CDYSEM_H_
#define __CDYSEM_H_
#ifdef _WINDOWS64
#ifdef PUB_TOOLS_EXPORTS
#define PUB_TOOLS_API __declspec(dllexport)
#else
#define PUB_TOOLS_API __declspec(dllimport)
#endif
#else
#define PUB_TOOLS_API
#endif
#include <iostream>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef _WINDOWS64
#include <unistd.h>
#include <sys/ipc.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <algorithm>
#include <errno.h>
#include <sys/sem.h>
#include <ctype.h>
#include <vector>
#else
#include <windows.h>
#endif
using namespace std;
union dy_semun
{
int val;
struct semid_ds *buf;
unsigned short *array;
};
class PUB_TOOLS_API CDySem
{
#ifndef _WINDOWS64
int m_nSemId;
#else
char m_pSemName[64];
#endif
public:
CDySem();
~CDySem();
#ifndef _WINDOWS64
int InitSem(key_t key, int nsems, int initval);
int GetSemValue(int sem_id, int sem_num);
int ClearSemValue(int sem_id, int sem_num);
#else
int InitSem(const char *sem_name);
#endif
int p();
int v();
};
#endif

View File

@@ -0,0 +1,35 @@
#ifndef __CDYSEMUSE_H_
#define __CDYSEMUSE_H_
#ifdef _WINDOWS64
#ifdef PUB_TOOLS_EXPORTS
#define PUB_TOOLS_API __declspec(dllexport)
#else
#define PUB_TOOLS_API __declspec(dllimport)
#endif
#else
#define PUB_TOOLS_API
#endif
#include "CDySem.h"
class PUB_TOOLS_API CDySemUse
{
public:
CDySemUse(CDySem &sem);
~CDySemUse();
private:
CDySem &m_Sem;
int m_nPflag;
int m_nVflag;
public:
int GetPflag();
int GetVflag();
};
#endif

View File

@@ -0,0 +1,86 @@
#ifndef __CDYSHM_H
#define __CDYSHM_H
#ifdef _WINDOWS64
#ifdef PUB_TOOLS_EXPORTS
#define PUB_TOOLS_API __declspec(dllexport)
#else
#define PUB_TOOLS_API __declspec(dllimport)
#endif
#else
#define PUB_TOOLS_API
#endif
#include <sys/types.h>
#ifndef _WINDOWS64
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/utsname.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <algorithm>
#include <errno.h>
#include <sys/sem.h>
#include <ctype.h>
#include <vector>
#include <math.h>
#include <sys/mman.h>
#include <assert.h>
#include <pthread.h>
#include <signal.h>
#include <dirent.h>
#include <malloc.h>
#else
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <direct.h>
#include <io.h>
#include <windows.h>
#include <errno.h>
#endif
class PUB_TOOLS_API CDyShm
{
public:
CDyShm();
~CDyShm();
private:
int m_TotalShmSize;
char* m_pShm;
public:
#ifndef _WINDOWS64
int InitShm(key_t key, int size);
#else
int InitShm(const char* file_name, const int size);
#endif
int SetShmSize(int nSize);
int GetShmSize(int &nSize);
int WriteShm(char * inShm, int inSize, int ptrOffset);
int ReadShm(char * &outShm, int outSize, int ptrOffset);
char* MapFile(const char* file_name, const int stab_total_size);
};
#endif

View File

@@ -0,0 +1,30 @@
//******************************************************************
// AUTHOR : WangChangpin
// FUNCTION : Ìṩ¶ÁÈ¡dy_get_tag.sysº¯Êý
// TIME : 2014.11.10
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2014.11.10 Creation
//******************************************************************
#ifndef _CDY_TAG_SHM_INFO_H_
#define _CDY_TAG_SHM_INFO_H_
#include "paramanage.h"
class CDyTagShmInfo
{
public:
CDyTagShmInfo();
~CDyTagShmInfo();
short GetMaxWaitTime(int& wait_time);
short GetMaxCountByDyName(const string dy_name,int& max_tag_count);
short GetShmKeyByDyName(const string dy_name,int& shm_key);
private:
CParaManage * pm;
};
#endif

View File

@@ -0,0 +1,94 @@
#ifndef _CERRORLOG_H
#define _CERRORLOG_H
#ifdef _WINDOWS64
#ifdef PUB_TOOLS_EXPORTS
#define PUB_TOOLS_API __declspec(dllexport)
#else
#define PUB_TOOLS_API __declspec(dllimport)
#endif
#else
#define PUB_TOOLS_API
#endif
#include <iostream>
#include <string>
#include <vector>
#include <sys/stat.h>
#ifdef _WINDOWS64
#include <time.h>
#include <direct.h>
#else
#include <sys/time.h>
#include <dirent.h>
#endif
//#include "paramanage.h"
#include "system.h"
#include "db_com/wholepubtools.h"
using namespace std;
const int ONE_DAY_TIME = 24 * 60 * 60;
const int MAX_ERROR_LOG_SIZE = 100;
const int ERR_MAX_FILE_NAME = 255;
const int ERR_MAX_PARA_NAME = 128;
const string ERR_IN_DIR_SEPARATOR = "/in/";
const string ERR_OUT_DIR_SEPARATOR = "/out/";
//错误信息结构
struct TDbErrorMsg
{
int err_no; //DBAccess错误号
string dbaccess_err; //DBAccess错误信息
string db_err; //数据库错误信息
};
class PUB_TOOLS_API CErrorLog
{
private:
time_t m_LastTime;
time_t m_CurTime;
string m_strFileName;
bool m_bReCreateFile;
int m_nFileNo;
bool m_LogFlag;
int m_nPid;
string m_strPubPath;
vector<string> m_strDbNameVec; //所有数据库服务器名
time_t m_LastWriteFileTime; //最近一次写SQL语句文件的时间
public:
CErrorLog();
~CErrorLog();
int InitErrorLog();
int WriteErrorLog(string sql, vector<TDbErrorMsg> err_vec, const string strpath, string strDbName = "");
int WriteLog(vector<string> strLogVec, const string strpath);
int WriteLog(string strLog, const string strpath);
//zhangkeheng add for LOB
int WriteErrorLog(string sql, string select_sql, vector<TDbErrorMsg> err_vec, const string strpath);
private:
int GetTimeStringByTime_t(const time_t seconds, string &value_string) const;
int CheckIfReCreateFile();
int GetPubPath();
string IntToStr(int nVal);
};
#endif

View File

@@ -0,0 +1,143 @@
#ifndef _CFINDFILE_H_
#define _CFINDFILE_H_
#ifdef _WINDOWS64
#ifdef PUB_TOOLS_EXPORTS
#define PUB_TOOLS_API __declspec(dllexport)
#else
#define PUB_TOOLS_API __declspec(dllimport)
#endif
#else
#define PUB_TOOLS_API
#endif
#include <stdlib.h>
#include <vector>
#include <iostream>
#include <functional>
#include <algorithm>
#include <string>
#include <stdio.h>
#ifndef _WINDOWS64
#include <unistd.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <vector>
#include <dirent.h>
#include <time.h>
#else
#include <windows.h>
#include <direct.h>
#include <vector>
#include <string>
#endif
using namespace std;
#define MAXNAMLENGTH 256
#ifndef _WINDOWS64
class CFindFile
{
public:
CFindFile();
~CFindFile();
private:
///enum {MAXNAMLEN = 256};
char m_chPath[MAXNAMLENGTH];
char m_chName[MAXNAMLENGTH];
DIR *m_pDir;
dirent *m_pDirent;
bool IsSpecialType(int nType) const;
public:
char *GetFileName() ;
bool IsDirectory() const;
bool IsFifo() const;
bool IsChar() const;
bool IsBlock() const;
bool IsLink() const;
bool IsSocket() const;
bool IsNormal() const;
void OwnerMode(bool &bRead,bool &bWrite,bool &bExec);
void GroupMode(bool &bRead,bool &bWrite,bool &bExec);
void OtherMode(bool &bRead,bool &bWrite,bool &bExec);
bool GetLastModifyTime(int &sec);
int chrcnt(const char *string,int letter);
public:
bool FindFile(char *pPath);
int FindNext();
int RmOldFile(char* pPath , int cur_sec , int time_interval);
bool GetFindFileName(string &filename);
bool GetFindFileName(const string strPathName , vector<string> &filenameVec , int nFileNum);
bool GetCurFileName(string & filename) ;
int CheckPath(string strPathname);
bool CheckDirSizeOutOfMaxSize(string strPathName , int nMaxSize);
int RemoveDir(string strPathName);
//zhangkeheng add for REP
bool GetFindFileNameByAlphaSort(string &filename);
bool GetFindFileNameByAlphaSort(const string strPathName , vector<string> &filenameVec , int nFileNum);
bool GetFindFileNameByAlphaSort1(string &filename , int & count);
//zhangkeheng add for 时序相关
bool GetRep1FileCountByAlphaSort(string &filename , int & rep1_count, const int max_count);
//chenpeng add for 复制服务分目录
bool GetFindDirNameByAlphaSort(const string strPathName , vector<string> &dirnameVec , int nDirNum);
bool GetFindDirNameByAlphaSort(const string strPathName , string &dirname ,bool need_check = true);
int GetFindFileNameByAlphaSort(const string strPathName , vector<string> &filenameVec , string &dirname,int nFileNum , bool need_check = true);
bool GetFindDirNameByAlphaSort1(string &dirname , int & count);
};
#else
class PUB_TOOLS_API CFindFile
{
public:
CFindFile();
~CFindFile();
public:
int CheckPath(string strPathname);
//zhangkeheng add for REP
bool GetFindFileNameByAlphaSort(string &filename);
bool GetFindFileNameByAlphaSort(const string strPathName, vector<string> &filenameVec , int nFileNum);
bool GetFindFileNameByAlphaSort1(string &filename , int & count);
//zhangkeheng add for 时序相关
bool GetRep1FileCountByAlphaSort(string &filename , int & rep1_count, const int max_count);
//chenpeng add for 复制服务分目录
bool GetFindDirNameByAlphaSort(const string strPathName , string &dirname ,bool need_check = true);
int GetFindFileNameByAlphaSort(const string strPathName , vector<string> &filenameVec , string &dirname,int nFileNum , bool need_check = true);
bool GetFindDirNameByAlphaSort1(string &dirname , int & count);
};
#endif
#endif

View File

@@ -0,0 +1,59 @@
#ifndef __CPRECTIME_H
#define __CPRECTIME_H
#ifdef _WINDOWS64
#ifdef PUB_TOOLS_EXPORTS
#define PUB_TOOLS_API __declspec(dllexport)
#else
#define PUB_TOOLS_API __declspec(dllimport)
#endif
#else
#define PUB_TOOLS_API
#endif
#include <iostream>
#include <string>
#ifdef _WINDOWS64
#include <windows.h>
#else
#include <sys/time.h>
#endif
using namespace std;
class PUB_TOOLS_API CPrecTime
{
string m_strWork;
public:
CPrecTime (const string & strWork);
~CPrecTime();
public:
int StartTime();
int FinishTime();
/************************************************************
Description:»ñÈ¡¼ÆÊ±Ê±¼ä
Input:
Output:
Input/Output:
Others:
************************************************************/
float GetUsedTime();
private:
#ifndef _WINDOWS64
struct timeval m_TpStart, m_TpFinish;
struct timezone m_TzpStart, m_TzpFinish;
#else
int m_StartMSec;
int m_EndMSec;
#endif
};
#endif

View File

@@ -0,0 +1,93 @@
/*
* CRecordSet.h
*
* Created on: 2013-2-19
* Author: drizzt
*/
#ifndef CRECORDSET_H_
#define CRECORDSET_H_
#include <string>
#include <iostream>
#include "db_com/wholesqlsp.h"
using namespace std;
class FieldValue
{
public:
FieldValue(TResultDataValue *data_value);
~FieldValue();
public:
short DataType();
bool isNull();
string toString();
int toInt();
long toLong();
float toFloat();
private:
TResultDataValue *m_result_data;
};
class CRecordSet
{
public:
CRecordSet();
~CRecordSet();
public:
int GetQueryResult(char *query_sql);
int GetRecordNum(); //获取查询结果记录个数
int GetColumnNum(); //获取查询结果域个数
template<class T>
int GetQueryResult(char *query_sql, vector<T> &query_record_vec)
{
int record_num;
SEQOutDataTypeStru data_type_seq;
TSelectResultStru result_ptr;
SEQDBErrorStru err_vec;
VIndicator is_nulls;
if (m_sql_sp_client->SelectSql(query_sql, QUERY_ALL_RESULT, data_type_seq, result_ptr, err_vec) != 0)
{
cout<<"GetRecordData SelectSql : "<<query_sql<<" 失败"<<endl;
cout<<"错误信息 : "<<err_vec[0].error_msg<<endl;
return -1;
}
record_num = result_ptr.data_num;
CSqlResultAlignClient result_align;
query_record_vec.clear();
query_record_vec.resize(record_num);
if (record_num > 0)
{
T *struct_ptr = &query_record_vec[0];
if(result_align.GetAlignResultClient(result_ptr.field_info, result_ptr.data_value_seq, is_nulls, struct_ptr, sizeof(T)) < 0)
{
cout<<"GetRecordData GetAlignResultClient 失败"<<endl;
query_record_vec.clear();
return -1;
}
}
return 0;
}
public:
FieldValue operator() (int row, int col);
short GetFieldDataType(int column_num);
private:
sql_sp_client_base *m_sql_sp_client;
int m_record_num;
int m_field_num;
SEQOutDataTypeStru m_data_type_seq;
TSelectResultStru m_result_ptr;
SEQDBErrorStru m_err_vec;
};
#endif /* CRECORDSET_H_ */

View File

@@ -0,0 +1,40 @@
#ifndef __C_REDIS_ACCESS_H__
#define __C_REDIS_ACCESS_H__
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <string>
#include <iostream>
#ifdef _REDIS_ACCESS
#include "hiredis.h"
#endif
using namespace std;
#define REDIS_ACCESS_SUCCESS 1
#define REDIS_ACCESS_FAIL -1
class CRedisAccess
{
public:
CRedisAccess();
int Connect(const char *ip, int port, string& err_str);
int disConnect();
int setString(const string &key, const string &value, string& err_str);
int setString(const string & data, string& err_str);
int getString(const string & key, string & value, string& err_str);
int freeReply();
bool isDisconnected();
private:
#ifdef _REDIS_ACCESS
redisContext * _context;
redisReply * _reply;
#endif
};
#endif

View File

@@ -0,0 +1,405 @@
/*************************************************
Copyright (C), 1988-1999, Nari Tech. Co., Ltd.
File name: CRepSet.h
Author: LH
Version: 1.0
Date: 2011.8.24
Description: 复制动态库头文件
Function List:
1.int InitReplicateSet(void); 初始化复制动态库
2.int ReplicateSql(const vector<string> &sqlVec); 复制sql请求至同步文件
Datetime Action Author Modify
-------------------------------------------------------------------
2011.8.24 Creation LH
2014.03.25 add wp
目前版本具有两套功能, 每套功能 的接口不能混用:
1.复制sql请求至同步文件(原有功能)
相关接口:
int InitReplicateSet(void);
int ReplicateSql(const vector<string> &sqlVec);
int WriteRepSql(const vector<string> &sql_vector);
int LogRepWrite(const string remote_db_name, const string &err_msg, int log_flag = 0);
int MoveInFileToOutFile(string inFilePath, string outFilePath, string remote_db_name);
int MoveFileToCommitDir(string &err_msg);
int GetAllDbPubPath(void);
int CheckCommitSysFile(string remote_db_name, string uncommit_file_path, vector<string> &commit_sql_vec);
int isAutoRep(void);
2.记录复制sql、回滚信息、回滚触发信息至同一个同步文件(新增功能) 可以多线程调用。
调用顺序: 先调用InitReplicateSet初始化GetRepFileName获取文件名然后就可以调用函数写入RepSql、RollbackInfo和RollbackTri
相关接口:
int InitReplicateSet(int thread_id);
int GetRepFileName(const string keyid, const string user_name,string & str_filename);
int WriteRepSqlByFilename(const string rep_file_name, const vector<string> &sql_vector);
int WriteRollbackInfoByFilename(const string rep_file_name, const vector<string> &sql_vector);
int WriteRollbackTriByFilename(const string rep_file_name, const vector<string> &sql_vector);
int WriteCommonInfoByFilename(const string rep_file_name, const vector<string> &sql_vector);
int WriteOrigStatusByFilename(const string rep_file_name, const string &sql_string);
int WriteModifiedStatusByFilename(const string rep_file_name, const string &sql_string);
int MoveFileToCommitDir (vector<string> file_name_vec, string &err_msg);
int MoveInFileToOutFileByFilename(string file_name);//WriteRepSqlByFilename调用此接口来移动文件到out目录中
int ReadRepSqlByFilename( const string file_name, vector<string> &str_sql_vec);
int ReadRollbackInfoByFilename( const string file_name, vector<string> &rollback_info_vec);
int ReadRollbackTriByFilename( const string file_name, vector<string> &rollback_tri_vec);
int ReadCommonInfoByFilename( const string file_name, vector<string> &common_vec);
int ReadOrigStatusByFilename( const string file_name, string &orig_string;
int ReadModifiedStatusByFilename( const string file_name, string &modify_string);
int GetAllDbPubPath(void);
int GetAutoRepFlag(void);
int CheckCommitSysFile(string remote_db_name, string uncommit_file_path, vector<string> &commit_sql_vec);
int LogRepWrite(const string dir_name, const string &err_msg, int log_flag, int thread_id);
int WriteByFilenameAndSeparator(const string file_name,const string dir_name, const string separator_begin, const string separator_end, const vector<string> &sql_vector);
int isAutoRep(void);
*************************************************/
#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 <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include "paramanage.h"
#include "system.h"
#include "db_com/wholepubtools.h"
#include "db_com/server_define.h"
#define ROLLBACK_MAXLINE 8000
const int MAX_PARA_NAME = 64;
const int MAX_FILE_NAME = 128;
const string FILE_SEPARATOR = "\n_NARI_D5000_NORMAL_SQL_\n";
#ifndef _WINDOWS64
const string FILE_END = "\n_FILE_END_\n";
#else
const string _FILE_END_ = "\n_FILE_END_\n";
#define FILE_END _FILE_END_;
#endif
const string REPSQL = "<RepSQL>";
const string REPSQL_END = "</RepSQL>";
const string ROLLBACKINFO = "<RollbackInfo>";
const string ROLLBACKINFO_END = "</RollbackInfo>";
const string ROLLBACKTRI = "<RollbackTriggedInfo>";
const string ROLLBACKTRI_END = "</RollbackTriggedInfo>";
const string COMMONINFO = "<CommonInfo>";
const string COMMONINFO_END = "</CommonInfo>";
const string ORIGINALSTATUS = "<OriginalStatus>";
const string ORIGINALSTATUS_END = "</OriginalStatus>";
const string MODIFIEDSTATUS = "<ModifiedStatus>";
const string MODIFIEDSTATUS_END = "</ModifiedStatus>";
const string ROLLBACKSQL = "[ROLLBACKSQL]";
const string COMMIT_DIR = "commit";
const string INTERFACE_ONE = "INTERFACE_ONE"; //第一套接口
const string INTERFACE_TWO = "INTERFACE_TWO"; //第二套接口
const int SCAN_DIR_NUM_ONE_TIME = 60;
const int SCAN_FILE_NUM_ONE_TIME = 36000;
class DB_REP_LIB_API CRepSet
{
public:
CRepSet();
~CRepSet();
public:
/* 初始化复制动态库*/
int InitReplicateSet (void);
/*************************************************
Function: InitReplicateSet(int)
Description: 初始化复制动态库
Calls: GetAllDbPubPath
Input: void
Output: void
Return: 0:成功
-1:失败
*************************************************/
int InitReplicateSet (int thread_id);
/*************************************************
Function: GetRepFileName
Description: 获取一个带本地时标的文件名(<128字符)。以便后续向此文件中写入复制内容。
Input: str_filename: 文件名的字符数组名
keyid: 设备keyid
user_name: 用户名
op_type: 操作类型MODIFY_OP_INSERT, MODIFY_OP_DELETE, MODIFY_OP_UPDATE, MODIFY_OP_DELALL
Output: 将生成的文件名填充到输入参数str_filename中
Return: 0:成功 -1:gettimeofday调用失败 -2: localtime_r调用失败
*************************************************/
int GetRepFileName (const string keyid, const string user_name, int op_type,
string & str_filename);
/* sql请求复制至文件中
* 返回值1 成功
* -1 失败
* */
int ReplicateSql (const vector<string> &sqlVec);
/*************************************************
Function: WriteRepSqlByFilename
Description: 写入复制sql至指定的rep_file_name同步文件
Input: const vector<string> &sqlVec const string rep_file_name文件名
Output: void
Return: 0:成功
-1:失败
*************************************************/
int WriteRepSqlByFilename (const string rep_file_name,
const vector<string> &sql_vector);
/*************************************************
Function: WriteRollbackInfoByFilename
Description: 写入回滚信息至指定的rep_file_name同步文件
Input: const vector<string> &sqlVec const string rep_file_name文件名
Output: void
Return: 0:成功
-1:失败
*************************************************/
int WriteRollbackInfoByFilename (const string rep_file_name,
const vector<string> &sql_vector);
/*************************************************
Function: WriteRollbackTriByFilename
Description: 写入回滚触发信息至指定的rep_file_name同步文件
Input: const vector<string> &sqlVec const string rep_file_name文件名
Output: void
Return: 0:成功
-1:失败
*************************************************/
int WriteRollbackTriByFilename (const string rep_file_name,
const vector<string> &sql_vector);
/*************************************************
Function: WriteCommonInfoByFilename
Description: 写入回滚触发信息至指定的rep_file_name同步文件
若为手动则写入manual目录中
Input: const string rep_file_name文件名
sql_vector为写入的内容: 回滚信息
Output: void
Return: 0:成功
-1:失败
*************************************************/
int WriteCommonInfoByFilename (const string rep_file_name,
const vector<string> &sql_vector);
/*************************************************
Function: WriteOrigStatusByFilename
Description: 写入原始信息至指定的rep_file_name同步文件
若为手动则写入manual目录中
Input: const string rep_file_name文件名
sql_string为写入的内容: 原始信息
Output: void
Return: 0:成功
-1:失败
*************************************************/
int WriteOrigStatusByFilename (const string rep_file_name,
const string &sql_string);
/*************************************************
Function: WriteModifiedStatusByFilename
Description: 写入修改后的信息至指定的rep_file_name同步文件
若为手动则写入manual目录中
Input: const string rep_file_name文件名
sql_string为写入的内容: 修改后的信息
Output: void
Return: 0:成功
-1:失败
*************************************************/
int WriteModifiedStatusByFilename (const string rep_file_name,
const string &sql_string);
/*将SQL、commit.sys等类型文件转移至同步目录中
* 返回值1 成功
* -1 失败
* */
int MoveFileToCommitDir (string &err_msg);
int MoveFileToCommitDir (vector<string> file_name_vec, string &err_msg);
//将图形文件转移至图形专用目录中
// int MoveGraphFileToCommitDir(vector<string> file_path_vec, string &err_msg);
/*************************************************
Function: MoveInFileToOutFileByFilename
Description: 根据文件名将in目录中同步文件移至out目录中. 根据FileName移动所有远端数据名下的in文件
移动之前,在文件中加入文件结束符,表示其文件完整性
Input: string FileName
Output: void
Return: 0:成功
-1:失败
*************************************************/
int MoveInFileToOutFileByFilename (string file_name);
/*************************************************
Function: ReadRepSqlFromFile
Description: 1.根据file_name,获取文件下所有sql
Calls:
Input: 1.file_name
Output: 1.vector<string> str_sql_vec
Return: 0:成功
-1:失败
*************************************************/
int ReadRepSqlByFilename (const string file_name, vector<string> &str_sql_vec);
/*************************************************
Function: ReadRollbackInfoByFilename
Description: 1.根据全路径文件名file_name,获取文件下回滚信息
Calls:
Input: 1.file_name
Output: 1.vector<string> rollback_info_vec回滚信息
Return: 0:成功 -1:失败
*************************************************/
int ReadRollbackInfoByFilename (const string file_name,
vector<string> &rollback_info_vec);
/*************************************************
Function: ReadRollbackTriFromFile
Description: 1.根据全路径文件名file_name,获取文件下回滚触发信息
Calls:
Input: 1.file_name
Output: 1.vector<string> rollback_tri_vec回滚信息
Return: 0:成功 -1:失败
*************************************************/
int ReadRollbackTriByFilename (const string file_name,
vector<string> &rollback_tri_vec);
/*************************************************
Function: ReadCommonInfoByFilename
Description: 1.根据全路径文件名file_name,获取文件下回滚信息
Input: 1.file_name
Output: 1.vector<string> rollback_tri_vec回滚信息
Return: 0:成功
-1:失败
*************************************************/
int ReadCommonInfoByFilename (const string file_name,
vector<string> &common_vec);
/*************************************************
Function: ReadOrigStatusByFilename
Description: 1.根据全路径文件名file_name,获取文件下原始信息
Input: 1.file_name
Output: 1.string orig_string原始信息
Return: 0:成功
-1:失败
*************************************************/
int ReadOrigStatusByFilename (const string file_name, string &orig_string);
/*************************************************
Function: ReadModifiedStatusByFilename
Description: 1.根据全路径文件名file_name,获取文件下修改后的信息
Input: 1.file_name
Output: 1.string modify_string修改后的信息
Return: 0:成功
-1:失败
*************************************************/
int ReadModifiedStatusByFilename (const string file_name,
string &modify_string);
/*************************************************
Function: isAutoRep
Description: 获取同步方式:手动/自动
Input: void
Output: int
Return: >=0:成功. =0手动.=1自动
*************************************************/
int isAutoRep (void);
private:
bool m_isRepFlag;
bool m_isAutoRep;
int m_nPid;
int m_nThreadid;
string m_PubPath;
string m_InterfaceIdentity; //标识是使用的哪一组功能接口:INTERFACE_ONE 还是INTERFACE_TWO. 调用InitReplicateSet时确定m_InterfaceIdentity的值
//使用不同组的接口会报错。
vector<string> m_DbNameVec; //所有需要同步的数据库名
map<string, string> m_remote_in_path_map;
map<string, string> m_remote_out_path_map;
map<string, string> m_remote_backup_path_map;
map<string, string> m_remote_base_path_map;
private:
/*获取所有同步文件存放路径*/
int GetAllDbPubPath (void);
/*************************************************
Function: GetAutoRepFlag
Description: 根据db_rep.sys文件读取是否自动[auto_replicate]is_auto_replicate=1的部分
Calls: CFindFile::CheckPath()
Input: void
Output: void
Return: 1:成功
-1:失败
*************************************************/
int GetAutoRepFlag (void);
/*获取部分复制数据库信息*/
int GetAllPartlyRepInfo (void);
int CheckCommitSysFile (string remote_db_name, string uncommit_file_path,
vector<string> &commit_sql_vec);
string IntToStr (int value);
/*写同步文件*/
int WriteRepSql (const vector<string> &sql_vector);
/*记录日志函数,默认log_flag为0,记录生成sql文件make日志*/
int LogRepWrite (const string remote_db_name, const string &err_msg,
int log_flag = 0);
/*************************************************
Function: LogRepWrite(const string dir_name, const string &err_msg, int log_flag, int thread_id)
Description: 记录日志函数,默认log_flag为0,记录生成sql文件make日志.
多线程版本,将不同线程的日志写入不同的文件中
Calls: CFindFile findfile;
Input: const string &err_msg 写入的信息
const string dir_name 目标目录名
int log_flag,
int thread_id 传入的线程号
Output: void
Return: 1:成功
-1:失败
*************************************************/
int LogRepWrite (const string dir_name, const string &err_msg, int log_flag,
int thread_id);
/*将同步文件从in 移送至out目录中*/
int MoveInFileToOutFile (string inFilePath, string outFilePath,
string remote_db_name);
/*************************************************
Function: WriteByFilenameAndSeprator
Description: 写入信息至指定的file_name文件
Input: const vector<string> &sqlVec const string file_name文件名
const string dir_name文件所在远端数据库名: 如huazhong . 当m_isAutoRep == false时参数需要为manual
const string separator_begin, const string separator_end 开始和结束的分隔符
Output: void
Return: 1:成功
-1:失败
*************************************************/
int WriteByFilenameAndSeparator (const string file_name, const string dir_name,
const string separator_begin, const string separator_end,
const vector<string> &sql_vector);
};
#endif

View File

@@ -0,0 +1,78 @@
#ifndef __CSAVERECOMMITSQL_H_
#define __CSAVERECOMMITSQL_H_
#ifdef _WINDOWS64
#ifdef SAVE_SQL_EXPORTS
#define SAVE_SQL_API __declspec(dllexport)
#else
#define SAVE_SQL_API __declspec(dllimport)
#endif
#else
#define SAVE_SQL_API
#endif
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const string FILE_SEPARATOR = "\n_NARI_RE_COMMIT_\n";
const string IN_DIR_SEPARATOR = "/in/";
const string OUT_DIR_SEPARATOR = "/out/";
const int MAX_FILE_NAME_LENGTH = 255;
const int R_HIGH_PRIOR = 1;
const int R_MIDDLE_PRIOR = 2;
const int R_LOW_PRIOR = 3;
const int NO_SQL_DUP_RE_COMMIT = 0;
const int SQL_DUP_RE_COMMIT = 1;
const int RE_COMMIT_SAMPLE = 1;
const int RE_COMMIT_SCADA = 2;
const int RE_COMMIT_MODEL = 3;
const int RE_COMMIT_STATICS = 4;
#include "db_com/wholepubtools.h"
#include "system.h"
#include "db_commit_m.h"
class SAVE_SQL_API CSaveReCommitSql
{
public:
CSaveReCommitSql();
~CSaveReCommitSql();
public:
int SaveCommitSqlToFile(const vector<string> & strCommitSqlVec , string strFileType , int nPrior , int nCommitType , int nDupType = SQL_DUP_RE_COMMIT );
int SaveSampleSqlToFile(const vector<string> & strCommitSqlVec , string strFileType , int nPrior , int nCommitType , int nDupType = SQL_DUP_RE_COMMIT );
int SaveWarnSqlToFile(const vector<string> & strCommitSqlVec , string strFileType , int nPrior , int nCommitType , int nDupType = SQL_DUP_RE_COMMIT );
int SaveModelSqlToFile(const vector<string> & strCommitSqlVec , string strFileType , int nPrior , int nCommitType , int nDupType = SQL_DUP_RE_COMMIT );
int SaveStaticsSqlToFile(const vector<string> & strCommitSqlVec , string strFileType , int nPrior , int nCommitType , int nDupType = SQL_DUP_RE_COMMIT );
int SaveBindStructToFile(const TCommitBindStru CommitBindStru, string strFileType , int nPrior , int nCommitType , int nDupType = SQL_DUP_RE_COMMIT );
private:
int m_nFileNo;
int m_LastSaveReCommitSqlTime;
string m_strInPathName;
string m_strOutPathName;
string m_strInPathNameBind;
string m_strOutPathNameBind;
int MoveInFileToOutFile(const string strInFileName);
int GetOutFileName(const string strInFileName , string &strOutFileName);
private:
int GetPathName();
};
#endif

View File

@@ -0,0 +1,52 @@
//******************************************************************
// 商用库查询结果按结构对齐类
//
// Author liumengjue
//
// function: Sql Result Align Class
//
// time : 2003.05.27
//
//******************************************************************
#ifndef __CSQLRESULTALIGN_H
#define __CSQLRESULTALIGN_H
#ifdef _WINDOWS64
#ifdef ALIGN_EXPORTS
#define ALIGN_API __declspec(dllexport)
#else
#define ALIGN_API __declspec(dllimport)
#endif
#else
#define ALIGN_API
#endif
#include "db_com/DBAccess.h"
#include <assert.h>
class ALIGN_API CSqlResultAlign
{
public:
CSqlResultAlign();
~CSqlResultAlign();
private:
int m_nMaxDataTypeLength; //最大数据类型长度
int m_nAlignLength; //按结构对齐以后的结果长度,与输入参数align_result_length作比较检查错误
int GetDataTypeLength(int data_type); // 通过统一数据类型得到每种数据类型的长度
int GetMaxDataTypeLength(int data_type,int *m_nMaxLength);//通过统一数据类型得到最大数据类型的长度
int DoAlign(int* x, int b);
public:
int GetAlignResult(const char* result_link_ptr,
const TResultHead *result_head_ptr,
const TFieldInfo *field_info_ptr,
void* align_result_ptr,
int struct_length); //得到按结构对齐以后的结果 返回align_result_ptr
};
#endif

View File

@@ -0,0 +1,71 @@
//******************************************************************
// 商用库查询结果按结构对齐类 --- 用于客户端直接SQL和存储过程通过CORBA调用
//
// Author liumengjue
//
// function: Sql Result Align Class for client, through CORBA
//
// time : 2003.05.27
//
// --------------------------------------------------------------
//
// 由 ZhaoTiger 根据 刘孟觉 CSqlResultAlign.h 改写
//
// TIME 2003.06.24
//******************************************************************
#ifndef __CSQLRESULTALIGNCLIENT_H
#define __CSQLRESULTALIGNCLIENT_H
#ifdef _WINDOWS64
#ifdef SQL_SP_CLIENT_EXPORTS
#define SQL_SP_CLIENT_API __declspec(dllexport)
#else
#define SQL_SP_CLIENT_API __declspec(dllimport)
#endif
#else
#define SQL_SP_CLIENT_API
#endif
#include <vector>
#include <iostream>
#include "common_types.h"
#include "sql_sp_m.h"
#include "system.h"
using namespace std;
#if (defined _LINUX || defined _SUN || defined _WINDOWS64)
#define FALSE 0
#define TRUE 1
#endif
#define ALIGN_TO_RTDBKEY 1
typedef vector<bool> VIndicator;
class SQL_SP_CLIENT_API CSqlResultAlignClient
{
public:
CSqlResultAlignClient();
~CSqlResultAlignClient();
private:
int m_nMaxDataTypeLength; //最大数据类型长度
int m_nAlignLength; //按结构对齐以后的结果长度,与输入参数align_result_length作比较检查错误
int GetDataTypeLength(int data_type); // 通过统一数据类型得到每种数据类型的长度
int GetMaxDataTypeLength(int data_type, int *m_nMaxLength); //通过统一数据类型得到最大数据类型的长度
int DoAlign(int* x, int b);
public:
//int GetAlignResultClient(SEQResultFieldInfo & field_ptr, SEQResultDataValue & data_ptr, VIndicator & null_vec, void * align_result_ptr, int struct_length); //得到按结构对齐以后的结果 返回align_result_ptr
int GetAlignResultClient(SEQResultFieldInfo & field_ptr, SEQResultDataValue & data_ptr, VIndicator & null_vec, void * align_result_ptr, int struct_length, int align_mode = 0); //新增将char[20]对齐到RTDB_KEY_STRU ( align_mode = ALIGN_TO_RTDBKEY)
};
#endif

View File

@@ -0,0 +1,55 @@
//******************************************************************
// 商用库查询结果按结构对齐类 --- 用于客户端直接SQL和存储过程通过CORBA调用
//
// Author liumengjue
//
// function: Sql Result Align Class for client, through CORBA
//
// time : 2003.05.27
//
// --------------------------------------------------------------
//
// 由 ZhaoTiger 根据 刘孟觉 CSqlResultAlign.h 改写
//
// TIME 2003.06.24
//******************************************************************
#ifndef __CSQLRESULTALIGNCLIENT_H
#define __CSQLRESULTALIGNCLIENT_H
#include <vector>
#include "model_query_m.h"
#include <iostream>
using namespace std;
typedef vector<bool> VIndicator;
class CSqlResultAlignClient
{
public:
CSqlResultAlignClient();
~CSqlResultAlignClient();
private:
int m_nMaxDataTypeLength; //最大数据类型长度
int m_nAlignLength; //按结构对齐以后的结果长度,与输入参数align_result_length作比较检查错误
int GetDataTypeLength(int data_type); // 通过统一数据类型得到每种数据类型的长度
int GetMaxDataTypeLength(int data_type,int *m_nMaxLength);//通过统一数据类型得到最大数据类型的长度
int DoAlign(int* x, int b);
public:
int GetAlignResultClient(SEQResultFieldInfo & field_ptr,
SEQResultDataValue & data_ptr,
VIndicator & null_vec,
void * align_result_ptr,
int struct_length); //得到按结构对齐以后的结果 返回align_result_ptr
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,103 @@
//******************************************************************
//
// AUTHOR : ShiHaoQiu
//
// FUNCTION : 将编解码函数封装形成的动态库可进行AES加解密、获取数据的MD5值。
//
// TIME : 2014.05.14
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2014.05.14 Creation ShiHaoQiu
//******************************************************************
#ifndef DBCIPHER_H
#define DBCIPHER_H
#ifdef _WINDOWS64
#ifdef DB_CIPHER_EXPORTS
#define DB_CIPHER_DLL __declspec(dllexport)
#else
#define DB_CIPHER_DLL __declspec(dllimport)
#endif
#else
#define DB_CIPHER_DLL
#endif
#include <string>
#include <iostream>
using namespace std;
class DB_CIPHER_DLL DBCipher
{
public:
DBCipher(unsigned char* key);
//key为128位的秘钥构造时指定
virtual ~DBCipher();
//AES 加解密(加密结果通过BASE64编码)
//最大支持对明文char[15]的加密
unsigned char* AESCipher(unsigned char* input); //加密
unsigned char* AESInvCipher(unsigned char* input); //解密
void* AESCipher(void* input, int length=0);
void* AESInvCipher(void* input, int length);
//MD5
string GetMD5Value(const unsigned char* input,size_t length); //获取MD5值
//BASE64 编解码函数
/*编码
DataByte
[in]输入的数据长度,以字节为单位
*/
string Base64Encode(const unsigned char* Data,int DataByte);
/*解码
DataByte
[in]输入的数据长度,以字节为单位
OutByte
[out]输出的数据长度,以字节为单位,请不要通过返回值计算
输出数据的长度
*/
string Base64Decode(const char* Data,int DataByte,int& OutByte);
private:
//AES加解密相关成员 begin
unsigned char Sbox[256];
unsigned char InvSbox[256];
unsigned char w[11][4][4];
void KeyExpansion(unsigned char* key, unsigned char w[][4][4]);
unsigned char FFmul(unsigned char a, unsigned char b);
void SubBytes(unsigned char state[][4]);
void ShiftRows(unsigned char state[][4]);
void MixColumns(unsigned char state[][4]);
void AddRoundKey(unsigned char state[][4], unsigned char k[][4]);
void InvSubBytes(unsigned char state[][4]);
void InvShiftRows(unsigned char state[][4]);
void InvMixColumns(unsigned char state[][4]);
//AES加解密相关成员 end
//MD5计算相关成员 begin
unsigned long _state[4]; /* state (ABCD) */
unsigned long _count[2]; /* number of bits, modulo 2^64 (low-order word first) */
unsigned char _buffer[64]; /* input buffer */
unsigned char _digest[16]; /* message digest */
bool _finished; /* calculate finished ? */
void transform(const unsigned char block[64]);
void final();
const unsigned char* digest();
void encode(const unsigned long *input, unsigned char *output, size_t length);
void decode(const unsigned char *input, unsigned long *output, size_t length);
string bytesToHexString(const unsigned char *input, size_t length);
void update(const unsigned char *input, size_t length);
//MD5计算相关成员 end
};
#endif // DBCIPHER_H

View File

@@ -0,0 +1,115 @@
/*
* DBConnectPool.h
*
* Created on: 2013-6-17
* Author: lihao
*/
#ifndef DBCONNECTPOOL_H_
#define DBCONNECTPOOL_H_
#include "ThreadKit/ThreadKit.h"
#include "db_com/DBAccess.h"
#include <vector>
#include <string>
#include <deque>
using namespace std;
struct TDBConnInfo
{
char user_name[16];
char passwd[16];
char db_server_name[16];
};
/*
* 工作任务类
*/
class ThreadTask : public THREADKIT::RefCount
{
public:
ThreadTask()
{
m_pdbaccess = NULL;
m_requestBuffer = NULL;
m_requestlen = 0;
m_responseBuffer = NULL;
m_responselen = NULL;
m_p_db_info= NULL;
}
virtual ~ThreadTask(){}
virtual void SetCurDBConnection(CDbAccess* pDbAccess, TDBConnInfo* last_db_info, unsigned int pid){}
// {
// m_pdbaccess = pDbAccess;
// m_pid = pid;
// }
virtual void ProcessOneTask(){}
virtual void Wait(){}
protected:
virtual void Signal(){}
protected:
CDbAccess *m_pdbaccess;
char *m_requestBuffer;
int m_requestlen;
char **m_responseBuffer;
int *m_responselen;
unsigned int m_pid;
bool m_can_start, m_is_stopped;
TDBConnInfo* m_p_db_info;
string err_msg;
};
typedef THREADKIT::Handle<ThreadTask> ThreadTaskHandle;
class DBConnectThread; // 单个线程类
class DBConnectPoolImpl; // 线程池实体类
//
class DBConnectPool
{
public:
/*
* 创建一个包含threadPoolNum个线程的线程池
*/
DBConnectPool(unsigned int threadPoolNum);
virtual ~DBConnectPool();
//int initAllConnect(const char* user_name, const char* passwd, const char* db_service_name, string &err_msg);
// 启动所有线程工作
int start(string &err_msg);
//获取线程池中当前线程个数
unsigned int getThreadCount();
//停止所有线程
void stop();
//等待所有工作队列任务都完成
bool wait();
//msec时间内,等待所有工作队列任务都完成
//如果所有任务都完成,则返回true
bool waitTimeout(unsigned long msec);
//在线程池中加入一个工作任务
void postWork(ThreadTaskHandle task);
//处理线程中的异常
virtual void uncaughtException(THREADKIT::Thread* t);
virtual void uncaughtException(THREADKIT::Thread* t, const THREADKIT::Exception &e);
private:
friend class DBConnectThread;
int m_can_start; //
ThreadTaskHandle waitForTask(); //获取队列头部任务
void finishThisWork();
DBConnectPoolImpl* m_pool_impl;
DECLARE_NO_ASSIGN_CLASS(DBConnectPool)
};
#endif /* DBCONNECTPOOL_H_ */

View File

@@ -0,0 +1,154 @@
/*
* CDbFileNetIf.h
*
* Created on: 2012-8-1
* Author: ThinkPad
*/
#ifndef CDBFILENETIF_H_
#define CDBFILENETIF_H_
#ifdef _WIN64
# ifdef NET_IF_EXPORTS
# define NET_IF_API __declspec(dllexport)
# else
# define NET_IF_API __declspec(dllimport)
# endif
# pragma warning(disable : 4251)
#else
# define NET_IF_API
#endif
#include "db_com/DBAccess.h"
/**
@brief 文件名信息数据
*/
struct FileNameData{
union{
long idx;
long keyWord;
};
///文件名
char name[128];
///文件子类型
long idxFileSubType;
///版本号
int iVersion;
///文件大小
int iSize;
///文件修改时刻
long tmModify;
///加锁状态
bool isLocked;
///当前用户索引号
long idxUserName;
///加锁的应用类型
long idxAppType;
///加锁结点
long idxLockNode;
///加锁时刻
long tmLock;
///所属厂站 =NS::NOEXIST表示全部厂站
long idxFactoryName;
FileNameData(){ SetDefaultData(); }
void SetDefaultData(){
memset(this, 0, sizeof(*this));
}
};
// 查询时需要用到的结果指针结构
struct TQueryResultPtr
{
char *result_link_ptr;
char *result_data_ptr;
short *result_indicator_ptr;
TResultHead *result_head_ptr;
TFieldInfo *field_info_ptr;
};
// 查询包含LOB字段的SQL时需要用到的结果指针结构
struct TLOBQueryResultPtr
{
char *result_link_ptr;
char *result_data_ptr;
short *result_indicator_ptr;
TLOBResultHead *result_head_ptr;
TLOBFieldInfo *field_info_ptr;
};
class NET_IF_API CDbFileNetIf //: public CDbFileIf
{
public:
/**
@brief 构造函数
*/
CDbFileNetIf();
///析构函数
~CDbFileNetIf();
public:
/**
@brief 单个文件读取, 读文件(包括文件头信息), 返回文件的实际大小
@param fileIdx 文件记录索引号
@param pFileNameData1 文件头指针
@param pReadBuf1 读取缓冲区,此参数必需为空时接口自动分配内存由调用方使用free释放
@param len1 缓冲区大小
@retval 成功返回NS::RETURN_OK,否则返回<0
*/
int Read( const long fileIdx, FileNameData *pFileNameData1,
char* &pReadBuf, int &file_len, int mode = 0);
/**
@brief 更新文件信息,文件版本号自动加1如果文件不存在自动创建
@param FileNameData stFileNameData 文件头
@param pWriteBuf1 文件内容指针
@retval 成功返回NS::RETURN_OK,否则返回<0
*/
int Update( FileNameData &stFileNameData, const char* pWriteBuf, int mode = 0);
/**
@brief 删除单个文件信息
@param idFile1 文件信息记录索引
@retval 成功返回NS::RETURN_OK,否则返回<0
*/
int DeleteSingleFile( const long fileIdx, int mode = 0);
/**
@brief 锁定文件信息
@param strUserName1 使用者名称
@param idHostNode1 节点号
@retval 成功返回NS::RETURN_OK,否则返回<0
*/
// INT32 Lock(const INT32 idFile1, const INT32 idUser1, const INT32 idHostNode1,INT32 mode = 0);
/**
@brief 解锁文件信息
@param strUserName11 使用者名称
@param idHostNode1 节点号
@param operMachineType1 操作机器类型,缺省为本地优先
@retval 成功返回NS::RETURN_OK,否则返回<0
*/
// INT32 Unlock(const INT32 idFile1, const INT32 idUser1, const INT32 idHostNode1,INT32 mode = 0);
private:
CDbAccess m_db_access;
private:
void NewQueryResultPtr(TQueryResultPtr &query_result_ptr_stru);
void DeleteQueryResultPtr(TQueryResultPtr & query_result_ptr_stru);
void NewLOBQueryResultPtr(TLOBQueryResultPtr & query_result_ptr_stru);
void DeleteLOBQueryResultPtr(TLOBQueryResultPtr & query_result_ptr_stru);
};
#endif /* CDBFILENETIF_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,24 @@
/**
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#ifndef Hbase_CONSTANTS_H
#define Hbase_CONSTANTS_H
#include "Hbase_types.h"
namespace apache { namespace hadoop { namespace hbase { namespace thrift {
class HbaseConstants {
public:
HbaseConstants();
};
extern const HbaseConstants g_Hbase_constants;
}}}} // namespace
#endif

View File

@@ -0,0 +1,742 @@
/**
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#ifndef Hbase_TYPES_H
#define Hbase_TYPES_H
#include <thrift/Thrift.h>
#include <thrift/TApplicationException.h>
#include <thrift/protocol/TProtocol.h>
#include <thrift/transport/TTransport.h>
namespace apache { namespace hadoop { namespace hbase { namespace thrift {
typedef std::string Text;
typedef std::string Bytes;
typedef int32_t ScannerID;
typedef struct _TCell__isset {
_TCell__isset() : value(false), timestamp(false) {}
bool value;
bool timestamp;
} _TCell__isset;
class TCell {
public:
static const char* ascii_fingerprint; // = "1CCCF6FC31CFD1D61BBBB1BAF3590620";
static const uint8_t binary_fingerprint[16]; // = {0x1C,0xCC,0xF6,0xFC,0x31,0xCF,0xD1,0xD6,0x1B,0xBB,0xB1,0xBA,0xF3,0x59,0x06,0x20};
TCell() : value(), timestamp(0) {
}
virtual ~TCell() throw() {}
Bytes value;
int64_t timestamp;
_TCell__isset __isset;
void __set_value(const Bytes& val) {
value = val;
}
void __set_timestamp(const int64_t val) {
timestamp = val;
}
bool operator == (const TCell & rhs) const
{
if (!(value == rhs.value))
return false;
if (!(timestamp == rhs.timestamp))
return false;
return true;
}
bool operator != (const TCell &rhs) const {
return !(*this == rhs);
}
bool operator < (const TCell & ) const;
uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
};
void swap(TCell &a, TCell &b);
typedef struct _ColumnDescriptor__isset {
_ColumnDescriptor__isset() : name(false), maxVersions(true), compression(true), inMemory(true), bloomFilterType(true), bloomFilterVectorSize(true), bloomFilterNbHashes(true), blockCacheEnabled(true), timeToLive(true) {}
bool name;
bool maxVersions;
bool compression;
bool inMemory;
bool bloomFilterType;
bool bloomFilterVectorSize;
bool bloomFilterNbHashes;
bool blockCacheEnabled;
bool timeToLive;
} _ColumnDescriptor__isset;
class ColumnDescriptor {
public:
static const char* ascii_fingerprint; // = "3B18638852FDF9DD911BC1174265F92E";
static const uint8_t binary_fingerprint[16]; // = {0x3B,0x18,0x63,0x88,0x52,0xFD,0xF9,0xDD,0x91,0x1B,0xC1,0x17,0x42,0x65,0xF9,0x2E};
ColumnDescriptor() : name(), maxVersions(3), compression("NONE"), inMemory(false), bloomFilterType("NONE"), bloomFilterVectorSize(0), bloomFilterNbHashes(0), blockCacheEnabled(false), timeToLive(-1) {
}
virtual ~ColumnDescriptor() throw() {}
Text name;
int32_t maxVersions;
std::string compression;
bool inMemory;
std::string bloomFilterType;
int32_t bloomFilterVectorSize;
int32_t bloomFilterNbHashes;
bool blockCacheEnabled;
int32_t timeToLive;
_ColumnDescriptor__isset __isset;
void __set_name(const Text& val) {
name = val;
}
void __set_maxVersions(const int32_t val) {
maxVersions = val;
}
void __set_compression(const std::string& val) {
compression = val;
}
void __set_inMemory(const bool val) {
inMemory = val;
}
void __set_bloomFilterType(const std::string& val) {
bloomFilterType = val;
}
void __set_bloomFilterVectorSize(const int32_t val) {
bloomFilterVectorSize = val;
}
void __set_bloomFilterNbHashes(const int32_t val) {
bloomFilterNbHashes = val;
}
void __set_blockCacheEnabled(const bool val) {
blockCacheEnabled = val;
}
void __set_timeToLive(const int32_t val) {
timeToLive = val;
}
bool operator == (const ColumnDescriptor & rhs) const
{
if (!(name == rhs.name))
return false;
if (!(maxVersions == rhs.maxVersions))
return false;
if (!(compression == rhs.compression))
return false;
if (!(inMemory == rhs.inMemory))
return false;
if (!(bloomFilterType == rhs.bloomFilterType))
return false;
if (!(bloomFilterVectorSize == rhs.bloomFilterVectorSize))
return false;
if (!(bloomFilterNbHashes == rhs.bloomFilterNbHashes))
return false;
if (!(blockCacheEnabled == rhs.blockCacheEnabled))
return false;
if (!(timeToLive == rhs.timeToLive))
return false;
return true;
}
bool operator != (const ColumnDescriptor &rhs) const {
return !(*this == rhs);
}
bool operator < (const ColumnDescriptor & ) const;
uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
};
void swap(ColumnDescriptor &a, ColumnDescriptor &b);
typedef struct _TRegionInfo__isset {
_TRegionInfo__isset() : startKey(false), endKey(false), id(false), name(false), version(false), serverName(false), port(false) {}
bool startKey;
bool endKey;
bool id;
bool name;
bool version;
bool serverName;
bool port;
} _TRegionInfo__isset;
class TRegionInfo {
public:
static const char* ascii_fingerprint; // = "B58AB7A239831F8614F7B6709C89DC7B";
static const uint8_t binary_fingerprint[16]; // = {0xB5,0x8A,0xB7,0xA2,0x39,0x83,0x1F,0x86,0x14,0xF7,0xB6,0x70,0x9C,0x89,0xDC,0x7B};
TRegionInfo() : startKey(), endKey(), id(0), name(), version(0), serverName(), port(0) {
}
virtual ~TRegionInfo() throw() {}
Text startKey;
Text endKey;
int64_t id;
Text name;
int8_t version;
Text serverName;
int32_t port;
_TRegionInfo__isset __isset;
void __set_startKey(const Text& val) {
startKey = val;
}
void __set_endKey(const Text& val) {
endKey = val;
}
void __set_id(const int64_t val) {
id = val;
}
void __set_name(const Text& val) {
name = val;
}
void __set_version(const int8_t val) {
version = val;
}
void __set_serverName(const Text& val) {
serverName = val;
}
void __set_port(const int32_t val) {
port = val;
}
bool operator == (const TRegionInfo & rhs) const
{
if (!(startKey == rhs.startKey))
return false;
if (!(endKey == rhs.endKey))
return false;
if (!(id == rhs.id))
return false;
if (!(name == rhs.name))
return false;
if (!(version == rhs.version))
return false;
if (!(serverName == rhs.serverName))
return false;
if (!(port == rhs.port))
return false;
return true;
}
bool operator != (const TRegionInfo &rhs) const {
return !(*this == rhs);
}
bool operator < (const TRegionInfo & ) const;
uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
};
void swap(TRegionInfo &a, TRegionInfo &b);
typedef struct _Mutation__isset {
_Mutation__isset() : isDelete(true), column(false), value(false), writeToWAL(true) {}
bool isDelete;
bool column;
bool value;
bool writeToWAL;
} _Mutation__isset;
class Mutation {
public:
static const char* ascii_fingerprint; // = "CD9E9D4A6406AD402C90440434AE18A0";
static const uint8_t binary_fingerprint[16]; // = {0xCD,0x9E,0x9D,0x4A,0x64,0x06,0xAD,0x40,0x2C,0x90,0x44,0x04,0x34,0xAE,0x18,0xA0};
Mutation() : isDelete(false), column(), value(), writeToWAL(true) {
}
virtual ~Mutation() throw() {}
bool isDelete;
Text column;
Text value;
bool writeToWAL;
_Mutation__isset __isset;
void __set_isDelete(const bool val) {
isDelete = val;
}
void __set_column(const Text& val) {
column = val;
}
void __set_value(const Text& val) {
value = val;
}
void __set_writeToWAL(const bool val) {
writeToWAL = val;
}
bool operator == (const Mutation & rhs) const
{
if (!(isDelete == rhs.isDelete))
return false;
if (!(column == rhs.column))
return false;
if (!(value == rhs.value))
return false;
if (!(writeToWAL == rhs.writeToWAL))
return false;
return true;
}
bool operator != (const Mutation &rhs) const {
return !(*this == rhs);
}
bool operator < (const Mutation & ) const;
uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
};
void swap(Mutation &a, Mutation &b);
typedef struct _BatchMutation__isset {
_BatchMutation__isset() : row(false), mutations(false) {}
bool row;
bool mutations;
} _BatchMutation__isset;
class BatchMutation {
public:
static const char* ascii_fingerprint; // = "4B8A4A9E051CAFF532E1C0D54F6AD2AB";
static const uint8_t binary_fingerprint[16]; // = {0x4B,0x8A,0x4A,0x9E,0x05,0x1C,0xAF,0xF5,0x32,0xE1,0xC0,0xD5,0x4F,0x6A,0xD2,0xAB};
BatchMutation() : row() {
}
virtual ~BatchMutation() throw() {}
Text row;
std::vector<Mutation> mutations;
_BatchMutation__isset __isset;
void __set_row(const Text& val) {
row = val;
}
void __set_mutations(const std::vector<Mutation> & val) {
mutations = val;
}
bool operator == (const BatchMutation & rhs) const
{
if (!(row == rhs.row))
return false;
if (!(mutations == rhs.mutations))
return false;
return true;
}
bool operator != (const BatchMutation &rhs) const {
return !(*this == rhs);
}
bool operator < (const BatchMutation & ) const;
uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
};
void swap(BatchMutation &a, BatchMutation &b);
typedef struct _TIncrement__isset {
_TIncrement__isset() : table(false), row(false), column(false), ammount(false) {}
bool table;
bool row;
bool column;
bool ammount;
} _TIncrement__isset;
class TIncrement {
public:
static const char* ascii_fingerprint; // = "5F9965D46A4F3845985AC0F9B81C3C69";
static const uint8_t binary_fingerprint[16]; // = {0x5F,0x99,0x65,0xD4,0x6A,0x4F,0x38,0x45,0x98,0x5A,0xC0,0xF9,0xB8,0x1C,0x3C,0x69};
TIncrement() : table(), row(), column(), ammount(0) {
}
virtual ~TIncrement() throw() {}
Text table;
Text row;
Text column;
int64_t ammount;
_TIncrement__isset __isset;
void __set_table(const Text& val) {
table = val;
}
void __set_row(const Text& val) {
row = val;
}
void __set_column(const Text& val) {
column = val;
}
void __set_ammount(const int64_t val) {
ammount = val;
}
bool operator == (const TIncrement & rhs) const
{
if (!(table == rhs.table))
return false;
if (!(row == rhs.row))
return false;
if (!(column == rhs.column))
return false;
if (!(ammount == rhs.ammount))
return false;
return true;
}
bool operator != (const TIncrement &rhs) const {
return !(*this == rhs);
}
bool operator < (const TIncrement & ) const;
uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
};
void swap(TIncrement &a, TIncrement &b);
typedef struct _TRowResult__isset {
_TRowResult__isset() : row(false), columns(false) {}
bool row;
bool columns;
} _TRowResult__isset;
class TRowResult {
public:
static const char* ascii_fingerprint; // = "AE98EA4F344566FAFE04FA5E5823D1ED";
static const uint8_t binary_fingerprint[16]; // = {0xAE,0x98,0xEA,0x4F,0x34,0x45,0x66,0xFA,0xFE,0x04,0xFA,0x5E,0x58,0x23,0xD1,0xED};
TRowResult() : row() {
}
virtual ~TRowResult() throw() {}
Text row;
std::map<Text, TCell> columns;
_TRowResult__isset __isset;
void __set_row(const Text& val) {
row = val;
}
void __set_columns(const std::map<Text, TCell> & val) {
columns = val;
}
bool operator == (const TRowResult & rhs) const
{
if (!(row == rhs.row))
return false;
if (!(columns == rhs.columns))
return false;
return true;
}
bool operator != (const TRowResult &rhs) const {
return !(*this == rhs);
}
bool operator < (const TRowResult & ) const;
uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
};
void swap(TRowResult &a, TRowResult &b);
typedef struct _TScan__isset {
_TScan__isset() : startRow(false), stopRow(false), timestamp(false), columns(false), caching(false), filterString(false) {}
bool startRow;
bool stopRow;
bool timestamp;
bool columns;
bool caching;
bool filterString;
} _TScan__isset;
class TScan {
public:
static const char* ascii_fingerprint; // = "2C111FDF8CD162886ECCCBB9C9051083";
static const uint8_t binary_fingerprint[16]; // = {0x2C,0x11,0x1F,0xDF,0x8C,0xD1,0x62,0x88,0x6E,0xCC,0xCB,0xB9,0xC9,0x05,0x10,0x83};
TScan() : startRow(), stopRow(), timestamp(0), caching(0), filterString() {
}
virtual ~TScan() throw() {}
Text startRow;
Text stopRow;
int64_t timestamp;
std::vector<Text> columns;
int32_t caching;
Text filterString;
_TScan__isset __isset;
void __set_startRow(const Text& val) {
startRow = val;
__isset.startRow = true;
}
void __set_stopRow(const Text& val) {
stopRow = val;
__isset.stopRow = true;
}
void __set_timestamp(const int64_t val) {
timestamp = val;
__isset.timestamp = true;
}
void __set_columns(const std::vector<Text> & val) {
columns = val;
__isset.columns = true;
}
void __set_caching(const int32_t val) {
caching = val;
__isset.caching = true;
}
void __set_filterString(const Text& val) {
filterString = val;
__isset.filterString = true;
}
bool operator == (const TScan & rhs) const
{
if (__isset.startRow != rhs.__isset.startRow)
return false;
else if (__isset.startRow && !(startRow == rhs.startRow))
return false;
if (__isset.stopRow != rhs.__isset.stopRow)
return false;
else if (__isset.stopRow && !(stopRow == rhs.stopRow))
return false;
if (__isset.timestamp != rhs.__isset.timestamp)
return false;
else if (__isset.timestamp && !(timestamp == rhs.timestamp))
return false;
if (__isset.columns != rhs.__isset.columns)
return false;
else if (__isset.columns && !(columns == rhs.columns))
return false;
if (__isset.caching != rhs.__isset.caching)
return false;
else if (__isset.caching && !(caching == rhs.caching))
return false;
if (__isset.filterString != rhs.__isset.filterString)
return false;
else if (__isset.filterString && !(filterString == rhs.filterString))
return false;
return true;
}
bool operator != (const TScan &rhs) const {
return !(*this == rhs);
}
bool operator < (const TScan & ) const;
uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
};
void swap(TScan &a, TScan &b);
typedef struct _IOError__isset {
_IOError__isset() : message(false) {}
bool message;
} _IOError__isset;
class IOError : public ::apache::thrift::TException {
public:
static const char* ascii_fingerprint; // = "EFB929595D312AC8F305D5A794CFEDA1";
static const uint8_t binary_fingerprint[16]; // = {0xEF,0xB9,0x29,0x59,0x5D,0x31,0x2A,0xC8,0xF3,0x05,0xD5,0xA7,0x94,0xCF,0xED,0xA1};
IOError() : message() {
}
virtual ~IOError() throw() {}
std::string message;
_IOError__isset __isset;
void __set_message(const std::string& val) {
message = val;
}
bool operator == (const IOError & rhs) const
{
if (!(message == rhs.message))
return false;
return true;
}
bool operator != (const IOError &rhs) const {
return !(*this == rhs);
}
bool operator < (const IOError & ) const;
uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
};
void swap(IOError &a, IOError &b);
typedef struct _IllegalArgument__isset {
_IllegalArgument__isset() : message(false) {}
bool message;
} _IllegalArgument__isset;
class IllegalArgument : public ::apache::thrift::TException {
public:
static const char* ascii_fingerprint; // = "EFB929595D312AC8F305D5A794CFEDA1";
static const uint8_t binary_fingerprint[16]; // = {0xEF,0xB9,0x29,0x59,0x5D,0x31,0x2A,0xC8,0xF3,0x05,0xD5,0xA7,0x94,0xCF,0xED,0xA1};
IllegalArgument() : message() {
}
virtual ~IllegalArgument() throw() {}
std::string message;
_IllegalArgument__isset __isset;
void __set_message(const std::string& val) {
message = val;
}
bool operator == (const IllegalArgument & rhs) const
{
if (!(message == rhs.message))
return false;
return true;
}
bool operator != (const IllegalArgument &rhs) const {
return !(*this == rhs);
}
bool operator < (const IllegalArgument & ) const;
uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
};
void swap(IllegalArgument &a, IllegalArgument &b);
typedef struct _AlreadyExists__isset {
_AlreadyExists__isset() : message(false) {}
bool message;
} _AlreadyExists__isset;
class AlreadyExists : public ::apache::thrift::TException {
public:
static const char* ascii_fingerprint; // = "EFB929595D312AC8F305D5A794CFEDA1";
static const uint8_t binary_fingerprint[16]; // = {0xEF,0xB9,0x29,0x59,0x5D,0x31,0x2A,0xC8,0xF3,0x05,0xD5,0xA7,0x94,0xCF,0xED,0xA1};
AlreadyExists() : message() {
}
virtual ~AlreadyExists() throw() {}
std::string message;
_AlreadyExists__isset __isset;
void __set_message(const std::string& val) {
message = val;
}
bool operator == (const AlreadyExists & rhs) const
{
if (!(message == rhs.message))
return false;
return true;
}
bool operator != (const AlreadyExists &rhs) const {
return !(*this == rhs);
}
bool operator < (const AlreadyExists & ) const;
uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
};
void swap(AlreadyExists &a, AlreadyExists &b);
}}}} // namespace
#endif

View File

@@ -0,0 +1,32 @@
// MyMutex.h: interface for the CMyMutex class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MYMUTEX_H__7EF7FB40_63CF_4215_B3BE_899084B79372__INCLUDED_)
#define AFX_MYMUTEX_H__7EF7FB40_63CF_4215_B3BE_899084B79372__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifdef _WINDOWS64
#include <windows.h>
#else
#include <pthread.h>
#endif
class CMyMutex
{
public:
bool unlock();
bool lock();
CMyMutex();
virtual ~CMyMutex();
private:
#ifdef _WINDOWS64
CRITICAL_SECTION m_mutex;
#else
pthread_mutex_t m_mutex;
#endif
};
#endif // !defined(AFX_MYMUTEX_H__7EF7FB40_63CF_4215_B3BE_899084B79372__INCLUDED_)

View File

@@ -0,0 +1,77 @@
//
// Created by wutao on 2018/8/30.
//
#ifndef CROSS_REGION_SYNC_CLIENT_H
#define CROSS_REGION_SYNC_CLIENT_H
#include <iostream>
//#include "servicesclient.h"
#include "system.h"
#include "db_com/sql_sp_m.h"
//#include "sam_service.h"
#include "servicemanage.h"
#include "sysadm/scn_service.h"
#include "crossRequest.h"
#ifdef _WINDOWS64
#ifdef CROSS_REGION_SYNC_CLIENT_EXPORTS
#define CROSS_REGION_SYNC_CLIENT_API __declspec(dllexport)
#else
#define CROSS_REGION_SYNC_CLIENT_API __declspec(dllimport)
#endif
#else
#define CROSS_REGION_SYNC_CLIENT_API
#endif
#ifndef MAX_PARA_NAME
#define MAX_PARA_NAME 255
#endif
using namespace std;
using namespace NS_SYSADMIN;
class CROSS_REGION_SYNC_CLIENT_API CrossRegionSyncClient
{
public:
CrossRegionSyncClient();
~CrossRegionSyncClient();
short ExecuteSql(const char* sql_str, SEQDBErrorStru& out_db_error, bool region = true);//func_no = 1 --> sql_sp_server func_no = 1
short SelectSql(const char* sql_str, unsigned int max_result_num, const SEQOutDataTypeStru& out_data_type, TSelectResultStru& out_select_result, SEQDBErrorStru& out_db_error, bool region = true);//func_no = 2 --> sql_sp_server func_no = 2
short ExecuteMultiSql(int sql_num, const StrSeq& seq_sql_str, SEQExecMultiResultStru& seq_exec_multi_result, bool region = true);//func_no = 3 --> sql_sp_server func_no = 3
short ExecuteSqlSync(const char* sql_str, SEQDBErrorStru& out_db_error, bool is_sync=false);//func_no = 4 --> sql_sp_server func_no = 1
short ExecuteMultiSqlSync(int sql_num, const StrSeq& seq_sql_str, SEQExecMultiResultStru& seq_exec_multi_result, bool is_sync = false);//func_no = 5 --> sql_sp_server func_no = 3
private:
#ifdef _BIGENDIAN
const unsigned char g_endian = 1;
#else
const unsigned char g_endian = 0;
#endif
DomainInfo m_local_domain_info;
ServiceInfo m_local_service_info;
Handle m_handle;
CDomainInfo m_cross_domain_info;
int m_division_handle;
int m_is_other_area;
int m_request_timeout;
int GetDomainConf(const char* domain_tmp);
int SetServiceHost();
// int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
int GetHostBySubScnName(char * host_name, const char * sub_scn_name, const char * scn_name);
char m_host_name[64];
char m_ip_address[64];
};
#endif //CROSS_REGION_SYNC_CLIENT_H

View File

@@ -0,0 +1,53 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __DATABASE_REP_M_H__
#define __DATABASE_REP_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
#include"public_m.h"
struct TBindRepDataValue
{
UDataValue data_value;
unsigned short is_null;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TBindRepDataValue> SEQBindRepDataValue;
struct TBindRepParaStru
{
unsigned short dci_type;
unsigned int data_size;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TBindRepParaStru> SEQBindRepParaStru;
struct TRepBindStru
{
MLang::STRING sql_str;
unsigned int row_num;
SEQBindRepParaStru seq_bind_para;
SEQBindRepDataValue seq_bind_value;
TRepBindStru();
TRepBindStru(const TRepBindStru&);
TRepBindStru&operator=(const TRepBindStru&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TSqlStu
{
MLang::VECTOR<MLang::STRING> sql_vec;
TSqlStu();
TSqlStu(const TSqlStu&);
TSqlStu&operator=(const TSqlStu&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,40 @@
#ifndef DB_COMMIT_DEFINE_H
#define DB_COMMIT_DEFINE_H
#ifndef _WINDOWS64
#ifdef _ALPHA
#include <sys/uswitch.h>
#endif
#endif
#include "paramanage.h"
//#include "sam_service.h"
//#include "sam_common.h"
#include "system.h"
#include "pub_ctx.h"
const string DB_SEPARATOR = " ; ";
const string DB_COMMIT_FILE_SEPARATOR = "\n_NARI_DB_COMMIT_\n";
const string IN_DIR = "/in/";
const string OUT_DIR = "/out/";
const int ANALAY_FILE_ALLOCAT_BYTE = 10240;
const int READ_MAX_SQL_NUM_ONE_TIME = 200;
const int COMMIT_MAX_SQL_NUM_ONE_TIME = 1000;
const int COMMIT_FILE_NUM_ONE_TIME = 10;
const int SCAN_FILE_NUM_ONE_TIME = 1000;
const int MAX_SQL_SIZE = 100000;
const int GET_DB_LOGIN_TIME_INTERVAL = 3;
const int HIGH = 1;
const int MIDDLE = 2;
const int LOW = 3;
const int NO_SQL_DUP = 0;
const int SQL_DUP = 1;
const int MAX_PARA_NAME = 128;
#ifdef _WIN64 // Windows compatible version
#define strcasecmp _stricmp
#endif
#endif

View File

@@ -0,0 +1,83 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __DB_COMMIT_M_H__
#define __DB_COMMIT_M_H__
#ifdef _WINDOWS64
#ifdef DB_COMMIT_DLL_EXPORTS
#define DB_COMMIT_DLL_API __declspec(dllexport)
#else
#define DB_COMMIT_DLL_API __declspec(dllimport)
#endif
#else
#define DB_COMMIT_DLL_API
#endif
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
#include"public_m.h"
typedef CharSeq CommitLOBValueType;
typedef MLang::VECTOR<CharSeq> SEQCommitLOBValueType;
struct DB_COMMIT_DLL_API TSqlCommitStru
{
MLang::VECTOR<MLang::STRING> strSql;
unsigned char uPrior;
TSqlCommitStru();
TSqlCommitStru(const TSqlCommitStru&);
TSqlCommitStru&operator=(const TSqlCommitStru&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSqlCommitStru> SEQ_SQL_COMMIT;
struct DB_COMMIT_DLL_API TCommitStru
{
SEQ_SQL_COMMIT seqSqlCommit;
TCommitStru();
TCommitStru(const TCommitStru&);
TCommitStru&operator=(const TCommitStru&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DB_COMMIT_DLL_API TBindDataValue
{
UDataValue data_value;
unsigned short is_null;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TBindDataValue> SEQBindDataValue;
struct DB_COMMIT_DLL_API TBindCommitParaStru
{
MLang::STRING col_name;
unsigned short is_where_condition;
unsigned short dci_type;
unsigned int data_size;
TBindCommitParaStru();
TBindCommitParaStru(const TBindCommitParaStru&);
TBindCommitParaStru&operator=(const TBindCommitParaStru&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TBindCommitParaStru> SEQBindCommitParaStru;
struct DB_COMMIT_DLL_API TCommitBindStru
{
MLang::STRING table_name;
unsigned int row_num;
unsigned int col_num;
unsigned int op_type;
SEQBindCommitParaStru seq_bind_para;
SEQBindDataValue seq_bind_value;
TCommitBindStru();
TCommitBindStru(const TCommitBindStru&);
TCommitBindStru&operator=(const TCommitBindStru&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,73 @@
#ifndef __DB_ERROR_DEFINE_H_
#define __DB_ERROR_DEFINE_H_
const int DB_SUCCESS_DEF = 0;
const int DB_FAIL_DEF = -1;
//common
const int DB_MEM_ALLOC_FAIL = -100; //内存分配失败
const int DB_OPEN_FILE_FAIL = -101; //打开文件失败
const int DB_READ_FILE_FAIL = -102; //读取文件失败
const int DB_WRITE_FILE_FAIL = -103; //写文件失败
const int DB_DLE_FILE_FAIL = -104; //删除文件失败
const int DB_FILE_EMPTY = -105; //文件大小为0
const int DB_STRING_LEN_ZERO = -106; //字符串参数长度为0
const int DB_INVALID_PARA = -107; //无效参数
const int DB_SERVICE_REQUEST_FAIL = -108; //服务请求失败
const int DB_CONNECT_FAIL = -109; //数据库连接失败
const int DB_INVALID_FILE_PATHNAME = -130; //文件全路径名称格式错误
const int DB_TABLE_NOT_EXIST = -200; //表不存在
const int DB_OPEN_SYSTABLEINFO_FAIL = -201; //查询表信息表失败
const int DB_OPEN_SYSCOLUMNINFO_FAIL = -202; //查询表信息表失败
const int DB_SQL_PRE_ANALYS_FAIL = -300; //SQL语法预分析出错
const int DB_GET_ALIGN_RESULT_FAIL = -301; //GetAlignResultClient出错
const int DB_CALL_SELECTSQL_FAIL = -302; //调用SelectSql出错
const int DB_CALL_MODEL_MODIFY_FAIL = -303; //调用model_modify出错
const int DB_NO_RECORDS_FAIL = -304; //无符合条件的记录
//service
const int DB_REQUEST_SERVICE_FAIL = -401; //获取应用主机失败
const int DB_FILESRV_SAVEFILE_FAIL = -402; //调用文件服务写文件失败
const int DB_FILESRV_LISTDIR_FAIL = -403; //列文件目录失败
const int DB_FILESRV_GETFILE_FAIL = -404; //调用文件服务读文件失败
const int DB_FILESRV_DELFILE_FAIL = -405; //调用文件服务删除文件失败
//download_server
const int DOWNLOAD_APPNO_MISMATCH = -501; //表不属于指定应用
//model_modify
const int DB_MODEL_INVALID_FILENAME = -1001; //无效的回退文件名称
const int DB_MODEL_INVALID_FILE_FORMAT = -1002; //无效的回退文件格式
const int DB_MODLE_QUERY_TABLEINFO_FAIL = -1003; //查询表信息失败
const int DB_MODEL_MODIFY_FAIL = -1004; //模型更新失败
const int DB_MODEL_ROLLBACK_FILES_FAIL = -1005; //获取回退文件列表失败
const int DB_ROLLBACK_FILE_PART_FAIL = -1006; //单个回退文件部分回退失败
const int DB_ROLLBACK_FILE_ALL_FAIL = -1007; //单个回退文件全部回退失败
const int DB_MODEL_LOCKED = -1008; //模型被锁定
const int DB_GET_APP_ACTIVE_NODES_FAIL = -1009; //通过系统管理获取应用节点失败
const int DB_DY_DOWN_PART_FAIL = -1010; //动态下装部分失败
const int DB_GET_TRIGGERRELATION_FAIL = -1011; //读取触发关系表失败
const int DB_REMOTE_DYDOWNLOAD_FAIL = -1012; //远程动态下装失败
const int DB_SET_EXIST_FLAG_FAIL = -1013; //设置model_lock_info表exist_flag标识位失败
const int DB_GET_EXIST_FLAG_FAIL = -1014; //读取model_lock_info表exist_flag标识位失败
const int DB_EXIST_FLAG = -1015; //model_lock_info表exist_flag标识位已被置位
const int DB_MODIFY_TYPE_DIFF = -1016; //同一个ModifyTableBySqls请求中多个表的是否需要验证不一致
const int DB_GET_SYS_DIST_INFO_FAIL = -1017; //读取应用分布信息表失败
const int DB_GET_APP_ALLTABLES_FAIL = -1018; //读取应用下装表信息失败
const int DB_GET_IDS_FROM_FILE_FAIL = -1019; //从回退文件读取设备关键字失败
const int DB_MULTI_KEY_ERROR = -1020; //多关键字错误
const int DB_GET_STATIC_RULE_FAIL = -1021; //读取模型静态规则表失败
const int DB_GET_TRIGGERS_INFO_FAIL = -1022; //读取触发器信息失败
const int DB_DISABLE_TRIGGERS_FAIL = -1023; //禁用触发器失败
const int DB_ENABLE_TRIGGERS_FAIL = -1024; //启用触发器失败
//model_admin
const int MODEL_INVALID_PARA = -2001; //无效入参
const int MODEL_DATASRV_SUBAPP_FULL = -2002; //data_srv小应用号已满
const int MODEL_GET_ALL_MODEL_FAIL = -2003; //查询所有的模型用例信息失败
const int MODEL_MODEL_VER_NOT_FOUND = -2004; //用例未找到
const int MODEL_VERSION_USED = -2005; //模型用例正被使用
#endif

View File

@@ -0,0 +1,53 @@
//******************************************************************
//
// AUTHOR : ZhaoTiger
//
// FUNCTION : 数据库模块需要用到的全局变量定义
//
// TIME : 2003.05.30
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2003.05.30 Creation ZhaoTiger
//
//******************************************************************
#ifndef _DB_EXTERN_H
#define _DB_EXTERN_H
#include "DBAccess.h"
#include "CSqlResultAlign.h"
//#include "sam_common.h"
#include "system.h"
#include "db_def/db_define.h"
#include "db_def/db_struct_public.h"
#include "CDbRepSet.h"
// 通用数据库封装类在DBAccess.h中定义
extern CDbAccess g_db_access;
extern CDbAccess g_db_access_lob;
extern CDbAccess g_hisdb_access;
extern CDbAccess g_hisdb_access_lob;
// 系统任务管理封装类在sam_common.h中定义
//extern CSamPub sysman_class;
// 全局变量表示当前数据库连接的名称如果为空则意味着没有可用数据库1+N
extern string g_cur_db_svr_name;
// 全局变量,表示当前数据库的名称,主要给复制类使用
extern string g_cur_db_name;
// 全局变量表示当前服务是否正在进行。如果正在进行则不允许进行数据库切换。0表示没有服务在进行。
extern int g_serving_num;
//extern map<int, SVR_SAMPLE_EXT_INFO_PUBLIC> g_sample_ext_info_map;
extern bool g_has_init_sample_ext_info;
extern CDbRepSet g_db_rep_set;
#endif

View File

@@ -0,0 +1,51 @@
//******************************************************************
//
// AUTHOR : ZhaoTiger
//
// FUNCTION : 数据库模块需要用到全局变量定义
//
// TIME : 2003.05.30
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2003.05.30 Creation ZhaoTiger
//
//******************************************************************
#ifndef _DB_GLOBAL_H
#define _DB_GLOBAL_H
#include "DBAccess.h"
#include "CSqlResultAlign.h"
//#include "sam_common.h"
#include "system.h"
#include "db_def/db_define.h"
#include "db_def/db_struct_public.h"
#include "CDbRepSet.h"
// 通用数据库封装类在DBAccess.h中定义
CDbAccess g_db_access;
CDbAccess g_db_access_lob;
CDbAccess g_hisdb_access;
CDbAccess g_hisdb_access_lob;
// 系统任务管理封装类在sam_common.h中定义
//CSamPub sysman_class;
// 全局变量表示当前数据库连接的名称如果为空则意味着没有可用数据库1+N
string g_cur_db_svr_name;
// 全局变量,表示当前数据库的名称,主要给复制类使用
string g_cur_db_name;
// 全局变量表示当前服务是否正在进行。如果正在进行则不允许进行数据库切换。0表示没有服务在进行。
int g_serving_num;
//map<int, SVR_SAMPLE_EXT_INFO_PUBLIC> g_sample_ext_info_map;
bool g_has_init_sample_ext_info;
CDbRepSet g_db_rep_set;
#endif

View File

@@ -0,0 +1,11 @@
#ifndef __DB_MICRO_DEFINE_H_
#define __DB_MICRO_DEFINE_H_
//db_commit
const int DB_COMMIT_SAMPLE = 1; //通过db_commit提交采样数据
const int DB_COMMIT_SCADA = 2; //通过db_commit提交SCADA数据
const int DB_COMMIT_ALARM = 3; //通过db_commit提交告警数据
//model_admin
const string MODEL_ADMIN_FILES_HOME = "fileserv/model_admin";
#endif

View File

@@ -0,0 +1,148 @@
#ifndef _DB_MONITOR_DEFINE_H_
#define _DB_MONITOR_DEFINE_H_
#ifndef _WINDOWS64
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/utsname.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/sem.h>
#include <ctype.h>
#include <vector>
#include <time.h>
#include <functional>
#include <algorithm>
#include <map>
#include <string.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#endif
#ifndef _WINDOWS64
#ifdef _ALPHA
#include <sys/uswitch.h>
#endif
#endif
#include "paramanage.h"
#include "sysadm/scn_service.h"
#include "system.h"
#ifndef _LOCAL
#include "db_com/CDbMonitorClient.h"
#endif
#include "db_com/wholepubtools.h"
#include "pub.h"
using namespace std;
const string DB_MONITOR_PROCESS = "db_monitor";
const string DB_REPLICATE_PROCESS = "database_replicate";
const string DB_WARN_SERVER_PROCESS = "db_warn_server";
#ifndef _WINDOWS64
const int MASTER_DB_SEM_KEY = 0x1950;
const int DB_NUM_KEY = 0x1951;
const int DB_SERVICE_INFO_SEM_KEY = 0x1952;
const int FILE_SEM_KEY = 0x1953;
const int RIGHT_LOGIN_SEM_KEY = 0x1954;
const int DB_MONITOR_SHM_KEY = 0x200;
#else
const string MASTER_DB_SEM_KEY = "MASTER_DB_SEM_NAME";
const string DB_NUM_KEY = "DB_NUM_NAME";
const string DB_SERVICE_INFO_SEM_KEY = "DB_SERVICE_INFO_SEM_NAME";
const string FILE_SEM_KEY = "FILE_SEM_NAME";
const string RIGHT_LOGIN_SEM_KEY = "RIGHT_LOGIN_SEM_NAME";
const string DB_MONITOR_SHM_KEY = "db_monitor.dat";
#endif
const int DB_MONITOR_SHM_SIZE = 10*1024;
const int DB_SEM_INIT_VAL = 1;
const int MAX_DB_PARA_NAME = 64;
const int READ_DB_CONFIG_INFO_TIME_INTERVAL = 3600*6;
//应用各个状态的定义
const int APP_STATUS_DUTY = 1;
const int APP_STATUS_STANDBY = 0;
const int APP_STATUS_OTHER = -1;
const string DEFAULT_DB_SERVICE_PROCESS = "db_commit download_server sql_sp_server query_sample_server sample_data_server sample_modify_server sample_define_server model_modify midhs db_warn_server query_stat_server sample_day_statics_server";
const int MAX_REP1_STUB_NUM = 0;
typedef struct LoginInfoStru
{
char db_service_name[MAX_DB_PARA_NAME];
char user_name[MAX_DB_PARA_NAME];
char user_password[MAX_DB_PARA_NAME];
char db_service_machine[MAX_DB_PARA_NAME];
char db_name[MAX_DB_PARA_NAME];
char db_service_describe[3*MAX_DB_PARA_NAME];
bool is_switch;
int db_host_prior;
short db_login_status;
char db_err[5*MAX_DB_PARA_NAME]; //数据库错误信息
int db_cur_time; //链接时的时间
int direct_access; //是否为可以直接连接的数据库 0 不是 1 是
bool is_sample_db; //是否作为采样存储库 0 不是 1 是
struct LoginInfoStru & operator= (const struct LoginInfoStru &login_stru)
{
if( this == &login_stru)
{
return *this;
}
strcpy(db_service_name , login_stru.db_service_name );
strcpy(user_name , login_stru.user_name);
strcpy(user_password , login_stru.user_password );
strcpy(db_service_machine , login_stru.db_service_machine);
strcpy(db_name , login_stru.db_name);
strcpy(db_service_describe , login_stru.db_service_describe );
is_switch = login_stru.is_switch;
db_host_prior = login_stru.db_host_prior;
db_login_status = login_stru.db_login_status;
strcpy(db_err , login_stru.db_err);
db_cur_time = login_stru.db_cur_time;
direct_access = login_stru.direct_access;
is_sample_db = login_stru.is_sample_db;
return *this;
}
}TLoginInfo;
struct TLoginUserInfo
{
char user_name[MAX_DB_PARA_NAME];
char user_password[MAX_DB_PARA_NAME];
char db_name[MAX_DB_PARA_NAME];
struct TLoginUserInfo & operator= (const struct TLoginUserInfo &userinfo_stru)
{
if( this == &userinfo_stru)
{
return *this;
}
strcpy(user_name , userinfo_stru.user_name);
strcpy(user_password , userinfo_stru.user_password );
strcpy(db_name , userinfo_stru.db_name);
return *this;
}
};
#endif

View File

@@ -0,0 +1,145 @@
#ifndef _DB_MONITOR_DEFINE_H_
#define _DB_MONITOR_DEFINE_H_
#ifndef _WINDOWS64
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/utsname.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/sem.h>
#include <ctype.h>
#include <vector>
#include <time.h>
#include <functional>
#include <algorithm>
#include <map>
#include <string.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#endif
#ifndef _WINDOWS64
#ifdef _ALPHA
#include <sys/uswitch.h>
#endif
#endif
#include "paramanage.h"
//#include "sam_service.h"
#include "system.h"
#ifndef _LOCAL
#include "db_com/CDbMonitorClient.h"
#endif
#include "db_com/wholepubtools.h"
#include "pub.h"
using namespace std;
const string DB_MONITOR_PROCESS = "db_monitor";
const string DB_REPLICATE_PROCESS = "database_replicate";
const string DB_WARN_SERVER_PROCESS = "db_warn_server";
#ifndef _WINDOWS64
const int MASTER_DB_SEM_KEY = 0x1950;
const int DB_NUM_KEY = 0x1951;
const int DB_SERVICE_INFO_SEM_KEY = 0x1952;
const int FILE_SEM_KEY = 0x1953;
const int RIGHT_LOGIN_SEM_KEY = 0x1954;
const int DB_MONITOR_SHM_KEY = 0x200;
#else
const string MASTER_DB_SEM_KEY = "MASTER_DB_SEM_NAME";
const string DB_NUM_KEY = "DB_NUM_NAME";
const string DB_SERVICE_INFO_SEM_KEY = "DB_SERVICE_INFO_SEM_NAME";
const string FILE_SEM_KEY = "FILE_SEM_NAME";
const string RIGHT_LOGIN_SEM_KEY = "RIGHT_LOGIN_SEM_NAME";
const string DB_MONITOR_SHM_KEY = "db_monitor.dat";
#endif
const int DB_MONITOR_SHM_SIZE = 10*1024;
const int DB_SEM_INIT_VAL = 1;
const int MAX_DB_PARA_NAME = 64;
const int READ_DB_CONFIG_INFO_TIME_INTERVAL = 3600*6;
//应用各个状态的定义
const int APP_STATUS_DUTY = 1;
const int APP_STATUS_STANDBY = 0;
const int APP_STATUS_OTHER = -1;
const string DEFAULT_DB_SERVICE_PROCESS = "db_commit,sql_sp_server,query_sample_server,sample_data_server,sample_modify_server,sample_define_server,model_modify";
const int MAX_REP1_STUB_NUM = 0;
typedef struct LoginInfoStru
{
char db_service_name[MAX_DB_PARA_NAME];
char user_name[MAX_DB_PARA_NAME];
char user_password[MAX_DB_PARA_NAME];
char db_service_machine[MAX_DB_PARA_NAME];
char db_name[MAX_DB_PARA_NAME];
char db_service_describe[3*MAX_DB_PARA_NAME];
bool is_switch;
int db_host_prior;
short db_login_status;
char db_err[5*MAX_DB_PARA_NAME]; //数据库错误信息
int db_cur_time; //链接时的时间
int direct_access; //是否为可以直接连接的数据库 0 不是 1 是
struct LoginInfoStru & operator= (const struct LoginInfoStru &login_stru)
{
if( this == &login_stru)
{
return *this;
}
strcpy(db_service_name , login_stru.db_service_name );
strcpy(user_name , login_stru.user_name);
strcpy(user_password , login_stru.user_password );
strcpy(db_service_machine , login_stru.db_service_machine);
strcpy(db_name , login_stru.db_name);
strcpy(db_service_describe , login_stru.db_service_describe );
is_switch = login_stru.is_switch;
db_host_prior = login_stru.db_host_prior;
db_login_status = login_stru.db_login_status;
strcpy(db_err , login_stru.db_err);
db_cur_time = login_stru.db_cur_time;
direct_access = login_stru.direct_access;
return *this;
}
}TLoginInfo;
struct TLoginUserInfo
{
char user_name[MAX_DB_PARA_NAME];
char user_password[MAX_DB_PARA_NAME];
char db_name[MAX_DB_PARA_NAME];
struct TLoginUserInfo & operator= (const struct TLoginUserInfo &userinfo_stru)
{
if( this == &userinfo_stru)
{
return *this;
}
strcpy(user_name , userinfo_stru.user_name);
strcpy(user_password , userinfo_stru.user_password );
strcpy(db_name , userinfo_stru.db_name);
return *this;
}
};
#endif

View File

@@ -0,0 +1,69 @@
//******************************************************************
//
// AUTHOR : LMJ
//
// FUNCTION : 数据库监视模块需要用到的全局变量定义
//
// TIME : 2003.12.6
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2003.12.6 Creation LMJ
//
//******************************************************************
#ifndef _DB_MONITOR_EXTERN_H_
#define _DB_MONITOR_EXTERN_H_
#include "db_monitor_define.h"
#include "CDbMonitorShm.h"
#ifndef _LOCAL
#include "SaveLog.h"
#endif
extern string g_process_name_str;
extern vector<TLoginInfo> g_db_config_info;
extern vector<TLoginInfo> g_db_config_info_ext;
extern CDbSem g_master_db_sem;
extern CDbSem g_db_num_sem;
extern CDbSem g_db_service_sem;
extern CDbSem g_file_sem;
extern CDbSem g_right_login_sem;
#ifndef _LOCAL
extern CDbMonitorClient * g_pInterface;
extern CDbMonitorClient * g_pInterface_self;
#endif
//extern CErrorLog g_error_log;
#ifndef _LOCAL
extern string g_error_log_path;
extern SaveLog g_savelog;
#endif
extern int g_last_search_time;
extern bool g_b_ent_no_db;
extern char g_home_path[128];
extern int g_service_status;
#ifndef _LOCAL
extern bool isExitFlag;
#endif
extern int gGetLogPath();
extern int gStringComp(char *des,char *src);
extern string gIntToStr(int nVal);
extern int gGetTimeStrBySeconds(time_t nSeconds, string & strTimeValue);
extern int gStringCopy(char *des,const char *src,int max_len);
extern void gUsleep(const int usec);
extern void printLoginInfo(TLoginInfo & login_info);
#endif

View File

@@ -0,0 +1,67 @@
//******************************************************************
//
// AUTHOR : LMJ
//
// FUNCTION : 数据库监视模块需要用到全局变量定义
//
// TIME : 2003.12.6
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2003.12.6 Creation LMJ
//
//******************************************************************
#ifndef _DB_MONITOR_GLOBAL_H_
#define _DB_MONITOR_GLOBAL_H_
#include "db_monitor_define.h"
#include "CDbMonitorShm.h"
#ifndef _LOCAL
#include "SaveLog.h"
#endif
vector<TLoginInfo> g_db_config_info;
vector<TLoginInfo> g_db_config_info_ext;
vector<string> g_db_name_vec;
vector<string> g_db_node_vec;
//string g_config_table_str;
string g_process_name_str;
CDbSem g_master_db_sem;
CDbSem g_db_num_sem;
CDbSem g_db_service_sem;
CDbSem g_file_sem;
CDbSem g_right_login_sem;
#ifndef _LOCAL
CDbMonitorClient *g_pInterface ;
CDbMonitorClient *g_pInterface_self;
#endif
#ifndef _LOCAL
string g_error_log_path;
SaveLog g_savelog;
#endif
int g_last_search_time;
bool g_b_ent_no_db;
char g_home_path[128];
int g_service_status;
#ifndef _LOCAL
bool isExitFlag;
#endif
int gGetLogPath();
int gStringComp(char *des,char *src);
string gIntToStr(int nVal);
int gGetTimeStrBySeconds(time_t nSeconds, string & strTimeValue);
int gStringCopy(char *des,const char *src,int max_len);
void gUsleep(const int usec);
void printLoginInfo(TLoginInfo & login_info);
#endif

View File

@@ -0,0 +1,57 @@
//**************************************
// Generated by mcpp translator
// Version 1.3
//**************************************
#ifndef __DB_MONITOR_M_H__
#define __DB_MONITOR_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
typedef MLang::VECTOR<MLang::STRING> StrSeq;
typedef MLang::VECTOR<MLang::Long> LongSeq;
typedef MLang::VECTOR<short> ShortSeq;
typedef MLang::VECTOR<char> CharSeq;
struct _DbLoginInfo
{
MLang::STRING user_name;
MLang::STRING user_password;
MLang::STRING db_login_service;
MLang::STRING db_service_machine;
MLang::STRING db_name;
MLang::STRING db_service_describe;
short db_status;
MLang::STRING strError;
bool is_sample_db;
_DbLoginInfo();
_DbLoginInfo(const _DbLoginInfo&);
_DbLoginInfo&operator=(const _DbLoginInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef _DbLoginInfo TDbLoginInfo;
typedef MLang::VECTOR<TDbLoginInfo> SEC_DB_INFO;
struct TDbServiceInfo
{
SEC_DB_INFO secDbServiceInfo;
TDbServiceInfo();
TDbServiceInfo(const TDbServiceInfo&);
TDbServiceInfo&operator=(const TDbServiceInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<MLang::STRING> SEC_STR_DB_NAME;
struct TDbServiceName
{
SEC_STR_DB_NAME secDbInfo;
TDbServiceName();
TDbServiceName(const TDbServiceName&);
TDbServiceName&operator=(const TDbServiceName&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,56 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __DB_MONITOR_M_H__
#define __DB_MONITOR_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
typedef MLang::VECTOR<MLang::STRING> StrSeq;
typedef MLang::VECTOR<MLang::Long> LongSeq;
typedef MLang::VECTOR<short> ShortSeq;
typedef MLang::VECTOR<char> CharSeq;
struct _DbLoginInfo
{
MLang::STRING user_name;
MLang::STRING user_password;
MLang::STRING db_login_service;
MLang::STRING db_service_machine;
MLang::STRING db_name;
MLang::STRING db_service_describe;
short db_status;
MLang::STRING strError;
_DbLoginInfo();
_DbLoginInfo(const _DbLoginInfo&);
_DbLoginInfo&operator=(const _DbLoginInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef _DbLoginInfo TDbLoginInfo;
typedef MLang::VECTOR<TDbLoginInfo> SEC_DB_INFO;
struct TDbServiceInfo
{
SEC_DB_INFO secDbServiceInfo;
TDbServiceInfo();
TDbServiceInfo(const TDbServiceInfo&);
TDbServiceInfo&operator=(const TDbServiceInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<MLang::STRING> SEC_STR_DB_NAME;
struct TDbServiceName
{
SEC_STR_DB_NAME secDbInfo;
TDbServiceName();
TDbServiceName(const TDbServiceName&);
TDbServiceName&operator=(const TDbServiceName&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,30 @@
#ifndef DB_DUP_DEFINE_H
#define DB_DUP_DEFINE_H
#include "paramanage.h"
#include "system.h"
#include "db_com/wholepubtools.h"
const string REP_FILE_SEPARATOR = "\n_NARI_D5000_NORMAL_SQL_\n";
const string REP_IN_DIR_SEPARATOR = "/in/";
const string REP_OUT_DIR_SEPARATOR = "/out/";
const int REP_MAX_FILE_NAME = 255;
const int REP_READ_ALL_DB_NAME_TIME = 20;
const int REP_CHECK_SAVE_RE_COMMIT_DIR_SIZE_TIME_INTERVAL = 60;
const int REP_MAX_SAVE_RECOMMIT_SQL_DIR_SIZE = 1;
const int REP_MAX_PARA_NAME = 128;
const int REP_MAX_PARA_VALUE = 1024;
//ZKH ADD FOR LOB REPLICATE
const string LOB_IN_DIR_SEPARATOR = "/lob.in/";
const string LOB_OUT_DIR_SEPARATOR = "/lob.out/";
const string LOB_SQL_FLAG = "_NARI_D5000_LOB_SQL_";
const string LOB_EXECSQL_FLAG = "_NARI_D5000_LOB_EXECSQL_";
//add Bind replicate by shihaoqiu 20130313
const string BIND_IN_DIR_SEPARATOR = "/bind.in/";
const string BIND_OUT_DIR_SEPARATOR = "/bind.out/";
#endif

View File

@@ -0,0 +1,38 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __DB_STAT_M_H__
#define __DB_STAT_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
typedef MLang::Long TStatKeyID;
typedef MLang::VECTOR<MLang::Long> LongSeq;
struct TReStatInfo
{
TStatKeyID keyid;
LongSeq seq_time;
TReStatInfo();
TReStatInfo(const TReStatInfo&);
TReStatInfo&operator=(const TReStatInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TReStatInfo> SEQReStatInfo;
struct TReStatInParm
{
int app_no;
SEQReStatInfo seq_restat_info;
TReStatInParm();
TReStatInParm(const TReStatInParm&);
TReStatInParm&operator=(const TReStatInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,69 @@
//******************************************************************
//
// AUTHOR : WangChangpin
//
// FUNCTION : db_monitor 进程的客户端类公用类定义
//
// TIME : 2011.08.23
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2011.08.23 Creation WangChangpin
//
//******************************************************************
#ifndef _DB_STAT_SERVICE_INTERFACE_H
#define _DB_STAT_SERVICE_INTERFACE_H
#include "db_stat_m.h"
#include "sam_service.h"
#include "system.h"
#include "serviceglobal.h"
#include "pub_ctx.h"
#include "servicesclient.h"
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
using namespace std;
class db_stat_service_interface
{
public:
db_stat_service_interface(const int port,const int request_timeout_seconds = 300);
~db_stat_service_interface();
//调用的接口函数声明在下面增加根据IDL映射后的头文件中定义设置
//ONEWAY 调用
short DbReStat(TReStatInParm& in_para);
//void SyncTagAttribute();
//add for remote access
int SetDomainInfo(const DomainInfo& domain_info); //设置远程信息(通用)
int SetDomainInfo(const char* domain_name, const tSecLabel& sec_label, const int app_no = AP_DATA_SRV, const int ctx_no = AC_REALTIME_NO);
int SetDomainName(const char* domain_name); //设置域名
int SetSecLabel(tSecLabel& sec_label); //设置标签
void ClearDomainName(); //清除域名m_DomainName设为local_domain
private:
DomainInfo m_DomainInfo;
ServiceInfo m_Serviceinfo;
int m_RequestTimeoutSeconds;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
CServicesManage* m_ServicesManage;
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
int SetServiceHost();
};
#endif

View File

@@ -0,0 +1,39 @@
// create by shq 20181204 for data_srv log features
// kill -30 [pid] // reload ds_log.sys
//////////////////////////////////////////////////////////////////////
#if !defined(SAVELOG_DEF)
#define SAVELOG_DEF
#define FILE_MAX_LEN 30000000
#include "pthread.h"
#include "MyMutex.h"
class DSLog
{
public:
DSLog();
int reloadConfig();
int setLog (char *server_name, long maxlen = FILE_MAX_LEN);
virtual ~DSLog();
int addlog (char *message);
int addlogdebug (char *message);
private:
FILE *fp;
CMyMutex m_mutex;
long filemaxlen;
char filename[512];
// int thisTag;
int _to_file;
int _to_screen;
int _full_log;
char _server_name[64];
int checkfile();
int startlog();
int gettag();
};
#endif // !defined(SAVELOG_DEF)

View File

@@ -0,0 +1,103 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __DY_COMMIT_M_H__
#define __DY_COMMIT_M_H__
#ifdef _WINDOWS64
#ifdef DY_COMMIT_DLL_EXPORTS
#define DY_COMMIT_DLL_API __declspec(dllexport)
#else
#define DY_COMMIT_DLL_API __declspec(dllimport)
#endif
#else
#define DY_COMMIT_DLL_API
#endif
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
typedef MLang::STRING TKeyIDStru;
struct DY_COMMIT_DLL_API TDyTime
{
MLang::Long second;
short millisecond;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef float TDyValue;
typedef int TDyStat;
typedef MLang::VECTOR<TKeyIDStru> SEQDyKeyID;
typedef MLang::VECTOR<TDyTime> SEQDyTime;
typedef MLang::VECTOR<TDyValue> SEQDyValue;
typedef MLang::VECTOR<TDyStat> SEQDyStat;
struct DY_COMMIT_DLL_API TDyCommitVS
{
int app_no;
int keyid_num;
TDyTime start_time;
int time_num;
int time_inteval;
SEQDyKeyID seq_keyid;
SEQDyValue seq_dy_value;
SEQDyStat seq_dy_stat;
unsigned char modify_flag;
TDyCommitVS();
TDyCommitVS(const TDyCommitVS&);
TDyCommitVS&operator=(const TDyCommitVS&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_COMMIT_DLL_API TKVSElement
{
TDyTime dy_time_stamp;
int keyid_num;
SEQDyKeyID seq_keyid;
SEQDyValue seq_dy_value;
SEQDyStat seq_dy_stat;
TKVSElement();
TKVSElement(const TKVSElement&);
TKVSElement&operator=(const TKVSElement&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TKVSElement> SEQKVSElement;
struct DY_COMMIT_DLL_API TDyCommitKVS
{
int app_no;
int sect_num;
SEQKVSElement seq_kvs_element;
unsigned char modify_flag;
TDyCommitKVS();
TDyCommitKVS(const TDyCommitKVS&);
TDyCommitKVS&operator=(const TDyCommitKVS&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_COMMIT_DLL_API TStringElement
{
TDyTime dy_time_stamp;
MLang::STRING string_value;
TStringElement();
TStringElement(const TStringElement&);
TStringElement&operator=(const TStringElement&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TStringElement> SEQStringElement;
struct DY_COMMIT_DLL_API TStringCommit
{
MLang::STRING tag_name;
SEQStringElement seq_string_element;
TStringCommit();
TStringCommit(const TStringCommit&);
TStringCommit&operator=(const TStringCommit&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,137 @@
#ifndef _DY_MONITOR_DEFINE_H_
#define _DY_MONITOR_DEFINE_H_
#ifndef _WINDOWS64
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/utsname.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <ctype.h>
#include <vector>
#include <time.h>
#include <functional>
#include <algorithm>
#include <map>
#include <string.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#ifndef _DB_MONITOR_DEFINE_H_
#include <netinet/ip_icmp.h>
#endif
#endif
#ifndef _WINDOWS64
#ifdef _ALPHA
#include <sys/uswitch.h>
#endif
#endif
#include "paramanage.h"
#include "sysadm/scn_service.h"
//#include "sam_switch.h"
#include "sysadm/scn_common.h"
#include "system.h"
#ifndef _LOCAL
#include "db_com/CDyMonitorClient.h"
#endif
//#include "db_com/wholepubtools.h"
#include "db_com/CCharArray.h"
#include "db_com/CDySem.h"
#include "db_com/CDySemUse.h"
#include "db_com/CDyShm.h"
#include "db_com/CErrorLog.h"
#include "db_com/CFindFile.h"
#include "db_com/CPrecTime.h"
#include "pub.h"
using namespace std;
#ifndef PORT_DY_MONITOR_BASE
#define PORT_DY_MONITOR_BASE 11300
#endif
#ifndef _WINDOWS64
const int DY_NUM_KEY = 0x1961;
const int DY_FILE_SEM_KEY = 0x1963;
const int DY_SERVICE_INFO_SEM_KEY = 0x2000;
const int DY_MONITOR_SHM_KEY = 0x211;
#else
const string DY_NUM_KEY = "DY_NUM_NAME";
const string DY_SERVICE_INFO_SEM_KEY = "DY_SERVICE_INFO_SEM_NAME";
const string DY_FILE_SEM_KEY = "DY_FILE_SEM_NAME";
const string DY_MONITOR_SHM_KEY = "dy_monitor.dat";
#endif
const int MAX_DY_COUNT = 256;
const int DY_MONITOR_SHM_SIZE = MAX_DY_COUNT*2048;
const int DY_SEM_INIT_VAL = 1;
const int MAX_DY_PARA_NAME = 64;
const int READ_DY_CONFIG_INFO_TIME_INTERVAL = 600;
//应用各个状态的定义
const int DY_APP_STATUS_DUTY = 1;
const int DY_APP_STATUS_STANDBY = 0;
const int DY_APP_STATUS_OTHER = -1;
typedef struct DyLoginInfoStru
{
char dy_service_name[MAX_DY_PARA_NAME];
char user_name[MAX_DY_PARA_NAME];
char user_password[MAX_DY_PARA_NAME];
char dy_service_machine[MAX_DY_PARA_NAME];
int dy_service_port;
char dy_name[MAX_DY_PARA_NAME];
char dy_service_describe[3*MAX_DY_PARA_NAME];
bool is_switch;
bool is_master_dy;
int dy_host_prior;
short dy_login_status;
char dy_err[5*MAX_DY_PARA_NAME]; //数据库错误信息
time_t dy_cur_time; //链接时的时间
int direct_access; //是否为可以直接连接的数据库 0 不是 1 是
struct DyLoginInfoStru & operator= (const struct DyLoginInfoStru &login_stru)
{
if( this == &login_stru)
{
return *this;
}
strcpy(dy_service_name , login_stru.dy_service_name );
strcpy(user_name , login_stru.user_name);
strcpy(user_password , login_stru.user_password );
strcpy(dy_service_machine , login_stru.dy_service_machine);
dy_service_port = login_stru.dy_service_port;
strcpy(dy_name , login_stru.dy_name);
strcpy(dy_service_describe , login_stru.dy_service_describe );
is_switch = login_stru.is_switch;
is_master_dy = login_stru.is_master_dy;
dy_host_prior = login_stru.dy_host_prior;
dy_login_status = login_stru.dy_login_status;
strcpy(dy_err , login_stru.dy_err);
dy_cur_time = login_stru.dy_cur_time;
direct_access = login_stru.direct_access;
return *this;
}
}TLoginDyInfo;
#endif

View File

@@ -0,0 +1,53 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __DY_MONITOR_M_H__
#define __DY_MONITOR_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
struct _DyLoginInfo
{
unsigned char is_master_dy;
MLang::STRING user_name;
MLang::STRING user_password;
MLang::STRING dy_service_name;
MLang::STRING dy_service_machine;
int dy_service_port;
MLang::STRING dy_name;
short dy_status;
MLang::STRING strError;
_DyLoginInfo();
_DyLoginInfo(const _DyLoginInfo&);
_DyLoginInfo&operator=(const _DyLoginInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef _DyLoginInfo TDyLoginInfo;
typedef MLang::VECTOR<TDyLoginInfo> SEC_DY_INFO;
struct TDyServiceInfo
{
SEC_DY_INFO secDyServiceInfo;
TDyServiceInfo();
TDyServiceInfo(const TDyServiceInfo&);
TDyServiceInfo&operator=(const TDyServiceInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<MLang::STRING> SEC_STR_DY_NAME;
struct TDYServiceName
{
SEC_STR_DY_NAME secDyInfo;
TDYServiceName();
TDYServiceName(const TDYServiceName&);
TDYServiceName&operator=(const TDYServiceName&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,88 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __DY_PUBLIC_M_H__
#define __DY_PUBLIC_M_H__
#ifdef _WINDOWS64
#ifdef DY_SAMPLE_DEFINE_DLL_EXPORTS
#define DY_SAMPLE_DEFINE_API __declspec(dllexport)
#else
#define DY_SAMPLE_DEFINE_API __declspec(dllimport)
#endif
#else
#define DY_SAMPLE_DEFINE_API
#endif
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
#include<string>
typedef std::string TStructKeyID;
const short CT_DEFAULT = 0;
const short CT_STRING = 1;
const short CT_UCHAR = 2;
const short CT_SHORT = 3;
const short CT_INT = 4;
const short CT_DATETIME = 5;
const short CT_FLOAT = 6;
const short CT_DOUBLE = 7;
struct DY_SAMPLE_DEFINE_API UAttrValue
{
private:
union
{
char* c_string;
unsigned char c_uchar;
short c_short;
int c_int;
int c_time;
float c_float;
double c_double;
char c_default;
}__u_val;
bool __u_init;
unsigned short __u_index;
public:
UAttrValue();
~UAttrValue();
UAttrValue(const UAttrValue&);
UAttrValue&operator=(const UAttrValue&);
short _d()const;
void __clear();
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
void c_string(const char*);
void c_string(const MLang::STRING&);
const char*c_string()const;
void c_uchar(const unsigned char);
const unsigned char c_uchar()const;
void c_short(const short);
const short c_short()const;
void c_int(const int);
const int c_int()const;
void c_time(const int);
const int c_time()const;
void c_float(const float);
const float c_float()const;
void c_double(const double);
const double c_double()const;
void c_default(const char);
const char c_default()const;
};
struct DY_SAMPLE_DEFINE_API TPointAttribute
{
MLang::STRING attr_name;
UAttrValue attr_value;
TPointAttribute();
TPointAttribute(const TPointAttribute&);
TPointAttribute&operator=(const TPointAttribute&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TPointAttribute> SEQPointAttribute;
#endif

View File

@@ -0,0 +1,225 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __DY_SAMPLE_DEFINE_M_H__
#define __DY_SAMPLE_DEFINE_M_H__
#ifdef _WINDOWS64
#ifdef DY_SAMPLE_DEFINE_DLL_EXPORTS
#define DY_SAMPLE_DEFINE_API __declspec(dllexport)
#else
#define DY_SAMPLE_DEFINE_API __declspec(dllimport)
#endif
#else
#define DY_SAMPLE_DEFINE_API
#endif
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
#include"dy_public_m.h"
const short OPERATE_SUCCESS = 0;
const short OPERATE_FAIL = -1;
const short IS_YC_SAMPLE = 0;
const short IS_YX_SAMPLE = 1;
struct DY_SAMPLE_DEFINE_API TDySampleInfo
{
std::string key_id;
SEQPointAttribute seq_point_attr;
TDySampleInfo();
TDySampleInfo(const TDySampleInfo&);
TDySampleInfo&operator=(const TDySampleInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TDySampleInfo> SEQDySampleInfo;
struct DY_SAMPLE_DEFINE_API AddDySampleInParm
{
int app_no;
unsigned char is_yx;
SEQDySampleInfo seq_dy_sample_info;
AddDySampleInParm();
AddDySampleInParm(const AddDySampleInParm&);
AddDySampleInParm&operator=(const AddDySampleInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_SAMPLE_DEFINE_API TDySampleResultInfo
{
short success_flag;
MLang::STRING err_string;
SEQPointAttribute seq_point_attr;
TDySampleResultInfo();
TDySampleResultInfo(const TDySampleResultInfo&);
TDySampleResultInfo&operator=(const TDySampleResultInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TDySampleResultInfo> SEQDySampleResultInfo;
struct DY_SAMPLE_DEFINE_API AddDySampleOutParm
{
int app_no;
short success_flag;
MLang::STRING invalid_string;
SEQDySampleResultInfo seq_dy_sample_result_info;
AddDySampleOutParm();
AddDySampleOutParm(const AddDySampleOutParm&);
AddDySampleOutParm&operator=(const AddDySampleOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_SAMPLE_DEFINE_API DeleteDySampleInParm
{
int app_no;
MLang::VECTOR<MLang::STRING> seq_dy_service_name;
MLang::VECTOR<MLang::STRING> seq_tag_name;
DeleteDySampleInParm();
DeleteDySampleInParm(const DeleteDySampleInParm&);
DeleteDySampleInParm&operator=(const DeleteDySampleInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_SAMPLE_DEFINE_API DeleteDySampleOutParm
{
int app_no;
short success_flag;
MLang::STRING invalid_string;
SEQDySampleResultInfo seq_dy_sample_result_info;
DeleteDySampleOutParm();
DeleteDySampleOutParm(const DeleteDySampleOutParm&);
DeleteDySampleOutParm&operator=(const DeleteDySampleOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_SAMPLE_DEFINE_API PauseDySampleInParm
{
int app_no;
MLang::VECTOR<MLang::STRING> seq_tag_name;
PauseDySampleInParm();
PauseDySampleInParm(const PauseDySampleInParm&);
PauseDySampleInParm&operator=(const PauseDySampleInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_SAMPLE_DEFINE_API PauseDySampleOutParm
{
int app_no;
short success_flag;
MLang::STRING invalid_string;
SEQDySampleResultInfo seq_dy_sample_result_info;
PauseDySampleOutParm();
PauseDySampleOutParm(const PauseDySampleOutParm&);
PauseDySampleOutParm&operator=(const PauseDySampleOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_SAMPLE_DEFINE_API RecoverDySampleInParm
{
int app_no;
MLang::VECTOR<MLang::STRING> seq_tag_name;
RecoverDySampleInParm();
RecoverDySampleInParm(const RecoverDySampleInParm&);
RecoverDySampleInParm&operator=(const RecoverDySampleInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_SAMPLE_DEFINE_API RecoverDySampleOutParm
{
int app_no;
short success_flag;
MLang::STRING invalid_string;
SEQDySampleResultInfo seq_dy_sample_result_info;
RecoverDySampleOutParm();
RecoverDySampleOutParm(const RecoverDySampleOutParm&);
RecoverDySampleOutParm&operator=(const RecoverDySampleOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_SAMPLE_DEFINE_API RelocateDySampleInParm
{
int app_no;
int key_num;
MLang::VECTOR<MLang::Long> seq_key_old;
SEQDySampleInfo seq_dy_sample_info;
RelocateDySampleInParm();
RelocateDySampleInParm(const RelocateDySampleInParm&);
RelocateDySampleInParm&operator=(const RelocateDySampleInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_SAMPLE_DEFINE_API RelocateDySampleOutParm
{
int app_no;
short success_flag;
MLang::STRING invalid_string;
SEQDySampleResultInfo seq_dy_sample_result_info;
RelocateDySampleOutParm();
RelocateDySampleOutParm(const RelocateDySampleOutParm&);
RelocateDySampleOutParm&operator=(const RelocateDySampleOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_SAMPLE_DEFINE_API GetDyPointAttrInParm
{
int app_no;
MLang::VECTOR<MLang::STRING> seq_dy_service_name;
MLang::VECTOR<MLang::STRING> seq_tag_name;
GetDyPointAttrInParm();
GetDyPointAttrInParm(const GetDyPointAttrInParm&);
GetDyPointAttrInParm&operator=(const GetDyPointAttrInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_SAMPLE_DEFINE_API TPointAttrResultInfo
{
MLang::STRING key_id;
short success_flag;
MLang::STRING err_string;
SEQPointAttribute seq_point_attr;
TPointAttrResultInfo();
TPointAttrResultInfo(const TPointAttrResultInfo&);
TPointAttrResultInfo&operator=(const TPointAttrResultInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TPointAttrResultInfo> SEQPointAttrResultInfo;
struct DY_SAMPLE_DEFINE_API GetDyPointAttrOutParm
{
int app_no;
short success_flag;
MLang::STRING invalid_string;
SEQPointAttrResultInfo seq_result_info;
GetDyPointAttrOutParm();
GetDyPointAttrOutParm(const GetDyPointAttrOutParm&);
GetDyPointAttrOutParm&operator=(const GetDyPointAttrOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_SAMPLE_DEFINE_API ModifyDyPointAttrInParm
{
int app_no;
SEQDySampleInfo seq_dy_sample_info;
ModifyDyPointAttrInParm();
ModifyDyPointAttrInParm(const ModifyDyPointAttrInParm&);
ModifyDyPointAttrInParm&operator=(const ModifyDyPointAttrInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_SAMPLE_DEFINE_API ModifyDyPointAttrOutParm
{
int app_no;
short success_flag;
MLang::STRING invalid_string;
SEQDySampleResultInfo seq_dy_sample_result_info;
ModifyDyPointAttrOutParm();
ModifyDyPointAttrOutParm(const ModifyDyPointAttrOutParm&);
ModifyDyPointAttrOutParm&operator=(const ModifyDyPointAttrOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,97 @@
#ifndef _DY_SAMPLE_DEFINE_SERVICE_INTERFACE_H
#define _DY_SAMPLE_DEFINE_SERVICE_INTERFACE_H
#ifdef _WINDOWS64
#ifdef DY_SAMPLE_DEFINE_DLL_EXPORTS
#define DY_SAMPLE_DEFINE_API __declspec(dllexport)
#else
#define DY_SAMPLE_DEFINE_API __declspec(dllimport)
#endif
#else
#define DY_SAMPLE_DEFINE_API
#endif
#ifndef _WINDOWS64
#include <arpa/inet.h>
#include <netdb.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include "dy_sample_define_m.h"
#include "sysadm/scn_service.h"
#include "port_def.h"
#include "mcode/mclient.h"
//#include "serviceglobal.h"
#include "pub_ctx.h"
#include "system.h"
#include "servicemanage.h"
#include "db_com/CDyCfgLocal.h"
//#include "servicesclient.h"
#include <iostream>
using namespace std;
using namespace NS_SYSADMIN;
//#include <OB/common_service_interface.h>
//该宏需要根据IDL 文件中不同的interface 名称进行修改
/*#define interface_var CDySampleDefineServer_var
#define interface_name CDySampleDefineServer*/
class DY_SAMPLE_DEFINE_API dy_sample_define_service_interface
{
public:
/*interface_var m_Specify_GenerInvoke;
interface_var m_GenerInvoke;*/
dy_sample_define_service_interface();
dy_sample_define_service_interface(const int port_no,const int request_timeout_seconds = 300);
~dy_sample_define_service_interface();
//调用的接口函数声明在下面增加根据IDL映射后的头文件中定义设置
short AddDySampleDefine(const AddDySampleInParm& in_para,
AddDySampleOutParm &out_para);
short DeleteDySampleDefine(const DeleteDySampleInParm& in_para,
DeleteDySampleOutParm &out_para);
/*short PauseDySampleDefine(const PauseDySampleInParm& in_para,
PauseDySampleOutParm &out_para);
short RecoverDySampleDefine(const RecoverDySampleInParm& in_para,
RecoverDySampleOutParm &out_para);*/
short GetDyPointAttribute(const GetDyPointAttrInParm& in_para,
GetDyPointAttrOutParm &out_para);
short ModifyDyPointAttribute(const ModifyDyPointAttrInParm& in_para,
ModifyDyPointAttrOutParm &out_para);
short RelocateDySampleDefine(const RelocateDySampleInParm& in_para,
RelocateDySampleOutParm &out_para);//5
//add for remote access
int SetDomainInfo(const DomainInfo& domain_info); //设置远程信息(通用)
int SetDomainInfo(const char* domain_name, const tSecLabel& sec_label, const int app_no = AP_DATA_SRV, const int ctx_no = AC_REALTIME_NO);
int SetDomainName(const char* domain_name); //设置域名
int SetSecLabel(tSecLabel& sec_label); //设置标签
void ClearDomainName(); //清除域名m_DomainName设为local_domain
private:
ServiceInfo m_Serviceinfo;
DomainInfo m_DomainInfo;
CDyCfgLocal m_dy_cfg_read;
int m_RequestTimeoutSeconds;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
CScnService* m_ServicesManage;
//是否需要自动获取端口号,dy_sample_define_service_interface(()下生效
bool m_is_port_auto_set;
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
int SetServiceHost(const int dy_app_no);
};
#endif

View File

@@ -0,0 +1,47 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __DY_STAT_M_H__
#define __DY_STAT_M_H__
#ifdef _WINDOWS64
#ifdef DY_STAT_DLL_EXPORTS
#define DY_STAT_DLL_API __declspec(dllexport)
#else
#define DY_STAT_DLL_API __declspec(dllimport)
#endif
#else
#define DY_STAT_DLL_API
#endif
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
typedef MLang::Long TDyStatKeyID;
typedef MLang::VECTOR<MLang::Long> LongSeq;
struct DY_STAT_DLL_API TDyReStatInfo
{
TDyStatKeyID keyid;
LongSeq seq_time;
TDyReStatInfo();
TDyReStatInfo(const TDyReStatInfo&);
TDyReStatInfo&operator=(const TDyReStatInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TDyReStatInfo> SEQDyReStatInfo;
struct DY_STAT_DLL_API TDyReStatInParm
{
int app_no;
SEQDyReStatInfo seq_dy_restat_info;
TDyReStatInParm();
TDyReStatInParm(const TDyReStatInParm&);
TDyReStatInParm&operator=(const TDyReStatInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,89 @@
//******************************************************************
//
// AUTHOR : WangChangpin
//
// FUNCTION : db_monitor 进程的客户端类公用类定义
//
// TIME : 2011.08.23
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2011.08.23 Creation WangChangpin
//
//******************************************************************
#ifndef _DY_STAT_SERVICE_INTERFACE_H
#define _DY_STAT_SERVICE_INTERFACE_H
#ifdef _WINDOWS64
#ifdef DY_STAT_DLL_EXPORTS
#define DY_STAT_DLL_API __declspec(dllexport)
#else
#define DY_STAT_DLL_API __declspec(dllimport)
#endif
#else
#define DY_STAT_DLL_API
#endif
#ifndef _WINDOWS64
#include <netdb.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include "dy_stat_m.h"
#include "sysadm/scn_service.h"
#include "system.h"
//#include "serviceglobal.h"
#include "pub_ctx.h"
#include "servicemanage.h"
#include "db_com/CDyCfgLocal.h"
using namespace std;
using namespace NS_SYSADMIN;
class DY_STAT_DLL_API dy_stat_service_interface
{
public:
dy_stat_service_interface(const int port,const int request_timeout_seconds = 300);
dy_stat_service_interface();
~dy_stat_service_interface();
//调用的接口函数声明在下面增加根据IDL映射后的头文件中定义设置
//ONEWAY 调用
short DyReStat(TDyReStatInParm& in_para);
//void SyncTagAttribute();
//add for remote access
int SetDomainInfo(const DomainInfo& domain_info); //设置远程信息(通用)
int SetDomainInfo(const char* domain_name, const tSecLabel& sec_label, const int app_no = AP_DATA_SRV, const int ctx_no = AC_REALTIME_NO);
int SetDomainName(const char* domain_name); //设置域名
int SetSecLabel(tSecLabel& sec_label); //设置标签
void ClearDomainName(); //清除域名m_DomainName设为local_domain
private:
DomainInfo m_DomainInfo;
ServiceInfo m_Serviceinfo;
CDyCfgLocal m_dy_cfg_read;
int m_RequestTimeoutSeconds;
char m_IpAddress[64];
// int m_Port;
Handle m_Handle;
char m_HostName[64];
CScnService* m_ServicesManage;
//是否需要自动获取端口号,dy_stat_service_interface()下生效
bool m_is_port_auto_set;
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
int SetServiceHost(const int dy_app_no);
};
#endif

View File

@@ -0,0 +1,202 @@
/*
* Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com>
* Copyright (c) 2010-2014, Pieter Noordhuis <pcnoordhuis at gmail dot com>
* Copyright (c) 2015, Matt Stancliff <matt at genges dot com>,
* Jan-Erik Rediger <janerik at fnordig dot com>
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __HIREDIS_H
#define __HIREDIS_H
#include "read.h"
#include <stdarg.h> /* for va_list */
#include <sys/time.h> /* for struct timeval */
#include <stdint.h> /* uintXX_t, etc */
#include "sds.h" /* for sds */
#define HIREDIS_MAJOR 0
#define HIREDIS_MINOR 14
#define HIREDIS_PATCH 0
#define HIREDIS_SONAME 0.14
/* Connection type can be blocking or non-blocking and is set in the
* least significant bit of the flags field in redisContext. */
#define REDIS_BLOCK 0x1
/* Connection may be disconnected before being free'd. The second bit
* in the flags field is set when the context is connected. */
#define REDIS_CONNECTED 0x2
/* The async API might try to disconnect cleanly and flush the output
* buffer and read all subsequent replies before disconnecting.
* This flag means no new commands can come in and the connection
* should be terminated once all replies have been read. */
#define REDIS_DISCONNECTING 0x4
/* Flag specific to the async API which means that the context should be clean
* up as soon as possible. */
#define REDIS_FREEING 0x8
/* Flag that is set when an async callback is executed. */
#define REDIS_IN_CALLBACK 0x10
/* Flag that is set when the async context has one or more subscriptions. */
#define REDIS_SUBSCRIBED 0x20
/* Flag that is set when monitor mode is active */
#define REDIS_MONITORING 0x40
/* Flag that is set when we should set SO_REUSEADDR before calling bind() */
#define REDIS_REUSEADDR 0x80
#define REDIS_KEEPALIVE_INTERVAL 15 /* seconds */
/* number of times we retry to connect in the case of EADDRNOTAVAIL and
* SO_REUSEADDR is being used. */
#define REDIS_CONNECT_RETRIES 10
#ifdef __cplusplus
extern "C" {
#endif
/* This is the reply object returned by redisCommand() */
typedef struct redisReply {
int type; /* REDIS_REPLY_* */
long long integer; /* The integer when type is REDIS_REPLY_INTEGER */
size_t len; /* Length of string */
char *str; /* Used for both REDIS_REPLY_ERROR and REDIS_REPLY_STRING */
size_t elements; /* number of elements, for REDIS_REPLY_ARRAY */
struct redisReply **element; /* elements vector for REDIS_REPLY_ARRAY */
} redisReply;
redisReader *redisReaderCreate(void);
/* Function to free the reply objects hiredis returns by default. */
void freeReplyObject(void *reply);
/* Functions to format a command according to the protocol. */
int redisvFormatCommand(char **target, const char *format, va_list ap);
int redisFormatCommand(char **target, const char *format, ...);
int redisFormatCommandArgv(char **target, int argc, const char **argv, const size_t *argvlen);
int redisFormatSdsCommandArgv(sds *target, int argc, const char ** argv, const size_t *argvlen);
void redisFreeCommand(char *cmd);
void redisFreeSdsCommand(sds cmd);
enum redisConnectionType {
REDIS_CONN_TCP,
REDIS_CONN_UNIX
};
/* Context for a connection to Redis */
typedef struct redisContext {
int err; /* Error flags, 0 when there is no error */
char errstr[128]; /* String representation of error when applicable */
int fd;
int flags;
char *obuf; /* Write buffer */
redisReader *reader; /* Protocol reader */
enum redisConnectionType connection_type;
struct timeval *timeout;
struct {
char *host;
char *source_addr;
int port;
} tcp;
struct {
char *path;
} unix_sock;
/* For non-blocking connect */
struct sockadr *saddr;
size_t addrlen;
} redisContext;
redisContext *redisConnect(const char *ip, int port);
redisContext *redisConnectWithTimeout(const char *ip, int port, const struct timeval tv);
redisContext *redisConnectNonBlock(const char *ip, int port);
redisContext *redisConnectBindNonBlock(const char *ip, int port,
const char *source_addr);
redisContext *redisConnectBindNonBlockWithReuse(const char *ip, int port,
const char *source_addr);
redisContext *redisConnectUnix(const char *path);
redisContext *redisConnectUnixWithTimeout(const char *path, const struct timeval tv);
redisContext *redisConnectUnixNonBlock(const char *path);
redisContext *redisConnectFd(int fd);
/**
* Reconnect the given context using the saved information.
*
* This re-uses the exact same connect options as in the initial connection.
* host, ip (or path), timeout and bind address are reused,
* flags are used unmodified from the existing context.
*
* Returns REDIS_OK on successful connect or REDIS_ERR otherwise.
*/
int redisReconnect(redisContext *c);
int redisSetTimeout(redisContext *c, const struct timeval tv);
int redisEnableKeepAlive(redisContext *c);
void redisFree(redisContext *c);
int redisFreeKeepFd(redisContext *c);
int redisBufferRead(redisContext *c);
int redisBufferWrite(redisContext *c, int *done);
/* In a blocking context, this function first checks if there are unconsumed
* replies to return and returns one if so. Otherwise, it flushes the output
* buffer to the socket and reads until it has a reply. In a non-blocking
* context, it will return unconsumed replies until there are no more. */
int redisGetReply(redisContext *c, void **reply);
int redisGetReplyFromReader(redisContext *c, void **reply);
/* Write a formatted command to the output buffer. Use these functions in blocking mode
* to get a pipeline of commands. */
int redisAppendFormattedCommand(redisContext *c, const char *cmd, size_t len);
/* Write a command to the output buffer. Use these functions in blocking mode
* to get a pipeline of commands. */
int redisvAppendCommand(redisContext *c, const char *format, va_list ap);
int redisAppendCommand(redisContext *c, const char *format, ...);
int redisAppendCommandArgv(redisContext *c, int argc, const char **argv, const size_t *argvlen);
/* Issue a command to Redis. In a blocking context, it is identical to calling
* redisAppendCommand, followed by redisGetReply. The function will return
* NULL if there was an error in performing the request, otherwise it will
* return the reply. In a non-blocking context, it is identical to calling
* only redisAppendCommand and will always return NULL. */
void *redisvCommand(redisContext *c, const char *format, va_list ap);
void *redisCommand(redisContext *c, const char *format, ...);
void *redisCommandArgv(redisContext *c, int argc, const char **argv, const size_t *argvlen);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,164 @@
//******************************************************************
//
// AUTHOR : ZhaoTiger
//
// FUNCTION : 通用SQL解析器头文件定义所有常量
//
// TIME : 2003.10.08
//
// HISTORY : 从胡泊的公式解析器改造而来
// Datetime Action Author Reason
// -----------------------------------------------------------------
// 2003.10.08 Creation ZhaoTiger
//
//******************************************************************
#ifndef __SQL_INTREPRETER_DEFINE_H__
#define __SQL_INTREPRETER_DEFINE_H__
//#ifdef _SUN
#if defined(_SUN) || defined(_LINUX)
#define FALSE 0
#define TRUE 1
#endif
#ifdef _WINDOWS32
#define FALSE 0
#define TRUE 1
#endif
namespace SQL_ANALYSER
{
#define KEYWORD_NUM 21 //关键字个数
#define MAX_CONSTANT_STRING_LEN 1024 //本解释器能处理的代码中字符串的最大长度
#define MAX_CONSTANT_BINARY_LEN 2048 //本解释器能处理的代码中二进制的最大长度
#define MAX_IDEN_NUM 1024 //域名序列的最大个数
#define MAX_IDEN_VALUE_NUM 1024 //域值序列的最大个数
#define MAX_ORDERBY_NUM 10 //ORDER BY子句后域名序列的最大个数
#define MAX_SYMBOL_LEN 64 //本解释器能处理的代码中标识符的最大长度
#define MAX_WHERE_CODE_LEN 10000 //WHERE子句逆波兰结构最大长度
#define MAX_ERRMSG_LEN 200 //最大的出错信息长度
// 定义SQL类型
#define SQL_TYPE_DELETE 0
#define SQL_TYPE_INSERT 1
#define SQL_TYPE_UPDATE 2
#define SQL_TYPE_SELECT 3
/*运算符和特殊符号*/
#define NOT_SYMBOL 100 // ! 不用
#define ADD_SYMBOL 101 // +
#define SUB_SYMBOL 102 // -
#define MUL_SYMBOL 103 // *
#define DIV_SYMBOL 104 // /
#define MOD_SYMBOL 105 // %
#define XOR_SYMBOL 106 // ^
#define ANB_SYMBOL 107 // &
#define ORB_SYMBOL 108 // |
#define GRT_SYMBOL 111 // >
#define GEQ_SYMBOL 112 // >=
#define LSS_SYMBOL 113 // <
#define LEQ_SYMBOL 114 // <=
#define EQU_SYMBOL 115 // =
#define NEQ_SYMBOL 116 // !=
#define LEFT_LARGE_BRACKET 121 // { 不用
#define RIGHT_LARGE_BRACKET 122 // } 不用
#define LEFT_MID_BRACKET 123 // [ 不用
#define RIGHT_MID_BRACKET 124 // ] 不用
#define LEFT_LITTLE_BRACKET 125 // (
#define RIGHT_LITTLE_BRACKET 126 // )
#define SEMICOLON 129 // ; 不用
#define COMMA 130 // ,
#define POINT 131 // .
#define NOB_SYMBOL 132 // ~ 不用
#define COLON 133 // :
#define DATABASE_MASK 141 // @ 不用
#define END_OF_PROGRAM 151 // 字符串结束标志,表示代码结束
#define UNRECOGNIZED_TOKEN 152 // 不认识的字符
/*保留字*/
#define KEY_DELETE 0 // DELETE
#define KEY_INSERT 1 // INSERT
#define KEY_UPDATE 2 // UPDATE
#define KEY_SELECT 3 // SELECT
#define KEY_FROM 4 // FROM
#define KEY_WHERE 5 // WHERE
#define KEY_SET 6 // SET
#define KEY_ORDER 7 // ORDER
#define KEY_BY 8 // BY
#define KEY_VALUES 9 // VALUES
#define KEY_AND 10 // AND
#define KEY_NOT 11 // NOT
#define KEY_OR 12 // OR
#define KEY_LIKE 13 // LIKE
#define KEY_IN 14 // IN
#define KEY_TIMESTR 15 // TIMESTR
#define KEY_TIMEINT 16 // TIMEINT
#define KEY_NULL 20 // NULL
#define KEY_RTDBKEY 21 // RTDBKEY
#define KEY_MEASRTDBKEY 22 // MEASRTDBKEY
#define KEY_APPRTDBKEY 23 // APPRTDBKEY
/*词法分析程序返回的单词的种类*/
#define IDENTIFIER 1000 //标识符
#define INTEGER_VALUE 1001 //整型数 包括长整型
#define REAL_VALUE 1002 //实型数
#define STRING_VALUE 1003 //字符串
#define BINARY_VALUE 1004 //二进制数
// 定义WHERE子句逆波兰结构内容的标识code_type
#define CODE_TYPE_IDENTIFIER 0 // 标识符,等同于域名称
#define CODE_TYPE_OPERATOR 1 // 运算符
#define CODE_TYPE_CONSTANT 2 // 常量值
// 定义语法分析阶段所有的数据类型,包括常量以及处理表达式时需要用到的数据类型
#define INTPRE_DATATYPE_INT 0 //包括长整型
#define INTPRE_DATATYPE_REAL 1
#define INTPRE_DATATYPE_STRING 2
// #define INTPRE_DATATYPE_BINARY 3
// #define INTPRE_DATATYPE_KEYID 4
#define INTPRE_DATATYPE_DATETIME 7
#define INTPRE_DATATYPE_BOOL 10
#define INTPRE_DATATYPE_NULL 11
#define INTPRE_DATATYPE_RTDBKEY 16
#define INTPRE_DATATYPE_MEASRTDBKEY 17
#define INTPRE_DATATYPE_APPRTDBKEY 18
#define INTPRE_DATATYPE_UNKNOWN 100
// 定义语法分析输出的所有操作符类型,也就是在逆波兰序列中的操作项
#define OPERATOR_CODE_ADD 0 // + 加
#define OPERATOR_CODE_SUB 1 // - 减
#define OPERATOR_CODE_MUL 2 // * 乘
#define OPERATOR_CODE_DIV 3 // / 浮点除
#define OPERATOR_CODE_IDV 4 // / 整除取商
#define OPERATOR_CODE_MOD 5 // % 整除取余
#define OPERATOR_CODE_ANB 6 // & 按位与
#define OPERATOR_CODE_ORB 7 // | 按位或
#define OPERATOR_CODE_XOR 8 // ^ 按位异或
#define OPERATOR_CODE_EQU 9 // = 等于
#define OPERATOR_CODE_NEQ 10 // != 不等于
#define OPERATOR_CODE_GRT 11 // > 大于
#define OPERATOR_CODE_GEQ 12 // >= 大于等于
#define OPERATOR_CODE_LSS 13 // < 小于
#define OPERATOR_CODE_LEQ 14 // <= 小于等于
#define OPERATOR_CODE_LKE 15 // LIKE 字符串匹配
#define OPERATOR_CODE_POS 16 // + 单目运算符正号
#define OPERATOR_CODE_NEG 17 // - 单目运算符负号
#define OPERATOR_CODE_AND 18 // AND 与
#define OPERATOR_CODE_ORR 19 // OR 或
#define OPERATOR_CODE_NOT 20 // NOT 非
}
#endif

View File

@@ -0,0 +1,130 @@
//******************************************************************
//
// AUTHOR : ZhaoTiger
//
// FUNCTION : 通用SQL解析器头文件定义重要结构
//
// TIME : 2003.10.08
//
// HISTORY : 从胡泊的公式解析器改造而来
// Datetime Action Author Reason
// -----------------------------------------------------------------
// 2003.10.08 Creation ZhaoTiger
//
//******************************************************************
#ifndef __SQL_INTREPRETER_STRUCT_H__
#define __SQL_INTREPRETER_STRUCT_H__
#ifdef _WINDOWS32
#ifdef SQL_ANALYSER_EXPORTS
#define SQL_ANALYSER_API __declspec(dllexport)
#else
#define SQL_ANALYSER_API __declspec(dllimport)
#endif
#else
#define SQL_ANALYSER_API
#endif
#include "db_api/odb_struct.h"
#include <vector>
#include <string>
using namespace std;
namespace SQL_ANALYSER
{
// 域的相关信息,这些信息从调用该语法分析模块的程序传入
// 这样可以使语法分析模块相对独立,不会因为是商用数据库
// 还是实时数据库产生代码上的依赖
typedef struct SQL_ANALYSER_API
{
char col_name[MAX_SYMBOL_LEN]; // 域名
short col_type; // 域数据类型
} TAnalysColumnInfo;
// 用于WHERE表达式处理时返回的一些信息
typedef struct SQL_ANALYSER_API
{
short typ; //值的类型如果为NULL常量类型为INTPRE_DATATYPE_NULL
bool can_like; //是否可以在其后跟上LIKE操作LIKE之前只能是一个域名
} ITEM_STRU;
// 定义常量UNION
typedef union SQL_ANALYSER_API
{
//int int_value; // 整型值数据包括UCHAR、SHORT、INT、DATETIME类型
long int_value; // 整型值数据包括UCHAR、SHORT、INT、LONG、DATETIME类型
float real_value; // 浮点值数据包括FLOAT、DOUBLE类型
char string_value[MAX_CONSTANT_STRING_LEN]; // 字符串数据包括CHAR(n)、STRING(n)类型
char binary_value[MAX_CONSTANT_BINARY_LEN]; // 二进制数据BINARY(n)类型
_RTDB_KEY_STRU rtdbkey_value;
_RTDB_KEY_STRU measrtdbkey_value;
_APP_KEY_STRU apprtdbkey_value;
} UConstValueInfo;
// 定义常量结构
typedef struct SQL_ANALYSER_API
{
bool is_null; // TRUE表示NULL常量FALSE表示非NULL常量
short const_type; // 非NULL常量的数据类型
UConstValueInfo const_value; // 常量的数值根据const_type来确认使用何分量
} TConstInfo;
// 定义WHERE子句的逆波兰结构
typedef struct SQL_ANALYSER_API
{
unsigned char code_type; // CODE_TYPE_IDENTIFIER, CODE_TYPE_OPERATOR, CODE_TYPE_CONSTANT
union
{
char iden_name[MAX_SYMBOL_LEN];
int operator_code;
TConstInfo const_info;
} code_info;
} TWhereAntiPorland;
// 定义语法分析结果
typedef struct SQL_ANALYSER_API
{
int sql_type; // SQL语句的类型
string table_name; // FROM 子句的表名称
vector<string> column_name_vec; // 域定义序列,适用于 INSERT / UPDATE / SELECT
vector<TConstInfo> column_value_vec; // 域值序列,适用于 INSERT / UPDATE
vector<string> order_name_vec; // ORDER BY 后的域名序列,适用于 SELECT
vector<TWhereAntiPorland> where_code_vec; // 指向WHERE子句逆波兰结构的指针适用于 DELETE / UPDATE / SELECT
} TSqlAnlsResult;
// 词法分析传出的结构
typedef struct SQL_ANALYSER_API
{
int word_id;
/*本次取到的单词的类型若为关键字,则值为关键字在关键字表中的位置(从0开始的正数
本次取到的单词的类型若为运算符则值为运算符对应的id (从100开始的正数
本次取到的单词的类型若为标识符则值为IDENTIFIER
本次取到的单词的类型若为整型数字(长整型)则值为INTEGER_VALUE
本次取到的单词的类型若为实型数字则值为REAL_VALUE
本次取到的单词的类型若为字符串则值为STRING_VALUE
本次取到的单词的类型若为二进制则值为BINARY_VALUE
本次取单词时若为非法字符则值为UNRECOGNIZED_TOKEN
本次取单词时若代码已结束则值为END_OF_PROGRAM
*/
union
{
char ident[MAX_SYMBOL_LEN]; //若本次取到的单词的类型为标识符其名称利用ident传出
float real_value; //若本次取到的单词的类型为实型数字其值利用real_value传出
//int int_value; //若本次取到的单词的类型为整型数字其值利用int_value传出
long int_value; //若本次取到的单词的类型为整型(包括长整型)数字其值利用int_value传出
char string_value[MAX_CONSTANT_STRING_LEN]; //若本次取到的单词的类型为字符串其值利用string_value传出
char binary_value[MAX_CONSTANT_BINARY_LEN]; //若本次取到的单词的类型为二进制其值利用binary_value传出
} value_union;
char rtdbkey_value[MAX_CONSTANT_STRING_LEN];
} LEXICAL_RET_RES_STRU;
}
#endif

View File

@@ -0,0 +1,67 @@
//******************************************************************
//
// AUTHOR : ZhaoTiger
//
// FUNCTION : 通用SQL解析器头文件定义词法分析的类结构
//
// TIME : 2003.10.08
//
// HISTORY : 从胡泊的公式解析器改造而来
// Datetime Action Author Reason
// -----------------------------------------------------------------
// 2003.10.08 Creation ZhaoTiger
//
//******************************************************************
#ifndef __SQL_LEXICAL_H__
#define __SQL_LEXICAL_H__
#ifdef _WINDOWS64
#ifdef SQL_ANALYSER_EXPORTS
#define SQL_ANALYSER_API __declspec(dllexport)
#else
#define SQL_ANALYSER_API __declspec(dllimport)
#endif
#else
#define SQL_ANALYSER_API
#endif
#include<stdio.h>
#include<string.h>
#include "interpreter_define.h"
#include "interpreter_struct.h"
namespace SQL_ANALYSER
{
//词法分析器
class SQL_ANALYSER_API CLexicalAnalyser
{
private :
char * m_SourceCode; // 源代码
int m_CurPos; // 指向源代码中待处理的字符的位置
int m_Line; // 指向源代码中待处理的字符的所在的行数
char m_ErrorMessage[MAX_ERRMSG_LEN]; // 出错信息
void ErrorProcess(); // 出错处理
bool OperationSymbol(int &word_id); // 对操作符的处理
int BinSearchInKeyword(char *word_buf); // 查找关键字表,看是否为关键字
public:
CLexicalAnalyser();
~CLexicalAnalyser();
void Initialize(const char *source_buffer); // 初始化
bool InSymbol(LEXICAL_RET_RES_STRU &lexical_ret_res); // 取一个单词的词法分析
void GetErrorMessage(char *err_msg); // 得到错误信息
int GetLine(); // 得到当前行数
void ResetPosition(); // 重新指向源代码的初始位置
};
}
#endif

View File

@@ -0,0 +1,156 @@
//**************************************
// Generated by mcpp translator
// Version 1.3
//**************************************
#ifndef __PUBLIC_M_H__
#define __PUBLIC_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
typedef MLang::VECTOR<MLang::STRING> StrSeq;
typedef MLang::VECTOR<MLang::Long> LongSeq;
typedef MLang::VECTOR<short> ShortSeq;
typedef MLang::VECTOR<char> CharSeq;
const short C_DATATYPE_DEFAULT = 0;
const short C_DATATYPE_STRING = 1;
const short C_DATATYPE_UCHAR = 2;
const short C_DATATYPE_SHORT = 3;
const short C_DATATYPE_INT = 4;
const short C_DATATYPE_DATETIME = 5;
const short C_DATATYPE_FLOAT = 6;
const short C_DATATYPE_DOUBLE = 7;
const short C_DATATYPE_KEYID = 8;
const short C_DATATYPE_BINARY = 9;
const short C_DATATYPE_TEXT = 10;
const short C_DATATYPE_IMAGE = 11;
const short C_DATATYPE_APPKEYID = 12;
const short C_DATATYPE_APPID = 13;
const short C_DATATYPE_UINT = 14;
const short C_DATATYPE_LONG = 15;
const short C_DATATYPE_RTDBKEY = 16;
const short C_DATATYPE_MEASRTDBKEY = 17;
const short C_DATATYPE_APPRTDBKEY = 18;
typedef MLang::Long TKeyID;
struct TAppKeyID
{
int app_id;
TKeyID key_id;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef TAppKeyID TAppID;
struct TRtdbKey
{
MLang::Long table_id;
MLang::Long region_record_column_id;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TAppRtdbKey
{
int app_id;
TRtdbKey rtdbkey_id;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct UDataValue
{
private:
union
{
char* c_string;
unsigned char c_uchar;
short c_short;
int c_int;
MLang::Long c_time;
float c_float;
double c_double;
TKeyID c_keyid;
CharSeq* c_binary;
CharSeq* c_text;
CharSeq* c_image;
TAppKeyID c_appkeyid;
TAppID c_appid;
char c_default;
unsigned int c_uint;
MLang::Long c_long;
TRtdbKey c_rtdbkey;
TRtdbKey c_measrtdbkey;
TAppRtdbKey c_apprtdbkey;
}__u_val;
bool __u_init;
unsigned short __u_index;
public:
UDataValue();
~UDataValue();
UDataValue(const UDataValue&);
UDataValue&operator=(const UDataValue&);
short _d()const;
void __clear();
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
void c_string(const char*);
void c_string(const MLang::STRING&);
const char*c_string()const;
void c_uchar(const unsigned char);
const unsigned char c_uchar()const;
void c_short(const short);
const short c_short()const;
void c_int(const int);
const int c_int()const;
void c_time(const MLang::Long);
const MLang::Long c_time()const;
void c_float(const float);
const float c_float()const;
void c_double(const double);
const double c_double()const;
void c_keyid(const TKeyID);
const TKeyID c_keyid()const;
void c_binary(const CharSeq&);
const CharSeq&c_binary()const;
CharSeq&c_binary();
void c_text(const CharSeq&);
const CharSeq&c_text()const;
CharSeq&c_text();
void c_image(const CharSeq&);
const CharSeq&c_image()const;
CharSeq&c_image();
void c_appkeyid(const TAppKeyID&);
const TAppKeyID&c_appkeyid()const;
TAppKeyID&c_appkeyid();
void c_appid(const TAppID&);
const TAppID&c_appid()const;
TAppID&c_appid();
void c_default(const char);
const char c_default()const;
void c_uint(const unsigned int);
const unsigned int c_uint()const;
void c_long(const MLang::Long);
const MLang::Long c_long()const;
void c_rtdbkey(const TRtdbKey&);
const TRtdbKey&c_rtdbkey()const;
TRtdbKey&c_rtdbkey();
void c_measrtdbkey(const TRtdbKey&);
const TRtdbKey&c_measrtdbkey()const;
TRtdbKey&c_measrtdbkey();
void c_apprtdbkey(const TAppRtdbKey&);
const TAppRtdbKey&c_apprtdbkey()const;
TAppRtdbKey&c_apprtdbkey();
};
typedef MLang::VECTOR<UDataValue> SEQDataValue;
struct TDBErrorStru
{
unsigned int error_no;
MLang::STRING error_msg;
TDBErrorStru();
TDBErrorStru(const TDBErrorStru&);
TDBErrorStru&operator=(const TDBErrorStru&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TDBErrorStru> SEQDBErrorStru;
#endif

View File

@@ -0,0 +1,945 @@
//**************************************
// Generated by mcpp translator
// Version 1.3
//**************************************
#ifndef __QUERY_SAMPLE_M_H__
#define __QUERY_SAMPLE_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
#include"public_m.h"
const short QUERY_MODE_START = 0;
const short QUERY_MODE_MIDDLE = 1;
const short QUERY_MODE_END = 2;
const short QUERY_MODE_MAX = 3;
const short QUERY_MODE_MIN = 4;
const short QUERY_MODE_AVERAGE = 5;
const short QUERY_YC_SAMPLE = 1;
const short QUERY_YX_SAMPLE = 0;
const short QUERY_SUCCESS = 0;
const short QUERY_FAIL = -1;
const short QUERY_REACH_MAX = 1;
const short QUERY_ALL_ROWS = -1;
const short STA_POLICY_INTELLIGENT = 0;
const short STA_POLICY_NORMAL = 1;
const short STA_POLICY_DAY = 2;
const short STA_POLICY_HOUR = 3;
const short STA_MODE_MAX = 0;
const short STA_MODE_MIN = 1;
const short STA_MODE_AVERAGE = 2;
const short STA_MODE_LOADRATE = 3;
const short STA_WITH_LIMIT = 0;
const short STA_WITHOUT_LIMIT = 1;
const short STA_WITHOUT_ABS = 0;
const short STA_WITH_ABS = 1;
const short SAMPLE_DATATYPE_INT = 0;
const short SAMPLE_DATATYPE_FLOAT = 1;
const short SAMPLE_DATATYPE_STRING = 2;
typedef MLang::VECTOR<MLang::STRING> SEQKeyID;
struct TKeyInfo
{
MLang::STRING keyid;
int max_result;
TKeyInfo();
TKeyInfo(const TKeyInfo&);
TKeyInfo&operator=(const TKeyInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TKeyInfo> SEQKeyInfo;
struct TSampleInfo
{
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
unsigned char is_yc;
int time_pace;
short sample_mode;
int specify_status;
unsigned char status_policy;
short key_num;
SEQKeyInfo seq_keyinfo;
TSampleInfo();
TSampleInfo(const TSampleInfo&);
TSampleInfo&operator=(const TSampleInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleInfo> SEQSampleInfo;
struct TQuerySampleInParm
{
int query_id;
SEQSampleInfo seq_sample_info;
TQuerySampleInParm();
TQuerySampleInParm(const TQuerySampleInParm&);
TQuerySampleInParm&operator=(const TQuerySampleInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct USampleValue
{
private:
union
{
unsigned char yx_value;
float yc_value;
}__u_val;
bool __u_init;
unsigned short __u_index;
public:
USampleValue();
~USampleValue();
USampleValue(const USampleValue&);
USampleValue&operator=(const USampleValue&);
short _d()const;
void __clear();
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
void yx_value(const unsigned char);
const unsigned char yx_value()const;
void yc_value(const float);
const float yc_value()const;
};
struct TSampleValueInfo
{
MLang::Long occur_time;
USampleValue value;
int status;
short is_null;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleValueInfo> SEQSampleValueInfo;
struct TSampleResultInfo
{
MLang::STRING keyid;
int max_result;
short success_flag;
MLang::STRING err_string;
short reach_max;
int result_num;
SEQSampleValueInfo seq_val;
TSampleResultInfo();
TSampleResultInfo(const TSampleResultInfo&);
TSampleResultInfo&operator=(const TSampleResultInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleResultInfo> SEQSampleResultInfo;
struct TSampleResult
{
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
unsigned char is_yc;
int time_pace;
short sample_mode;
int specify_status;
unsigned char status_policy;
short key_num;
short valid_flag;
MLang::STRING invalid_string;
SEQSampleResultInfo seq_sample_result_info;
TSampleResult();
TSampleResult(const TSampleResult&);
TSampleResult&operator=(const TSampleResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleResult> SEQSampleResult;
struct TQuerySampleOutParm
{
int query_id;
SEQSampleResult seq_sample_result;
TQuerySampleOutParm();
TQuerySampleOutParm(const TQuerySampleOutParm&);
TQuerySampleOutParm&operator=(const TQuerySampleOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TStatisticsKeyInfo
{
MLang::STRING keyid;
TStatisticsKeyInfo();
TStatisticsKeyInfo(const TStatisticsKeyInfo&);
TStatisticsKeyInfo&operator=(const TStatisticsKeyInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TStatisticsKeyInfo> SEQStatisticsKeyInfo;
struct TStatisticsInfo
{
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
unsigned char statistics_policy;
int time_pace;
short statistics_mode;
unsigned char except_limit;
unsigned char is_abs;
short key_num;
SEQStatisticsKeyInfo seq_statistics_keyinfo;
TStatisticsInfo();
TStatisticsInfo(const TStatisticsInfo&);
TStatisticsInfo&operator=(const TStatisticsInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TStatisticsInfo> SEQStatisticsInfo;
struct TStatisticsSampleInParm
{
int query_id;
SEQStatisticsInfo seq_statistics_info;
TStatisticsSampleInParm();
TStatisticsSampleInParm(const TStatisticsSampleInParm&);
TStatisticsSampleInParm&operator=(const TStatisticsSampleInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TStatisticsResultInfo
{
MLang::STRING keyid;
short success_flag;
MLang::STRING err_string;
float value;
MLang::Long occur_time;
short is_null;
TStatisticsResultInfo();
TStatisticsResultInfo(const TStatisticsResultInfo&);
TStatisticsResultInfo&operator=(const TStatisticsResultInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TStatisticsResultInfo> SEQStatisticsResultInfo;
struct TStatisticsResult
{
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
unsigned char statistics_policy;
unsigned char is_real;
int time_pace;
short statistics_mode;
unsigned char except_limit;
unsigned char is_abs;
short key_num;
short valid_flag;
MLang::STRING invalid_string;
SEQStatisticsResultInfo seq_statistics_result_info;
TStatisticsResult();
TStatisticsResult(const TStatisticsResult&);
TStatisticsResult&operator=(const TStatisticsResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TStatisticsResult> SEQStatisticsResult;
struct TStatisticsSampleOutParm
{
int query_id;
SEQStatisticsResult seq_statistics_result;
TStatisticsSampleOutParm();
TStatisticsSampleOutParm(const TStatisticsSampleOutParm&);
TStatisticsSampleOutParm&operator=(const TStatisticsSampleOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TDiscreteInfo
{
MLang::STRING sample_name;
MLang::STRING keyid;
unsigned char is_yc;
MLang::Long time_num;
LongSeq seq_timeinfo;
TDiscreteInfo();
TDiscreteInfo(const TDiscreteInfo&);
TDiscreteInfo&operator=(const TDiscreteInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TDiscreteInfo> SEQDiscreteInfo;
struct TDiscreteSampleInParm
{
int query_id;
SEQDiscreteInfo seq_discrete_info;
TDiscreteSampleInParm();
TDiscreteSampleInParm(const TDiscreteSampleInParm&);
TDiscreteSampleInParm&operator=(const TDiscreteSampleInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TDiscreteResult
{
MLang::STRING sample_name;
MLang::STRING keyid;
unsigned char is_yc;
unsigned char is_real;
short success_flag;
MLang::STRING err_string;
int time_num;
SEQSampleValueInfo seq_val;
TDiscreteResult();
TDiscreteResult(const TDiscreteResult&);
TDiscreteResult&operator=(const TDiscreteResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TDiscreteResult> SEQDiscreteResult;
struct TDiscreteSampleOutParm
{
int query_id;
SEQDiscreteResult seq_discrete_result;
TDiscreteSampleOutParm();
TDiscreteSampleOutParm(const TDiscreteSampleOutParm&);
TDiscreteSampleOutParm&operator=(const TDiscreteSampleOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TTriggerSampleInfo
{
int sample_type;
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
int max_result;
unsigned char offer_id;
LongSeq seq_id;
unsigned char return_all;
short keyid_num;
SEQKeyID seq_keyid;
TTriggerSampleInfo();
TTriggerSampleInfo(const TTriggerSampleInfo&);
TTriggerSampleInfo&operator=(const TTriggerSampleInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTriggerSampleInfo> SEQTriggerSampleInfo;
struct TTriggerSampleInParm
{
int query_id;
SEQTriggerSampleInfo seq_trigger_sample_info;
TTriggerSampleInParm();
TTriggerSampleInParm(const TTriggerSampleInParm&);
TTriggerSampleInParm&operator=(const TTriggerSampleInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct USampleDataValue
{
private:
union
{
int c_int;
float c_float;
char* c_string;
}__u_val;
bool __u_init;
unsigned short __u_index;
public:
USampleDataValue();
~USampleDataValue();
USampleDataValue(const USampleDataValue&);
USampleDataValue&operator=(const USampleDataValue&);
short _d()const;
void __clear();
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
void c_int(const int);
const int c_int()const;
void c_float(const float);
const float c_float()const;
void c_string(const char*);
void c_string(const MLang::STRING&);
const char*c_string()const;
};
struct TSampleQueryKeyInfo
{
MLang::STRING keyid;
MLang::STRING keyid_description;
short keyid_datatype;
short is_success;
MLang::STRING err_string;
short is_null;
USampleDataValue keyid_value;
TSampleQueryKeyInfo();
TSampleQueryKeyInfo(const TSampleQueryKeyInfo&);
TSampleQueryKeyInfo&operator=(const TSampleQueryKeyInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleQueryKeyInfo> SEQTriggerSampleKeyValue;
struct TTriggerQueryResult
{
int occur_time;
SEQTriggerSampleKeyValue seq_sample_value;
TTriggerQueryResult();
TTriggerQueryResult(const TTriggerQueryResult&);
TTriggerQueryResult&operator=(const TTriggerQueryResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTriggerQueryResult> SEQTriggerQueryResult;
struct TTriggerSampleResult
{
int sample_type;
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
int max_result;
unsigned char offer_id;
LongSeq seq_id;
unsigned char return_all;
short success_flag;
MLang::STRING err_string;
short reach_max;
short keyid_num;
SEQTriggerQueryResult seq_sample_query_result;
TTriggerSampleResult();
TTriggerSampleResult(const TTriggerSampleResult&);
TTriggerSampleResult&operator=(const TTriggerSampleResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTriggerSampleResult> SEQTriggerSampleResult;
struct TTriggerSampleOutParm
{
int query_id;
SEQTriggerSampleResult seq_trigger_sample_result;
TTriggerSampleOutParm();
TTriggerSampleOutParm(const TTriggerSampleOutParm&);
TTriggerSampleOutParm&operator=(const TTriggerSampleOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TTriggerStatisticsInfo
{
int sample_type;
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
short statistics_mode;
unsigned char except_limit;
unsigned char is_abs;
unsigned char offer_id;
LongSeq seq_id;
unsigned char return_all;
short keyid_num;
SEQKeyID seq_keyid;
TTriggerStatisticsInfo();
TTriggerStatisticsInfo(const TTriggerStatisticsInfo&);
TTriggerStatisticsInfo&operator=(const TTriggerStatisticsInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTriggerStatisticsInfo> SEQTriggerStatisticsInfo;
struct TTriggerStatisticsInParm
{
int query_id;
SEQTriggerStatisticsInfo seq_trigger_statistics_info;
TTriggerStatisticsInParm();
TTriggerStatisticsInParm(const TTriggerStatisticsInParm&);
TTriggerStatisticsInParm&operator=(const TTriggerStatisticsInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TSampleStatisticsKeyInfo
{
MLang::STRING keyid;
MLang::STRING keyid_description;
short keyid_datatype;
short is_success;
MLang::STRING err_string;
short is_null;
MLang::Long occur_time;
USampleDataValue keyid_value;
TSampleStatisticsKeyInfo();
TSampleStatisticsKeyInfo(const TSampleStatisticsKeyInfo&);
TSampleStatisticsKeyInfo&operator=(const TSampleStatisticsKeyInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleStatisticsKeyInfo> SEQTriggerStatisticsKeyValue;
struct TTriggerStatisticsResult
{
int sample_type;
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
short statistics_mode;
unsigned char except_limit;
unsigned char is_abs;
unsigned char offer_id;
LongSeq seq_id;
unsigned char return_all;
short success_flag;
MLang::STRING err_string;
short keyid_num;
SEQTriggerStatisticsKeyValue seq_sample_statistics_key_value;
TTriggerStatisticsResult();
TTriggerStatisticsResult(const TTriggerStatisticsResult&);
TTriggerStatisticsResult&operator=(const TTriggerStatisticsResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTriggerStatisticsResult> SEQTriggerStatisticsResult;
struct TTriggerStatisticsOutParm
{
int query_id;
SEQTriggerStatisticsResult seq_trigger_statistics_result;
TTriggerStatisticsOutParm();
TTriggerStatisticsOutParm(const TTriggerStatisticsOutParm&);
TTriggerStatisticsOutParm&operator=(const TTriggerStatisticsOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TTriggerKeyInfo
{
MLang::STRING sample_name;
MLang::STRING keyid;
TTriggerKeyInfo();
TTriggerKeyInfo(const TTriggerKeyInfo&);
TTriggerKeyInfo&operator=(const TTriggerKeyInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTriggerKeyInfo> SEQTriggerKeyInfo;
struct TTriggerKeyInfoInParm
{
SEQTriggerKeyInfo seq_trigger_key_info;
TTriggerKeyInfoInParm();
TTriggerKeyInfoInParm(const TTriggerKeyInfoInParm&);
TTriggerKeyInfoInParm&operator=(const TTriggerKeyInfoInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TTriggerReturnInfo
{
int sample_type;
MLang::STRING sample_name;
unsigned char offer_id;
TTriggerReturnInfo();
TTriggerReturnInfo(const TTriggerReturnInfo&);
TTriggerReturnInfo&operator=(const TTriggerReturnInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTriggerReturnInfo> SEQTriggerReturnInfo;
struct TTriggerKeyInfoResult
{
MLang::STRING sample_name;
MLang::STRING keyid;
short success_flag;
MLang::STRING err_string;
SEQTriggerReturnInfo seq_trigger_return_info;
TTriggerKeyInfoResult();
TTriggerKeyInfoResult(const TTriggerKeyInfoResult&);
TTriggerKeyInfoResult&operator=(const TTriggerKeyInfoResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTriggerKeyInfoResult> SEQTriggerKeyInfoResult;
struct TTriggerKeyInfoOutParm
{
SEQTriggerKeyInfoResult seq_trigger_key_info_result;
TTriggerKeyInfoOutParm();
TTriggerKeyInfoOutParm(const TTriggerKeyInfoOutParm&);
TTriggerKeyInfoOutParm&operator=(const TTriggerKeyInfoOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TSampleKeyInfo
{
MLang::STRING sample_name;
SEQKeyID seq_keyid;
TSampleKeyInfo();
TSampleKeyInfo(const TSampleKeyInfo&);
TSampleKeyInfo&operator=(const TSampleKeyInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleKeyInfo> SEQSampleKeyInfo;
struct TSampleKeyInfoInParm
{
unsigned char is_yc;
unsigned char is_real;
SEQSampleKeyInfo seq_sample_key_info;
TSampleKeyInfoInParm();
TSampleKeyInfoInParm(const TSampleKeyInfoInParm&);
TSampleKeyInfoInParm&operator=(const TSampleKeyInfoInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TSampleReturnInfo
{
MLang::STRING keyid;
unsigned char is_sample;
int sample_interval;
TSampleReturnInfo();
TSampleReturnInfo(const TSampleReturnInfo&);
TSampleReturnInfo&operator=(const TSampleReturnInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleReturnInfo> SEQSampleReturnInfo;
struct TSampleKeyInfoResult
{
MLang::STRING sample_name;
SEQKeyID seq_keyid;
short success_flag;
MLang::STRING err_string;
SEQSampleReturnInfo seq_sample_return_info;
TSampleKeyInfoResult();
TSampleKeyInfoResult(const TSampleKeyInfoResult&);
TSampleKeyInfoResult&operator=(const TSampleKeyInfoResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleKeyInfoResult> SEQSampleKeyInfoResult;
struct TSampleKeyInfoOutParm
{
unsigned char is_yc;
unsigned char is_real;
SEQSampleKeyInfoResult seq_sample_key_info_result;
TSampleKeyInfoOutParm();
TSampleKeyInfoOutParm(const TSampleKeyInfoOutParm&);
TSampleKeyInfoOutParm&operator=(const TSampleKeyInfoOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct UIdValue
{
private:
union
{
char* keyid;
int id;
}__u_val;
bool __u_init;
unsigned short __u_index;
public:
UIdValue();
~UIdValue();
UIdValue(const UIdValue&);
UIdValue&operator=(const UIdValue&);
short _d()const;
void __clear();
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
void keyid(const char*);
void keyid(const MLang::STRING&);
const char*keyid()const;
void id(const int);
const int id()const;
};
struct TStatisticsCond
{
MLang::STRING cond_col_name;
short condition_num;
SEQDataValue cond_value;
TStatisticsCond();
TStatisticsCond(const TStatisticsCond&);
TStatisticsCond&operator=(const TStatisticsCond&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TStatisticsCond> SEQStatisticsCondInfo;
struct TNumberStatisticsInfo
{
UIdValue statistics_id;
int statistics_mode;
int statistics_status;
short field_num;
SEQStatisticsCondInfo seq_cond_info;
TNumberStatisticsInfo();
TNumberStatisticsInfo(const TNumberStatisticsInfo&);
TNumberStatisticsInfo&operator=(const TNumberStatisticsInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TNumberStatisticsInfo> SEQNumberStatisticsInfo;
struct TNumberStatisticsTypeInfo
{
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
short key_num;
SEQNumberStatisticsInfo seq_number_statistics_info;
TNumberStatisticsTypeInfo();
TNumberStatisticsTypeInfo(const TNumberStatisticsTypeInfo&);
TNumberStatisticsTypeInfo&operator=(const TNumberStatisticsTypeInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TNumberStatisticsTypeInfo> SEQNumStatisticsTypeInfo;
struct TNumberStatisticsInParm
{
SEQNumStatisticsTypeInfo seq_num_statistics_type_info;
TNumberStatisticsInParm();
TNumberStatisticsInParm(const TNumberStatisticsInParm&);
TNumberStatisticsInParm&operator=(const TNumberStatisticsInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TNumStatisticsResultInfo
{
UIdValue statistics_id;
int statistics_mode;
int statistics_status;
short success_flag;
MLang::STRING err_string;
int value;
TNumStatisticsResultInfo();
TNumStatisticsResultInfo(const TNumStatisticsResultInfo&);
TNumStatisticsResultInfo&operator=(const TNumStatisticsResultInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TNumStatisticsResultInfo> SEQNumStatisticsResultInfo;
struct TNumStatisticsTypeResult
{
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
short key_num;
short valid_flag;
MLang::STRING invalid_string;
SEQNumStatisticsResultInfo seq_num_statistics_result_info;
TNumStatisticsTypeResult();
TNumStatisticsTypeResult(const TNumStatisticsTypeResult&);
TNumStatisticsTypeResult&operator=(const TNumStatisticsTypeResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TNumStatisticsTypeResult> SEQNumStatisticsTypeResult;
struct TNumberStatisticsOutParm
{
SEQNumStatisticsTypeResult seq_num_statistics_type_result;
TNumberStatisticsOutParm();
TNumberStatisticsOutParm(const TNumberStatisticsOutParm&);
TNumberStatisticsOutParm&operator=(const TNumberStatisticsOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TTimeStatisticsInfo
{
UIdValue statistics_id;
int statistics_mode;
int statistics_status;
short field_num;
SEQStatisticsCondInfo seq_cond_info;
TTimeStatisticsInfo();
TTimeStatisticsInfo(const TTimeStatisticsInfo&);
TTimeStatisticsInfo&operator=(const TTimeStatisticsInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTimeStatisticsInfo> SEQTimeStatisticsInfo;
struct TTimeStatisticsTypeInfo
{
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
short key_num;
SEQTimeStatisticsInfo seq_time_statistics_info;
TTimeStatisticsTypeInfo();
TTimeStatisticsTypeInfo(const TTimeStatisticsTypeInfo&);
TTimeStatisticsTypeInfo&operator=(const TTimeStatisticsTypeInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTimeStatisticsTypeInfo> SEQTimeStatisticsTypeInfo;
struct TTimeStatisticsInParm
{
SEQTimeStatisticsTypeInfo seq_time_statistics_type_info;
TTimeStatisticsInParm();
TTimeStatisticsInParm(const TTimeStatisticsInParm&);
TTimeStatisticsInParm&operator=(const TTimeStatisticsInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TTimeStatisticsResultInfo
{
UIdValue statistics_id;
int statistics_mode;
int statistics_status;
short success_flag;
MLang::STRING err_string;
int value;
TTimeStatisticsResultInfo();
TTimeStatisticsResultInfo(const TTimeStatisticsResultInfo&);
TTimeStatisticsResultInfo&operator=(const TTimeStatisticsResultInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTimeStatisticsResultInfo> SEQTimeStatisticsResultInfo;
struct TTimeStatisticsTypeResult
{
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
short key_num;
short valid_flag;
MLang::STRING invalid_string;
SEQTimeStatisticsResultInfo seq_time_statistics_result_info;
TTimeStatisticsTypeResult();
TTimeStatisticsTypeResult(const TTimeStatisticsTypeResult&);
TTimeStatisticsTypeResult&operator=(const TTimeStatisticsTypeResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTimeStatisticsTypeResult> SEQTimeStatisticsTypeResult;
struct TTimeStatisticsOutParm
{
SEQTimeStatisticsTypeResult seq_time_statistics_type_result;
TTimeStatisticsOutParm();
TTimeStatisticsOutParm(const TTimeStatisticsOutParm&);
TTimeStatisticsOutParm&operator=(const TTimeStatisticsOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TSampleInfoFromStat
{
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
unsigned char source_flag;
short statistics_mode;
short key_num;
SEQKeyID seq_keyid;
TSampleInfoFromStat();
TSampleInfoFromStat(const TSampleInfoFromStat&);
TSampleInfoFromStat&operator=(const TSampleInfoFromStat&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleInfoFromStat> SEQSampleInfoFromStat;
struct TQuerySampleFromStatInParm
{
int query_id;
SEQSampleInfoFromStat seq_sample_info_from_stat;
TQuerySampleFromStatInParm();
TQuerySampleFromStatInParm(const TQuerySampleFromStatInParm&);
TQuerySampleFromStatInParm&operator=(const TQuerySampleFromStatInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TSampleValueFromStatInfo
{
MLang::Long occur_time;
MLang::Long stat_occur_time;
float value;
int status;
short is_null;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleValueFromStatInfo> SEQSampleValueFromStatInfo;
struct TSampleResultFromStatInfo
{
MLang::STRING keyid;
short success_flag;
MLang::STRING err_string;
int result_num;
SEQSampleValueFromStatInfo seq_val;
TSampleResultFromStatInfo();
TSampleResultFromStatInfo(const TSampleResultFromStatInfo&);
TSampleResultFromStatInfo&operator=(const TSampleResultFromStatInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleResultFromStatInfo> SEQSampleResultFromStatInfo;
struct TSampleResultFromStat
{
MLang::STRING sample_name;
MLang::Long start_time;
MLang::Long end_time;
unsigned char source_flag;
short statistics_mode;
short key_num;
short valid_flag;
MLang::STRING invalid_string;
SEQSampleResultFromStatInfo seq_sample_result_from_stat_info;
TSampleResultFromStat();
TSampleResultFromStat(const TSampleResultFromStat&);
TSampleResultFromStat&operator=(const TSampleResultFromStat&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleResultFromStat> SEQSampleResultFromStat;
struct TQuerySampleFromStatOutParm
{
int query_id;
SEQSampleResultFromStat seq_sample_result_from_stat;
TQuerySampleFromStatOutParm();
TQuerySampleFromStatOutParm(const TQuerySampleFromStatOutParm&);
TQuerySampleFromStatOutParm&operator=(const TQuerySampleFromStatOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TAllSampleInfo
{
MLang::STRING sample_name;
SEQKeyID seq_keyid;
unsigned char is_yc;
unsigned char is_real;
LongSeq seq_occur_time;
TAllSampleInfo();
TAllSampleInfo(const TAllSampleInfo&);
TAllSampleInfo&operator=(const TAllSampleInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TAllQuerySampleInParm
{
int query_id;
TAllSampleInfo all_sample_info;
TAllQuerySampleInParm();
TAllQuerySampleInParm(const TAllQuerySampleInParm&);
TAllQuerySampleInParm&operator=(const TAllQuerySampleInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TAllSampleValueInfo
{
MLang::Long occur_time;
MLang::VECTOR<USampleValue> seq_value;
LongSeq seq_status;
ShortSeq seq_is_null;
TAllSampleValueInfo();
TAllSampleValueInfo(const TAllSampleValueInfo&);
TAllSampleValueInfo&operator=(const TAllSampleValueInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TAllSampleValueInfo> SEQAllSampleValueInfo;
struct TAllSampleResult
{
MLang::STRING sample_name;
SEQKeyID seq_keyid;
unsigned char is_yc;
unsigned char is_real;
LongSeq seq_occur_time;
short valid_flag;
MLang::STRING invalid_string;
SEQAllSampleValueInfo seq_all_value;
TAllSampleResult();
TAllSampleResult(const TAllSampleResult&);
TAllSampleResult&operator=(const TAllSampleResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TAllQuerySampleOutParm
{
int query_id;
TAllSampleResult all_sample_result;
TAllQuerySampleOutParm();
TAllQuerySampleOutParm(const TAllQuerySampleOutParm&);
TAllQuerySampleOutParm&operator=(const TAllQuerySampleOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,444 @@
//**************************************************************************************************
//
// AUTHOR : ChenPeng
//
// FUNCTION : PI数据库采样查询专用IDL定义
// TIME : 2007.03.06
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------------------------------------
// 2007.03.06 Creation ChenPeng
// 2007.03.13 Add ChenPeng Add PI StatisticsSample API
// 2007.04.11 Add ChenPeng Add PI GetDiscreteSampleResultFromPI()
//**************************************************************************************************
#include "public.h"
#include "mcode/mtypes.h"
const short QUERY_YC_SAMPLE_PI = 1;
const short QUERY_YX_SAMPLE_PI = 0;
const short QUERY_SUCCESS_PI = 0;
const short QUERY_FAIL_PI = -1;
const short QUERY_REACH_MAX_PI = 1;
//union USampleValuePI switch(short)
//{
// case 1: unsigned char yx_value; /*YX值*/
// case 2: float yc_value; /*YC值*/
//};
struct USampleValuePI
{
int type;
union{
unsigned char yx_value;//1
float yc_value;//2
}val;
};
struct TSampleValueInfoPI
{
long occur_time; /*采样时间,单位秒*/
short occur_time_ms; /*采样时间毫秒*/
USampleValuePI value; /*值*/
int status; /*状态*/
short is_null; /*是否为空 取值=-1表示空*/
};
struct TSampleResultInfoPI
{
TKeyID keyid; /*YX或YC的ID号*/
int max_result; /*检索时的最大返回数,-1为全部查询*/
short success_flag; /*检索成功标记 取值 QUERY_SUCCESS成功取值 QUERY_FAIL失败*/
varchar err_string; /*检索失败错误信息仅在success_flag=QUERY_FAIL有效*/
short reach_max; /*是否越界 取值 QUERY_REACH_MAX越界取值 QUERY_SUCCESS未越界*/
int result_num; /*返回结果数,时间个数n*/
vector<TSampleValueInfoPI> seq_val; /*YX或YC的检索结果信息(重复n次)*/
};
struct TSampleResultPI
{
int app_no; /*应用号*/
long start_time; /*起始时间*/
short start_time_ms; /*起始时间,单位毫秒 与start_time共同确定一个精确到毫秒的时间*/
long end_time; /*终止时间*/
short end_time_ms; /*终止时间,单位毫秒 与end_time共同确定一个精确到毫秒的时间*/
unsigned char arc_mode; /*取数模式
ARC_MODE_EVEN平均时间间隔
ARC_MODE_COMP取所有值*/
int time_pace; /*时间步长*/
short sample_mode; /*检索方式,保留暂不实现*/
int specify_status; /*指定状态,保留暂不实现*/
unsigned char status_policy; /*指定状态策略,保留暂不实现*/
short key_num; /*YX或YC个数m*/
short valid_flag; /*有效性标记 取值 QUERY_SUCCESS有效
取值 QUERY_FAIL无效*/
varchar invalid_string; /*无效错误信息仅在valid_flag=QUERY_FAIL有效*/
vector<TSampleResultInfoPI> seq_pi_sample_result_info; /*(重复m次)*/
};
struct TQuerySampleOutParmPI
{
int query_id; /*查询ID仅在异步查询时使用,暂不实现*/
vector<TSampleResultPI> seq_sample_result_pi;
};
struct TKeyInfoPI
{
TKeyID keyid; /*YX或YC的ID号*/
int max_result; /*检索时的最大返回数*/
};
struct TSampleInfoPI
{
int app_no; /*应用号*/
long start_time; /*起始时间,单位秒 检索时大于等于该时间*/
short start_time_ms; /*起始时间,单位毫秒 与start_time共同确定一个精确到毫秒的时间*/
long end_time; /*终止时间,单位秒 检索时小于该时间,注意不包括该时间*/
short end_time_ms; /*终止时间,单位毫秒 与end_time共同确定一个精确到毫秒的时间*/
unsigned char is_yc; /*YC或YX标志 取值 QUERY_YC_SAMPLE遥测
取值 QUERY_YX_SAMPLE遥信
取值遥信时is_real参数无效
同时time_pace必须为1小时的整数倍
小于1小时的time_pace将会强制为1小时
sample_mode强制为QUERY_MODE_START*/
unsigned char arc_mode; /*动态信息数据库取数模式
ARC_MODE_EVEN: 每隔time_pace取一个值(可能是拟合值)
ARC_MODE_COMP取所有实际归档的值(都是实际值*/
int time_pace; /*时间步长单位毫秒。arc_mode=ARC_MODE_EVEN时有效*/
short sample_mode; /*检索方式,保留暂不实现*/
int specify_status; /*指定状态,保留暂不实现*/
unsigned char status_policy; /*指定状态策略,保留暂不实现*/
short key_num; /*YX或YC个数m调用者自己保证等于seq_keyinfo.length(),程序以后者为准*/
vector<TKeyInfoPI> seq_keyinfo; /*(重复m次)*/
};
struct TQuerySampleInParmPI
{
int query_id; /*查询ID仅在异步查询时使用若使用同步接口该参数无效异步查询暂不实现*/
vector<TSampleInfoPI> seq_sample_info_pi;
};
struct TPMUDataInfo
{
int app_no; /*应用号*/
long start_time; /*起始时间,单位秒 检索时大于等于该时间*/
short start_time_ms; /*起始时间,单位毫秒 与start_time共同确定一个精确到毫秒的时间*/
long end_time; /*终止时间,单位秒 检索时小于该时间,注意不包括该时间*/
short end_time_ms; /*终止时间,单位毫秒 与end_time共同确定一个精确到毫秒的时间*/
int time_pace; /*时间步长,单位毫秒 */
unsigned char result_mode; /*查询结果模式
RESULT_MODE_NO_DIFF: 不区分查询结果是否是拟合值
RESULT_MODE_DIFF: 区分查询结果是否是拟合值*/
short key_num; /*YX或YC个数m调用者自己保证等于seq_keyinfo.length(),程序以后者为准*/
vector<TKeyID> seq_keyid; /*(重复m次)*/
};
struct TQueryPMUInParmPI
{
int query_id; /*查询ID仅在异步查询时使用,异步查询暂不实现*/
vector<TPMUDataInfo> seq_pmu_data_info;
};
struct TPMUValueInfo
{
float value; /*值*/
int status; /*状态*/
};
struct TPMUResultInfo
{
TKeyID keyid; /*YX或YC的ID号*/
short success_flag; /*检索成功标记 取值 QUERY_SUCCESS成功
取值 QUERY_FAIL失败*/
varchar err_string; /*检索失败错误信息仅在success_flag=QUERY_FAIL有效*/
vector<TPMUValueInfo> seq_val; /*YX或YC的检索结果信息(重复n次)*/
};
struct TPMUResult
{
int app_no; /*应用号*/
long start_time; /*起始时间*/
short start_time_ms; /*起始时间,单位毫秒 与start_time共同确定一个精确到毫秒的时间*/
long end_time; /*终止时间*/
short end_time_ms; /*终止时间,单位毫秒 与end_time共同确定一个精确到毫秒的时间*/
int time_pace; /*时间步长*/
short key_num; /*YX或YC个数m*/
short valid_flag; /*有效性标记 取值 QUERY_SUCCESS有效
取值 QUERY_FAIL无效*/
varchar invalid_string; /*无效错误信息仅在valid_flag=QUERY_FAIL有效*/
vector<TPMUResultInfo> seq_pmu_result_info; /*(重复m次)*/
};
struct TQueryPMUOutParmPI
{
int query_id; /*查询ID仅在异步查询时使用,暂不实现*/
vector<TPMUResult> seq_pmu_result;
};
/********************************************************************************************
* 查询采样数据统计值(针对YC统计) *
* 指定时间段,步长查询最大值,最小值,最大值发生时间,最小值发生时间,平均值,负荷率 *
* 数据可来源于 *
*********************************************************************************************/
struct TStatisticsKeyInfoPI
{
TKeyID keyid; /*YC的ID号*/
};
typedef vector<TStatisticsKeyInfoPI> SEQStatisticsKeyInfoPI ;
struct TStatisticsInfoPI
{
int app_no; /*应用号*/
long start_time; /*起始时间,单位秒 检索时大于等于该时间*/
long end_time; /*终止时间,单位秒 检索时小于该时间,注意不包括该时间*/
unsigned char statistics_policy; /*统计策略
= STA_POLICY_NORMAL 1 统计结果来源于基础数据
= STA_POLICY_DAY 2 统计结果来源于日统计数据
= STA_POLICY_HOUR 3 统计结果来源于小时统计数据
若统计策略不为STA_POLICY_NORMAL则is_realtime_pace参数无效
对于策略STA_POLICY_DAY 起始中止时间必须为一天的开始及结束时间并且保证时间段必须为一日的整数倍(>=1)
对于策略STA_POLICY_HOUR 起始中止时间必须为一小时的开始及结束时间并且保证时间段必须为一小时的整数倍(>=1)*/
unsigned char is_real; /*是否为实时采样表 取值 QUERY_RS_SAMPLE实时
取值 QUERY_HS_SAMPLE历史*/
int time_pace; /*时间步长,单位秒 要求:步长大于等于采样周期且步长必须为采样周期的整数倍*/
short statistics_mode;/*统计方式*/
unsigned char except_limit; /*统计时是否包含越限值统计 取值 STA_WITH_LIMIT包含越限值统计
取值 STA_WITHOUT_LIMIT不包含越限值统计*/
unsigned char is_abs; /*统计时是否采用绝对值 取值 STA_WITH_ABS按绝对值统计
取值 STA_WITHOUT_ABS按实际值统计*/
short key_num; /*YC个数m调用者自己保证等于seq_statistic_keyinfo.length(),程序以后者为准*/
SEQStatisticsKeyInfoPI seq_statistics_keyinfo; /*(重复m次)*/
};
typedef vector<TStatisticsInfoPI> SEQStatisticsInfoPI;
struct TStatisticsSampleInParmPI
{
int query_id; /*查询ID仅在异步查询时使用若使用同步接口该参数无效*/
SEQStatisticsInfoPI seq_statistics_info;
};
struct TStatisticsResultInfoPI
{
TKeyID keyid; /*YC的ID号*/
short success_flag; /*检索成功标记 取值 QUERY_SUCCESS成功
取值 QUERY_FAIL失败*/
varchar err_string; /*检索失败错误信息仅在success_flag=QUERY_FAIL有效*/
float value; /*统计值*/
long occur_time; /*统计值发生时间,单位秒,仅对于最大最小统计有效*/
short is_null; /*是否为空 取值=-1表示空*/
};
typedef vector<TStatisticsResultInfoPI> SEQStatisticsResultInfoPI;
struct TStatisticsResultPI
{
int app_no; /*应用号*/
long start_time; /*起始时间*/
long end_time; /*终止时间*/
unsigned char statistics_policy; /*统计策略*/
unsigned char is_real; /*是否为实时采样表 */
int time_pace; /*时间步长*/
short statistics_mode; /*统计方式*/
unsigned char except_limit; /*统计时是否包含越限值*/
unsigned char is_abs; /*统计时是否采用绝对值*/
short key_num; /*YC个数m*/
short valid_flag; /*有效性标记 取值 QUERY_SUCCESS有效
取值 QUERY_FAIL无效*/
varchar invalid_string; /*无效错误信息仅在valid_flag=QUERY_FAIL有效*/
SEQStatisticsResultInfoPI seq_statistics_result_info; /*(重复m次)*/
};
typedef vector<TStatisticsResultPI> SEQStatisticsResultPI;
struct TStatisticsSampleOutParmPI
{
int query_id; /*查询ID仅在异步查询时使用*/
SEQStatisticsResultPI seq_statistics_result;
};
/********************************************************************************************
* 查询采样数据(数据来源为统计值)值只对于YC * *
*********************************************************************************************/
typedef vector<TKeyID> SEQKeyIDPI;
struct TSampleInfoFromStatPI
{
int app_no; /*应用号*/
long start_time; /*起始时间,单位秒 检索时大于等于该时间*/
long end_time; /*终止时间,单位秒 检索时小于该时间,注意不包括该时间*/
unsigned char source_flag; /*数据来源标志 取值 0来源为日统计
取值 1来源为小时统计暂时无效
*/
short statistics_mode;/*统计方式,取最大,最小,平均或负荷率*/
short key_num; /*YC个数m调用者自己保证等于seq_keyid.length(),程序以后者为准*/
SEQKeyIDPI seq_keyid; /*(重复m次)*/
};
typedef vector<TSampleInfoFromStatPI> SEQSampleInfoFromStatPI;
struct TQuerySampleFromStatInParmPI
{
int query_id; /*查询ID仅在异步查询时使用若使用同步接口该参数无效*/
SEQSampleInfoFromStatPI seq_sample_info_from_stat;
};
struct TSampleValueFromStatInfoPI
{
long occur_time; /*结果时间。单位秒
对于source_flag = 0该时间精确到日而不是秒*/
long stat_occur_time; /*统计发生时间,只对于最大最小统计,其余无效。单位秒*/
float value; /*统计YC值*/
int status; /*统计YC状态*/
short is_null; /*是否为空 取值=-1表示空*/
};
typedef vector<TSampleValueFromStatInfoPI> SEQSampleValueFromStatInfoPI;
struct TSampleResultFromStatInfoPI
{
TKeyID keyid; /*YC的ID号*/
short success_flag; /*检索成功标记 取值 QUERY_SUCCESS成功
取值 QUERY_FAIL失败*/
varchar err_string; /*检索失败错误信息仅在success_flag=QUERY_FAIL有效*/
int result_num; /*返回结果数,时间个数n*/
SEQSampleValueFromStatInfoPI seq_val; /*YC的检索结果信息(重复n次)*/
};
typedef vector<TSampleResultFromStatInfoPI> SEQSampleResultFromStatInfoPI;
struct TSampleResultFromStatPI
{
int app_no; /*应用号*/
long start_time; /*起始时间*/
long end_time; /*终止时间*/
unsigned char source_flag; /*数据来源标志*/
short statistics_mode; /*统计方式*/
short key_num; /*YC个数m*/
short valid_flag; /*有效性标记 取值 QUERY_SUCCESS有效
取值 QUERY_FAIL无效*/
varchar invalid_string; /*无效错误信息仅在valid_flag=QUERY_FAIL有效*/
SEQSampleResultFromStatInfoPI seq_sample_result_from_stat_info; /*(重复m次)*/
};
typedef vector<TSampleResultFromStatPI> SEQSampleResultFromStatPI;
struct TQuerySampleFromStatOutParmPI
{
int query_id; /*查询ID仅在异步查询时使用*/
SEQSampleResultFromStatPI seq_sample_result_from_stat;
};
//根据KEYID提出请求返回(普通)采样基本信息
struct TSampleKeyInfoPI
{
int app_no; // 应用号
SEQKeyIDPI seq_keyid; // KEYID序列
};
typedef vector<TSampleKeyInfoPI> SEQSampleKeyInfoPI;
struct TSampleKeyInfoInParmPI
{
unsigned char is_yc; /*YC或YX标志 取值 QUERY_YC_SAMPLE遥测
取值 QUERY_YX_SAMPLE遥信
取值遥信时is_real参数无效*/
unsigned char is_real; /*是否为实时采样表 取值 QUERY_RS_SAMPLE实时
取值 QUERY_HS_SAMPLE历史*/
SEQSampleKeyInfoPI seq_sample_key_info;
};
struct TSampleReturnInfoPI
{
TKeyID keyid; // 返回指定KEYID
unsigned char is_sample; /* 返回指定条件下(is_yc/is_real)的KEYID是否采样
= 1 采样
= 0 未采样*/
int sample_interval; /* 如果采样,返回采样周期(单位:秒)
如果 is_yc = QUERY_YX_SAMPLE时sample_interval = 3600
如果 is_yc = QUERY_YC_SAMPLE并且is_real = QUERY_RS_SAMPLE时
sample_interval = 5*/
};
typedef vector<TSampleReturnInfoPI> SEQSampleReturnInfoPI;
struct TSampleKeyInfoResultPI
{
int app_no; // 应用号
SEQKeyIDPI seq_keyid; // KEYID序列
short success_flag; /* 检索成功标记 取值 QUERY_SUCCESS成功
取值 QUERY_FAIL失败 seq_sample_return_info.length=0 */
varchar err_string; // 检索失败错误信息仅在success_flag=QUERY_FAIL有效
SEQSampleReturnInfoPI seq_sample_return_info;
};
typedef vector<TSampleKeyInfoResultPI> SEQSampleKeyInfoResultPI;
struct TSampleKeyInfoOutParmPI
{
unsigned char is_yc;
unsigned char is_real;
SEQSampleKeyInfoResultPI seq_sample_key_info_result;
};
/***************************************************************************
* 离散点查询 *
****************************************************************************/
struct TDiscreteInfoPI
{
int app_no; /*应用号*/
TKeyID keyid; /*YX或YC的ID号*/
unsigned char is_yc; /*YC或YX标志 取值 QUERY_YC_SAMPLE遥测
取值 QUERY_YX_SAMPLE遥信
取值遥信时is_real参数无效*/
unsigned char is_real; /*是否为实时采样表 取值 QUERY_RS_SAMPLE实时
取值 QUERY_HS_SAMPLE历史*/
int time_num; /*时间个数m*/
LongSeq seq_timeinfo; /*时间序列(重复m次)*/
};
typedef vector<TDiscreteInfoPI> SEQDiscreteInfoPI;
struct TDiscreteSampleInParmPI
{
int query_id; /*查询ID仅在异步查询时使用若使用同步接口该参数无效*/
SEQDiscreteInfoPI seq_discrete_info;
};
typedef vector<TSampleValueInfoPI> SEQSampleValueInfoPI;
struct TDiscreteResultPI
{
int app_no; /*应用号*/
TKeyID keyid; /*YX或YC的ID号*/
unsigned char is_yc; /*YC或YX标志*/
unsigned char is_real; /*是否为实时采样表*/
short success_flag; /*检索成功标记 取值 QUERY_SUCCESS成功
取值 QUERY_FAIL失败*/
varchar err_string; /*检索失败错误信息仅在success_flag=QUERY_FAIL有效*/
int time_num; /*返回结果数,时间个数n*/
SEQSampleValueInfoPI seq_val; /*YX或YC的检索结果信息(重复n次)*/
};
typedef vector<TDiscreteResultPI> SEQDiscreteResultPI;
struct TDiscreteSampleOutParmPI
{
int query_id; /*查询ID仅在异步查询时使用*/
SEQDiscreteResultPI seq_discrete_result;
};
/*interface CQuerySamplePI
{
//用于从PI取SCADA采样数据数
short GetSampleResultFromPI(in TQuerySampleInParmPI in_para, out TQuerySampleOutParmPI out_para);
//用于从PI取PMU历史数据
short GetPMUResultFromPI(in TQueryPMUInParmPI in_para, out TQueryPMUOutParmPI out_para);
//用于从PI取SCADA统计数据
short GetStatisticsSampleResultFromPI(in TStatisticsSampleInParmPI in_para, out TStatisticsSampleOutParmPI out_para);
//
short GetQuerySampleResultFromStatFromPI(in TQuerySampleFromStatInParmPI in_para, out TQuerySampleFromStatOutParmPI out_para);
//工具函数根据KEYID和应用号得到是否有采样
short GetSampleInfoByKEYIDFromPI(in TSampleKeyInfoInParmPI in_para, out TSampleKeyInfoOutParmPI out_para);
short GetDiscreteSampleResultFromPI(in TDiscreteSampleInParmPI in_para, out TDiscreteSampleOutParmPI out_para);
};*/

View File

@@ -0,0 +1,531 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __QUERY_SAMPLE_PI_M_H__
#define __QUERY_SAMPLE_PI_M_H__
#ifdef _WINDOWS64
#ifdef DY_QUERY_SAMPLE_DLL_EXPORTS
#define DY_QUERY_SAMPLE_API __declspec(dllexport)
#else
#define DY_QUERY_SAMPLE_API __declspec(dllimport)
#endif
#else
#define DY_QUERY_SAMPLE_API
#endif
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
#include"public_m.h"
const short QUERY_YC_SAMPLE_PI = 1;
const short QUERY_YX_SAMPLE_PI = 0;
const short QUERY_SUCCESS_PI = 0;
const short QUERY_FAIL_PI = -1;
const short QUERY_REACH_MAX_PI = 1;
struct DY_QUERY_SAMPLE_API USampleValuePI
{
private:
union
{
unsigned char yx_value;
float yc_value;
}__u_val;
bool __u_init;
unsigned short __u_index;
public:
USampleValuePI();
~USampleValuePI();
USampleValuePI(const USampleValuePI&);
USampleValuePI&operator=(const USampleValuePI&);
short _d()const;
void __clear();
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
void yx_value(const unsigned char);
const unsigned char yx_value()const;
void yc_value(const float);
const float yc_value()const;
};
struct DY_QUERY_SAMPLE_API TSampleValueInfoPI
{
MLang::Long occur_time;
short occur_time_ms;
USampleValuePI value;
int status;
short is_null;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TSampleResultInfoPI
{
MLang::STRING keyid;
int max_result;
short success_flag;
MLang::STRING err_string;
short reach_max;
int result_num;
MLang::VECTOR<TSampleValueInfoPI> seq_val;
TSampleResultInfoPI();
TSampleResultInfoPI(const TSampleResultInfoPI&);
TSampleResultInfoPI&operator=(const TSampleResultInfoPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TSampleResultPI
{
int app_no;
MLang::Long start_time;
short start_time_ms;
MLang::Long end_time;
short end_time_ms;
unsigned char arc_mode;
int time_pace;
short sample_mode;
int specify_status;
unsigned char status_policy;
short key_num;
short valid_flag;
MLang::STRING invalid_string;
MLang::VECTOR<TSampleResultInfoPI> seq_pi_sample_result_info;
TSampleResultPI();
TSampleResultPI(const TSampleResultPI&);
TSampleResultPI&operator=(const TSampleResultPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TQuerySampleOutParmPI
{
int query_id;
MLang::VECTOR<TSampleResultPI> seq_sample_result_pi;
TQuerySampleOutParmPI();
TQuerySampleOutParmPI(const TQuerySampleOutParmPI&);
TQuerySampleOutParmPI&operator=(const TQuerySampleOutParmPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API DY_QUERY_SAMPLE_API TKeyInfoPI
{
MLang::STRING keyid;
int max_result;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TSampleInfoPI
{
int app_no;
MLang::Long start_time;
short start_time_ms;
MLang::Long end_time;
short end_time_ms;
unsigned char is_yc;
unsigned char arc_mode;
int time_pace;
short sample_mode;
int specify_status;
unsigned char status_policy;
short key_num;
MLang::VECTOR<TKeyInfoPI> seq_keyinfo;
TSampleInfoPI();
TSampleInfoPI(const TSampleInfoPI&);
TSampleInfoPI&operator=(const TSampleInfoPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TQuerySampleInParmPI
{
int query_id;
MLang::VECTOR<TSampleInfoPI> seq_sample_info_pi;
TQuerySampleInParmPI();
TQuerySampleInParmPI(const TQuerySampleInParmPI&);
TQuerySampleInParmPI&operator=(const TQuerySampleInParmPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TPMUDataInfo
{
int app_no;
MLang::Long start_time;
short start_time_ms;
MLang::Long end_time;
short end_time_ms;
int time_pace;
unsigned char result_mode;
short key_num;
MLang::VECTOR<MLang::STRING> seq_keyid;
TPMUDataInfo();
TPMUDataInfo(const TPMUDataInfo&);
TPMUDataInfo&operator=(const TPMUDataInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TQueryPMUInParmPI
{
int query_id;
MLang::VECTOR<TPMUDataInfo> seq_pmu_data_info;
TQueryPMUInParmPI();
TQueryPMUInParmPI(const TQueryPMUInParmPI&);
TQueryPMUInParmPI&operator=(const TQueryPMUInParmPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TPMUValueInfo
{
float value;
int status;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TPMUResultInfo
{
MLang::STRING keyid;
short success_flag;
MLang::STRING err_string;
MLang::VECTOR<TPMUValueInfo> seq_val;
TPMUResultInfo();
TPMUResultInfo(const TPMUResultInfo&);
TPMUResultInfo&operator=(const TPMUResultInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TPMUResult
{
int app_no;
MLang::Long start_time;
short start_time_ms;
MLang::Long end_time;
short end_time_ms;
int time_pace;
short key_num;
short valid_flag;
MLang::STRING invalid_string;
MLang::VECTOR<TPMUResultInfo> seq_pmu_result_info;
TPMUResult();
TPMUResult(const TPMUResult&);
TPMUResult&operator=(const TPMUResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API DY_QUERY_SAMPLE_API TQueryPMUOutParmPI
{
int query_id;
MLang::VECTOR<TPMUResult> seq_pmu_result;
TQueryPMUOutParmPI();
TQueryPMUOutParmPI(const TQueryPMUOutParmPI&);
TQueryPMUOutParmPI&operator=(const TQueryPMUOutParmPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API DY_QUERY_SAMPLE_API TStatisticsKeyInfoPI
{
TKeyID keyid;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TStatisticsKeyInfoPI> SEQStatisticsKeyInfoPI;
struct DY_QUERY_SAMPLE_API TStatisticsInfoPI
{
int app_no;
MLang::Long start_time;
MLang::Long end_time;
unsigned char statistics_policy;
unsigned char is_real;
int time_pace;
short statistics_mode;
unsigned char except_limit;
unsigned char is_abs;
short key_num;
SEQStatisticsKeyInfoPI seq_statistics_keyinfo;
TStatisticsInfoPI();
TStatisticsInfoPI(const TStatisticsInfoPI&);
TStatisticsInfoPI&operator=(const TStatisticsInfoPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TStatisticsInfoPI> SEQStatisticsInfoPI;
struct DY_QUERY_SAMPLE_API TStatisticsSampleInParmPI
{
int query_id;
SEQStatisticsInfoPI seq_statistics_info;
TStatisticsSampleInParmPI();
TStatisticsSampleInParmPI(const TStatisticsSampleInParmPI&);
TStatisticsSampleInParmPI&operator=(const TStatisticsSampleInParmPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TStatisticsResultInfoPI
{
TKeyID keyid;
short success_flag;
MLang::STRING err_string;
float value;
MLang::Long occur_time;
short is_null;
TStatisticsResultInfoPI();
TStatisticsResultInfoPI(const TStatisticsResultInfoPI&);
TStatisticsResultInfoPI&operator=(const TStatisticsResultInfoPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TStatisticsResultInfoPI> SEQStatisticsResultInfoPI;
struct DY_QUERY_SAMPLE_API TStatisticsResultPI
{
int app_no;
MLang::Long start_time;
MLang::Long end_time;
unsigned char statistics_policy;
unsigned char is_real;
int time_pace;
short statistics_mode;
unsigned char except_limit;
unsigned char is_abs;
short key_num;
short valid_flag;
MLang::STRING invalid_string;
SEQStatisticsResultInfoPI seq_statistics_result_info;
TStatisticsResultPI();
TStatisticsResultPI(const TStatisticsResultPI&);
TStatisticsResultPI&operator=(const TStatisticsResultPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TStatisticsResultPI> SEQStatisticsResultPI;
struct DY_QUERY_SAMPLE_API TStatisticsSampleOutParmPI
{
int query_id;
SEQStatisticsResultPI seq_statistics_result;
TStatisticsSampleOutParmPI();
TStatisticsSampleOutParmPI(const TStatisticsSampleOutParmPI&);
TStatisticsSampleOutParmPI&operator=(const TStatisticsSampleOutParmPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<MLang::STRING> SEQKeyIDPI;
struct DY_QUERY_SAMPLE_API TSampleInfoFromStatPI
{
int app_no;
MLang::Long start_time;
MLang::Long end_time;
unsigned char source_flag;
short statistics_mode;
short key_num;
SEQKeyIDPI seq_keyid;
TSampleInfoFromStatPI();
TSampleInfoFromStatPI(const TSampleInfoFromStatPI&);
TSampleInfoFromStatPI&operator=(const TSampleInfoFromStatPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleInfoFromStatPI> SEQSampleInfoFromStatPI;
struct DY_QUERY_SAMPLE_API TQuerySampleFromStatInParmPI
{
int query_id;
SEQSampleInfoFromStatPI seq_sample_info_from_stat;
TQuerySampleFromStatInParmPI();
TQuerySampleFromStatInParmPI(const TQuerySampleFromStatInParmPI&);
TQuerySampleFromStatInParmPI&operator=(const TQuerySampleFromStatInParmPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TSampleValueFromStatInfoPI
{
MLang::Long occur_time;
MLang::Long stat_occur_time;
float value;
int status;
short is_null;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleValueFromStatInfoPI> SEQSampleValueFromStatInfoPI;
struct DY_QUERY_SAMPLE_API TSampleResultFromStatInfoPI
{
TKeyID keyid;
short success_flag;
MLang::STRING err_string;
int result_num;
SEQSampleValueFromStatInfoPI seq_val;
TSampleResultFromStatInfoPI();
TSampleResultFromStatInfoPI(const TSampleResultFromStatInfoPI&);
TSampleResultFromStatInfoPI&operator=(const TSampleResultFromStatInfoPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleResultFromStatInfoPI> SEQSampleResultFromStatInfoPI;
struct DY_QUERY_SAMPLE_API TSampleResultFromStatPI
{
int app_no;
MLang::Long start_time;
MLang::Long end_time;
unsigned char source_flag;
short statistics_mode;
short key_num;
short valid_flag;
MLang::STRING invalid_string;
SEQSampleResultFromStatInfoPI seq_sample_result_from_stat_info;
TSampleResultFromStatPI();
TSampleResultFromStatPI(const TSampleResultFromStatPI&);
TSampleResultFromStatPI&operator=(const TSampleResultFromStatPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleResultFromStatPI> SEQSampleResultFromStatPI;
struct DY_QUERY_SAMPLE_API TQuerySampleFromStatOutParmPI
{
int query_id;
SEQSampleResultFromStatPI seq_sample_result_from_stat;
TQuerySampleFromStatOutParmPI();
TQuerySampleFromStatOutParmPI(const TQuerySampleFromStatOutParmPI&);
TQuerySampleFromStatOutParmPI&operator=(const TQuerySampleFromStatOutParmPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TSampleKeyInfoPI
{
int app_no;
SEQKeyIDPI seq_keyid;
TSampleKeyInfoPI();
TSampleKeyInfoPI(const TSampleKeyInfoPI&);
TSampleKeyInfoPI&operator=(const TSampleKeyInfoPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleKeyInfoPI> SEQSampleKeyInfoPI;
struct DY_QUERY_SAMPLE_API TSampleKeyInfoInParmPI
{
unsigned char is_yc;
unsigned char is_real;
SEQSampleKeyInfoPI seq_sample_key_info;
TSampleKeyInfoInParmPI();
TSampleKeyInfoInParmPI(const TSampleKeyInfoInParmPI&);
TSampleKeyInfoInParmPI&operator=(const TSampleKeyInfoInParmPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TSampleReturnInfoPI
{
MLang::STRING keyid;
unsigned char is_sample;
int sample_interval;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleReturnInfoPI> SEQSampleReturnInfoPI;
struct DY_QUERY_SAMPLE_API TSampleKeyInfoResultPI
{
int app_no;
SEQKeyIDPI seq_keyid;
short success_flag;
MLang::STRING err_string;
SEQSampleReturnInfoPI seq_sample_return_info;
TSampleKeyInfoResultPI();
TSampleKeyInfoResultPI(const TSampleKeyInfoResultPI&);
TSampleKeyInfoResultPI&operator=(const TSampleKeyInfoResultPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleKeyInfoResultPI> SEQSampleKeyInfoResultPI;
struct DY_QUERY_SAMPLE_API TSampleKeyInfoOutParmPI
{
unsigned char is_yc;
unsigned char is_real;
SEQSampleKeyInfoResultPI seq_sample_key_info_result;
TSampleKeyInfoOutParmPI();
TSampleKeyInfoOutParmPI(const TSampleKeyInfoOutParmPI&);
TSampleKeyInfoOutParmPI&operator=(const TSampleKeyInfoOutParmPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TDiscreteInfoPI
{
int app_no;
TKeyID keyid;
unsigned char is_yc;
unsigned char is_real;
int time_num;
LongSeq seq_timeinfo;
TDiscreteInfoPI();
TDiscreteInfoPI(const TDiscreteInfoPI&);
TDiscreteInfoPI&operator=(const TDiscreteInfoPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TDiscreteInfoPI> SEQDiscreteInfoPI;
struct DY_QUERY_SAMPLE_API TDiscreteSampleInParmPI
{
int query_id;
SEQDiscreteInfoPI seq_discrete_info;
TDiscreteSampleInParmPI();
TDiscreteSampleInParmPI(const TDiscreteSampleInParmPI&);
TDiscreteSampleInParmPI&operator=(const TDiscreteSampleInParmPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TSampleValueInfoPI> SEQSampleValueInfoPI;
struct DY_QUERY_SAMPLE_API TDiscreteResultPI
{
int app_no;
TKeyID keyid;
unsigned char is_yc;
unsigned char is_real;
short success_flag;
MLang::STRING err_string;
int time_num;
SEQSampleValueInfoPI seq_val;
TDiscreteResultPI();
TDiscreteResultPI(const TDiscreteResultPI&);
TDiscreteResultPI&operator=(const TDiscreteResultPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TDiscreteResultPI> SEQDiscreteResultPI;
struct DY_QUERY_SAMPLE_API TDiscreteSampleOutParmPI
{
int query_id;
SEQDiscreteResultPI seq_discrete_result;
TDiscreteSampleOutParmPI();
TDiscreteSampleOutParmPI(const TDiscreteSampleOutParmPI&);
TDiscreteSampleOutParmPI&operator=(const TDiscreteSampleOutParmPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TQueryCaseInParaPI
{
MLang::Long query_time;
int app_no;
unsigned char is_yx;
SEQKeyIDPI seq_keyid;
TQueryCaseInParaPI();
TQueryCaseInParaPI(const TQueryCaseInParaPI&);
TQueryCaseInParaPI&operator=(const TQueryCaseInParaPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct DY_QUERY_SAMPLE_API TCaseValueStatus
{
USampleValuePI value;
int status;
short is_null;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TCaseValueStatus> SEQValueStatus;
struct DY_QUERY_SAMPLE_API TQueryCaseOutParaPI
{
MLang::Long query_time;
unsigned char is_yx;
short success_flag;
MLang::STRING err_string;
SEQValueStatus seq_value_status;
TQueryCaseOutParaPI();
TQueryCaseOutParaPI(const TQueryCaseOutParaPI&);
TQueryCaseOutParaPI&operator=(const TQueryCaseOutParaPI&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,202 @@
//******************************************************************
//
// AUTHOR : ZhangKeHeng
//
// FUNCTION : QUERY_SAMPLE_SERVER 进程的客户端类公用类定义
//
// TIME : 2003.09.25
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2003.09.25 Creation ZhangKeHeng
// 2003.11.15 Modify ZhangKeHeng new interface
// 2004.03.31 Modify ZhangKeHeng Add TiggerSample
//******************************************************************
#ifndef __QUERY_SAMPLE_SERVICE_INTERFACE_H__
#define __QUERY_SAMPLE_SERVICE_INTERFACE_H__
#ifdef _WINDOWS64
#ifdef QUERY_SAMPLE_CLIENT_EXPORTS
#define QUERY_SAMPLE_CLIENT __declspec(dllexport)
#else
#define QUERY_SAMPLE_CLIENT __declspec(dllimport)
#endif
#else
#define QUERY_SAMPLE_CLIENT
#endif
#ifndef _WINDOWS64
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include <iostream>
#include "query_sample_m.h"
#include "servicemanage.h"
#include "pub_ctx.h"
#include "system.h"
#include "port_def.h"
#include "paramanage.h"
#include "dcidefine.h"
#include "sysadm/scn_service.h"
using namespace std;
using namespace NS_SYSADMIN;
class QUERY_SAMPLE_CLIENT query_sample_service_interface
{
public:
query_sample_service_interface();
query_sample_service_interface (const int port_no,
const int request_timeout_seconds = 120);
~query_sample_service_interface();
int GetCurveData (CurvePara &param, time_t timeout, CurveData ** datap,
int &items, ErrorInfo &error);
public:
//同步调用的接口函数声明在下面增加根据IDL映射后的头文件中定义设置
short GetQuerySampleResult (const TQuerySampleInParm& in_para,
TQuerySampleOutParm & out_para);
short GetStatisticsSampleResult (const TStatisticsSampleInParm& in_para,
TStatisticsSampleOutParm & out_para);
short GetDiscreteSampleResult (const TDiscreteSampleInParm& in_para,
TDiscreteSampleOutParm & out_para);
short GetTriggerSampleResult (const TTriggerSampleInParm& in_para,
TTriggerSampleOutParm & out_para);
short GetTriggerSampleInfoByKEYID (const TTriggerKeyInfoInParm& in_para,
TTriggerKeyInfoOutParm & out_para);
short GetTriggerStatisticsResult (const TTriggerStatisticsInParm& in_para,
TTriggerStatisticsOutParm & out_para);
short GetNumberStatisticsResult (const TNumberStatisticsInParm& in_para,
TNumberStatisticsOutParm & out_para);
short GetTimeStatisticsResult (const TTimeStatisticsInParm& in_para,
TTimeStatisticsOutParm & out_para);
short GetSampleInfoByKEYID (const TSampleKeyInfoInParm& in_para,
TSampleKeyInfoOutParm & out_para);
short GetQuerySampleResultFromStat (const TQuerySampleFromStatInParm& in_para,
TQuerySampleFromStatOutParm & out_para);
short GetAllQuerySampleResult (const TAllQuerySampleInParm& in_para,
TAllQuerySampleOutParm & out_para);
/*保留以下接口为现场升级方便
//异步corba初始化
short asyn_comm();
//1异步接口(GetQuerySampleResult)
short PutAsynQuerySampleResult(const TQuerySampleInParm& in_para);
short GetAsynQuerySampleResult(TQuerySampleOutParm & out_para);
*/
//2异步接口(GetStatisticsSampleResult)
short PutAsynStatisticsSampleResult (const TStatisticsSampleInParm& in_para);
short GetAsynStatisticsSampleResult (TStatisticsSampleOutParm & out_para);
//3异步接口(GetDiscreteSampleResult)
short PutAsynDiscreteSampleResult (const TDiscreteSampleInParm& in_para);
short GetAsynDiscreteSampleResult (TDiscreteSampleOutParm & out_para);
/*
//4异步接口(GetTriggerSampleResult)
short PutAsynTriggerSampleResult(const TTriggerSampleInParm& in_para);
short GetAsynTriggerSampleResult(TTriggerSampleOutParm & out_para);
*/
//D5000新增异步接口
//1异步接口(GetQuerySampleResult)
short PutAsynQuerySampleResult (const TQuerySampleInParm& in_para,
Handle &async_Handle);
short GetAsynQuerySampleResult (Handle &async_Handle,
TQuerySampleOutParm & out_para);
//2异步接口(GetStatisticsSampleResult)
short PutAsynStatisticsSampleResult (const TStatisticsSampleInParm& in_para,
Handle &async_Handle);
short GetAsynStatisticsSampleResult (Handle &async_Handle,
TStatisticsSampleOutParm& out_para);
//3异步接口(GetDiscreteSampleResult)
short PutAsynDiscreteSampleResult (const TDiscreteSampleInParm& in_para,
Handle &async_Handle);
short GetAsynDiscreteSampleResult (Handle &async_Handle,
TDiscreteSampleOutParm & out_para);
//4异步接口(GetTriggerSampleResult)
short PutAsynTriggerSampleResult (const TTriggerSampleInParm& in_para,
Handle &async_Handle);
short GetAsynTriggerSampleResult (Handle &async_Handle,
TTriggerSampleOutParm & out_para);
//6异步接口(GetTriggerStatisticsResult)
short PutAsynTriggerStatisticsResult (const TTriggerStatisticsInParm& in_para,
Handle &async_Handle);
short GetAsynTriggerStatisticsResult (Handle &async_Handle,
TTriggerStatisticsOutParm & out_para);
//7异步接口(GetNumberStatisticsResult)
short PutAsynNumberStatisticsResult (const TNumberStatisticsInParm& in_para,
Handle &async_Handle);
short GetAsynNumberStatisticsResult (Handle &async_Handle,
TNumberStatisticsOutParm & out_para);
//8异步接口(GetTimeStatisticsResult)
short PutAsynTimeStatisticsResult (const TTimeStatisticsInParm& in_para,
Handle &async_Handle);
short GetAsynTimeStatisticsResult (Handle &async_Handle,
TTimeStatisticsOutParm & out_para);
//10异步接口(GetQuerySampleResultFromStat)
short PutAsynQuerySampleResultFromStat (const TQuerySampleFromStatInParm&
in_para, Handle &async_Handle);
short GetAsynQuerySampleResultFromStat (Handle &async_Handle,
TQuerySampleFromStatOutParm & out_para);
//11异步接口(GetAllQuerySampleResult)
short PutAsynAllQuerySampleResult (const TAllQuerySampleInParm& in_para,
Handle &async_Handle);
short GetAsynAllQuerySampleResult (Handle &async_Handle,
TAllQuerySampleOutParm & out_para);
//add for remote access
int SetDomainInfo (const DomainInfo & domain_info); //设置远程信息(通用)
int SetDomainInfo (const char *domain_name, const tSecLabel &sec_label,
const int app_no = AP_DATA_SRV, const int ctx_no = AC_REALTIME_NO);
int SetDomainName (const char *domain_name); //设置域名
int SetSecLabel (tSecLabel &sec_label); //设置标签
void ClearDomainName(); //清除域名m_DomainName设为local_domain
void SetRequestTimeoutSeconds (const int timeout); //设置请求超时
#ifdef _DATASRV_DIVERSION
//DATA_SRV分模式下指定访问的应用
//app_name = data_srv_dms 访问配网data_srv
//其余取值访问主网data_srv
void SetServiceApp(const char* app_name);
void ClearServiceApp();
#endif
private:
DomainInfo m_DomainInfo;
ServiceInfo m_Serviceinfo;
char m_IpAddress[64];
//int m_Port;
int m_RequestTimeoutSeconds;
Handle m_Handle;
char m_HostName[64];
CScnService *m_ServicesManage;
bool m_is_pure_d5000; //当前系统是否老的D5000
int GetHostByAppNo (char* host_name, const int app_no, const short context_no);
int SetServiceHost();
int getD5000Type();
#ifdef _DATASRV_DIVERSION
char m_app_name[64];
#endif
};
#endif

View File

@@ -0,0 +1,135 @@
//******************************************************************
//
// AUTHOR : ZhangKeHeng
//
// FUNCTION : QUERY_SAMPLE_SERVER 进程的客户端类公用类定义
//
// TIME : 2003.09.25
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2003.09.25 Creation ZhangKeHeng
// 2003.11.15 Modify ZhangKeHeng new interface
// 2004.03.31 Modify ZhangKeHeng Add TiggerSample
//******************************************************************
#ifndef __QUERY_SAMPLE_SERVICE_PI_INTERFACE_H__
#define __QUERY_SAMPLE_SERVICE_PI_INTERFACE_H__
#ifdef _WINDOWS64
#ifdef DY_QUERY_SAMPLE_DLL_EXPORTS
#define DY_QUERY_SAMPLE_API __declspec(dllexport)
#else
#define DY_QUERY_SAMPLE_API __declspec(dllimport)
#endif
#else
#define DY_QUERY_SAMPLE_API
#endif
const short STA_POLICY_NORMAL_PI = 1; //实时统计(统计结果来源于基础数据)
const short STA_POLICY_DAY_PI = 2; //日统计(统计结果来源于日统计数据)
const short STA_POLICY_HOUR_PI = 3; //小时统计(统计结果来源于小时统计数据)
//统计模式
const short STA_MODE_MAX_PI = 0; //统计最大值及其发生时间
const short STA_MODE_MIN_PI = 1; //统计最小值及其发生时间
const short STA_MODE_AVERAGE_PI = 2; //统计平均值
const short STA_MODE_LOADRATE_PI = 3; //统计负荷率
const short STA_WITH_LIMIT_PI = 0; //包含越限值统计,
const short STA_WITHOUT_LIMIT_PI = 1; //不包含越限值统计
const short STA_WITHOUT_ABS_PI = 0; //按实际值统计
const short STA_WITH_ABS_PI = 1; //按绝对值统计
//查询结果模式
const short RESULT_MODE_NO_DIFF = 0; //不区分查询结果是否是拟合值
const short RESULT_MODE_DIFF = 1; //区分查询结果是否是拟合值
//离散点查询支持指定查询策略
//456与123对应,若查询时间点较近时间范围内没有值:
//123可能查询不到,456会强制向前或向后继续查询取值
const unsigned char DY_QUERY_INTERPOLATION = 0;//插值查询
const unsigned char DY_QUERY_SNAP_FORWARD = 1;//阶梯向前查询
const unsigned char DY_QUERY_SNAP_BACKWARD = 2;//阶梯向后查询
const unsigned char DY_QUERY_SNAP_NEAR = 3;//阶梯最近值
const unsigned char DY_QUERY_SNAP_FORWARD_FORCE = 4;//阶梯向前查询
const unsigned char DY_QUERY_SNAP_BACKWARD_FORCE = 5;//阶梯向后查询
const unsigned char DY_QUERY_SNAP_NEAR_FORCE = 6;//阶梯最近值
//const unsigned char QUERY_HS_SAMPLE = 0;
//const unsigned char QUERY_RS_SAMPLE = 1;
#ifndef _WINDOWS64
#include <arpa/inet.h>
#include <netdb.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include "query_sample_pi_m.h"
#include "sysadm/scn_service.h"
#include "mcode/mclient.h"
//#include "serviceglobal.h"
#include "pub_ctx.h"
#include "port_def.h"
#include "system.h"
#include "servicemanage.h"
#include "db_com/CDyCfgLocal.h"
using namespace NS_SYSADMIN;
//#include <OB/common_service_interface.h>
class DY_QUERY_SAMPLE_API query_sample_service_pi_interface
{
// public:
// CQuerySamplePI_var m_Specify_GenerInvoke;
// CQuerySamplePI_var m_GenerInvoke;
public:
query_sample_service_pi_interface(const int port_no,const int request_timeout_seconds = 300);
query_sample_service_pi_interface();
~query_sample_service_pi_interface();
//PI interface
short GetSampleResultFromPI(const TQuerySampleInParmPI& in_para,TQuerySampleOutParmPI& out_para);
short GetPMUResultFromPI(const TQueryPMUInParmPI& in_para,TQueryPMUOutParmPI& out_para);
short GetSampleInfoByKEYIDFromPI(const TSampleKeyInfoInParmPI& in_para, TSampleKeyInfoOutParmPI& out_para);
short GetStatisticsSampleResultFromPI(const TStatisticsSampleInParmPI& in_para, TStatisticsSampleOutParmPI& out_para);
short GetQuerySampleResultFromStatFromPI(const TQuerySampleFromStatInParmPI& in_para, TQuerySampleFromStatOutParmPI& out_para);
short GetDiscreteSampleResultFromPI(const TDiscreteSampleInParmPI& in_para, TDiscreteSampleOutParmPI& out_para);
short GetCaseResultFromPI(const TQueryCaseInParaPI& in_para, TQueryCaseOutParaPI& out_para );
//add for remote access
int SetDomainInfo(const DomainInfo& domain_info); //设置远程信息(通用)
int SetDomainInfo(const char* domain_name, const tSecLabel& sec_label, const int app_no = AP_DATA_SRV, const int ctx_no = AC_REALTIME_NO);
int SetDomainName(const char* domain_name); //设置域名
int SetSecLabel(tSecLabel& sec_label); //设置标签
void ClearDomainName(); //清除域名m_DomainName设为local_domain
private:
DomainInfo m_DomainInfo;
ServiceInfo m_Serviceinfo;
CDyCfgLocal m_dy_cfg_read;
int m_RequestTimeoutSeconds;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
CScnService* m_ServicesManage;
//是否需要自动获取端口号,dy_stat_service_interface()下生效
bool m_is_port_auto_set;
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
int SetServiceHost(const int dy_app_no);
};
#endif

View File

@@ -0,0 +1,124 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __QUERY_STAT_M_H__
#define __QUERY_STAT_M_H__
#ifdef _WINDOWS64
#ifdef QUERY_STAT_CLIENT_EXPORTS
#define QUERY_STAT_CLIENT_API __declspec(dllexport)
#else
#define QUERY_STAT_CLIENT_API __declspec(dllimport)
#endif
#else
#define QUERY_STAT_CLIENT_API
#endif
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
#include"public_m.h"
struct QUERY_STAT_CLIENT_API TOneStaInfo
{
int sta_type;
int sta_status;
MLang::Long start_time;
MLang::Long end_time;
int time_pace;
unsigned char interval_type;
unsigned char sta_policy;
unsigned char result_type;
short key_num;
MLang::VECTOR<TKeyID> seq_keyinfo;
SEQDataValue reserve_info;
TOneStaInfo();
TOneStaInfo(const TOneStaInfo&);
TOneStaInfo&operator=(const TOneStaInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TOneStaInfo> SEQOneStaInfo;
struct QUERY_STAT_CLIENT_API TAppStaInfo
{
int app_id;
SEQOneStaInfo seq_sta_info;
TAppStaInfo();
TAppStaInfo(const TAppStaInfo&);
TAppStaInfo&operator=(const TAppStaInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TAppStaInfo> SEQAppStaInfo;
struct QUERY_STAT_CLIENT_API TAppStaInParm
{
int query_id;
SEQAppStaInfo seq_app_sta_info;
TAppStaInParm();
TAppStaInParm(const TAppStaInParm&);
TAppStaInParm&operator=(const TAppStaInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct QUERY_STAT_CLIENT_API TOneStaResultInfo
{
TKeyID keyid;
short success_flag;
MLang::STRING err_string;
short is_null;
UDataValue stat_result;
TOneStaResultInfo();
TOneStaResultInfo(const TOneStaResultInfo&);
TOneStaResultInfo&operator=(const TOneStaResultInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TOneStaResultInfo> SEQOneStaResultInfo;
struct QUERY_STAT_CLIENT_API TOneStaResult
{
int sta_type;
int sta_status;
MLang::Long start_time;
MLang::Long end_time;
int time_pace;
unsigned char interval_type;
unsigned char sta_policy;
unsigned char result_type;
short key_num;
short valid_flag;
MLang::STRING invalid_string;
SEQOneStaResultInfo seq_sta_result_info;
SEQDataValue reserve_info;
TOneStaResult();
TOneStaResult(const TOneStaResult&);
TOneStaResult&operator=(const TOneStaResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TOneStaResult> SEQOneStaResult;
struct QUERY_STAT_CLIENT_API TAppStaResult
{
int app_id;
SEQOneStaResult seq_sta_result;
TAppStaResult();
TAppStaResult(const TAppStaResult&);
TAppStaResult&operator=(const TAppStaResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TAppStaResult> SEQAppStaResult;
struct QUERY_STAT_CLIENT_API TAppStaOutParm
{
int query_id;
SEQAppStaResult seq_app_sta_result;
TAppStaOutParm();
TAppStaOutParm(const TAppStaOutParm&);
TAppStaOutParm&operator=(const TAppStaOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,70 @@
//******************************************************************
//
// AUTHOR : ShiHaoQiu
//
// FUNCTION : QUERY_STAT_SERVER 进程的客户端类公用类定义
//
// TIME : 2011.05.18
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2011.05.18 Creation ShiHaoQiu
//******************************************************************
#ifndef __QUERY_STAT_SERVICE_INTERFACE_H__
#define __QUERY_STAT_SERVICE_INTERFACE_H__
#ifdef _WINDOWS64
#ifdef QUERY_STAT_CLIENT_EXPORTS
#define QUERY_STAT_CLIENT_API __declspec(dllexport)
#else
#define QUERY_STAT_CLIENT_API __declspec(dllimport)
#endif
#else
#define QUERY_STAT_CLIENT_API
#endif
#ifndef _WINDOWS64
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include "query_stat_m.h"
#include "serviceglobal.h"
#include "sam_service.h"
#include "pub_ctx.h"
#include "system.h"
class QUERY_STAT_CLIENT_API query_stat_service_interface
{
public:
query_stat_service_interface(const int port_no,const int request_timeout_seconds = 300);
query_stat_service_interface();
~query_stat_service_interface();
short GetQueryStat(const TAppStaInParm& in_para,TAppStaOutParm& out_para);//1
private:
ServiceInfo m_Serviceinfo;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
CServicesManage* m_ServicesManage;
int m_RequestTimeoutSeconds;
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
int SetServiceHost();
};
#endif

View File

@@ -0,0 +1,139 @@
/*
* rdb_commit_server_client.h
*
* Created on: 2017-12-6
* Author: shq
*/
#ifndef RDB_COMMIT_SERVER_CLIENT_H_
#define RDB_COMMIT_SERVER_CLIENT_H_
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include "pthread.h"
#include "system.h"
#include "servicemanage.h"
#include "pub_ctx.h"
#include "sql_sp_m.h"
#include "CServiceLocatorClient.h"
using namespace std;
using namespace servicelocator;
//#ifndef BindTime
//struct BindTime
//{
// unsigned char TimeHH; /* hours; range is 0 <= hours <=23 */
// unsigned char TimeMI; /* minutes; range is 0 <= minutes <= 59 */
// unsigned char TimeSS; /* seconds; range is 0 <= seconds <= 59 */
//};
//
//typedef struct BindTime BindTime;
//#endif
//#ifndef BindDate
//struct BindDate
//{
// unsigned short DateYYYY; /* gregorian year; range is -4712 <= year <= 9999 */
// unsigned char DateMM; /* month; range is 1 <= month < 12 */
// unsigned char DateDD; /* day; range is 1 <= day <= 31 */
// BindTime DateTime; /* time */
//};
//
//typedef struct BindDate BindDate;
//#endif
struct TStage
{
int app_no;
string module_name;
int context_no;
string domain_name;
int stage;
string stage_message;
string description;
int map_no;
int run_status;
};
//错误信息结构
struct TRdbCommitErrorMsg
{
int err_no; //DBAccess错误号
string db_err; //数据库错误信息
};
class RdbCommitClient
{
public:
RdbCommitClient(char *db_service);
RdbCommitClient(char *db_service, int seconds);
~RdbCommitClient();
void SetRequestTimeout(int seconds);
int SetDomainName(vector<string> domain_name);
public:
//提供兼容sql_sp的接口(均最终一致性)
//21
short ExecuteSql(const char* sql_str, SEQDBErrorStru& out_db_error);
//22
short ExecuteBind(const char * sql_str, SEQBindParaStru &seq_bind_para, char * data_buffer, char * null_flag_buffer, unsigned int row_num, SEQDBErrorStru& out_db_error);
//23
short ExecuteMultiSql(int sql_num, const StrSeq& seq_sql_str, SEQExecMultiResultStru& seq_exec_multi_result);
//设置和读取状态的接口
//101
int GetStage(const int app_no, const char* module_name, int context_no, char* domain = NULL);
//102
int SetStage(const int app_no, const char* module_name, const int stage, int context_no = 0, char* domain = NULL);
//103
int GetAllStage(vector<TStage> &ts);
//104
int GetStage(TStage &ts);
//102
int SetStage(TStage ts);
public:
//一致性提交接口
//1 强一致性提交接口
int SQLCommitWithSC(char *cmd_string, vector<TRdbCommitErrorMsg> &err_vec);
public:
int SQLCommit(char *cmd_string, int commit_type, vector<TRdbCommitErrorMsg> &err_vec);
int RollbackAllTransaction();
int RollbackTransactionByDomainname(char* domain); //2
int ResetWorkState();
int ResetWorkStateByDomainname(char* domain); //3
int CommitAllTransaction();
int CommitTransactionByDomainname(char* domain); //4
int SQLCommitWithSCByDomainname(char *cmd_string,char* domain, vector<TRdbCommitErrorMsg> &err_vec); //11
//add for remote access
int SetDomainName(const char* domain_name); //设置域名
void ClearDomainName(); //清除域名m_DomainName设为local_domain
private:
int SetServiceHost();
ServiceInfo m_Serviceinfo;
DomainInfo m_DomainInfo;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
vector<string> v_domain_name;
char m_HostName[64];
CServiceLocatorClient m_serviceInfoTable;
pthread_mutex_t m_mutex;
int m_RequestTimeoutSeconds;
};
#endif

View File

@@ -0,0 +1,42 @@
//**************************************
// Generated by mcpp translator
// Version 1.3
//**************************************
#ifndef __RDB_COMMIT_M_H__
#define __RDB_COMMIT_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
struct TStageStru
{
int app_no;
MLang::STRING module_name;
int context_no;
MLang::STRING domain_name;
int stage;
MLang::STRING stage_message;
MLang::STRING description;
int map_no;
int run_status;
TStageStru();
TStageStru(const TStageStru&);
TStageStru&operator=(const TStageStru&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TStageStru> SEQStageStru;
struct TSEQStageStru
{
SEQStageStru seq_stage;
TSEQStageStru();
TSEQStageStru(const TSEQStageStru&);
TSEQStageStru&operator=(const TSEQStageStru&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,111 @@
/*
* Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com>
* Copyright (c) 2010-2011, Pieter Noordhuis <pcnoordhuis at gmail dot com>
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __HIREDIS_READ_H
#define __HIREDIS_READ_H
#include <stdio.h> /* for size_t */
#define REDIS_ERR -1
#define REDIS_OK 0
/* When an error occurs, the err flag in a context is set to hold the type of
* error that occurred. REDIS_ERR_IO means there was an I/O error and you
* should use the "errno" variable to find out what is wrong.
* For other values, the "errstr" field will hold a description. */
#define REDIS_ERR_IO 1 /* Error in read or write */
#define REDIS_ERR_EOF 3 /* End of file */
#define REDIS_ERR_PROTOCOL 4 /* Protocol error */
#define REDIS_ERR_OOM 5 /* Out of memory */
#define REDIS_ERR_OTHER 2 /* Everything else... */
#define REDIS_REPLY_STRING 1
#define REDIS_REPLY_ARRAY 2
#define REDIS_REPLY_INTEGER 3
#define REDIS_REPLY_NIL 4
#define REDIS_REPLY_STATUS 5
#define REDIS_REPLY_ERROR 6
#define REDIS_READER_MAX_BUF (1024*16) /* Default max unused reader buffer. */
#ifdef __cplusplus
extern "C" {
#endif
typedef struct redisReadTask {
int type;
int elements; /* number of elements in multibulk container */
int idx; /* index in parent (array) object */
void *obj; /* holds user-generated value for a read task */
struct redisReadTask *parent; /* parent task */
void *privdata; /* user-settable arbitrary field */
} redisReadTask;
typedef struct redisReplyObjectFunctions {
void *(*createString)(const redisReadTask*, char*, size_t);
void *(*createArray)(const redisReadTask*, int);
void *(*createInteger)(const redisReadTask*, long long);
void *(*createNil)(const redisReadTask*);
void (*freeObject)(void*);
} redisReplyObjectFunctions;
typedef struct redisReader {
int err; /* Error flags, 0 when there is no error */
char errstr[128]; /* String representation of error when applicable */
char *buf; /* Read buffer */
size_t pos; /* Buffer cursor */
size_t len; /* Buffer length */
size_t maxbuf; /* Max length of unused buffer */
redisReadTask rstack[9];
int ridx; /* Index of current read task */
void *reply; /* Temporary reply pointer */
redisReplyObjectFunctions *fn;
void *privdata;
} redisReader;
/* Public API for the protocol parser. */
redisReader *redisReaderCreateWithFunctions(redisReplyObjectFunctions *fn);
void redisReaderFree(redisReader *r);
int redisReaderFeed(redisReader *r, const char *buf, size_t len);
int redisReaderGetReply(redisReader *r, void **reply);
#define redisReaderSetPrivdata(_r, _p) (int)(((redisReader*)(_r))->privdata = (_p))
#define redisReaderGetObject(_r) (((redisReader*)(_r))->reply)
#define redisReaderGetError(_r) (((redisReader*)(_r))->errstr)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,52 @@
/*
* rtdbkey_defs.h
*
* Created on: 2018-6-23
* Author: lihao
*/
#ifndef RTDBKEY_DEFS_H_
#define RTDBKEY_DEFS_H_
#include "common_types.h"
//关系型数据库中varchar长度
const cmnInt32 RTDBKEY_LEN_IN_DB = 20;
const cmnInt32 MEASRTDBKEY_LEN_IN_DB = 30;
const cmnInt32 APPRTDBKEY_LEN_IN_DB = 40;
//RTDBKEY类型对应的原始商用库字符串长度
const cmnInt32 RTDBKEY_LEN_10 = 10;
const cmnInt32 RTDBKEY_LEN_14 = 14;
const cmnInt32 RTDBKEY_LEN_18 = 18;
const cmnInt32 RTDBKEY_LEN_20 = 20;
const cmnInt32 COLUMN_ID_LEN = 4;
const cmnInt32 COLUMN_ID_OFFSET = 10000;
//量测ID在商用库中字符串长度
//商用库中组成方式:
//RTDBKEY + "_" + COLUMN_ID_LEN
const cmnInt32 MEASRTDBKEY_LEN_15 = 15;
const cmnInt32 MEASRTDBKEY_LEN_19 = 19;
const cmnInt32 MEASRTDBKEY_LEN_23 = 23;
const cmnInt32 MEASRTDBKEY_LEN_25 = 25;
const cmnInt32 APP_ID_LEN = 10;
//应用量测转发ID在商用库中字符串长度
//商用库中组成方式:
//RTDBKEY + "_" + COLUMN_ID_LEN + "_" + APP_ID_LEN
const cmnInt32 APPRTDBKEY_LEN_26 = 26;
const cmnInt32 APPRTDBKEY_LEN_30 = 30;
const cmnInt32 APPRTDBKEY_LEN_34 = 34;
const cmnInt32 APPRTDBKEY_LEN_36 = 36;
const cmnInt32 SG_MODEL_TABLE_NO_MAX = 9999;
const cmnInt32 RTDB_MODEL_TABLE_NO_MIN = 100000;
const cmnInt32 RTDB_MODEL_TABLE_NO_MAX = 999999;
const cmnInt32 SG_MODEL_TABLE_NO_LENGTH = 4; //调用云通用结构化设计模型表ID使用4位表号
const cmnInt32 RTDB_MODEL_TABLE_NO_LENGTH = 6; //扩展表表号从100000开始,6位表号
const cmnInt32 REGION_NO_LENGTH = 6; //区域号长度
#endif /* RTDBKEY_DEFS_H_ */

View File

@@ -0,0 +1,68 @@
//******************************************************************
//
// AUTHOR : ZhaoTiger
//
// FUNCTION : SAMPLE_DATA_SERVER 进程的客户端类公用类定义
//
// TIME : 2003.12.16
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2003.12.16 Creation ZhaoTiger
//
//******************************************************************
#ifndef __SAMPLE_DATA_CLIENT_BASE_H__
#define __SAMPLE_DATA_CLIENT_BASE_H__
#include "sample_data_m.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include "servicesclient.h"
#include <iostream>
#include "system.h"
class sample_data_client_base
{
public:
sample_data_client_base(int port);
sample_data_client_base(int port, int seconds);
sample_data_client_base();
~sample_data_client_base();
void SetRequestTimeout(int seconds);
//调用的接口函数声明在下面增加根据IDL映射后的头文件中定义设置
short SampleFutureData(const TFutSmpDataInPara& futsmp_in_para,
TFutSmpDataOutPara & futsmp_out_para);//1
short BatchSampleFutureData(const TBatchFutSmpDataInPara& batchfutsmp_in_para);//2
//add for remote access
int SetDomainInfo(const DomainInfo& domain_info); //设置远程信息(通用)
int SetDomainInfo(const char* domain_name, const tSecLabel& sec_label, const int app_no = AP_DATA_SRV, const int ctx_no = AC_REALTIME_NO);
int SetDomainName(const char* domain_name); //设置域名
int SetSecLabel(tSecLabel& sec_label); //设置标签
void ClearDomainName(); //清除域名m_DomainName设为local_domain
private:
DomainInfo m_DomainInfo;
ServiceInfo m_Serviceinfo;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
int m_RequestTimeoutSeconds;
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
int SetServiceHost();
};
#endif

View File

@@ -0,0 +1,99 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __SAMPLE_DATA_M_H__
#define __SAMPLE_DATA_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
#include"public_m.h"
struct TFutSmpDataValue
{
MLang::Long sample_time;
float sample_value;
int sample_status;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TFutSmpDataValue> SEQFutSmpDataValue;
struct TFutSmpDataInfo
{
TKeyID key_id;
SEQFutSmpDataValue seq_sample_value;
TFutSmpDataInfo();
TFutSmpDataInfo(const TFutSmpDataInfo&);
TFutSmpDataInfo&operator=(const TFutSmpDataInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TFutSmpDataInfo> SEQFutSmpDataInfo;
struct TFutSmpDataReturn
{
TKeyID key_id;
short is_success;
MLang::STRING fail_reason;
TFutSmpDataReturn();
TFutSmpDataReturn(const TFutSmpDataReturn&);
TFutSmpDataReturn&operator=(const TFutSmpDataReturn&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TFutSmpDataReturn> SEQFutSmpDataReturn;
struct TFutSmpDataInPara
{
int app_no;
SEQFutSmpDataInfo seq_sample_data;
TFutSmpDataInPara();
TFutSmpDataInPara(const TFutSmpDataInPara&);
TFutSmpDataInPara&operator=(const TFutSmpDataInPara&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TFutSmpDataOutPara
{
int app_no;
MLang::STRING fail_reason;
SEQFutSmpDataReturn seq_sample_return;
TFutSmpDataOutPara();
TFutSmpDataOutPara(const TFutSmpDataOutPara&);
TFutSmpDataOutPara&operator=(const TFutSmpDataOutPara&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TBatchFutSmpDataValue
{
TKeyID key_id;
float sample_value;
int sample_status;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TBatchFutSmpDataValue> SEQBatchFutSmpDataValue;
struct TBatchFutSmpDataInfo
{
MLang::Long sample_time;
SEQBatchFutSmpDataValue seq_sample_value;
TBatchFutSmpDataInfo();
TBatchFutSmpDataInfo(const TBatchFutSmpDataInfo&);
TBatchFutSmpDataInfo&operator=(const TBatchFutSmpDataInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TBatchFutSmpDataInfo> SEQBatchFutSmpDataInfo;
struct TBatchFutSmpDataInPara
{
int app_no;
SEQBatchFutSmpDataInfo seq_sample_data;
TBatchFutSmpDataInPara();
TBatchFutSmpDataInPara(const TBatchFutSmpDataInPara&);
TBatchFutSmpDataInPara&operator=(const TBatchFutSmpDataInPara&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,57 @@
//**************************************
// Generated by mcpp translator
// Version 1.3
//**************************************
#ifndef __SAMPLE_DEFINE_M_H__
#define __SAMPLE_DEFINE_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
#include"public_m.h"
//typedef TRtdbKey TNewKeyID;
typedef MLang::STRING TNewKeyID;
typedef MLang::VECTOR<TNewKeyID> KeyIDSEQ;
struct TKeyIDSEQ
{
KeyIDSEQ key_id;
TKeyIDSEQ();
TKeyIDSEQ(const TKeyIDSEQ&);
TKeyIDSEQ&operator=(const TKeyIDSEQ&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TAddYCSamDefReqStru
{
TNewKeyID key_id;
short sample_interval;
TAddYCSamDefReqStru();
TAddYCSamDefReqStru(const TAddYCSamDefReqStru&);
TAddYCSamDefReqStru&operator=(const TAddYCSamDefReqStru&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TAddYCSamDefReqStru> SEQAddYCSamDefReq;
struct TSEQAddYCSamDefReq
{
SEQAddYCSamDefReq key_id;
TSEQAddYCSamDefReq();
TSEQAddYCSamDefReq(const TSEQAddYCSamDefReq&);
TSEQAddYCSamDefReq&operator=(const TSEQAddYCSamDefReq&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TStrSeq
{
StrSeq str_seq;
TStrSeq();
TStrSeq(const TStrSeq&);
TStrSeq&operator=(const TStrSeq&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,93 @@
//******************************************************************
//
// AUTHOR : ZhaoTiger
//
// FUNCTION : SAMPLE_DEFINE_SERVER 进程的客户端类公用类定义
//
// TIME : 2003.08.27
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2003.08.27 Creation ZhaoTiger
//
//******************************************************************
#ifndef __SAMPLE_DEFINE_SERVICE_INTERFACE_H__
#define __SAMPLE_DEFINE_SERVICE_INTERFACE_H__
#ifdef _WINDOWS64
#ifdef SAMPLE_DEFINE_EXPORTS
#define SAMPLE_DEFINE_API __declspec(dllexport)
#else
#define SAMPLE_DEFINE_API __declspec(dllimport)
#endif
#else
#define SAMPLE_DEFINE_API
#endif
#ifndef _WINDOWS64
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include "sample_define_m.h"
// 2018
// #include "sam_service.h"
#include "servicemanage.h"
#include "sysadm/scn_service.h"
#include "pub_ctx.h"
#include "system.h"
using namespace std;
//该宏需要根据IDL 文件中不同的interface 名称进行修改
class SAMPLE_DEFINE_API sample_define_service_interface
{
public:
sample_define_service_interface(int specify_port, const int request_timeout_seconds = 100);
~sample_define_service_interface();
//调用的接口函数声明在下面增加根据IDL映射后的头文件中定义设置
short AddYXSampleDefine(string sample_name, const KeyIDSEQ& seq_key_id); //1
short DeleteYXSampleDefine(string sample_name, const KeyIDSEQ& seq_key_id); //2
// short AddYCRecallDefine(string sample_name, const KeyIDSEQ& seq_key_id); //3
// short DeleteYCRecallDefine(string sample_name, const KeyIDSEQ& seq_key_id); //4
short AddYCSampleDefine(string sample_name, const SEQAddYCSamDefReq& seq_add_yc_req); //5
short DeleteYCSampleDefine(string sample_name, const KeyIDSEQ& seq_key_id); //6
short PauseYCSampleDefine(string sample_name, const KeyIDSEQ& seq_key_id); //7
short RecoverYCSampleDefine(string sample_name, const KeyIDSEQ& seq_key_id); //8
// 2018
short AddSampleDefineByID(string sample_name, const StrSeq& seq_record_id); //9
//add for remote access
int SetDomainInfo(const DomainInfo& domain_info); //设置远程信息(通用)
int SetDomainInfo(const char* domain_name, const tSecLabel& sec_label, const int app_no = AP_DATA_SRV, const int ctx_no = AC_REALTIME_NO);
int SetDomainName(const char* domain_name); //设置域名
int SetSecLabel(tSecLabel& sec_label); //设置标签
void ClearDomainName(); //清除域名m_DomainName设为local_domain
private:
DomainInfo m_DomainInfo;
ServiceInfo m_Serviceinfo;
int m_RequestTimeoutSeconds;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
int SetServiceHost();
};
#endif

View File

@@ -0,0 +1,343 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __SAMPLE_MODIFY_M_H__
#define __SAMPLE_MODIFY_M_H__
#ifdef _WINDOWS64
#ifdef SAMPLE_MODIFY_CLIENT_EXPORTS
#define SAMPLE_MODIFY_CLIENT_API __declspec(dllexport)
#else
#define SAMPLE_MODIFY_CLIENT_API __declspec(dllimport)
#endif
#else
#define SAMPLE_MODIFY_CLIENT_API
#endif
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
#include"public_m.h"
const short MODIFY_SUCCESS = 0;
const short MODIFY_FAIL = -1;
const short MODIFY_WARNING = -1;
const short MODIFY_YC_SAMPLE = 1;
const short MODIFY_YX_SAMPLE = 0;
const short SYNC_RS_HS = 1;
const short NOT_SYNC_RS_HS = 0;
const short MODIFY_RS_SAMPLE = 1;
const short MODIFY_HS_SAMPLE = 0;
const short SET_MODIFY = 1;
const short NOT_MODIFY = 0;
const short TRI_DATATYPE_INT = 0;
const short TRI_DATATYPE_FLOAT = 1;
const short TRI_DATATYPE_STRING = 2;
struct SAMPLE_MODIFY_CLIENT_API TValueInfo
{
MLang::Long time;
float value;
int stat;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TValueInfo> SEQTValueInfo;
struct SAMPLE_MODIFY_CLIENT_API TModifyInfo
{
int app_no;
TKeyID keyid;
unsigned char is_yc;
unsigned char is_real;
unsigned char is_sync;
unsigned char is_modify_value;
unsigned char is_modify_stat;
short time_num;
SEQTValueInfo seq_valueinfo;
TModifyInfo();
TModifyInfo(const TModifyInfo&);
TModifyInfo&operator=(const TModifyInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TModifyInfo> SEQModifyInfo;
struct SAMPLE_MODIFY_CLIENT_API TSampleModifyInParm
{
SEQModifyInfo seq_modify_info;
TSampleModifyInParm();
TSampleModifyInParm(const TSampleModifyInParm&);
TSampleModifyInParm&operator=(const TSampleModifyInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct SAMPLE_MODIFY_CLIENT_API TSampleModifyExInParm
{
MLang::STRING node_name;
MLang::STRING user_name;
MLang::STRING proc_name;
SEQModifyInfo seq_modify_info;
TSampleModifyExInParm();
TSampleModifyExInParm(const TSampleModifyExInParm&);
TSampleModifyExInParm&operator=(const TSampleModifyExInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct SAMPLE_MODIFY_CLIENT_API TModifyErrInfo
{
MLang::Long time;
MLang::STRING err_string;
TModifyErrInfo();
TModifyErrInfo(const TModifyErrInfo&);
TModifyErrInfo&operator=(const TModifyErrInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TModifyErrInfo> SEQModifyErrInfo;
struct SAMPLE_MODIFY_CLIENT_API TModifyResultInfo
{
short success_flag;
short fail_num;
SEQModifyErrInfo seq_errinfo;
short warning_flag;
short warning_num;
SEQModifyErrInfo seq_warninginfo;
TModifyResultInfo();
TModifyResultInfo(const TModifyResultInfo&);
TModifyResultInfo&operator=(const TModifyResultInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct SAMPLE_MODIFY_CLIENT_API TModifyResult
{
int app_no;
TKeyID keyid;
unsigned char is_yc;
unsigned char is_sync;
unsigned char is_real;
unsigned char is_modify_value;
unsigned char is_modify_stat;
short time_num;
short valid_flag;
MLang::STRING invalid_string;
TModifyResultInfo modify_result_info;
TModifyResult();
TModifyResult(const TModifyResult&);
TModifyResult&operator=(const TModifyResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TModifyResult> SEQModifyResult;
struct SAMPLE_MODIFY_CLIENT_API TSampleModifyOutParm
{
SEQModifyResult seq_modify_result;
TSampleModifyOutParm();
TSampleModifyOutParm(const TSampleModifyOutParm&);
TSampleModifyOutParm&operator=(const TSampleModifyOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct SAMPLE_MODIFY_CLIENT_API TSampleModifyExOutParm
{
MLang::STRING node_name;
MLang::STRING user_name;
MLang::STRING proc_name;
SEQModifyResult seq_modify_result;
TSampleModifyExOutParm();
TSampleModifyExOutParm(const TSampleModifyExOutParm&);
TSampleModifyExOutParm&operator=(const TSampleModifyExOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct SAMPLE_MODIFY_CLIENT_API TBatchValueInfo
{
float value;
int stat;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TBatchValueInfo> SEQBatchValueInfo;
struct SAMPLE_MODIFY_CLIENT_API TBatchModifyInfo
{
int app_no;
unsigned char is_yc;
unsigned char is_real;
unsigned char is_sync;
unsigned char is_modify_value;
unsigned char is_modify_stat;
MLang::Long occur_time;
MLang::VECTOR<TKeyID> seq_keyid;
int keyid_num;
SEQBatchValueInfo seq_batch_value_info;
TBatchModifyInfo();
TBatchModifyInfo(const TBatchModifyInfo&);
TBatchModifyInfo&operator=(const TBatchModifyInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TBatchModifyInfo> SEQBatchModifyInfo;
struct SAMPLE_MODIFY_CLIENT_API TBatchSampleModifyInParm
{
int modify_id;
SEQBatchModifyInfo seq_batch_modify_info;
TBatchSampleModifyInParm();
TBatchSampleModifyInParm(const TBatchSampleModifyInParm&);
TBatchSampleModifyInParm&operator=(const TBatchSampleModifyInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct SAMPLE_MODIFY_CLIENT_API TBatchModifyResultInfo
{
short success_flag;
MLang::STRING err_string;
TBatchModifyResultInfo();
TBatchModifyResultInfo(const TBatchModifyResultInfo&);
TBatchModifyResultInfo&operator=(const TBatchModifyResultInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TBatchModifyResultInfo> SEQBatchModifyResultInfo;
struct SAMPLE_MODIFY_CLIENT_API TBatchModifyResult
{
int app_no;
unsigned char is_yc;
unsigned char is_real;
unsigned char is_sync;
unsigned char is_modify_value;
unsigned char is_modify_stat;
MLang::Long occur_time;
MLang::VECTOR<TKeyID> seq_keyid;
int keyid_num;
short valid_flag;
MLang::STRING invalid_string;
SEQBatchModifyResultInfo seq_batch_modify_result_info;
TBatchModifyResult();
TBatchModifyResult(const TBatchModifyResult&);
TBatchModifyResult&operator=(const TBatchModifyResult&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TBatchModifyResult> SEQBatchModifyResult;
struct SAMPLE_MODIFY_CLIENT_API TBatchSampleModifyOutParm
{
int modify_id;
SEQBatchModifyResult seq_batch_modify_result;
TBatchSampleModifyOutParm();
TBatchSampleModifyOutParm(const TBatchSampleModifyOutParm&);
TBatchSampleModifyOutParm&operator=(const TBatchSampleModifyOutParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct SAMPLE_MODIFY_CLIENT_API TReStatInfo
{
TKeyID keyid;
LongSeq seq_time;
TReStatInfo();
TReStatInfo(const TReStatInfo&);
TReStatInfo&operator=(const TReStatInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TReStatInfo> SEQReStatInfo;
struct SAMPLE_MODIFY_CLIENT_API TReStatInfoInParm
{
int app_no;
SEQReStatInfo seq_re_stat_info;
TReStatInfoInParm();
TReStatInfoInParm(const TReStatInfoInParm&);
TReStatInfoInParm&operator=(const TReStatInfoInParm&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct SAMPLE_MODIFY_CLIENT_API UTriDataValue
{
private:
union
{
int c_int;
float c_float;
char* c_string;
}__u_val;
bool __u_init;
unsigned short __u_index;
public:
UTriDataValue();
~UTriDataValue();
UTriDataValue(const UTriDataValue&);
UTriDataValue&operator=(const UTriDataValue&);
short _d()const;
void __clear();
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
void c_int(const int);
const int c_int()const;
void c_float(const float);
const float c_float()const;
void c_string(const char*);
void c_string(const MLang::STRING&);
const char*c_string()const;
};
struct SAMPLE_MODIFY_CLIENT_API TTriKeyValueInfo
{
TKeyID keyid;
short keyid_datatype;
UTriDataValue keyid_value;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTriKeyValueInfo> SEQTriKeyValueInfo;
struct SAMPLE_MODIFY_CLIENT_API TTriSampleModifyInfo
{
MLang::Long occur_time;
SEQTriKeyValueInfo seq_tri_key_value_info;
TTriSampleModifyInfo();
TTriSampleModifyInfo(const TTriSampleModifyInfo&);
TTriSampleModifyInfo&operator=(const TTriSampleModifyInfo&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TTriSampleModifyInfo> SEQTriSampleModifyInfo;
struct SAMPLE_MODIFY_CLIENT_API TTriSampleModifyInfoInPara
{
int sample_type;
int app_no;
unsigned char offer_id;
MLang::Long id;
MLang::Long user_id;
MLang::Long host_id;
MLang::STRING program_name;
int modify_policy;
int reserve_1;
int reserve_2;
int reserve_3;
SEQTriSampleModifyInfo seq_tri_sample_modify_info;
TTriSampleModifyInfoInPara();
TTriSampleModifyInfoInPara(const TTriSampleModifyInfoInPara&);
TTriSampleModifyInfoInPara&operator=(const TTriSampleModifyInfoInPara&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct SAMPLE_MODIFY_CLIENT_API TTriSampleModifyInfoOutPara
{
int sample_type;
int app_no;
unsigned char offer_id;
MLang::Long id;
MLang::Long user_id;
MLang::Long host_id;
MLang::STRING program_name;
int modify_policy;
int reserve_1;
int reserve_2;
int reserve_3;
short success_flag;
MLang::STRING fail_string;
TTriSampleModifyInfoOutPara();
TTriSampleModifyInfoOutPara(const TTriSampleModifyInfoOutPara&);
TTriSampleModifyInfoOutPara&operator=(const TTriSampleModifyInfoOutPara&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
#endif

View File

@@ -0,0 +1,99 @@
//******************************************************************
//
// AUTHOR : ZhangKeHeng
//
// FUNCTION : SAMPLE_MODIFY_SERVER 进程的客户端类公用类定义
//
// TIME : 2003.09.26
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2003.09.26 Creation ZhangKeHeng
// 2005.12.13 Modify ZhangKeHeng Add TriggerModify
// 2006.02.22 Mdifyy ZhangKeHeng Add Warn
//******************************************************************
#ifndef __SAMPLE_MODIFY_SERVICE_INTERFACE_H__
#define __SAMPLE_MODIFY_SERVICE_INTERFACE_H__
#ifdef _WINDOWS64
#ifdef SAMPLE_MODIFY_CLIENT_EXPORTS
#define SAMPLE_MODIFY_CLIENT_API __declspec(dllexport)
#else
#define SAMPLE_MODIFY_CLIENT_API __declspec(dllimport)
#endif
#else
#define SAMPLE_MODIFY_CLIENT_API
#endif
#ifndef _WINDOWS64
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include "sample_modify_m.h"
#include "servicesclient.h"
#include <iostream>
#include "system.h"
class SAMPLE_MODIFY_CLIENT_API sample_modify_service_interface
{
public:
sample_modify_service_interface();
sample_modify_service_interface(int port,const int request_timeout_seconds = 300);
~sample_modify_service_interface();
void SetRequestTimeout(int seconds);
//调用的接口函数声明在下面增加根据IDL映射后的头文件中定义设置
short SampleModify(const TSampleModifyInParm& in_para, TSampleModifyOutParm & out_para);//1
short BatchSampleModify(const TBatchSampleModifyInParm& in_para, TBatchSampleModifyOutParm & out_para);//2
//ONEWAY 调用
short ReStatisticsOneWay(const TReStatInfoInParm& in_para);//3
short TriSampleModify(const TTriSampleModifyInfoInPara& in_para, TTriSampleModifyInfoOutPara & out_para);//4
short SampleModifyEx(const TSampleModifyExInParm& in_para, TSampleModifyExOutParm & out_para);//5
//20141023 增加对历史缓存的支持
short SampleModifyCache(const TSampleModifyInParm& in_para, TSampleModifyOutParm & out_para);//11
short SampleModifyHis(const TSampleModifyInParm& in_para, TSampleModifyOutParm & out_para);//12
short SampleModifyExCache(const TSampleModifyExInParm& in_para, TSampleModifyExOutParm & out_para);//13
short SampleModifyExHis(const TSampleModifyExInParm& in_para, TSampleModifyExOutParm & out_para);//14
short BatchSampleModifyCache(const TBatchSampleModifyInParm& in_para, TBatchSampleModifyOutParm & out_para);//15
short BatchSampleModifyHis(const TBatchSampleModifyInParm& in_para, TBatchSampleModifyOutParm & out_para);//16
//20141023 end
//add for remote access
int SetDomainInfo(const DomainInfo& domain_info); //设置远程信息(通用)
int SetDomainInfo(const char* domain_name, const tSecLabel& sec_label, const int app_no = AP_DATA_SRV, const int ctx_no = AC_REALTIME_NO);
int SetDomainName(const char* domain_name); //设置域名
int SetSecLabel(tSecLabel& sec_label); //设置标签
void ClearDomainName(); //清除域名m_DomainName设为local_domain
private:
DomainInfo m_DomainInfo;
ServiceInfo m_Serviceinfo;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
int m_RequestTimeoutSeconds;
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
int SetServiceHost();
};
#endif

View File

@@ -0,0 +1,273 @@
/* SDSLib 2.0 -- A C dynamic strings library
*
* Copyright (c) 2006-2015, Salvatore Sanfilippo <antirez at gmail dot com>
* Copyright (c) 2015, Oran Agra
* Copyright (c) 2015, Redis Labs, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __SDS_H
#define __SDS_H
#define SDS_MAX_PREALLOC (1024*1024)
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
typedef char *sds;
/* Note: sdshdr5 is never used, we just access the flags byte directly.
* However is here to document the layout of type 5 SDS strings. */
struct __attribute__ ((__packed__)) sdshdr5 {
unsigned char flags; /* 3 lsb of type, and 5 msb of string length */
char buf[];
};
struct __attribute__ ((__packed__)) sdshdr8 {
uint8_t len; /* used */
uint8_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
char buf[];
};
struct __attribute__ ((__packed__)) sdshdr16 {
uint16_t len; /* used */
uint16_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
char buf[];
};
struct __attribute__ ((__packed__)) sdshdr32 {
uint32_t len; /* used */
uint32_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
char buf[];
};
struct __attribute__ ((__packed__)) sdshdr64 {
uint64_t len; /* used */
uint64_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
char buf[];
};
#define SDS_TYPE_5 0
#define SDS_TYPE_8 1
#define SDS_TYPE_16 2
#define SDS_TYPE_32 3
#define SDS_TYPE_64 4
#define SDS_TYPE_MASK 7
#define SDS_TYPE_BITS 3
#define SDS_HDR_VAR(T,s) struct sdshdr##T *sh = (struct sdshdr##T *)((s)-(sizeof(struct sdshdr##T)));
#define SDS_HDR(T,s) ((struct sdshdr##T *)((s)-(sizeof(struct sdshdr##T))))
#define SDS_TYPE_5_LEN(f) ((f)>>SDS_TYPE_BITS)
static inline size_t sdslen(const sds s) {
unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) {
case SDS_TYPE_5:
return SDS_TYPE_5_LEN(flags);
case SDS_TYPE_8:
return SDS_HDR(8,s)->len;
case SDS_TYPE_16:
return SDS_HDR(16,s)->len;
case SDS_TYPE_32:
return SDS_HDR(32,s)->len;
case SDS_TYPE_64:
return SDS_HDR(64,s)->len;
}
return 0;
}
static inline size_t sdsavail(const sds s) {
unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) {
case SDS_TYPE_5: {
return 0;
}
case SDS_TYPE_8: {
SDS_HDR_VAR(8,s);
return sh->alloc - sh->len;
}
case SDS_TYPE_16: {
SDS_HDR_VAR(16,s);
return sh->alloc - sh->len;
}
case SDS_TYPE_32: {
SDS_HDR_VAR(32,s);
return sh->alloc - sh->len;
}
case SDS_TYPE_64: {
SDS_HDR_VAR(64,s);
return sh->alloc - sh->len;
}
}
return 0;
}
static inline void sdssetlen(sds s, size_t newlen) {
unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) {
case SDS_TYPE_5:
{
unsigned char *fp = ((unsigned char*)s)-1;
*fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS);
}
break;
case SDS_TYPE_8:
SDS_HDR(8,s)->len = newlen;
break;
case SDS_TYPE_16:
SDS_HDR(16,s)->len = newlen;
break;
case SDS_TYPE_32:
SDS_HDR(32,s)->len = newlen;
break;
case SDS_TYPE_64:
SDS_HDR(64,s)->len = newlen;
break;
}
}
static inline void sdsinclen(sds s, size_t inc) {
unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) {
case SDS_TYPE_5:
{
unsigned char *fp = ((unsigned char*)s)-1;
unsigned char newlen = SDS_TYPE_5_LEN(flags)+inc;
*fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS);
}
break;
case SDS_TYPE_8:
SDS_HDR(8,s)->len += inc;
break;
case SDS_TYPE_16:
SDS_HDR(16,s)->len += inc;
break;
case SDS_TYPE_32:
SDS_HDR(32,s)->len += inc;
break;
case SDS_TYPE_64:
SDS_HDR(64,s)->len += inc;
break;
}
}
/* sdsalloc() = sdsavail() + sdslen() */
static inline size_t sdsalloc(const sds s) {
unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) {
case SDS_TYPE_5:
return SDS_TYPE_5_LEN(flags);
case SDS_TYPE_8:
return SDS_HDR(8,s)->alloc;
case SDS_TYPE_16:
return SDS_HDR(16,s)->alloc;
case SDS_TYPE_32:
return SDS_HDR(32,s)->alloc;
case SDS_TYPE_64:
return SDS_HDR(64,s)->alloc;
}
return 0;
}
static inline void sdssetalloc(sds s, size_t newlen) {
unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) {
case SDS_TYPE_5:
/* Nothing to do, this type has no total allocation info. */
break;
case SDS_TYPE_8:
SDS_HDR(8,s)->alloc = newlen;
break;
case SDS_TYPE_16:
SDS_HDR(16,s)->alloc = newlen;
break;
case SDS_TYPE_32:
SDS_HDR(32,s)->alloc = newlen;
break;
case SDS_TYPE_64:
SDS_HDR(64,s)->alloc = newlen;
break;
}
}
sds sdsnewlen(const void *init, size_t initlen);
sds sdsnew(const char *init);
sds sdsempty(void);
sds sdsdup(const sds s);
void sdsfree(sds s);
sds sdsgrowzero(sds s, size_t len);
sds sdscatlen(sds s, const void *t, size_t len);
sds sdscat(sds s, const char *t);
sds sdscatsds(sds s, const sds t);
sds sdscpylen(sds s, const char *t, size_t len);
sds sdscpy(sds s, const char *t);
sds sdscatvprintf(sds s, const char *fmt, va_list ap);
#ifdef __GNUC__
sds sdscatprintf(sds s, const char *fmt, ...)
__attribute__((format(printf, 2, 3)));
#else
sds sdscatprintf(sds s, const char *fmt, ...);
#endif
sds sdscatfmt(sds s, char const *fmt, ...);
sds sdstrim(sds s, const char *cset);
void sdsrange(sds s, int start, int end);
void sdsupdatelen(sds s);
void sdsclear(sds s);
int sdscmp(const sds s1, const sds s2);
sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, int *count);
void sdsfreesplitres(sds *tokens, int count);
void sdstolower(sds s);
void sdstoupper(sds s);
sds sdsfromlonglong(long long value);
sds sdscatrepr(sds s, const char *p, size_t len);
sds *sdssplitargs(const char *line, int *argc);
sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen);
sds sdsjoin(char **argv, int argc, char *sep);
sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen);
/* Low level functions exposed to the user API */
sds sdsMakeRoomFor(sds s, size_t addlen);
void sdsIncrLen(sds s, int incr);
sds sdsRemoveFreeSpace(sds s);
size_t sdsAllocSize(sds s);
void *sdsAllocPtr(sds s);
/* Export the allocator used by SDS to the program using SDS.
* Sometimes the program SDS is linked to, may use a different set of
* allocators, but may want to allocate or free things that SDS will
* respectively free or allocate. */
void *sds_malloc(size_t size);
void *sds_realloc(void *ptr, size_t size);
void sds_free(void *ptr);
#ifdef REDIS_TEST
int sdsTest(int argc, char *argv[]);
#endif
#endif

View File

@@ -0,0 +1,83 @@
//******************************************************************
//
// AUTHOR : ZhaoTiger
//
// FUNCTION : 数据库模块需要用到的所有常量定义
//
// TIME : 2003.06.02
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2003.06.02 Creation ZhaoTiger
//
//******************************************************************
#ifndef _SERVER_DEFINE_H
#define _SERVER_DEFINE_H
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
#define MAX_TABLE_NAME_ENG_LEN 32
#define MAX_TABLE_NAME_CHN_LEN 64
#define MAX_COLUMN_NAME_ENG_LEN 32
#define MAX_COLUMN_NAME_CHN_LEN 64
#define MAX_MENU_NAME_LEN 40
#define MAX_STRING_DATA_LEN 4096
#define MAX_FAIL_REASON_LEN 200
#define MODIFY_OP_INSERT 0
#define MODIFY_OP_DELETE 1
#define MODIFY_OP_UPDATE 2
#define MODIFY_OP_DELALL 3
#define KEY_GENERATE_NONE 0
#define KEY_GENERATE_TABLE 1
#define KEY_GENERATE_NORMAL 2
// 域信息表中data_type, 引用sys_menu_info中的菜单定义值
// 定义统一数据库数据类型
#define UNI_DATATYPE_CHAR 1
#define UNI_DATATYPE_STRING 2
#define UNI_DATATYPE_UCHAR 3
#define UNI_DATATYPE_SHORT 4
#define UNI_DATATYPE_INT 5
#define UNI_DATATYPE_FLOAT 6
#define UNI_DATATYPE_DOUBLE 7
#define UNI_DATATYPE_DATETIME 8
#define UNI_DATATYPE_KEYID 9
#define UNI_DATATYPE_BINARY 10
#define UNI_DATATYPE_TEXT 11
#define UNI_DATATYPE_IMAGE 12
#define UNI_DATATYPE_APPKEYID 13
#define UNI_DATATYPE_APPID 14
#define UNI_DATATYPE_LONG 15
#define UNI_DATATYPE_RTDBKEY 16
#define UNI_DATATYPE_MEASRTDBKEY 17
#define UNI_DATATYPE_APPRTDBKEY 18
// 定义出错代码
#define DB_SERVER_SUCCESS 0
#define DB_SERVER_ERR_NO_TABLE -1
#define DB_SERVER_ERR_QUERY_FAIL -2
#define DB_SERVER_ERR_MEMORY_FAIL -3
#define DB_SERVER_ERR_WRONG_APP -4
#define DB_SERVER_ERR_NO_COLUMN -5
#define DB_SERVER_ERR_WRONG_DATATYPE -6
#define DB_SERVER_ERR_WRONG_REC_APP -7
#define DB_SERVER_ERR_WRONG_KEY_INFO -8
#define DB_SERVER_ERR_NO_MATCH -9
#define DB_SERVER_ERR_NO_TABLE_STR "该表不存在"
#define DB_SERVER_ERR_QUERY_FAIL_STR "检索过程出错"
#define DB_SERVER_ERR_MEMORY_FAIL_STR "内存分配出错"
#define DB_SERVER_ERR_WRONG_APP_STR "应用号出错"
#define DB_SERVER_ERR_NO_COLUMN_STR "SQL中SELECT子句没有域"
#define DB_SERVER_ERR_WRONG_DATATYPE_STR "不支持的数据类型"
#define DB_SERVER_ERR_WRONG_REC_APP_STR "缺少record_app域"
#define DB_SERVER_ERR_WRONG_KEY_INFO_STR "部分下装时关键字信息出错"
#define DB_SERVER_ERR_NO_MATCH_STR "触发规则不匹配"
#endif

View File

@@ -0,0 +1,98 @@
/*********************************************/
/*********Name :hisclient.h*******************/
/*********************************************/
#ifndef _HISCLIENT_H
#define _HISCLIENT_H
#ifdef _WINDOWS64
#ifdef HIS_CLIENT_EXPORTS
#define HIS_CLIENT_API __declspec(dllexport)
#else
#define HIS_CLIENT_API __declspec(dllimport)
#endif
#else
#define HIS_CLIENT_API
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#ifdef _WINDOWS64
#include <winsock2.h>
#include <windows.h>
#include <time.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <dcidefine.h>
#include <unistd.h>
#endif
#include "servicemanage.h"
#define ONE_PACKAGE_SIZE 100000
#ifdef _WIN64
extern unsigned char g_endian;
extern unsigned char net_endian;
#else
extern unsigned char g_endian;
extern unsigned char net_endian;
#endif
typedef struct HisInfo
{
int code_id; //接口内部使用用户调用时不需要指定。提供服务的类型为selectupdateinsertdelete等各种数据操作类型。
int appsid; //应用的id号
char resververd[32]; //保留空间,当结构发生改变时,可以从中抽出一部分它用,达到保持结构体大小不变,以保证免以前的程序可以兼容
// int sid; //Sid号
// int sourcetype; //局域网内部服务还是外部服务
// int timemode ; //是否需要时间配对。
} HisInfo_struct; //输入
#define MAX_COL_DATA_LEN 300
class HIS_CLIENT_API SheetDataClientInterface
{
public:
void GetSheetDataClient (CurvePara &param, vector<ColAttr_t> &attr,
vector<ColDataItem> &data, vector<string> &colname, const char* where_str,
const char* order_by, ErrorInfo &error);
SheetDataClientInterface();
virtual ~SheetDataClientInterface();
bool SetDomainInfo (DomainInfo *domainInfo);
bool CleanDomainInfo (void);
//danath 南瑞要求异步图表提交接口 20120223
int SetSheetDataAsync (char *model_name, vector<SheetRecData> &rec,
ErrorInfo &error);
//20141023 end
int GetCurveData (CurvePara &param, time_t timeout, CurveData ** datap,
int &items, ErrorInfo &error);
int SetCurveData (CurvePara &param, CurveData *curvedatap, ub2 items,
ErrorInfo &error);
int GetCurveData (CurvePara &param, time_t timeout,CurveData ** datap,
int &items,ErrorInfo &error,bool is_cache, bool is_retry);
int SetCurveDataAsync (CurvePara &param, char * user_name,
char * host_name, char * proc_name, CurveData *curvedatap, ub2 items, ErrorInfo &error,bool is_cache, bool is_retry);
private:
int RestSocket (int no = 1);
Handle requesthandle;
Handle requesthandle_async;
ServiceInfo servicep;
DomainInfo *domain_info;
};
#endif

View File

@@ -0,0 +1,86 @@
/*********************************************/
/*********Name :hisclient.h*******************/
/*********************************************/
#ifndef _HISCLIENT_H
#define _HISCLIENT_H
#ifdef _WINDOWS64
#ifdef HIS_CLIENT_EXPORTS
#define HIS_CLIENT_API __declspec(dllexport)
#else
#define HIS_CLIENT_API __declspec(dllimport)
#endif
#else
#define HIS_CLIENT_API
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#ifdef _WINDOWS64
#include <winsock2.h>
#include <windows.h>
#include <time.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <dcidefine.h>
#include <unistd.h>
#endif
#include "servicemanage.h"
#define ONE_PACKAGE_SIZE 100000
#ifdef _WIN64
extern unsigned char g_endian;
extern unsigned char net_endian;
#else
extern unsigned char g_endian;
extern unsigned char net_endian;
#endif
typedef struct HisInfo
{
int code_id; //接口内部使用用户调用时不需要指定。提供服务的类型为selectupdateinsertdelete等各种数据操作类型。
int appsid; //应用的id号
char resververd[32]; //保留空间,当结构发生改变时,可以从中抽出一部分它用,达到保持结构体大小不变,以保证免以前的程序可以兼容
// int sid; //Sid号
// int sourcetype; //局域网内部服务还是外部服务
// int timemode ; //是否需要时间配对。
} HisInfo_struct; //输入
#define MAX_COL_DATA_LEN 300
class HIS_CLIENT_API SheetDataClientInterface
{
public:
void GetSheetDataClient (CurvePara &param, vector<ColAttr_t> &attr,
vector<ColDataItem> &data, vector<string> &colname, const char* where_str,
const char* order_by, ErrorInfo &error);
SheetDataClientInterface();
virtual ~SheetDataClientInterface();
bool SetDomainInfo (DomainInfo *domainInfo);
bool CleanDomainInfo (void);
//danath 南瑞要求异步图表提交接口 20120223
int SetSheetDataAsync (char *model_name, vector<SheetRecData> &rec,
ErrorInfo &error);
//20141023 end
private:
int RestSocket (int no = 1);
Handle requesthandle;
Handle requesthandle_async;
ServiceInfo servicep;
DomainInfo *domain_info;
};
#endif

View File

@@ -0,0 +1,148 @@
//******************************************************************
//
// AUTHOR : JiXuechun
//
// FUNCTION : SQL_SP_SERVER 进程的客户端类公用类定义
//
// TIME : 2009.06.02
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2009.06.02 Creation JiXuechun
// 2011.01.13 Add ChenPeng 增加变量绑定接口
// 2011.09.23 Add CuiWeiYe 重载构造函数
//******************************************************************
#ifndef __SQL_SP_CLIENT_BASE_H__
#define __SQL_SP_CLIENT_BASE_H__
#ifdef _WINDOWS64
#ifdef SQL_SP_CLIENT_EXPORTS
#define SQL_SP_CLIENT_API __declspec(dllexport)
#else
#define SQL_SP_CLIENT_API __declspec(dllimport)
#endif
#else
#define SQL_SP_CLIENT_API
#endif
#ifndef _WINDOWS64
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include <iostream>
#include "servicemanage.h"
#include "system.h"
#include "sql_sp_m.h"
#include "sysadm/scn_service.h"
#include "pub_ctx.h"
#include "logclient.h"
#include "rdb_define.pb.h"
#include "sql_sp_define.h"
using namespace std;
#define BIND_CHR 1 /* 字符型 unsigned char */
#define BIND_INT 3 /* 短整型short 整形int 长整型long */
#define BIND_FLT 4 /* 浮点数float double */
#define BIND_STR 5 /* 字符串string */
#define BIND_ODT 156 /* 日期型date*/
struct BindTime
{
unsigned char TimeHH; /* hours; range is 0 <= hours <=23 */
unsigned char TimeMI; /* minutes; range is 0 <= minutes <= 59 */
unsigned char TimeSS; /* seconds; range is 0 <= seconds <= 59 */
};
typedef struct BindTime BindTime;
struct BindDate
{
unsigned short DateYYYY; /* gregorian year; range is -4712 <= year <= 9999 */
unsigned char DateMM; /* month; range is 1 <= month < 12 */
unsigned char DateDD; /* day; range is 1 <= day <= 31 */
BindTime DateTime; /* time */
};
typedef struct BindDate BindDate;
//namespace SQL_SP_SERVER
//{
class SQL_SP_CLIENT_API sql_sp_client_base
{
public:
sql_sp_client_base();
sql_sp_client_base(int port);
sql_sp_client_base(int port, int seconds);
~sql_sp_client_base();
void SetRequestTimeout(int seconds);
short SelectSql(const char* sql_str, unsigned int max_result_num, const SEQOutDataTypeStru& out_data_type, TSelectResultStru& out_select_result, SEQDBErrorStru& out_db_error);
//远程调阅多线程安全版
//short SelectSql(const char* sql_str, unsigned int max_result_num, const SEQOutDataTypeStru& out_data_type, TSelectResultStru& out_select_result, SEQDBErrorStru& out_db_error,DomainInfo_name &domain_info);
// protobuf
short SelectSql(const char* sql_str, unsigned int max_result_num, const SQL_SP_DEFINE::VEC_OUT_DATA_TYPE & out_data_type, SQL_SP_DEFINE::SELECT_RESULT & out_select_result, SQL_SP_DEFINE::VEC_DB_ERROR & out_db_error);
short SelectSqlUsingGS(const char* sql_str, unsigned int max_result_num, const SEQOutDataTypeStru& out_data_type, TSelectResultStru& out_select_result, SEQDBErrorStru& out_db_error);
short ExecuteSql(const char* sql_str, SEQDBErrorStru& out_db_error);
// protobuf
short ExecuteSql(const char* sql_str, SQL_SP_DEFINE::VEC_DB_ERROR & out_db_error);
short ExecuteBind(const char * sql_str, SEQBindParaStru &seq_bind_para, char * data_buffer, char * null_flag_buffer, unsigned int row_num, SEQDBErrorStru& out_db_error);
short ExecuteSqlUsingGS(const char* sql_str, SEQDBErrorStru& out_db_error);
short ExecuteMultiSql(int sql_num, const StrSeq& seq_sql_str, SEQExecMultiResultStru& seq_exec_multi_result);
short ExecuteMultiSqlUsingGS(int sql_num, const StrSeq& seq_sql_str, SEQExecMultiResultStru& seq_exec_multi_result);
short ExecuteSpWithReturn(const char* package_name, const char* procedure_name, const StrSeq& para_seq, unsigned int max_result_num, const SEQOutDataTypeStru& out_data_type, TSelectResultStru& out_select_result, SEQDBErrorStru& out_db_error);
short ExecuteSpWithoutReturn(const char* package_name, const char* procedure_name, const StrSeq& para_seq, SEQDBErrorStru& out_db_error);
short ExecuteSqlWithLOB(const char* sql_str, SEQDBErrorStru& out_db_error);
short SelectSqlWithLOB(const char* sql_str, unsigned int max_result_num, SEQOutDataTypeStru& out_data_type, TSelectResultStru& out_select_result, SEQDBErrorStru& out_db_error);
short InsertSqlWithLOB(const char* sql_insert, const char* sql_select, const SEQLOBValueType& seq_lob_value, SEQDBErrorStru& out_db_error);
short UpdateSqlWithLOB(const char* sql_update, const char* sql_select, const SEQLOBValueType& seq_lob_value, SEQDBErrorStru& out_db_error);
short ExecuteSqlEx(const char* sql_str, SEQDBErrorStru& out_db_error, short rep_flag);
short ExecuteMultiSqlEx(int sql_num, const StrSeq& seq_sql_str, SEQExecMultiResultStru seq_exec_multi_result, short rep_flag);
short ExecuteSpWithoutReturnEx(const char* package_name, const char* procedure_name, const StrSeq& para_seq, SEQDBErrorStru& out_db_error, short rep_flag);
short ExecuteSqlWithLOBEx(const char* sql_str, SEQDBErrorStru& out_db_error, short rep_flag);
short InsertSqlWithLOBEx(const char* sql_insert, const char* sql_select, const SEQLOBValueType& seq_lob_value, SEQDBErrorStru& out_db_error, short rep_flag);
short UpdateSqlWithLOBEx(const char* sql_update, const char* sql_select, const SEQLOBValueType& seq_lob_value, SEQDBErrorStru& out_db_error, short rep_flag);
short ExecuteSqlUsingGSEx(const char* sql_str, SEQDBErrorStru& out_db_error, short rep_flag);
short ExecuteMultiSqlUsingGSEx(int sql_num, const StrSeq& seq_sql_str, SEQExecMultiResultStru seq_exec_multi_result, short rep_flag);
//add for remote access
int SetDomainInfo(const DomainInfo& domain_info); //设置远程信息(通用)
int SetDomainInfo(const char* domain_name, const tSecLabel& sec_label, const int app_no = AP_DATA_SRV, const int ctx_no = AC_REALTIME_NO);
int SetDomainName(const char* domain_name); //设置域名
int SetSecLabel(tSecLabel& sec_label); //设置标签
void ClearDomainName(); //清除域名m_DomainName设为local_domain
private:
DomainInfo m_DomainInfo;
ServiceInfo m_Serviceinfo;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
int m_RequestTimeoutSeconds;
int SetServiceHost();
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
};
//}
#endif

View File

@@ -0,0 +1,210 @@
//
// Created by wutao on 2020/1/7.
//
#ifndef SQL_SP_DLL_SQL_SP_DEFINE_H
#define SQL_SP_DLL_SQL_SP_DEFINE_H
#include <string>
#include <vector>
using namespace std;
namespace SQL_SP_DEFINE
{
const short C_DATATYPE_DEFAULT = 0;
const short C_DATATYPE_STRING = 1;
const short C_DATATYPE_UCHAR = 2;
const short C_DATATYPE_SHORT = 3;
const short C_DATATYPE_INT = 4;
const short C_DATATYPE_DATETIME = 5;
const short C_DATATYPE_FLOAT = 6;
const short C_DATATYPE_DOUBLE = 7;
const short C_DATATYPE_KEYID = 8;
const short C_DATATYPE_BINARY = 9;
const short C_DATATYPE_TEXT = 10;
const short C_DATATYPE_IMAGE = 11;
const short C_DATATYPE_APPKEYID = 12;
const short C_DATATYPE_APPID = 13;
const short C_DATATYPE_UINT = 14;
const short C_DATATYPE_LONG = 15;
const short C_DATATYPE_RTDBKEY = 16;
const short C_DATATYPE_MEASRTDBKEY = 17;
const short C_DATATYPE_APPRTDBKEY = 18;
// public_m
typedef vector<string> VEC_STRING;
typedef vector<long> VEC_LONG;
typedef vector<short> VEC_SHORT;
typedef vector<char> VEC_CHAR;
typedef long KEY_ID;
struct APP_KEY_ID
{
int app_id;
KEY_ID key_id;
};
typedef APP_KEY_ID APP_ID;
struct RTDB_KEY
{
long table_id;
long region_record_column_id;
};
struct APP_RTDB_KEY
{
int app_id;
RTDB_KEY rtdbkey_id;
};
struct DATA_VALUE
{
private:
union
{
char* c_string;
unsigned char c_uchar;
short c_short;
int c_int;
long c_time;
float c_float;
double c_double;
KEY_ID c_keyid;
VEC_CHAR* c_binary;
VEC_CHAR* c_text;
VEC_CHAR* c_image;
APP_KEY_ID c_appkeyid;
APP_ID c_appid;
char c_default;
unsigned int c_uint;
long c_long;
RTDB_KEY c_rtdbkey;
RTDB_KEY c_measrtdbkey;
APP_RTDB_KEY c_apprtdbkey;
}__u_val;
bool __u_init;
unsigned short __u_index;
public:
DATA_VALUE();
~DATA_VALUE();
DATA_VALUE(const DATA_VALUE&);
DATA_VALUE&operator=(const DATA_VALUE&);
short _d()const;
void __clear();
void c_string(const char*);
void c_string(const string&);
const char*c_string()const;
void c_uchar(const unsigned char);
const unsigned char c_uchar()const;
void c_short(const short);
const short c_short()const;
void c_int(const int);
const int c_int()const;
void c_time(const long);
const long c_time()const;
void c_float(const float);
const float c_float()const;
void c_double(const double);
const double c_double()const;
void c_keyid(const KEY_ID);
const KEY_ID c_keyid()const;
void c_binary(const VEC_CHAR&);
const VEC_CHAR&c_binary()const;
VEC_CHAR&c_binary();
void c_text(const VEC_CHAR&);
const VEC_CHAR&c_text()const;
VEC_CHAR&c_text();
void c_image(const VEC_CHAR&);
const VEC_CHAR&c_image()const;
VEC_CHAR&c_image();
void c_appkeyid(const APP_KEY_ID&);
const APP_KEY_ID&c_appkeyid()const;
APP_KEY_ID&c_appkeyid();
void c_appid(const APP_ID&);
const APP_ID&c_appid()const;
APP_ID&c_appid();
void c_default(const char);
const char c_default()const;
void c_uint(const unsigned int);
const unsigned int c_uint()const;
void c_long(const long);
const long c_long()const;
void c_rtdbkey(const RTDB_KEY&);
const RTDB_KEY&c_rtdbkey()const;
RTDB_KEY&c_rtdbkey();
void c_measrtdbkey(const RTDB_KEY&);
const RTDB_KEY&c_measrtdbkey()const;
RTDB_KEY&c_measrtdbkey();
void c_apprtdbkey(const APP_RTDB_KEY&);
const APP_RTDB_KEY&c_apprtdbkey()const;
APP_RTDB_KEY&c_apprtdbkey();
};
typedef vector<DATA_VALUE> VEC_DATA_VALUE;
struct DB_ERROR
{
unsigned int error_no;
string error_msg;
};
typedef vector<DB_ERROR> VEC_DB_ERROR;
// sql_sp_m
struct RESULT_DATA_VALUE
{
bool is_null;
DATA_VALUE data_value;
};
typedef vector<RESULT_DATA_VALUE> VEC_RESULT_DATA_VALUE;
struct RESULT_FIELD_INFO
{
short data_type;
short data_len;
char col_name[64];
};
typedef vector<RESULT_FIELD_INFO> VEC_RESULT_FIELD_INFO;
struct OUT_DATA_TYPE
{
short out_field_position;
short out_field_datatype;
};
typedef vector<OUT_DATA_TYPE> VEC_OUT_DATA_TYPE;
struct SELECT_RESULT
{
short field_num;
VEC_RESULT_FIELD_INFO field_info;
unsigned int data_num;
VEC_RESULT_DATA_VALUE data_value_seq;
};
struct EXEC_MULTI_RESULT
{
bool is_success;
DB_ERROR db_error;
};
typedef vector<EXEC_MULTI_RESULT> VEC_EXEC_MULTI_RESULT;
// typedef VEC_CHAR LOB_VALUE_TYPE;
// typedef vec<VEC_CHAR > VEC_LOB_VALUE_TYPE;
struct BIND_PARA
{
unsigned short dci_type;
unsigned int data_size;
};
typedef vector<BIND_PARA> VEC_BIND_PARA;
}
#endif //SQL_SP_DLL_SQL_SP_DEFINE_H

View File

@@ -0,0 +1,84 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __SQL_SP_M_H__
#define __SQL_SP_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
#include"public_m.h"
const int QUERY_ALL_RESULT = -1;
struct TResultDataValue
{
bool is_null;
UDataValue data_value;
void __write (MLang::OutputStream&__os)const;
void __read (MLang::InputStream&__is);
};
typedef MLang::VECTOR<TResultDataValue> SEQResultDataValue;
struct TResultFieldInfo
{
short data_type;
short data_len;
char col_name[64];
void __write (MLang::OutputStream&__os)const;
void __read (MLang::InputStream&__is);
};
typedef MLang::VECTOR<TResultFieldInfo> SEQResultFieldInfo;
struct TOutDataTypeStru
{
short out_field_position;
short out_field_datatype;
void __write (MLang::OutputStream&__os)const;
void __read (MLang::InputStream&__is);
};
typedef MLang::VECTOR<TOutDataTypeStru> SEQOutDataTypeStru;
struct TSelectResultStru
{
short field_num;
SEQResultFieldInfo field_info;
unsigned int data_num;
SEQResultDataValue data_value_seq;
TSelectResultStru();
TSelectResultStru (const TSelectResultStru&);
TSelectResultStru&operator= (const TSelectResultStru&);
void __write (MLang::OutputStream&__os)const;
void __read (MLang::InputStream&__is);
};
struct TExecMultiResultStru
{
bool is_success;
TDBErrorStru db_error;
TExecMultiResultStru();
TExecMultiResultStru (const TExecMultiResultStru&);
TExecMultiResultStru&operator= (const TExecMultiResultStru&);
void __write (MLang::OutputStream&__os)const;
void __read (MLang::InputStream&__is);
};
typedef MLang::VECTOR<TExecMultiResultStru> SEQExecMultiResultStru;
typedef CharSeq LOBValueType;
typedef MLang::VECTOR<CharSeq> SEQLOBValueType;
struct TSEQLOBValueType
{
SEQLOBValueType seq_lob_value;
TSEQLOBValueType();
TSEQLOBValueType (const TSEQLOBValueType&);
TSEQLOBValueType&operator= (const TSEQLOBValueType&);
void __write (MLang::OutputStream&__os)const;
void __read (MLang::InputStream&__is);
};
struct TBindParaStru
{
unsigned short dci_type;
unsigned int data_size;
void __write (MLang::OutputStream&__os)const;
void __read (MLang::InputStream&__is);
};
typedef MLang::VECTOR<TBindParaStru> SEQBindParaStru;
#endif

View File

@@ -0,0 +1,125 @@
//******************************************************************
//
// AUTHOR : JiXuechun
//
// FUNCTION : SQL_SP_SERVER 进程的客户端类公用类定义
//
// TIME : 2009.06.02
//
// HISTORY :
// Datetime Action Author Reason
// -------------------------------------------------------------------
// 2009.06.02 Creation JiXuechun
// 2011.01.13 Add ChenPeng 增加变量绑定接口
// 2011.09.23 Add CuiWeiYe 重载构造函数
//******************************************************************
#ifndef __SQL_SP_SEND_CLIENT_BASE_H__
#define __SQL_SP_SEND_CLIENT_BASE_H__
#include "sql_sp_m.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include "servicesclient.h"
#include <iostream>
#include "system.h"
#define BIND_CHR 1 /* 字符型 unsigned char */
#define BIND_INT 3 /* 短整型short 整形int 长整型long */
#define BIND_FLT 4 /* 浮点数float double */
#define BIND_STR 5 /* 字符串string */
#define BIND_ODT 156 /* 日期型date*/
using namespace std;
//struct BindTime
//{
// unsigned char TimeHH; /* hours; range is 0 <= hours <=23 */
// unsigned char TimeMI; /* minutes; range is 0 <= minutes <= 59 */
// unsigned char TimeSS; /* seconds; range is 0 <= seconds <= 59 */
//};
//typedef struct BindTime BindTime;
//struct BindDate
//{
// unsigned short DateYYYY; /* gregorian year; range is -4712 <= year <= 9999 */
// unsigned char DateMM; /* month; range is 1 <= month < 12 */
// unsigned char DateDD; /* day; range is 1 <= day <= 31 */
// BindTime DateTime; /* time */
//};
//typedef struct BindDate BindDate;
//namespace SQL_SP_SERVER
//{
class sql_sp_send_client_base
{
public:
sql_sp_send_client_base();
sql_sp_send_client_base(int port);
sql_sp_send_client_base(int port, int seconds);
~sql_sp_send_client_base();
void SetRequestTimeout(int seconds);
//add jihy for send
short ExecuteSqlForSend(const char* sql_str,
SEQDBErrorStru& out_db_error,
const char * domain_name);
short ExecuteBindForSend(const char * sql_str,
SEQBindParaStru &seq_bind_para, char * data_buffer,
char * null_flag_buffer, unsigned int row_num,
SEQDBErrorStru& out_db_error,
const char * domain_name);
short ExecuteMultiSqlForSend(int sql_num,
const StrSeq& seq_sql_str,
SEQExecMultiResultStru& seq_exec_multi_result,
const char * domain_name);
//add end
//add new interface
short ExecuteSqlForSend(const char* sql_str,
SEQDBErrorStru& out_db_error,
int app_no,
const char * proc_alias,
const char * domain_name);
short ExecuteMultiSqlForSend(int sql_num,
const StrSeq& seq_sql_str,
SEQExecMultiResultStru& seq_exec_multi_result,
int app_no,
const char * proc_alias,
const char * domain_name);
//add end
//add for remote access
int SetDomainInfo(const DomainInfo& domain_info); //设置远程信息(通用)
int SetDomainInfo(const char* domain_name, const tSecLabel& sec_label, const int app_no = AP_DATA_SRV, const int ctx_no = AC_REALTIME_NO);
int SetDomainName(const char* domain_name); //设置域名
int SetSecLabel(tSecLabel& sec_label); //设置标签
void ClearDomainName(); //清除域名m_DomainName设为local_domain
private:
DomainInfo m_DomainInfo;
ServiceInfo m_Serviceinfo;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
int m_RequestTimeoutSeconds;
int SetServiceHost();
int GetHostByAppNo(char* host_name, const int app_no, const short context_no);
int getOperatorType(string sql_str,string & operator_type);
};
//}
#endif

View File

@@ -0,0 +1,179 @@
//******************************************************************
//
// AUTHOR : ZhaoTiger
//
// FUNCTION : 通用SQL解析器头文件定义语法分析类
//
// TIME : 2003.10.21
//
// HISTORY : 从胡泊的公式解析器改造而来
// Datetime Action Author Reason
// -----------------------------------------------------------------
// 2003.10.21 Creation ZhaoTiger
//
//******************************************************************
#ifndef __SQL_SYNTAX_ANLS_H__
#define __SQL_SYNTAX_ANLS_H__
#ifdef _WINDOWS32
#ifdef SQL_ANALYSER_EXPORTS
#define SQL_ANALYSER_API __declspec(dllexport)
#else
#define SQL_ANALYSER_API __declspec(dllimport)
#endif
#else
#define SQL_ANALYSER_API
#endif
#include "lexical_anls.h"
using namespace std;
namespace SQL_ANALYSER
{
//sql语法分析器
class SQL_ANALYSER_API CSqlSyntaxAnalyser
{
private :
//词法分析器
CLexicalAnalyser m_LxcAnls;
//域的名字和类型信息
vector<TAnalysColumnInfo> m_AnlsColInfo;
//域名称检查是否大小写敏感
bool m_CaseSensitive;
//调用词法分析器一次得到当前一个单词的分析结果
LEXICAL_RET_RES_STRU m_LexicalRetRes;
//出错信息
char m_ErrMsg[MAX_ERRMSG_LEN];
// 语法分析结果
TSqlAnlsResult m_SqlAnlsResult;
void ErrorProcess();
void FatalProcess();
// 处理WHERE子句之前的SQL语句
bool SqlExpression();
// 处理SELECT子句
bool SelectExpression();
// 处理INSERT子句
bool InsertExpression();
// 处理DELETE子句
bool DeleteExpression();
// 处理UPDATE子句
bool UpdateExpression();
// 处理SELECT中的ORDER BY 子句
bool OrderByExpression();
// 处理WHERE子句
bool WhereExpression();
//处理SQL语句中的where表达式中的“or”运算
bool OrExpression(ITEM_STRU *attribute_ptr);
//处理表达式中的"and"运算
bool AndExpression(ITEM_STRU *attribute_ptr);
//处理表达式中的"not"运算
bool NotExpression(ITEM_STRU *attribute_ptr);
//处理SQL语句中的where表达式中的“Like"和"As”运算
bool FuzzyExpression(ITEM_STRU *attribute_ptr) ;
//处理表达式中的>、>=、<、<=、<>、!=、=等比较运算符
bool CompareExpression(ITEM_STRU *attribute_ptr);
//处理表达式中的+、-运算符
bool SimpleExpression(ITEM_STRU *attribute_ptr);
//处理表达式中的*、/、%、&、|、^运算符
bool Term(ITEM_STRU *attribute_ptr);
//处理表达式中的! 、~、-运算符
bool SingleItemExpression(ITEM_STRU *attribute_ptr);
//处理表达式中因子
bool Factor(ITEM_STRU *attribute_ptr);
//得到WHERE之前的常量信息
bool GetConstInfo(const LEXICAL_RET_RES_STRU & lexi_ret_res, TConstInfo & const_info);
//处理TIMESTR
bool GetConstTimeStr(long & time_long);
//处理TIMEINT
bool GetConstTimeInt(long & time_long);
bool GetConstRtdbKey(_RTDB_KEY_STRU &rtdbkey_value);
bool GetConstMeasRtdbKey(_RTDB_KEY_STRU &measrtdbkey_value);
bool GetConstAppRtdbKey(_APP_KEY_STRU &apprtdbkey_value);
//处理带符号的数值
bool GetConstSignedNumber(const int sign_symbol, TConstInfo & const_info);
bool IsNumericalDataType(const short data_type);
bool IsCanAddDataType(const short data_type);
bool IsIntegralDataType(const short data_type);
bool IsCanCompareDataType(const short data_type);
bool IsCanLikeDataType(const short data_type);
bool IsCanCompareTwoType(const short data_type_1, const short data_type_2);
//对数据类型进行赋值兼容性的匹配检查
bool IsCanEvaluateTwoType(const short data_type_1, const short data_type_2);
//进入WHERE子句的逆波兰序列
bool EnterWhereCode(const TWhereAntiPorland & one_code);
//根据标识符名称在域信息中查询是否是合法的域
bool IsIdenALegalColumn(const char * iden_name);
//根据标识符名称在域信息中查询是否是合法的域并且得到该域的数据类型以进行类型检查
bool GetIdenDataType(const char * iden_name, short & data_type);
//转换成大写
void UpperString(char * str);
//转换成小写
void LowerString(char * str);
public:
// 传出错误
void GetError(char * err_msg);
// 预分析过程传出SQL的表名和SQL类型从而让调用方组织该表所有的域信息用于语法分析的类型检查
bool SqlPreAnalysProcess(char * table_name, int & sql_type);
// 开始对SQL进行语法分析
bool SqlAnalysProcess();
// 初始化
bool Initialize(const char *source);
// 传入域的数据类型信息
void PutAnalysColumnInfo(const bool need_transfer, const vector<TAnalysColumnInfo> & anls_col_info, const bool case_sensitive = true);
// 传出结果
void ExportTable(TSqlAnlsResult &sql_anls_result);
// 根据操作符得到操作优先级
int GetOperatorClass(const int operator_code);
};
}
#endif

View File

@@ -0,0 +1,170 @@
#ifndef _SQL_TO_CIME_H
#define _SQL_TO_CIME_H
#include <iostream>
#include <vector>
#include <map>
#include <fstream>
#include <time.h>
#include <string>
//#include <qstring>
//#include <QString>
#include "db_com/CFindFile.h"
#include "db_com/db_error_define.h"
#include "db_com/DBAccess.h"
#include "db_com/sql_syntax_anls.h"
#include "db_com/interpreter_define.h"
#include "db_com/interpreter_struct.h"
#include "db_com/db_extern.h"
#include "db_com/server_define.h"
#include "db_com/sql_sp_client_base.h"
#include "db_com/CSqlResultAlignClient.h"
#include "db_com/CSqlResultAlign.h"
#include "paramanage.h"
#define ANLS_ERR -1
#define NO_TABLE 2
//const int SCAN_DIR_NUM_ONE_TIME = 1;
const int SCAN_FILE_NUM_TIME = 360;
#define uchar unsigned char
using namespace std;
using namespace SQL_ANALYSER;
typedef vector<TAnalysColumnInfo> VECAnalysColumnInfo;
// 插入或者修改时域的信息
struct TModifiedColumn_str
{
short column_id;
char column_name[32];
char column_name_chn[64];
uchar column_type;
short column_length;
uchar is_key;
uchar allow_null;
int app_type;
uchar reference_mode;//是否外键 zhangkeheng add 2005.08.18
int column_special;//域特殊属性
int reserved_1;//是否模型同步
};
typedef vector<TModifiedColumn_str> VModifiedColumn_str;
//select a.table_name_eng,b.column_id, b.column_name_eng, b.column_name_chn, b.data_type,b.data_length, b.is_key, b.allow_null, b.app_type, b.reference_mode, b.column_special, b.reserved_1
// 插入或者修改时域的信息
struct TModifiedColumn_str_ex
{
char table_name_eng[32];
short column_id;
char column_name[32];
char column_name_chn[64];
uchar column_type;
short column_length;
uchar is_key;
uchar allow_null;
int app_type;
uchar reference_mode;//是否外键 zhangkeheng add 2005.08.18
int column_special;//域特殊属性
int reserved_1;//是否模型同步
};
typedef vector<TModifiedColumn_str> VModifiedColumn_str_ex;
// 查询时需要用到的结果指针结构
//struct TQueryResultPtr
struct TQueryResultPtr_str
{
char *result_link_ptr;
char *result_data_ptr;
short *result_indicator_ptr;
TResultHead *result_head_ptr;
TFieldInfo *field_info_ptr;
};
//struct TTableColumnStu
struct TTableColumnStu
{
int table_no;
string table_name;
VModifiedColumn_str all_col_vec;
VECAnalysColumnInfo anls_col_vec;
};
struct OperaStru
{
char sql[512]; //sql语句
char table_name[512]; //表名
int operate; //操作 insert update delete
string value; //值
string attribute; // 属性
long index_id; //id
bool disp_flag; //是否显示
};
struct TTableInf
{
int table_no; //表号
char table_name_eng[32];
int reserved_4; //是否分区
};
class analytic
{
public:
analytic(CDbAccess* db_access);
~analytic();
CDbAccess* m_db_access;
protected:
string area_str ;
string cime_type ;
ofstream m_outFileStream;
ofstream m_outLogStream;
map<int ,string> m_allSql; //sql 索引sql语句
map<int ,OperaStru> m_out; //转换后的结构
map<long,string> m_relation; //记录Id和操作例如delete insert update 操作合并
vector<OperaStru> v_all_Op; //所有的项
map<string,TTableInf> m_all_tableInf;
map<int,TModifiedColumn_str> m_all_coluInf;
map<string,TTableColumnStu> m_all_coluInf_ex;
map<string,int> m_sys_table;
map<int,TTableColumnStu> m_colum;
vector<string> m_all_sql;
string m_file_path;
string m_file_name;
// string m_new_file_path="/data/sqltocime";
public:
int WriteToFile(string &filePath);
void setPath(const string &filePath);
protected:
int GetDbConfig();
string space();
bool close();
string eraseNull( string text);
bool open(string &fullFilePath, string &fullLogPath);
string GetTimeStringBySeconds(long seconds);
int sqlAnaly(const char* sql_str);
bool GetTableColInfoByTableName(const char * table_name, TTableColumnStu & table_column_info);
void DeleteQueryResultPtr(TQueryResultPtr_str & query_result_ptr_stru);
void NewQueryResultPtr(TQueryResultPtr_str & query_result_ptr_stru);
bool init(map<string,TTableColumnStu> &all_coluInf_ex);
int GetFilesql(vector<string>& v_all_sql,string & m_new_file_path);
void PrintExportResult(const char * sql_str, const TSqlAnlsResult & sql_anls_result);
void WhiteSpace(string &str);
int readFile(const char* filePath,const char* key,vector<string>& v_all_sql);
};
#endif

View File

@@ -0,0 +1,375 @@
/*************************************************
Copyright (C), 1988-1999, Nari Tech. Co., Ltd.
File name: sqlite_access_interface.h
Author: LH
Version: 1.0
Date: 2012.6.4
Description: 访问sqlite库封装接口
Function List:
Datetime Action Author Modify
-------------------------------------------------------------------
2012.6.4 Creation LH
*************************************************/
#ifndef SQLITE_ACCESS_H_
#define SQLITE_ACCESS_H_
#include "sqlite3.h"
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;
#define DB_SUCCESS 0
#define DB_FAIL -1
#define DB_NO_DATA 100
#define DB_AUTO_LOGOFF 0
#define DB_MANUAL_LOGOFF 1
#define DB_STATUS_CONNECT 0
#define DB_STATUS_DISCONNECT 1
#define GET_ALL_RESULT -1
#define LOGIN_DEFAULT_MODE 0
#define LOGIN_THREADED_MODE 1
//统一C数据类型
#define DB_DATATYPE_STRING 1
#define DB_DATATYPE_UCHAR 2
#define DB_DATATYPE_SHORT 3
#define DB_DATATYPE_INT 4
#define DB_DATATYPE_DATETIME 5
#define DB_DATATYPE_FLOAT 6
#define DB_DATATYPE_DOUBLE 7
#define DB_DATATYPE_KEYID 8
#define DB_DATATYPE_BINARY 9
#define DB_DATATYPE_TEXT 10
#define DB_DATATYPE_IMAGE 11
#define DB_DATATYPE_APPKEYID 12
#define DB_DATATYPE_APPID 13
#define DB_DATATYPE_LONG 15
#define MAX_COL_NUMBER 1024
#define MAX_LOB_NUMBER 1024
#define MAX_COLNAME_LENGTH 255
#define MAX_PROCNAME_LENGTH 255
#define MAX_SQL_LENGTH 10240
#define QUERY_RECORD_BUF 102400 // 记录集预分配内存100K
#ifdef _ALPHA
#define READ_BUFSIZE 204800 //
#endif
#ifdef _IBM
#define READ_BUFSIZE 204800 //
#endif
#ifdef _SUN
#define READ_BUFSIZE 102400 //
#endif
#ifdef _HPUX
#define READ_BUFSIZE 204800 //
#endif
#ifdef _LINUX
#define READ_BUFSIZE 204800 //
#endif
struct TResultHead
{
int field_num;
int field_size;
int data_num;
int data_size;
int record_length;
int reach_max;
};
struct TFieldInfo
{
short field_type;
short field_length;
};
struct TFieldAttr {
char colName[64];
unsigned int colNameLen;
unsigned short field_type;
unsigned int field_len;
unsigned char field_precision;
signed char field_scale;
TFieldAttr()
{
memset(this,0,sizeof(TFieldAttr));
}
};
//LOB使用的ResultHead
struct TLOBResultHead
{
int field_num;
int field_size;
int data_num;
int data_size;
vector<int> record_length_vec; //如果data_num==0则record_length_vec不可用
int reach_max;
};
//LOB使用的FieldInfo
struct TLOBFieldInfo
{
short field_type;
vector<int> field_length_vec; //field_length_vec.size等于TLOBResultHead中的data_num //如果data_num == 0, 则field_length_vec.size = 1
};
//错误信息结构
struct TErrorMsg
{
int err_no; //DBAccess错误号
string dbaccess_err; //DBAccess错误信息
string db_err; //数据库错误信息
};
// Define the KeyID_Type's Description
struct TKeyidType
{
int record_id;
short column_id;
};
struct TAppKeyidType
{
long key_id;
int app_id;
};
// Define the AppID_Type's Description
struct TAppidType
{
int app_id;
int record_id;
};
// LOB内容结构
struct TLOBContent
{
unsigned char *lob_content;
int lob_content_size;
};
typedef map<int,int> UserSpecTypeMap;
class SqliteAccess
{
public:
//构造函数auto_logoff == true 或无参数时不需要显示调用Logoff会在析构函数中调用
//反之程序需要显示调用Logoff注销数据库登录否则连接没有释放
SqliteAccess(bool auto_logoff = true);
~SqliteAccess();
private:
void stripWhiteSpace(string &str);
int PrintError(string &err_string);
int PrepareOneSentence(sqlite3_stmt* &stmt, const char *query_string, vector<TErrorMsg> &err_vec);
int FreeOneStatement(sqlite3_stmt* &stmt, vector<TErrorMsg> &err_vec);
int ExecuteOneSelectSentence(sqlite3_stmt* &stmt, bool &is_no_record, vector<TErrorMsg> &err_vec);
int ExecuteOneModifySentence(sqlite3_stmt* &stmt, vector<TErrorMsg> &err_vec);
void GetSelectColNum(sqlite3_stmt* &stmt, int &num_cols);
int GetSingleColInfo(sqlite3_stmt *stmt, int col_num, TFieldAttr &field_attr, string &column_decltype, string &field_precision, string &field_scale, string &field_len, vector<TErrorMsg> &err_vec);
TKeyidType* ConvertKeyidToStruct(char *keyid);
TAppKeyidType* ConvertAppKeyidToStruct(char *keyid);
TAppidType* ConvertAppidToStruct(char *keyid);
int ConvertSQLDateToTimet(char* date_ptr,time_t *osdate);
public:
/*---------------------------------------------------------------------------------
- 功能描述: 数据库注册
- 输 入: server: 服务名
- 输 出: err_vec: 错误返回结构Vector
- 返 回: DB_SUCCESS: 成功
DB_FAIL: 失败
----------------------------------------------------------------------------------*/
int Login(char *server, vector<TErrorMsg> &err_vec);
/*---------------------------------------------------------------------------------
- 功能描述: 数据库注销
- 输 入: 无
- 输 出: err_vec: 错误返回结构Vector
- 返 回: DB_SUCCESS: 成功
DB_FAIL: 失败
----------------------------------------------------------------------------------*/
int Logoff(vector<TErrorMsg> &err_vec);
/*---------------------------------------------------------------------------------
- 功能描述: 取SQL查询返回结果集(不包含LOB类型数据)
- 输 入: query_string: SQL查询命令
max_result: 结果集最大行数GET_ALL_RESULT表示取所有行
user_type_map: 用户指定返回数据类型MAP类型
- 输 出: result_link: 结果集指针
result_indicator 是否为空指针
err_vec: 错误返回结构Vector
result_link_length 结果集内存块长度
result_indicator_length 结果集内存块长度
- 返 回: DB_SUCCESS: 成功
DB_FAIL: 失败
----------------------------------------------------------------------------------*/
int GetQueryResult(char *query_string,
int max_result,
UserSpecTypeMap user_type_map,
char *&result_link,
signed short *&result_indicator,
vector<TErrorMsg> &err_vec,
int &result_link_length,
int &result_indicator_length
);
/*---------------------------------------------------------------------------------
- 功能描述: 取结果集的HEADFIELDDATA指针
- 输 入: result_link: 结果集指针
- 输 出: result_head_ptr: HEAD指针
field_info_ptr: FIELD指针
data_ptr: DATA指针
err_vec: 错误返回结构Vector
- 返 回: DB_SUCCESS: 成功
DB_FAIL: 失败
----------------------------------------------------------------------------------*/
int GetQueryHead( char *result_link,
TResultHead *&result_head_ptr,
TFieldInfo *&field_info_ptr,
char *&data_ptr,
vector<TErrorMsg> &err_vec);
/*---------------------------------------------------------------------------------
- 功能描述: 执行SQL命令并提交
- 输 入: cmd_string: SQL命令
- 输 出: err_vec: 错误返回结构Vector
- 返 回: DB_SUCCESS: 成功
DB_FAIL: 失败
----------------------------------------------------------------------------------*/
int ExecuteCommandWithCommit(char *cmd_string, vector<TErrorMsg> &err_vec);
/*---------------------------------------------------------------------------------
- 功能描述: 执行包含LOB数据的INSERT命令并提交
- 输 入: insert_string: INSERT(LOB)命令
select_string: 附加的SELECT FOR UPDATE(只需要写LOB域)命令
lob_vec: LOB域的Vector
- 输 出: err_vec: 错误返回结构Vector
- 返 回: DB_SUCCESS: 成功
DB_FAIL: 失败
- 说 明:
1、insert_string参数举例
【ORACLE】"insert into my_test_lob(id,clob_content,blob_content)
values(1,empty_clob(),empty_blob())"
【SYBASE】"insert into my_test_lob(id,clob_content,blob_content)
values(1,'','')"
如果需要在select语句中更新LOB域注意不要在Insert语句中将LOB域置为空NULL
对于ORACLE使用empty_clob()、empty_blob()插入EMPTY
对于SYBASE使用''插入EMPTY
2、select_string参数举例
【ORACLE】"select clob_content,blob_content from my_test_lob where id = 1 for update"
【SYBASE】"select clob_content,blob_content from my_test_lob where id = 1"
注意若where子句不对应insert语句中的主键则更新结果不可预见
对于ORACLE “for update”关键词是必须的
3、lob_vec包含LOB实际数据lob_vec.size()必须与select_string中LOB域的个数一致
----------------------------------------------------------------------------------*/
int ExecuteInsertCommandWithLOB(const char *insert_string, const char *select_string,
const vector<TLOBContent> &lob_vec, vector<TErrorMsg> &err_vec);
/*---------------------------------------------------------------------------------
- 功能描述: 取SQL查询返回结果集(包含LOB类型数据)
- 输 入: query_string: SQL查询命令
max_result: 结果集最大行数GET_ALL_RESULT表示取所有行
user_type_map: 用户指定返回数据类型MAP类型
注意LOB域无法指定数据类型
- 输 出: result_link: 结果集指针
result_indicator 是否为空指针
err_vec: 错误返回结构Vector
- 返 回: DB_SUCCESS: 成功
DB_FAIL: 失败
- 说 明:
1、由于SYBASE数据库要求检索的LOB域都必须放在BIND域普通域的后面
因此统一要求query_string中的所有LOB域都在普通域之后
----------------------------------------------------------------------------------*/
int GetQueryResultWithLOB( const char *query_string,
int max_result,
UserSpecTypeMap user_type_map,
char *&result_link,
signed short *&result_indicator,
TLOBResultHead *&result_head_ptr,
TLOBFieldInfo *&field_info_ptr,
vector<TErrorMsg> &err_vec,
int &result_link_length,
int &result_indicator_length
);
/*---------------------------------------------------------------------------------
- 功能描述: 取结果集的HEADFIELDDATA指针(包含LOB类型数据)
- 输 入: result_link: 结果集指针
- 输 出: result_head_ptr: HEAD指针对应TLOBResultHead结构
field_info_ptr: FIELD指针对应TLOBFieldInfo结构
data_ptr: DATA指针
err_vec: 错误返回结构Vector
- 返 回: DB_SUCCESS: 成功
DB_FAIL: 失败
----------------------------------------------------------------------------------*/
int GetQueryHeadWithLOB( char *result_link,
TLOBResultHead *&result_head_ptr,
TLOBFieldInfo *&field_info_ptr,
char *&data_ptr,
vector<TErrorMsg> &err_vec);
/*---------------------------------------------------------------------------------
- 功能描述: 执行包含LOB数据的UPDATE命令并提交
- 输 入: update_string: UPDATE(LOB)命令
select_string: 附加的SELECT FOR UPDATE(只需要写LOB域)命令
lob_vec: LOB域的Vector
- 输 出: err_vec: 错误返回结构Vector
- 返 回: DB_SUCCESS: 成功
DB_FAIL: 失败
- 说 明:
1、update_string参数举例
【ORACLE】"update my_test_lob set blob_content = empty_blob() where id = 1"
【SYBASE】"update my_test_lob set blob_content = '' where id = 1"
如果需要在select语句中更新LOB域注意不要在Update语句中将LOB域置为空NULL
对于ORACLE使用empty_clob()、empty_blob()插入EMPTY
对于SYBASE使用''插入EMPTY
2、select_string参数举例
【ORACLE】"select clob_content,blob_content from my_test_lob where id = 1 for update"
【SYBASE】"select clob_content,blob_content from my_test_lob where id = 1"
注意若where子句不对应update语句中的主键则更新结果不可预见
2、lob_vec包含LOB实际数据lob_vec.size()必须与select_string中LOB域的个数一致
----------------------------------------------------------------------------------*/
int ExecuteUpdateCommandWithLOB( const char *update_string,
const char *select_string,
const vector<TLOBContent> &lob_vec,
vector<TErrorMsg> &err_vec
);
private:
sqlite3 *m_db_handle;
private:
int m_Status;
int m_LoginMode;
int m_LogoffFlag;
};
#endif /* SQLITE_ACCESS_INTERFACE_H_ */

View File

@@ -0,0 +1,156 @@
/*
* sqlite_server_client.h
*
* Created on: 2012-6-6
* Author: LH
*/
#ifndef SQLITE_SERVER_CLIENT_H_
#define SQLITE_SERVER_CLIENT_H_
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include "pthread.h"
#include "system.h"
#include "sam_service.h"
#include "servicesclient.h"
#include "pub_ctx.h"
using namespace std;
//错误信息结构
struct TSqliteErrorMsg
{
int err_no; //DBAccess错误号
string db_err; //数据库错误信息
};
//LOB使用的ResultHead
struct TSqliteLOBResultHead
{
int field_num;
int field_size;
int data_num;
int data_size;
vector<int> record_length_vec; //如果data_num==0则record_length_vec不可用
int reach_max;
};
//LOB使用的FieldInfo
struct TSqliteLOBFieldInfo
{
short field_type;
vector<int> field_length_vec; //field_length_vec.size等于TLOBResultHead中的data_num
//如果data_num == 0, 则field_length_vec.size = 1
};
struct TSqliteLOBContent
{
unsigned char *lob_content;
int lob_content_size;
};
class SqliteServerClient
{
public:
SqliteServerClient(char *db_service);
SqliteServerClient(char *db_service, int seconds);
~SqliteServerClient();
void SetRequestTimeout(int seconds);
int SetHostName(char * host_name);
public:
/*---------------------------------------------------------------------------------
- 功能描述: 取SQL查询返回结果集(不包含LOB类型数据)
- 输 入: query_string: SQL查询命令
max_result: 结果集最大行数GET_ALL_RESULT表示取所有行
user_type_map: 用户指定返回数据类型MAP类型
- 输 出: result_link: 结果集指针
result_indicator 是否为空指针
err_vec: 错误返回结构Vector
- 返 回: DB_SUCCESS: 成功
DB_FAIL: 失败
----------------------------------------------------------------------------------*/
int GetQueryResult(char *query_string,
int max_result,
map<int,int> user_type_map,
char *&result_link,
signed short *&result_indicator,
vector<TSqliteErrorMsg> &err_vec
); // fun_no=1;
/*---------------------------------------------------------------------------------
- 功能描述: 向data_srv主机提交执行SQL命令
- 输 入: cmd_string: SQL命令
- 输 出: err_vec: 错误返回结构Vector
- 返 回: DB_SUCCESS: 成功
DB_FAIL: 失败
----------------------------------------------------------------------------------*/
int ExecuteCommandWithCommitToMaster(char *cmd_string, vector<TSqliteErrorMsg> &err_vec); // fun_no=2
/*---------------------------------------------------------------------------------
- 功能描述: 向data_srv备机提交执行SQL命令
- 输 入: cmd_string: SQL命令
- 输 出: err_vec: 错误返回结构Vector
- 返 回: DB_SUCCESS: 成功
DB_FAIL: 失败
----------------------------------------------------------------------------------*/
int ExecuteCommandWithCommitToSlave(Handle async_commit_handle, char *cmd_string, vector<TSqliteErrorMsg> &err_vec); // fun_no=3;
int FetchDBFileByHostName(char *host_name, vector<TSqliteErrorMsg> &err_vec); // fun_no=4;
int ExecuteInsertCommandWithLOB(const char *insert_string, const char *select_string,
const vector<TSqliteLOBContent> &lob_vec, vector<TSqliteErrorMsg> &err_vec); // fun_no=5
int ExecuteInsertCommandWithLOBToSlave(const char *insert_string, const char *select_string,
const vector<TSqliteLOBContent> &lob_vec, vector<TSqliteErrorMsg> &err_vec); // fun_no=7
int ExecuteUpdateCommandWithLOB( const char *update_string,
const char *select_string,
const vector<TSqliteLOBContent> &lob_vec,
vector<TSqliteErrorMsg> &err_vec
); // fun_no=6
int ExecuteUpdateCommandWithLOBToSlave( const char *update_string,
const char *select_string,
const vector<TSqliteLOBContent> &lob_vec,
vector<TSqliteErrorMsg> &err_vec
); // fun_no=8
int GetQueryResultWithLOB(const char *query_string,
int max_result,
map<int,int> user_type_map,
char *&result_link,
signed short *&result_indicator,
TSqliteLOBResultHead &result_head_ptr,
TSqliteLOBFieldInfo &field_info_ptr,
vector<TSqliteErrorMsg> &err_vec
); // fun_no=9
private:
int SetServiceHost(int policy); //传入查找主机或备机 1 主机 2 备机
int GetHostByAppNo(char* host_name, const int app_no, const short context_no, const int policy);
private:
ServiceInfo m_Serviceinfo;
char m_IpAddress[64];
int m_Port;
Handle m_Handle;
char m_HostName[64];
CServicesManage* m_ServicesManage;
pthread_mutex_t m_mutex;
bool is_sethostname;
int m_RequestTimeoutSeconds;
};
#endif /* SQLITE_SERVER_CLIENT_H_ */

View File

@@ -0,0 +1,90 @@
//**************************************
// Generated by mcpp translator
// Version 1.2
//**************************************
#ifndef __SQLITE_SRV_M_H__
#define __SQLITE_SRV_M_H__
#include"mcode/mvector.h"
#include"mcode/mstring.h"
#include"mcode/mstream.h"
#include"mcode/mclient.h"
#include"public_m.h"
const int QUERY_ALL_RESULT = -1;
struct TResultDataValue
{
bool is_null;
UDataValue data_value;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TResultDataValue> SEQResultDataValue;
struct TResultFieldInfo
{
short data_type;
short data_len;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TResultFieldInfo> SEQResultFieldInfo;
struct TOutDataTypeStru
{
short out_field_position;
short out_field_datatype;
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TOutDataTypeStru> SEQOutDataTypeStru;
struct TSelectResultStru
{
short field_num;
SEQResultFieldInfo field_info;
unsigned int data_num;
SEQResultDataValue data_value_seq;
TSelectResultStru();
TSelectResultStru(const TSelectResultStru&);
TSelectResultStru&operator=(const TSelectResultStru&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TExecMultiResultStru
{
bool is_success;
TDBErrorStru db_error;
TExecMultiResultStru();
TExecMultiResultStru(const TExecMultiResultStru&);
TExecMultiResultStru&operator=(const TExecMultiResultStru&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef MLang::VECTOR<TExecMultiResultStru> SEQExecMultiResultStru;
struct TSQLiteLOBResultHeadStru
{
int field_num;
int field_size;
int data_num;
int data_size;
MLang::VECTOR<int> record_length_vec;
int reach_max;
TSQLiteLOBResultHeadStru();
TSQLiteLOBResultHeadStru(const TSQLiteLOBResultHeadStru&);
TSQLiteLOBResultHeadStru&operator=(const TSQLiteLOBResultHeadStru&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
struct TSQLiteLOBFieldInfoStru
{
short field_type;
MLang::VECTOR<int> field_length_vec;
TSQLiteLOBFieldInfoStru();
TSQLiteLOBFieldInfoStru(const TSQLiteLOBFieldInfoStru&);
TSQLiteLOBFieldInfoStru&operator=(const TSQLiteLOBFieldInfoStru&);
void __write(MLang::OutputStream&__os)const;
void __read(MLang::InputStream&__is);
};
typedef CharSeq LOBValueType;
typedef MLang::VECTOR<CharSeq> SEQLOBValueType;
#endif

Some files were not shown because too many files have changed in this diff Show More