?? 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 + -