📄 shppsessioninterface.cpp
字号:
break;
case 1:
nLen = sprintf(chLog,"%s %s应答:\r\n%s\r\n",chTime,m_chClientIP,pLog);
break;
case 2:
nLen = sprintf(chLog,"%s %s处理错误:%s\r\n",chTime,m_chClientIP,pLog);
break;
default:
nLen = sprintf(chLog,"%s %s %s\r\n",chTime,m_chClientIP,pLog);
break;
}
return OSThread::TWrite(chLog,nLen);
}
KN_Error CSHPPSessionInterface::AdmiPopedom()
{
KN_Error knError;
char chParam[6][FIELDBUFFER];
UInt16 nServerType;
nServerType = m_shppRequest.GetServerType();
if(nServerType == shppPrintMethods)
return shppPopedomErr;
return shppNotDefine;
knError = m_shppRequest.GetNextParameter(6,(char**)chParam);
if(nServerType == shppListMethod) //0004 列出所有营业厅管理员的代号、ID和PASS
{
}
else if(nServerType == shppChangeMethod) //0005 修改密码(营业厅管理员只能改自己的密码)
{
}
else if(nServerType == shppRecordMethod) //0006 打印某个时间段的打印记录
{
}
else if(nServerType == shppAddPrintMethod) //0007 增加一个打印机(sever admi)
{
}
else if(nServerType == shppDeletePrintMethod)//0008 删除一个打印机
{
}
else if(nServerType == shppAddPosMethod) //0009 增加一个营业厅
{
}
else if(nServerType == shppDeletePosMethod) //0010 删除一个营业厅
{
}
else if(nServerType == shppFindPosMethod ) //0011 查找营业厅的ID
{
}
else if(nServerType == shppPrintFeeMethod) //0012 1为欠费可打0为不能打印
{
}
else if(nServerType == shppPrintDegreeMethod)//0013 限制打印次数
{
}
return KN_OK;
}
//在线更新客户端
KN_Error CSHPPSessionInterface::OnLiveOpdata()
{
char chFile[PACKETBUFFER];
char *pHeadPath,*pServerPath,*pClientPath,chPath[512];
FILE* fb = 0;
int nRead = 0;
KN_Error knError;
strcpy(chPath,"p_20021016.log\t.\\p_20020919.txt\r\n\r\n");
pHeadPath = chPath;
while(memcmp(pHeadPath,"\r\n",2))
{
pServerPath = pHeadPath;
pClientPath = strchr(pHeadPath,'\t');
if(pClientPath == NULL)
break;
*pClientPath = '\0';
pClientPath++;
pHeadPath = pClientPath;
fb = fopen(pServerPath,"rb");
if(fb <=0)
{
return shppOpdataErr;
}
pServerPath = strchr(pHeadPath,'\r');
if(pServerPath == NULL)
break;
*pServerPath = '\0';
pHeadPath = pServerPath + 2;
m_shppRequest.PutParameter(pClientPath);
while(1)
{
pHeadPath = chPath;
nRead = fread(chFile,1,PACKETBUFFER - 2*knPacketMinSize,fb);//PACKETBUFFER - 2*knPacketMinSize
m_shppRequest.PutParameter((char*)chFile,nRead);
if(nRead < PACKETBUFFER - 2*knPacketMinSize)
{
m_shppRequest.Flush();
fclose(fb);
// nRead = ferror (fb);
break;
}
}
//接收更新的信息
knError = m_shppRequest.Parse();
if(knError != 0 )
return knError;
if(m_shppRequest.GetServerType() != shppFileOpdataEnd)
return shppRequestErr;
}
m_shppRequest.SendError(shppOK);
return KN_OK;
}
KN_Error CSHPPSessionInterface::ManagePopedom()
{
KN_Error knError = KN_OK;
UInt16 nServerType;
char chParam[5][FIELDBUFFER];
char chTel[knTelOffset+1];
// LPSCHAR lpParam;
nServerType = m_shppRequest.GetServerType();
// if(nServerType >= shppListMethod && nServerType <= shppPrintDegreeMethod)
// return shppPopedomErr;
if(nServerType >= shppAddPosMethod)
return shppPopedomErr3;
knError = m_shppRequest.GetNextParameter(6,(char**)chParam);
if(nServerType == shppListMethod) //营业厅有那几台打印机的
{
return shppNotDefine;
}
else if(nServerType == shppChangeMethod) //修改密码(营业厅管理员只能改自己的密码)
{
char *pPass;
m_shppRequest.GetTel(m_shppRequest.GetSocker()->GetReadBuf(),chTel);
if(chParam[0][0] == '\0')
{
return m_shppRequest.SendError(shppParameterErr);
}
pPass = chParam[0];
//修改密码
knError = m_pDBAmin->DBChangeOperPasswd(m_nPosNO,m_chPhone,m_chPass,pPass);
if(knError != KN_OK)
knError = shppLost;
return m_shppRequest.SendError(knError);
}
else if(nServerType == shppRecordMethod) //0006 打印某个时间段的打印记录)
{
char *pchRecord;
int nLen,nParamLen,nMode;
//打印某个时间段的打印记录
pchRecord = NULL;
nLen = strlen(chParam[0]);
nParamLen = strlen(chParam[1]);
if(nLen == 8 && nParamLen != 8) //按日查询
nMode = 0;
else if(nLen == 8 && nParamLen == 8 ) //按时间段查询
nMode = 2;
else if(nLen == 6) //按月查询
nMode = 1;
else
return shppParameterErr;
printf("DB%s:打印记录,%s\n",m_chClientIP,m_chPhone);
if(nMode == 1)
knError = m_pDBAmin->DBQueryPrtposPrintInfo(m_nPosNO,nMode,
chParam[0],&pchRecord);
else if(nMode == 0)
knError = m_pDBAmin->DBQueryPrtposPrintInfoDetail(m_nPosNO,chParam[0],&pchRecord);
else
knError = m_pDBAmin->DBQueryPrtposPrintInfoDetailScope(m_nPosNO,chParam[0],chParam[1],&pchRecord);
printf("DB%s:打印记录end,%sknError = %d\n",m_chClientIP ,m_chPhone,knError);
// if(m_pDBAmin->DBQueryPrtposPrintInfo(m_nPosNO,nMode,
// chParam[0],&pchRecord) != KN_OK)
// if(knError != KN_OK)
// return shppParameterErr;
if(knError != KN_OK || pchRecord == NULL)
{
printf("DB %s***********m_pDBAmin->DBFreeBuff()********\n",m_chClientIP);
if(pchRecord)
m_pDBAmin->DBFreeBuff(pchRecord);
printf("DB %s***********DBFreeBuff end!!!*********\n",m_chClientIP);
return shppNotListErr;
}
m_shppRequest.ResetField();
PrintListHead(chParam[0]);
if(nMode == 0 || nMode == 2) //按日查询
{
m_shppRequest.AddPrintField(12); //电话号
m_shppRequest.AddPrintField(18); //打印时间20020801 19:25:02
m_shppRequest.AddPrintField(7); //目标月份200207
m_shppRequest.AddPrintField(4,2); //打印条数
m_shppRequest.AddPrintField(7,2); //打印话费
m_shppRequest.PutParameter("电话号 打印时间 目标月份 总条数 总话费");
}
else //if(nMode == 1)//按月查询
{
m_shppRequest.AddPrintField(20); //日期
m_shppRequest.AddPrintField(6); //人次
m_shppRequest.AddPrintField(6,2); //行数
m_shppRequest.AddPrintField(6,2);//用纸量
m_shppRequest.AddPrintField(10,2);//总话费
m_shppRequest.PutParameter(" 日期 人次 行数 用纸量(mm) 总话费");
}
m_shppRequest.PutParameter(s_chSeparator);
//写日月报
PrintFilde(pchRecord);
printf("DB %s*********m_pDBAmin->DBFreeBuff() = *****\n",m_chClientIP);
m_pDBAmin->DBFreeBuff(pchRecord);
printf("DB %s********DBFreeBuff end!!!************\n",m_chClientIP);
m_shppRequest.ResetField();
if(nMode != 1)
{
m_shppRequest.AddPrintField(6); //合计:
m_shppRequest.AddPrintField(8,2); //人次
m_shppRequest.AddPrintField(8,2); //行数
m_shppRequest.AddPrintField(12,2);//用纸量
m_shppRequest.AddPrintField(14,2);//总话费
//人次\t行数\t用纸量(mm)\t打印话费
m_shppRequest.PutParameter(s_chSeparator);
m_shppRequest.PutParameter(" 人次 行数 用纸量(mm) 总话费");
if(nMode == 0)
m_pDBAmin->DBQueryPrtposPrintInfo(m_nPosNO,nMode,
chParam[0],&pchRecord);
else
m_pDBAmin->DBQueryPrtposPrintInfoScope(m_nPosNO,
chParam[0],chParam[1],&pchRecord);
m_shppRequest.AddFieldVal("合计:",strlen("合计:"));
PrintFilde(pchRecord);
m_pDBAmin->DBFreeBuff(pchRecord);
}
this->PrintListTail();
// m_shppRequest.PutParameter(s_chSeparator);
m_shppRequest.Flush();
WriteLog("查看日月报退出!",-1);
}
return KN_OK;
}
KN_Error CSHPPSessionInterface::UserPopedom()
{
KN_Error knError;
char chParam[6][FIELDBUFFER];
// SInt16 i;
int nIsPrint = 1;
char buf[252];
// char *pList;//m_chMonth1[FIELDBUFFER],
// char chTel[knTelOffset];
UInt16 nServerType;
nServerType = m_shppRequest.GetServerType();
if(nServerType != shppPrintMethods && nServerType != shppPrintEnd)
return shppPopedomErr4;
if(nServerType == shppPrintEnd)
{
#if PRINTEND
char *pTemp = (char*)chParam;
if(m_nCountLine == 0)
return m_shppRequest.SendError(shppOK);
printf("DB %s*********DBAddPrintRecord*****\n",m_chClientIP);
#ifndef _WIN32
pthread_mutex_lock(&db_mutex);
#else
WaitForSingleObject(db_mutex,INFINITE);
#endif //_WIN32
// if( m_sysParamStruct.bRealTimeQuery != 1 || m_IsSelect != 1 )
m_pDBAmin->DBAddPrintRecord(0,m_nPosNO,m_chPhone,m_chMonth,
m_sysParamStruct.chTelCode[m_nTelType],NULL,NULL,m_nCountLine,(long)(m_fFeeCount*100),0);
printf("DB %s: print end ***\n",m_chClientIP);
#ifndef _WIN32
pthread_mutex_unlock(&db_mutex);
#else
ReleaseMutex(db_mutex);
#endif //_WIN32
m_shppRequest.SendError(shppOK);
sprintf(pTemp,"m_chPhone = %s,m_chMonth = %s,\nm_nCountLine = %d,m_fFeeCount = %0.2f",m_chPhone,m_chMonth,
m_nCountLine,m_fFeeCount);
this->WriteLog(pTemp,1);
return KN_OK;
#else //PRINTEND
printf("!!!!!!!!2.DB %s DBAddPrintRecord***\n",m_chClientIP);
return m_shppRequest.SendError(shppOK);
#endif //PRINTEND
}
knError = m_shppRequest.GetNextParameter(6,(char**)chParam);
if(chParam[0][0] == '\0'|| chParam[1][0] == '\0'
||chParam[2][0] == '\0'||chParam[3][0] == '\0')
{
return m_shppRequest.SendError(shppParameterErr);
}
if(chParam[1][0] != '0' )
return shppPrintLimit;
//提取话单
m_IsSelect = chParam[2][0] - '0';
if(m_IsSelect < 1 || m_IsSelect > m_sysParamStruct.nMonthSize)
return shppPrintLimit;
strcpy(m_chMonth,m_sysParamStruct.chPrintMonth[chParam[2][0] - '0' -1]);
//向监控程序发送日志
sprintf(buf,"<183>[%9s%2s%05d][02]%s%s",m_chPhone+2,m_chMonth+4,m_nSessionID,m_chBusinessTitle,m_chClientIP);
SendMsg(buf);
//是否超过打印次
if(chParam[3][0] == '0')
{
//==================
/* if(g_sysParamStruct.bRealTimeQuery == 1 && chParam[2][0] == '1')
{
sprintf(chParam[1],"%s%02d",m_chMonth,OS::GetDay());
m_pDBAmin->DBQueryPhonePrintInfoReal(m_chPhone,chParam[1],&nIsPrint);
if(nIsPrint == 0)
return shppLimitDay;
}
else
{
here*/
//================
nIsPrint = 1;
printf("DB %s ,%s是否超过打印次数---开始------\n",m_chPhone,m_chMonth);
m_nTelType = chParam[0][0] - '0';
if(m_nTelType > m_sysParamStruct.nTelType)
return shppPrintErr;
if(m_sysParamStruct.nTelType > 0)
m_nTelType--;
#ifndef _WIN32
pthread_mutex_lock(&db_mutex);
#else
WaitForSingleObject(db_mutex,INFINITE);
#endif //_WIN32
m_pDBAmin->DBQueryPhonePrintInfo(m_chPhone,m_chMonth,m_sysParamStruct.chTelCode[m_nTelType],&nIsPrint);
printf("DB %s ,%s是否超过打印次数---结束---%d--\n",m_chPhone,m_chMonth,nIsPrint);
#ifndef _WIN32
pthread_mutex_unlock(&db_mutex);
#else
ReleaseMutex(db_mutex);
#endif //_WIN32
if(nIsPrint == 0)
{
sprintf(buf,"<176>[%9s%2s%05d][03]%s%s用户达到限制次数",m_chPhone+2,m_chMonth+4,m_nSessionID,m_chBusinessTitle,m_chClientIP);
SendMsg(buf);
m_shppRequest.Reset();
return m_shppRequest.SendError(shppPrintErr);
}
// }
}
//是否欠费
/* if(m_sysParamStruct.PrintIsFeeIs != '1')
{
chParam[4][0] = 0;
if(UserIsFee(m_chPhone,m_chMonth,chParam[4]) != KN_OK)
{
if(chParam[4][0] != 0)
m_shppRequest.PutParameter(chParam[4]);
return shppHaveFeeErr;
}
}
*/
m_fFeeCount = 0.0;
m_nCountLine = 0;
chParam[3][0] = 0;
m_shppRequest.Reset();
// knError = UserPrint(m_chPhone,m_sysParamStruct.chTelCode[m_nTelType],m_chMonth,NULL,&m_fFeeCount,
// &m_nCountLine,chParam[3]);
knError = UserPrint(m_chPhone,m_sysParamStruct.wsaddrlist,m_chMonth,NULL,&m_fFeeCount,
&m_nCountLine,chParam[5]);
if(knError != KN_OK)
{
sprintf(buf,"<184>[%9s%2s%05d][07]%s%s",m_chPhone+2,m_chMonth+4,m_nSessionID,m_chBusinessTitle,m_chClientIP);
SendMsg(buf);
m_shppRequest.Reset();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -