⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shppsessioninterface.h

📁 本源码为移动公司话费查询中间件TUXEDO使用的实例
💻 H
字号:
/*******************************************
* file name:   SHPPSessionInterface.h
* date:        2002.7.27
* 用途:       定义自助话打印协议SHPP
* 作者:       林游海
*******************************************/
#if !defined(_MANAGE_H_LINYOUHAI)
#define _MANAGE_H_LINYOUHAI

#include "SHPP.h"
#include "SHPPRequest.h"
#include "OSThread.h"
#include "dbadmin.h"
#include "OSHashTable.h"

#define PHONEBUFFER  18
#define IPBUFFER     20

struct SysParamStruct
{

//	UInt16 nPost;           //本服务器端口
	UInt16 nTelType;        //话单类型个数
	UInt16 nIsView;			//是否打印预览
	UInt16 nIsSelfQuery;	//是否自定义查询
	char  PrintDefPwd;      //默认密码是否充许打印:1为充许
	char  PrintIsFeeIs;     //欠费是否可打:1为可打印
	char  bRealTimeQuery;   //实时话单是否能打印:1为可打印

	UInt16 nBeginDay;       //出帐起始的时间
	UInt16 nEndDay;         //出帐终始的时间
	UInt16 nBackDay;        //出帐延时几天打印

	UInt16 nH2Post;         //H2端口号
	char   chH2IP[22];      //H2服务器的IP
	char   wsaddrlist[30];  //记录中间件的地址和端口
	
	UInt16 nMonthSize;        //可打的几个月
	char   chPrintTime[512];  //打印时间的文本串
	char   chPrintMonth[6][9];//按键对应的打印月份

	char   chTelType[512];    //话单类型内容
	char   chTelCode[10][10]; //话单类型对应的代码
	char   chPrintTail[1024]; //话单说明
};

enum
{
	knNULLPopedom               = -1, //没有权限
	knAdimiPopedom				= 0,  //0000   查看命令ID说明
	knManagePopedom             = 1,
	knUserPopedom               = 2
};

class CSHPPSessionInterface :public OSThread
{
public:
	CSHPPSessionInterface(CSHPPSocket* pSocket,CDBAdmin *pDBAmin,UInt32 nSessionID,long nPosNO,char* pClientIP = NULL);
	~CSHPPSessionInterface();
	static int Initialize();

	virtual    SInt64			Run();

	KN_Error Popedom();
	KN_Error AdmiPopedom();
	KN_Error ManagePopedom();
	KN_Error UserPopedom();

	char* GetPhone(){return m_chPhone;}
	char* GetPass(){return m_chPass;}
	CStrPtrLen* GetClientIP(){return &m_splClientIP;}
	CStrPtrLen* GetSqlSessionID(){return &m_splSessionID;}
	char* GetBusinessTitle(){return m_chBusinessTitle;}
	char* GetBusinessAddr(){return m_chBusinessAddr;}

	char*  GetPrintFont(){return m_chFont;}
	char*  GetPrintArea(){return m_chArea;}
	void   SetPrintFont(char *pFont){strcpy(m_chFont,pFont);}
	void   SetPrintArea(char *pArea){strcpy(m_chArea,pArea);}

	UInt16 GetServerType(){return m_shppRequest.GetServerType();}
	SInt32 GetPopedom(){return m_nPopedom;}

	void SetSocket(CSHPPSocket* pSocket)
//	{ m_shppRequest.GetSocker()->m_hSocket = pSocket->m_hSocket;}
	{ if(m_sConnect.m_hSocket) m_sConnect.Cleanup();m_sConnect.m_hSocket = pSocket->m_hSocket;}
	CSHPPSocket* GetSocket()
	{ return &m_sConnect;}

	void SetBusinessTitle(char* pPos){ strcpy(m_chBusinessTitle,pPos);}
	void SetBusinessAddr(char* pAddr){ strcpy(m_chBusinessAddr,pAddr);}
	void SetClientIP(char* pClientIP){ strcpy(m_chClientIP,pClientIP);	m_splClientIP.Set(m_chClientIP);}

	KN_Error SentPrintDate();

	void PrintListHead(char *pTime);
	void PrintListTail();
	void PrintFilde(char* pHead);

	KN_Error OnLiveOpdata();   //在线更新客户端

	void SHPPClose();

	UInt32 GetSessionID(){ return m_nSessionID;}
	void   SetSessionID(UInt32 nSessionID) { m_nSessionID = nSessionID;}

	int WriteLog(char *pLog,UInt16 nType = 0);

	int SubLiveTime(){return --m_nLiveTime;}

	//
//	virtual KN_Error GetPrintTime(char* pPrintTime,int nBeginDay,int nEndDay,
//		int nBack = 0 ,char bReal = 0);
	virtual KN_Error GetPrintTime(char* pPrintTime,int nBeginDay,int nEndDay,
		int nBack = 0 ,char bReal = 0,char nPrintMonth = 3);
	virtual KN_Error GetEndDay(int nYear,int nMonth);

	void    InitSysParam(CDBAdmin *pDBAmin);
	struct  SysParamStruct* GetSysParam(){return &m_sysParamStruct;}

protected:

	//在派生类中一定要实现这三个函数
	virtual KN_Error UserCheckPass(char* pPhone,char *pPass,char *pOther = NULL,char *pOutError = NULL) = 0;
	virtual KN_Error UserCheck2Pass(char* pPhone,char *pPass,char *pOther = NULL,char *pOutError = NULL) = 0;
	virtual KN_Error UserIsFee(char* pPhone , char *pAccMonth,char *pOutError)=0;
	virtual KN_Error UserPrint(char* pPhone ,char* nTelType, char *pBeginDate, char* pEndDate,
		double *pCountFee,int *pCountLine,char *pOutError)=0;

	static CStrPtrLen s_splTelType[];

	CSHPPSocket  m_sConnect;

	static char s_chSeparator[];
	CStrPtrLen   m_splClientIP;
	CStrPtrLen   m_splSessionID;
	CSHPPRequest m_shppRequest;

	//用户
	char m_chPhone[knTelOffset+1];
	char m_chPass[PHONEBUFFER+1];

	//营业厅信息
	char  m_chFont[10];                //打印机的字体大种类
	char  m_chArea[20];            //区域标识符

	char  m_chClientIP[IPBUFFER];  //打印机IP
	char  m_chBusinessTitle[FIELDBUFFER];//营业厅标题
	char  m_chBusinessAddr[FIELDBUFFER]; //营业厅地址

	int   m_nPopedom;
	long  m_nPosNO;                  //打印机ID
	UInt32 m_nSessionID;
//	char m_chBillPhone[knTelOffset]; //营业厅管理员ID
//	char m_chBillPass[PHONEBUFFER];  //营业厅管理员密码

	CDBAdmin     *m_pDBAmin;

	char   m_IsSelect;
	int    m_nTelType;
	double m_fFeeCount;
	int    m_nCountLine;
	char   m_chMonth[7];

	int    m_nLiveTime;           //存活时间

	//系统参数
	struct SysParamStruct m_sysParamStruct;

public:
	int SendMsg(char *strMsg);
	
#ifndef _WIN32
	static pthread_mutex_t db_mutex ;//PTHREAD_MUTEX_INITALIZER;
#else
	static HANDLE          db_mutex ;//PTHREAD_MUTEX_INITALIZER;
#endif


};

/***************class CSHPPSessionTemp*****************/
class CSHPPSessionTemp :public OSThread
{
public:
	CSHPPSessionTemp(CKNSocket* pSocket,CDBAdmin *pDBAmin = NULL);
	virtual ~CSHPPSessionTemp();
	void     SetSocket(CKNSocket* pSocket);
	virtual    SInt64			Run();
	void SetClientIP(char* pClientIP){ strcpy(m_chClientIP,pClientIP);	m_splClientIP.Set(m_chClientIP);}
	void SetError(KN_Error knError){ m_knError = knError; }

	CStrPtrLen* GetSplInLine() { return &m_splLine; }

protected:
	KN_Error m_knError;
	CSHPPSocket m_knSocket;

	char m_chClientIP[IPBUFFER];
	char  m_bInLine[2];
	CStrPtrLen m_splLine;
	CStrPtrLen m_splClientIP;
};


#endif //_MANAGE_H_LINYOUHAI

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -