📄 tuxedo.cpp
字号:
char memorybuf[25600];//用于存放读文件一行的信息
m_nindex = 0;//判断话单类型
char *str=NULL;
try
{
PrintListHead();
memset(memorybuf,'\0',25600);
while((str=strchr(filename,'\r'))!=NULL)//没有考虑最后一个,因为最后的已经是结尾了
{
if((str-filename)>3)
{
if((str-filename)>25600)
{
printf("**************************************\n");
printf("=========== ~_~ ++++++++++++++++++++\n");
printf("**************************************\n");
return -1;
}
//
strncpy(memorybuf,filename,(str-filename));
memorybuf[(str-filename)]='\0';
filename=filename+(str-filename);
str=NULL;
//m_nindex=-1;
if(findtypeindex(memorybuf)==0)//,m_nindex
continue;
if(m_nindex==16)
break;//如果是话簿管家就退出
try
{
if(switchbill(memorybuf,phone)!=0)//,m_nindex
return -1;
}
catch(...)
{
printf("%s\n",memorybuf);
}
memset(memorybuf,'\0',25600);
}
else
{
filename=filename+2;
str=NULL;
}
}
}
catch(...)
{
printf("%s\n",memorybuf);
printf("类型是:%d\n",m_nindex);
return -1;
}
return 0;
}
//===============================================
//在rebuf中查找特定的字符 将标志值赋给m_nindex
//
int CTuxedo::findtypeindex(char *rebuf)//,int &m_nindex)
{
char *str=NULL;
int returnnum=0;
if(strlen(rebuf)<5)
return 0;
if(strstr(rebuf,"-----")!=NULL)
returnnum = 1;
else if(strstr(rebuf,"号")!=NULL)//不可以和“合计”颠倒了!!!!!!
returnnum = 0;
else if(strstr(rebuf,"呼叫")!=NULL)
returnnum = 0;
else if(strstr(rebuf,"普通语音话单")!=NULL)
{
m_nindex = 1;
returnnum = 0;
}
else if(strstr(rebuf,"呼转语音话单")!=NULL)
{
m_nindex = 2;
returnnum = 0;
}
else if(strstr(rebuf,"VPMN语音话单")!=NULL)
{
m_nindex = 3;
returnnum = 0;
}
else if(strstr(rebuf,"语音杂志话单")!=NULL)
{
m_nindex = 4;
returnnum = 0;
}
else if(strstr(rebuf,"普通短信话单")!=NULL)
{
m_nindex = 5;
returnnum = 0;
}
else if(strstr(rebuf,"互通短信话单")!=NULL)
{
m_nindex = 6;
returnnum = 0;
}
else if(strstr(rebuf,"移动梦网短信话单")!=NULL)
{
m_nindex = 7;
returnnum = 0;
}
else if(strstr(rebuf,"代收话单")!=NULL)
{
m_nindex = 8;
returnnum = 0;
}
else if(strstr(rebuf,"GPRS话单")!=NULL)
{
m_nindex = 9;
returnnum = 0;
}
else if(strstr(rebuf,"移动彩信话单")!=NULL)
{
m_nindex = 10;
returnnum = 0;
}
else if(strstr(rebuf,"移动电话购物话单")!=NULL)
{
m_nindex = 11;
returnnum = 0;
}
else if(strstr(rebuf,"WLAN话单")!=NULL)
{
m_nindex = 12;
returnnum = 0;
}
else if(strstr(rebuf,"彩铃话单")!=NULL)
{
m_nindex = 13;
returnnum = 0;
}
else if(strstr(rebuf,"彩话话单")!=NULL)
{
m_nindex = 14;
returnnum = 0;
}
else if(strstr(rebuf,"彩话话单-包月")!=NULL)
{
m_nindex = 15;
returnnum = 0;
}
else if(strstr(rebuf,"话薄管家话单")!=NULL)
{
m_nindex = 16;
returnnum = 0;
}
else
returnnum=1;
return returnnum;
}
int CTuxedo::switchbill(char *rebuf,char *phone)//,int m_nindex)
{
int number=0;
switch(m_nindex)
{
case 1:
number=putongyuyin(rebuf,phone);//普通语音
break;
case 2:
number=huzhuanyuyin(rebuf,phone);//呼转话语音
break;
case 3:
number=vpmn(rebuf,phone);//vpmn
break;
case 4:
number=yuyinzazhi(rebuf,phone);//语音杂志
break;
case 5:
number=putongduanxin(rebuf,phone);//普通短信
break;
case 6:
number=hutongduanxin(rebuf,phone);//互通短信
break;
case 7:
number=yidongmengwang(rebuf,phone);//移动梦网
break;
case 8:
number=daishouhuadan(rebuf,phone);//代收话费
break;
case 9:
number=gprs(rebuf,phone);//GPRS
break;
case 10:
number=yidongcaixin(rebuf,phone);//移动彩信
break;
case 11:
number=yidonggouwu(rebuf,phone);//移动购物
break;
case 12:
number=wlan(rebuf,phone);//WLAN
break;
case 13:
number=cailinghuadan(rebuf,phone);//彩铃话单
break;
case 14:
number=caihuaxinxi(rebuf,phone);//彩话信息
break;
case 15:
number=caihuabaoyue(rebuf,phone);//彩话包月
break;
case 16:
number=huabuguanjia(rebuf,phone);//话薄管家
break;
default:
number=-1;
break;
}
if(number==-1)
{
printf("m_nindex=%d,rebuf=%s,phone=%s\n",m_nindex,rebuf,phone);
}
return number;
}
//==========================================
//语音话单-普通语音话单
//===========================
int CTuxedo::putongyuyin(char *rebuf,char *phone)
{
char *str=NULL;
int number = 100;
// char linebuf[256];
if((strstr(rebuf,"合计")!=NULL)&&(startindex==0)&&(strstr(rebuf,"-------")==NULL))
return 0;
if((strstr(rebuf,"--------")!=NULL)&&(strlen(rebuf)<150))
return 0;
if((strstr(rebuf,"合计")!=NULL)&&(startindex==0)&&(strstr(rebuf,phone)==NULL))
return 0;
if(strlen(rebuf)<10)
return 0;
if(strstr(rebuf,"基本费合计")!=NULL)
{
endindex=1;
if((endindex==1)&&(m_nCountLine!=0))
{
//处理结尾
char pList[256];
m_pShppRequest->PutParameter(s_chSeparator);
sprintf(pList,"普通语音话单 总费用:%0.2f元;",m_fFeeCount);
m_tempfee=m_tempfee+m_fFeeCount;
m_pShppRequest->PutParameter(pList);
sprintf(pList,"普通语音话单 总次数:%d次;", m_nCountLine);
m_tempcount=m_tempcount+m_nCountLine;
m_pShppRequest->PutParameter(pList);
m_pShppRequest->PutParameter(s_chSeparator);
// *m_pfOutFeeCount += m_fFeeCount;
// *m_pnLineCount += m_nCountLine;
//m_pShppRequest->Flush();
m_fFeeCount = 0.0;
m_nCountLine = 0;
startindex = 0;
endindex = 0;
}
return 0;
}
/*
m_pShppRequest->AddPrintField(6,2); //4时长(秒)
m_pShppRequest->AddPrintField(6,2); //5话费
m_pShppRequest->AddPrintField(9,2); //6本方所在地
*/
if(startindex==0)
{
m_pShppRequest->ResetField();
m_pShppRequest->AddPrintField(13); //1对方号码
m_pShppRequest->AddPrintField(3); //2方式
m_pShppRequest->AddPrintField(13); //3日期 时间20020321 03-21
m_pShppRequest->AddPrintField(6,2); //4时长(秒)
m_pShppRequest->AddPrintField(6,2); //5话费
m_pShppRequest->AddPrintField(9,2); //6本方所在地
m_pShppRequest->PrintLine("语音话单-普通语音话单",LPLCENTER);
m_pShppRequest->PutParameter("对方号码 方式 日期 时间 时长 话费 通话地");
m_pShppRequest->PutParameter(s_chSeparator);
startindex = 1;
m_fFeeCount =0.0;//费用
m_nCountLine=0;;//行数
input1.count = 13;
for(int i=0;i<15;i++)
for(int j=0;j<3;j++)
{
input1.num[i][j]='\0';
input2.num[i][j]='\0';
}
strcpy(input1.num[0],"15");strcpy(input1.num[1],"15");strcpy(input1.num[2],"20");
strcpy(input1.num[3],"5");strcpy(input1.num[4],"5");strcpy(input1.num[5],"7");
strcpy(input1.num[6],"7");strcpy(input1.num[7],"7");strcpy(input1.num[8],"9");
strcpy(input1.num[9],"5");strcpy(input1.num[10],"7");strcpy(input1.num[11],"7");
strcpy(input1.num[12],"7");
input2.count = 6;//count 里面存放的几个是时间
strcpy(input2.num[0],"1");strcpy(input2.num[1],"2");strcpy(input2.num[2],"3");
strcpy(input2.num[3],"5");strcpy(input2.num[4],"14");strcpy(input2.num[5],"10");
strcpy(input2.num[6],"3");
}
//rebuf=rebuf+114;//将前面的横线去掉
int countindex=0;
number = strlen(rebuf);
if((str=strstr(rebuf,"基本费合计"))!=NULL)
{
endindex=1;
number=str-rebuf;
}
while(number>2)
{
// str=rebuf;
countindex=0;
//if(daishouaddline(rebuf,input1,input2,countindex)==0)//
try
{
//countindex=putongaddline(rebuf,input1,input2);
countindex=putongaddline(rebuf,14,3);//jiangsihui
}
catch(...)
{
printf("总于逮到了普通语音,haha %s %d\n",phone,countindex);
return -1;
}
if(countindex>0)
{//加记录到内存
m_fFeeCount=m_fFeeCount+atof(Param[13]);//费用
try
{
if(strncmp(Param[0],phone,strlen(phone))==0)
{
m_pShppRequest->AddFieldVal(rtrim(Param[1]),strlen(Param[1]));
m_pShppRequest->AddFieldVal("主",2);
}
else
{
m_pShppRequest->AddFieldVal(rtrim(Param[0]),strlen(Param[0]));
m_pShppRequest->AddFieldVal("被",2);
}
}
catch(...)
{
printf("普通语音出错步骤1 %s,%d\n",phone,__LINE__);
printf("%s\n%s\n",Param[0],Param[1]);
for(int j=2;j<14;j++)
{
printf("%s\n",Param[j-1]);
}
return -1;
}
try
{
//for(int j=2;j<input2.count;j++)
// m_pShppRequest->AddFieldVal(Param[atoi(input2.num[j])-1],strlen(rtrim(Param[atoi(input2.num[j])-1])));
m_pShppRequest->AddFieldVal(Param[2],strlen(Param[2]));
m_pShppRequest->AddFieldVal(Param[4],strlen(Param[4]));
m_pShppRequest->AddFieldVal(Param[13],strlen(Param[13]));
m_pShppRequest->AddFieldVal(Param[9],strlen(Param[9]));
}
catch(...)
{
printf("普通语音出错步骤2%s,%d\n",phone,__LINE__);
printf("%s\n%s\n",Param[0],Param[1]);
for(int j=2;j<14;j++)
{
printf("%s\n",Param[j-1]);
}
return -1;
}
m_nCountLine=m_nCountLine+1;
number=number-countindex;
rebuf=rebuf+countindex;
while(rebuf[0]==' ')
{
rebuf=rebuf+1;
number=number-1;
}
}//添加记录结束
else
{
m_pShppRequest->Reset();
return -1;
}
}
if((endindex==1)&&(m_nCountLine!=0))
{
//处理结尾
char pList[256];
m_pShppRequest->PutParameter(s_chSeparator);
sprintf(pList,"普通语音话单 总费用:%0.2f元;",m_fFeeCount);
m_tempfee=m_tempfee+m_fFeeCount;
m_pShppRequest->PutParameter(pList);
sprintf(pList,"普通语音话单 总次数:%d次;", m_nCountLine);
m_tempcount=m_tempcount+m_nCountLine;
m_pShppRequest->PutParameter(pList);
m_pShppRequest->PutParameter(s_chSeparator);
// *m_pfOutFeeCount += m_fFeeCount;
// *m_pnLineCount += m_nCountLine;
//m_pShppRequest->Flush();
m_fFeeCount = 0.0;
m_nCountLine = 0;
startindex = 0;
endindex = 0;
}
return 0;
}
//==========================================
int CTuxedo::huzhuanyuyin(char *rebuf,char *phone)
{
char *str=NULL;
int number = 100;
// char linebuf[256];
float tempfee = 0.0;
if((strstr(rebuf,"合计")!=NULL)&&(startindex==0))
return 0;
if((strstr(rebuf,"--------")!=NULL)&&(strlen(rebuf)<150))
return 0;
// if((strstr(rebuf,"合计")!=NULL)&&(startindex==0))
// return 0;
if(strlen(rebuf)<10)
return 0;
if(strstr(rebuf,"呼转长途费1合计")!=NULL)
{
endindex=1;
if((endindex==1)&&(m_nCountLine!=0))
{
//处理结尾
char pList[256];
m_pShppRequest->PutParameter(s_chSeparator);
sprintf(pList,"呼转语音话单 总费用:%0.2f元;",m_fFeeCount);
m_tempfee=m_tempfee+m_fFeeCount;
m_pShppRequest->PutParameter(pList);
sprintf(pList,"呼转语音话单 总次数:%d次;", m_nCountLine);
m_tempcount=m_tempcount+m_nCountLine;
m_pShppRequest->PutParameter(pList);
m_pShppRequest->PutParameter(s_chSeparator);
// *m_pfOutFeeCount += m_fFeeCount;
// *m_pnLineCount += m_nCountLine;
//m_pShppRequest->Flush();
m_fFeeCount = 0.0;
m_nCountLine = 0;
startindex = 0;
endindex = 0;
}
return 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -