numbertab檔案内容,第一列首字母為關鍵字,其餘資料插入到ListBox顯示
#本SAG負責的号段(跟業務能力相關)
001138 123456
001021 123456
004138 123456
004021 123456
006138 123456
006021 123456
008138 123456
008021 123456
009138 123456
009021 123456
#第三方發起呼叫時,選擇網關(基于網關移動、固定、NGN)
11 CAP
10217777 INAP
10218888 SIP
#資料類SE的路由資料
909 http://192.168.2.221/mm7
911 http://192.168.2.221/le
912 http://192.168.2.221/pap
#短信過濾關鍵字
#F+關鍵字GBK碼經bcdtoasc後的内容 關鍵字GBK嗎
F2bcbac2b 布什
F1beb0cda5b7c 本拉登
void CNumberTabCtrl::OnBtOut()
{
// TODO: Add your control notification handler code here
CString file_content_before;
CString file_content_behind;
ListBox1.DeleteAllItems();
remove("numbertab");
if(m_bGet)
return;
m_bGet = true;
LoadProfile(pPage->GetValue("FTPConfig"));
CInternetSession sess (_T("CIN-VAS/3.0"));
CFtpConnection* pConnect = NULL;
try
{
pConnect = sess.GetFtpConnection(LPCTSTR(g_FtpHost),LPCTSTR(g_FtpUser),LPCTSTR(g_FtpPass),g_uiPort);
if(!pConnect)
{
sess.Close();
return;
}
}
catch (CInternetException* pEx)
{
TCHAR sz[1024];
pEx->GetErrorMessage(sz, 1024);
pEx->Delete();
m_bGet = false;
MessageBox("無法連接配接SAG伺服器。");
return;
}
pConnect->SetCurrentDirectory(g_FtpPath);
pConnect->GetFile("RemoteFile","LocalFile",FALSE);
sess.Close();
FILE *hResFile = fopen("LocalFile","rb");
if(hResFile==NULL)
{
m_bGet = false;
MessageBox("無法連接配接SAG伺服器。");
return;
}
int ilenofline=100;
char textout[3000],sTemp[100],number[2][40];
CString file_content;
int ibefore=0,ibehind=0,icurrent=0;
bool bcurrent=false;
for(int i=1,iline=0;;i++) //每個循環是一行記錄
{
textout[0]=0x00;
if(!fgets(textout,ilenofline,hResFile))
{
break;
}
if(textout[0]==0x00||textout[0]=='/r')
break;
//格式化,讀取部分以前的内容儲存在file_content_before,以後内容儲存在file_content_behind
if(textout[0]!=keyword)
{
if(bcurrent==false)
file_content_before+=textout;
else
file_content_behind+=textout;
continue; //有用嗎?時間長,忘了:-(
}
else//讀取内容儲存在file_content
{
//讀取内容分成兩列,分别儲存到number[0]和number[1],然後插入到ListBox1顯示
for(int i=0,j=0,k=0; i<=ilenofline; i++)
{
if(textout[i] == 0x00)
{
if(j != 0)
{
sTemp[j] = 0;
strcpy(number[k],sTemp);
k++;
}
break;
}
if(textout[i] == ' '||textout[i] == '/t'||textout[i] == '/n')
{
if(j != 0)
{
sTemp[j] = 0;
strcpy(number[k],sTemp);
k++;
}
j = 0;
continue;
}
sTemp[j] = textout[i];
j++;
}
if(keyword=='0')
{
//讀取内容再細分
char sTemp2[3]="/0/0";
strncpy(sTemp2,&number[0][1],2);
if(strcmp(CString(sTemp2),pPage->GetValue("NumTabType"))<0)
file_content_before+=textout;
if(strcmp(pPage->GetValue("NumTabType"),CString(sTemp2))==0)
{
file_content+=textout;
ListBox1.InsertItem(iline++,&number[0][3]);
GetDlgItem(IDC_EDIT_CONTENT2)->SetWindowText(number[1]);
bcurrent=true;
}
if(strcmp(CString(sTemp2),pPage->GetValue("NumTabType"))>0)
{
file_content_behind+=textout;
bcurrent=true;
}
}
else
{
file_content+=textout;
ListBox1.InsertItem(iline,&number[0][1]);
ListBox1.SetItemText(iline++,1,number[1]);
bcurrent=true;
}
}
} //end of for(i=1;i<=MAX_ONEDAY;i++)
if(strcmp(file_content,"")==0)
MessageBox("沒有您要查找的記錄。");
fclose(hResFile);
m_bGet=false;
}