123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- // SendReg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "AutoRun.h"
- #include "SendReg.h"
- #include "mysqldata.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- extern DWORD g_nSendCode;
- /////////////////////////////////////////////////////////////////////////////
- // SendReg dialog
- SendReg::SendReg(CWnd* pParent /*=NULL*/)
- : CDialog(SendReg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(SendReg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- m_times=0;
- }
- void SendReg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(SendReg)
- DDX_Control(pDX, IDC_LIST1, m_List1);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(SendReg, CDialog)
- //{{AFX_MSG_MAP(SendReg)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_WM_TIMER()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // SendReg message handlers
- BOOL SendReg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- m_List1.SetHeadings("账号,100;号码,100;内容,100;时间,100;费用,100;报告,100" );
- m_List1.LoadColumnInfo (119);
- OnButton1();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void SendReg::OnButton1()
- {
- // TODO: Add your control notification handler code here
- GetDlgItem(IDC_BUTTON1)->EnableWindow(0);
- m_times=0;
- SetTimer(1, 1000, NULL);
- Refresh();
- CRecordset myset(&g_db);
- CString sql="select count(*) as cot from sendreg";
- myset.Open (CRecordset::forwardOnly, sql);
- myset.GetFieldValue ("cot", sql);
- myset.Close();
- m_List1array.SetSize(atol(sql) , 1 );
- RstSendReg rsSt;
- rsSt.Open();
- DWORD ii=0;
- while(!rsSt.IsEOF())
- {
- m_List1array.ElementAt (ii).RemoveAll ();
- m_List1array.ElementAt (ii).Add(rsSt.m_account) ;
- m_List1array.ElementAt (ii).Add(rsSt.m_phones) ;
- m_List1array.ElementAt (ii).Add(rsSt.m_content) ;
- m_List1array.ElementAt (ii).Add(rsSt.m_timestamp) ;
- m_List1array.ElementAt (ii).Add(rsSt.m_msgcount) ;
- m_List1array.ElementAt (ii).Add("发送:"+rsSt.m_log) ;
- ii++;
- rsSt.MoveNext();if(m_List1array.GetSize ()<=ii)break;
- }
- rsSt.Close();m_List1array.SetSize(ii , 1 );
-
- FillGrid();
- }
- void SendReg::FillGrid()
- {
- m_List1.DeleteAllItems2 ();
- int ii=0;
- m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
- int count=0;
-
- for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
- {
- m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
- }
-
- m_List1.m_arLabels.SetSize(count, 1);
- ii=count;
- m_List1.m_LabelCount=ii;
- m_List1.SetItemCountEx (ii);
- }
- void SendReg::Refresh()
- {
- RstSendReg rsSt;
- rsSt.m_strFilter ="[status]<>'OK'";
- rsSt.Open();
- DWORD ii=0;
- CString timestamp="";
- CStringArray idarray;
- while(!rsSt.IsEOF())
- {
- timestamp+=rsSt.m_timestamp ;
- idarray.Add (rsSt.m_id);
- ii++;
- if(ii>9)break;
- rsSt.MoveNext();
- }
- rsSt.Close();
- if(timestamp.IsEmpty ())return;
- CString str;
- str=m_strLoginID;
- str+="\r\n";
- str+=m_strLoginPwd;
- str+="\r\n";
- str+=timestamp;
- BYTE *pData=new BYTE[str.GetLength ()];
- memcpy(pData, str.GetBuffer (0), str.GetLength ());
- str.ReleaseBuffer ();
- EncryptFile2(pData, str.GetLength (), "888666333");
- g_nSendCode=4;
- g_pMainWnd->ProcessChatMessageRequest2(pData, str.GetLength ());
- g_nSendCode=0;
- delete []pData;
- if(g_bSendOK==0)return;
- if(g_str.GetLength ())
- {
- CStringArray strarray;
- int pos=g_str.Find (",");
- if(pos!=-1)
- {
- strarray.Add(g_str.Left (pos));
- g_str=g_str.Right (g_str.GetLength ()-pos-1);
- pos=g_str.Find (",");
- while(pos!=-1)
- {
- strarray.Add (g_str.Left (pos));
- g_str=g_str.Right (g_str.GetLength ()-pos-1);
- pos=g_str.Find (",");
- }
- strarray.Add (g_str);
- }
- else
- strarray.Add (g_str);
- if(strarray.GetSize ()!=idarray.GetSize ())return;
- CString sql,sok;
- for(int i=0; i<strarray.GetSize (); i++)
- {
- str=strarray.ElementAt (i);
- pos=str.Find ('/');
- if(pos==-1)continue;
- if(str.Left (pos)==str.Right (str.GetLength ()-pos-1) && atoi(str.Left (pos))!=0)
- sok="OK";
- else
- sok="0";
- sql.Format("update sendreg set [log]='"+str+"',[status]='"+sok+"' where [autoid]=%d", atol(idarray.ElementAt (i)));
- g_db.ExecuteSQL (sql);
- }
- }
- }
- void SendReg::OnTimer(UINT nIDEvent)
- {
- // TODO: Add your message handler code here and/or call default
- m_times++;
- if(m_times>10)
- {
- KillTimer(nIDEvent);
- GetDlgItem(IDC_BUTTON1)->EnableWindow(1);
- GetDlgItem(IDC_BUTTON1)->SetWindowText("刷新");
- return;
- }
- CString str;
- str.Format ("刷新(%d)", 11-m_times);
- GetDlgItem(IDC_BUTTON1)->SetWindowText(str);
- }
|