?? shppsessioninterface.cpp
字號:
break;
case 1:
nLen = sprintf(chLog,"%s %s應(yīng)答:\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 列出所有營業(yè)廳管理員的代號、ID和PASS
{
}
else if(nServerType == shppChangeMethod) //0005 修改密碼(營業(yè)廳管理員只能改自己的密碼)
{
}
else if(nServerType == shppRecordMethod) //0006 打印某個時間段的打印記錄
{
}
else if(nServerType == shppAddPrintMethod) //0007 增加一個打印機(jī)(sever admi)
{
}
else if(nServerType == shppDeletePrintMethod)//0008 刪除一個打印機(jī)
{
}
else if(nServerType == shppAddPosMethod) //0009 增加一個營業(yè)廳
{
}
else if(nServerType == shppDeletePosMethod) //0010 刪除一個營業(yè)廳
{
}
else if(nServerType == shppFindPosMethod ) //0011 查找營業(yè)廳的ID
{
}
else if(nServerType == shppPrintFeeMethod) //0012 1為欠費(fèi)可打0為不能打印
{
}
else if(nServerType == shppPrintDegreeMethod)//0013 限制打印次數(shù)
{
}
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) //營業(yè)廳有那幾臺打印機(jī)的
{
}
else if(nServerType == shppChangeMethod) //修改密碼(營業(yè)廳管理員只能改自己的密碼)
{
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); //目標(biāo)月份200207
m_shppRequest.AddPrintField(4,2); //打印條數(shù)
m_shppRequest.AddPrintField(7,2); //打印話費(fèi)
m_shppRequest.PutParameter("電話號 打印時間 目標(biāo)月份 總條數(shù) 總話費(fèi)");
}
else //if(nMode == 1)//按月查詢
{
m_shppRequest.AddPrintField(20); //日期
m_shppRequest.AddPrintField(6); //人次
m_shppRequest.AddPrintField(6,2); //行數(shù)
m_shppRequest.AddPrintField(6,2);//用紙量
m_shppRequest.AddPrintField(10,2);//總話費(fèi)
m_shppRequest.PutParameter(" 日期 人次 行數(shù) 用紙量(mm) 總話費(fèi)");
}
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); //行數(shù)
m_shppRequest.AddPrintField(12,2);//用紙量
m_shppRequest.AddPrintField(14,2);//總話費(fèi)
//人次\t行數(shù)\t用紙量(mm)\t打印話費(fèi)
m_shppRequest.PutParameter(s_chSeparator);
m_shppRequest.PutParameter(" 人次 行數(shù) 用紙量(mm) 總話費(fèi)");
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]);
//向監(jiān)控程序發(fā)送日志
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是否超過打印次數(shù)---開始------\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是否超過打印次數(shù)---結(jié)束---%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用戶達(dá)到限制次數(shù)",m_chPhone+2,m_chMonth+4,m_nSessionID,m_chBusinessTitle,m_chClientIP);
SendMsg(buf);
m_shppRequest.Reset();
return m_shppRequest.SendError(shppPrintErr);
}
// }
}
//是否欠費(fèi)
/* 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();
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -