// DLG_White2.cpp : implementation file // #include "stdafx.h" #include "corpsms.h" #include "DLG_White2.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #include "DLG_User_InportP2.h" #include "FPLFile.h" #include "MainFrm.h" #include "ProcessSocket.h" ///////////////////////////////////////////////////////////////////////////// // DLG_White2 dialog DLG_White2::DLG_White2(CWnd* pParent /*=NULL*/) : CDialog(DLG_White2::IDD, pParent) , m_strSubmit(_T("")) , m_strAudit(_T("")) , m_strCount(_T("")) { //{{AFX_DATA_INIT(DLG_White2) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_pMainFrame = (CMainFrame * )pParent; m_lMobileCount = 0; m_dwAllCount = 0; m_dwUpCount = 0; m_dwUpSucess=0; m_dwUpFail=0; m_bUpload = false; memset(&m_White2,0,sizeof(m_White2)); // m_strCount = _T(""); m_strMobile = _T(""); m_strMobile2 = _T(""); m_strAddTime = _T(""); } void DLG_White2::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(DLG_White2) DDX_Control(pDX, IDC_PLFILE_ADD_GDT, m_P_GDT); DDX_Control(pDX, IDC_PLFILE_ADD_UPLOAD, m_B_Upload); DDX_Control(pDX, IDC_PLFILE_ADD_ADD, m_B_Add); DDX_Control(pDX, IDC_PLFILE_ADD_COUNT, m_E_Count); //}}AFX_DATA_MAP DDX_Control(pDX, IDC_CHECKLOCALBACK, m_B_CheckLocalBack); // DDX_Control(pDX, IDC_CHECKREMOBILE, m_B_CheckReMobile); DDX_Control(pDX, IDC_REUPLOAD, m_B_ReUpload); DDX_Control(pDX, IDC_PLFILE_DEL, m_B_Del); DDX_Control(pDX, IDC_PLFILE_RESET, m_B_Reset); DDX_Text(pDX, IDC_PLFILE_MOBILE, m_strMobile); DDV_MaxChars(pDX, m_strMobile, 16); DDX_Text(pDX, IDC_PLFILE_MOBILE2, m_strMobile2); DDX_Text(pDX, IDC_PLFILE_ADDTIME, m_strAddTime); // DDX_Text(pDX, IDC_PLFILE_COUNT, m_strCount); DDX_Text(pDX, IDC_PLFILE_SUBMIT, m_strSubmit); DDX_Text(pDX, IDC_PLFILE_AUDIT, m_strAudit); DDX_Text(pDX, IDC_PLFILE_COUNT, m_strCount); } BEGIN_MESSAGE_MAP(DLG_White2, CDialog) //{{AFX_MSG_MAP(DLG_White2) ON_BN_CLICKED(IDC_PLFILE_ADD_ADD, OnPlfileAddAdd) ON_BN_CLICKED(IDC_PLFILE_ADD_UPLOAD, OnPlfileAddUpload) ON_WM_TIMER() //}}AFX_MSG_MAP ON_WM_CLOSE() ON_BN_CLICKED(IDC_PLFILE_QUERY, &DLG_White2::OnBnClickedPlfileQuery) ON_BN_CLICKED(IDC_PLFILE_ADD, &DLG_White2::OnBnClickedPlfileAdd) ON_BN_CLICKED(IDC_PLFILE_DEL, &DLG_White2::OnBnClickedPlfileDel) ON_BN_CLICKED(IDC_PLFILE_RESET, &DLG_White2::OnBnClickedPlfileReset) ON_EN_CHANGE(IDC_PLFILE_MOBILE, &DLG_White2::OnEnChangePlfileMobile) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // DLG_White2 message handlers void DLG_White2::OnOK() { CDialog::OnOK(); } void DLG_White2::OnPlfileAddAdd() { m_bCheckLocalBack = m_B_CheckLocalBack.GetCheck(); m_bReUpload = m_B_ReUpload.GetCheck(); Inport_Field Field[] = { //{_T("姓名"),0,0,-1}, //{_T("昵称"),0,1,-1}, //{_T("性别"),0,2,-1}, //{_T("生日"),0,3,-1}, //{_T("公司"),0,4,-1}, //{_T("职务"),0,5,-1}, //{_T("地址"),0,6,-1}, {_T("手机号码"),0,7,-1}, //{_T("电话"),0,8,-1}, //{_T("传真"),0,9,-1}, //{_T("Email"),0,10,-1}, //{_T("QQ号码"),0,11,-1}, //{_T("备注"),0,12,-1}, }; DLG_User_InportP2 dlg(this); dlg.SetParam(&Field[0],sizeof(Field)/sizeof(Inport_Field),12); if ( dlg.DoModal() == IDOK ) { } CString str; str.Format(_T("%d") , m_lMobileCount ); m_E_Count.SetWindowText(str); } BOOL DLG_White2::OnInitDialog() { CDialog::OnInitDialog(); //m_E_Count.SetWindowText(_T("0")); m_B_CheckLocalBack.SetCheck(false); m_B_ReUpload.SetCheck(false); m_B_Del.EnableWindow(false); m_B_Reset.EnableWindow(false); m_strCount.Format(_T("总数量:%d"),m_White2.lWhite2Count); m_strAudit.Format(_T("已通过:%d"),m_White2.lWhite2Audit); m_strSubmit.Format(_T("待审核:%d"),m_White2.lWhite2Submit); m_strMobile2 = CString(_T("")); m_strAddTime = CString(_T("")); if ( this->m_pMainFrame ) { m_AdoRSL2.SetAdoConnection(&m_pMainFrame->m_adoConnection); } UpdateData(false); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void DLG_White2::AddUser(PAddress user,long lItem) { ExChar(user.szMobile,_T(" ")); ExChar(user.szMobile,_T("\r")); ExChar(user.szMobile,_T("\n")); ExChar(user.szMobile,_T("\t")); ExChar(user.szMobile,_T("'")); ExChar(user.szMobile,_T("\"")); ExMobileGZM(user.szMobile); //去除国际码 if ( !isMobileNum( user.szMobile ) ) //不是手机号码,不用添加或修改 return ; CString str; //判断是否是本地黑名单 if (m_bCheckLocalBack) { str.Format( _T("select * from back where Mobile='%s' and Status=1") , user.szMobile ); if ( m_AdoRSL2.Open(str) && !m_AdoRSL2.IsEOF() ) { return ; } } if ( m_strSort.Add(user.szMobile) ) m_lMobileCount++; } BOOL DLG_White2::CreateNullFile() { return true; } void DLG_White2::OnPlfileAddUpload() { if ( m_bUpload ) { m_bUpload = false; CString str; str.Format(_T("上传白名单号码停止,已上传:%d,成功:%d,失败:%d") , m_dwUpCount,m_dwUpSucess,m_dwUpFail); MessageBox(str , _T("消息") , MB_ICONINFORMATION ); m_dwAllCount = 0; m_dwUpCount= 0; m_dwUpSucess=0; m_dwUpFail=0; m_P_GDT.SetRange32(0,m_dwAllCount); m_B_Add.EnableWindow(true); m_B_Upload.SetWindowText(_T("上传白名单号码")); } else { m_bReUpload = m_B_ReUpload.GetCheck(); //上传文件 if ( m_lMobileCount<0 ) { MessageBox(_T("请先导入号码后再上传!"),_T("错误") , MB_ICONWARNING ); GetDlgItem(IDC_PLFILE_ADD_UPLOAD)->SetFocus(); return ; } m_dwAllCount = m_lMobileCount; m_dwUpCount= 0; m_dwUpSucess=0; m_dwUpFail=0; m_P_GDT.SetRange32(0,m_dwAllCount); m_B_Add.EnableWindow(false); m_B_Upload.SetWindowText(_T("停止上传")); m_bUpload = true; UpFile_Next(); } } void DLG_White2::OnTimer(UINT_PTR nIDEvent) { CDialog::OnTimer(nIDEvent); } BOOL DLG_White2::ProcessSocket(Socket_Head_Add *pHead, BYTE *pFrame) { if ( pHead->lFuncType == SMSFUNC_WHITE2_GET ) { ANS_White2_Get * pGet = (ANS_White2_Get *)pFrame; if ( pGet->lStatus==1 ) { m_strCount.Format(_T("总数量:%d"),pGet->lWhite2Count); m_strAudit.Format(_T("已通过:%d"),pGet->lWhite2Audit); m_strSubmit.Format(_T("待审核:%d"),pGet->lWhite2Submit); if ( pGet->lQueryType == 1 ) //查询号码 { if ( pGet->lWhite2ID>0 ) { if ( pGet->lWhite2Status==1 ) m_strMobile2.Format(_T("%s 已通过") , pGet->szWhite2Mobile); else m_strMobile2.Format(_T("%s 待审核") , pGet->szWhite2Mobile); m_strAddTime.Format(_T("加入时间 %04d.%02d.%02d") , pGet->tWhie2AddTime.wYear,pGet->tWhie2AddTime.wMonth,pGet->tWhie2AddTime.wDay); m_B_Del.EnableWindow(true); m_B_Reset.EnableWindow(true); m_White2 = * pGet; } else { m_strMobile2.Format(_T("%s 无记录") , pGet->szMobile); } UpdateData(false); } else { MessageBox(_T("查询异常,请检查。"),_T("错误") , MB_ICONWARNING); } } return true; } if ( pHead->lFuncType == SMSFUNC_WHITE2_OPER ) { ANS_White2_Oper * pGet = (ANS_White2_Oper *)pFrame; if ( pGet->lStatus==1 ) { m_strCount.Format(_T("总数量:%d"),pGet->lWhite2Count); m_strAudit.Format(_T("已通过:%d"),pGet->lWhite2Audit); m_strSubmit.Format(_T("待审核:%d"),pGet->lWhite2Submit); UpdateData(false); } if ( pGet->lOperType==1 ) //删除号码 { if ( pGet->lStatus==1 ) { MessageBox(_T("删除白名单号码成功。"),_T("信息") , MB_ICONINFORMATION); } else { MessageBox(_T("删除白名单号码成功失败。"),_T("错误") , MB_ICONWARNING); } } if ( pGet->lOperType==0 ) //重置状态号码 { if ( pGet->lStatus==1 ) { MessageBox(_T("重置白名单号码状态成功,请等待审核后生效。"),_T("信息") , MB_ICONINFORMATION); } else { MessageBox(_T("重置白名单号码状态成功失败。"),_T("错误") , MB_ICONWARNING); } } if ( pGet->lOperType==2 ) //添加号码 { if ( pGet->lStatus==1 ) { MessageBox(_T("添加白名单成功,如果需要添加多个号码,建议使用导入功能。"),_T("信息") , MB_ICONINFORMATION); } else { MessageBox(_T("添加白名单失败,请检查号码是否重复、是否为移动号码。"),_T("错误") , MB_ICONWARNING); } } } if ( pHead->lFuncType == SMSFUNC_WHITE2_UPLOAD ) { ANS_White2_Upload * pUp = (ANS_White2_Upload *)pFrame; if ( pUp->lStatus ==1 ) //上传成功 { m_dwUpCount= pUp->lUpCount; m_dwUpSucess += pUp->lSucess; m_dwUpFail += pUp->lFail; m_P_GDT.SetPos(m_dwUpCount); UpFile_Next(); } else { MessageBox(_T("上传白名单产生未知错误!") , _T("错误") , MB_ICONWARNING ); if ( m_bUpload) { OnPlfileAddUpload(); //停止上传 } } return true; } return false; } BOOL DLG_White2::UpFile_Next() { if ( !m_bUpload ) return false; if ( m_strSort.GetCount()<(long)m_dwAllCount ) //数据不对,取消上传 return false; long lUpLen = 128; //每次上传128个号码 if ( m_dwUpCount + lUpLen>m_dwAllCount ) { lUpLen = m_dwAllCount-m_dwUpCount; } if ( lUpLen<=0 ) { //上传已完成 CString str; str.Format(_T("上传白名单号码成功,共:%d,成功:%d,失败:%d") , m_dwUpCount,m_dwUpSucess,m_dwUpFail); MessageBox(str , _T("消息") , MB_ICONINFORMATION ); EndDialog(IDOK); return true; } long lSize = sizeof(REQ_White2_Upload) + sizeof(ANS_White2_Data)*lUpLen; BYTE * pData = new BYTE[lSize]; memset(pData , 0 , lSize ); REQ_White2_Upload * pUp = (REQ_White2_Upload * )pData; ANS_White2_Data * pUpData = (ANS_White2_Data *)(pData+sizeof(REQ_White2_Upload)); pUp->lAllCount = m_dwAllCount; pUp->lUpCount = m_dwUpCount; pUp->lCount = lUpLen; pUp->lCorpID = m_pMainFrame->m_lCorpID; pUp->lUserID = m_pMainFrame->m_lUserID; pUp->lReset = m_bReUpload; for ( int i=0 ; i< lUpLen; i++ ) { _tcscpy(pUpData[i].szMobile , m_strSort.GetAt(pUp->lUpCount+i)); } m_pMainFrame->SendFrame(SMSFUNC_WHITE2_UPLOAD , pData , lSize ); return true; } void DLG_White2::OnClose() { if ( !m_bUpload && m_lMobileCount>0 ) { int iRet = MessageBox( _T("已导入号码数据,需要执行\"上传白名单\"才生效。\r\n是否放弃上传而退出?") , _T("提问") , MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2); if ( iRet != IDYES ) { return ; } } if ( m_bUpload ) { int iRet = MessageBox( _T("正在上传白名单号码,是否确认中断操作?") , _T("提问") , MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2); if ( iRet != IDYES ) { return ; } } CDialog::OnClose(); } void DLG_White2::Setparam(ANS_White2_Get get) { m_White2 =get; } void DLG_White2::OnBnClickedPlfileQuery() { if ( !UpdateData(true) ) return ; if ( m_strMobile.GetLength()<=0 ) { MessageBox(_T("请输入需要查询的手机号码。"),_T("信息"),MB_ICONINFORMATION); GetDlgItem(IDC_PLFILE_MOBILE)->SetFocus(); return ; } //查询前,先置默认查询不到的状态 m_strMobile2 = CString(_T("")); m_strAddTime = CString(_T("")); m_B_Del.EnableWindow(false); m_B_Reset.EnableWindow(false); UpdateData(false); memset(&m_White2,0,sizeof(m_White2)); REQ_White2_Get * pReq = new REQ_White2_Get; memset(pReq,0,sizeof(REQ_White2_Get)); pReq->lQueryType = 1; //查询号码 pReq->lCorpID = m_pMainFrame->m_lCorpID; pReq->lUserID = m_pMainFrame->m_lUserID; ::ExMobileGZM(m_strMobile); _tcscpy(pReq->szMobile , m_strMobile); //发送请求查看 m_pMainFrame->SendFrame( SMSFUNC_WHITE2_GET , (BYTE*)pReq , sizeof(REQ_White2_Get) ); } void DLG_White2::OnBnClickedPlfileAdd() { if ( !UpdateData(true) ) return ; if ( m_strMobile.GetLength()<=0 ) { MessageBox(_T("请输入需要查询的手机号码。"),_T("信息"),MB_ICONINFORMATION); GetDlgItem(IDC_PLFILE_MOBILE)->SetFocus(); return ; } ::ExMobileGZM(m_strMobile); if ( !::isMobileNum(m_strMobile) ) { MessageBox(_T("请输入正确的手机号码。"),_T("信息"),MB_ICONINFORMATION); GetDlgItem(IDC_PLFILE_MOBILE)->SetFocus(); return ; } //查询前,先置默认查询不到的状态 m_strMobile2 = CString(_T("")); m_strAddTime = CString(_T("")); m_B_Del.EnableWindow(false); m_B_Reset.EnableWindow(false); UpdateData(false); memset(&m_White2,0,sizeof(m_White2)); REQ_White2_Oper * pReq = new REQ_White2_Oper; memset(pReq,0,sizeof(REQ_White2_Oper)); pReq->lOperType = 2; //添加号码 pReq->lCorpID = m_pMainFrame->m_lCorpID; pReq->lUserID = m_pMainFrame->m_lUserID; _tcscpy(pReq->szMobile , m_strMobile); //发送请求查看 m_pMainFrame->SendFrame( SMSFUNC_WHITE2_OPER , (BYTE*)pReq , sizeof(REQ_White2_Oper) ); } void DLG_White2::OnBnClickedPlfileDel() { if (m_White2.lWhite2ID<=0 ) { MessageBox(_T("请先查询白名单记录,再进行删除操作。"),_T("信息"),MB_ICONINFORMATION); GetDlgItem(IDC_PLFILE_MOBILE)->SetFocus(); return ; } //查询前,先置默认查询不到的状态 m_strMobile2 = CString(_T("")); m_strAddTime = CString(_T("")); m_B_Del.EnableWindow(false); m_B_Reset.EnableWindow(false); UpdateData(false); REQ_White2_Oper * pReq = new REQ_White2_Oper; memset(pReq,0,sizeof(REQ_White2_Oper)); pReq->lOperType = 1; //删除号码 pReq->lCorpID = m_pMainFrame->m_lCorpID; pReq->lUserID = m_pMainFrame->m_lUserID; pReq->lWhtie2ID = m_White2.lWhite2ID; _tcscpy(pReq->szMobile , m_White2.szWhite2Mobile); memset(&m_White2,0,sizeof(m_White2)); //发送请求查看 m_pMainFrame->SendFrame( SMSFUNC_WHITE2_OPER , (BYTE*)pReq , sizeof(REQ_White2_Oper) ); } void DLG_White2::OnBnClickedPlfileReset() { if (m_White2.lWhite2ID<=0 ) { MessageBox(_T("请先查询白名单记录,再进行删除操作。"),_T("信息"),MB_ICONINFORMATION); GetDlgItem(IDC_PLFILE_MOBILE)->SetFocus(); return ; } //查询前,先置默认查询不到的状态 m_strMobile2 = CString(_T("")); m_strAddTime = CString(_T("")); m_B_Del.EnableWindow(false); m_B_Reset.EnableWindow(false); UpdateData(false); REQ_White2_Oper * pReq = new REQ_White2_Oper; memset(pReq,0,sizeof(REQ_White2_Oper)); pReq->lOperType = 0; //重置状态 pReq->lCorpID = m_pMainFrame->m_lCorpID; pReq->lUserID = m_pMainFrame->m_lUserID; pReq->lWhtie2ID = m_White2.lWhite2ID; _tcscpy(pReq->szMobile , m_White2.szWhite2Mobile); memset(&m_White2,0,sizeof(m_White2)); //发送请求查看 m_pMainFrame->SendFrame( SMSFUNC_WHITE2_OPER , (BYTE*)pReq , sizeof(REQ_White2_Oper) ); } void DLG_White2::OnEnChangePlfileMobile() { UpdateData(true); m_strMobile2 = CString(_T("")); m_strAddTime = CString(_T("")); m_B_Del.EnableWindow(false); m_B_Reset.EnableWindow(false); UpdateData(false); memset(&m_White2,0,sizeof(m_White2)); }