📄 message.cpp
字号:
// MESSAGE.cpp : implementation file
//
#include "stdafx.h"
#include "SMS.h"
#include "MESSAGE.h"
#include "math.h"
#include "mmsystem.h"
#include "Export.h"
#include "MainFrm.h"
#include "string.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMESSAGE dialog
CMESSAGE::CMESSAGE(CWnd* pParent /*=NULL*/)
: CDialog(CMESSAGE::IDD, pParent)
{
//{{AFX_DATA_INIT(CMESSAGE)
m_message1 = _T("");
//}}AFX_DATA_INIT
}
void CMESSAGE::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMESSAGE)
DDX_Text(pDX, IDC_EDIT1, m_message1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMESSAGE, CDialog)
//{{AFX_MSG_MAP(CMESSAGE)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMESSAGE message handlers
void CMESSAGE::OnButton1()
{
UpdateData(true);
CString mes;
CString outstring[20];
int longth=0;
int Countbit=68;
CString name=theApp.m_sCurrentUser;
name.TrimRight(" ");
if ( ""==m_message1)
{
AfxMessageBox(_T("请填写需要通知的内容"), MB_ICONEXCLAMATION);
return;
}
mes=name+":"+m_message1;
CharASCII(mes,outstring,longth,Countbit);
if (IFInitInterface(3, 1, "10.33.2.144 5018 5000")) //IP地址 端口号 超时时间
{
if (!Login("njwggj", "njwggj"))
{
AfxMessageBox("Fail to login into smc!");
IFExitInterface();
}
else
{
for (int j=0;j<=longth;j++)
{
for(int i=0;i<=jkcount;i++)
{
theApp.submitSM(outstring[j],"04410", mobilenum[i]);
}
}
AfxMessageBox("短信发送完毕!");
Logout();
IFExitInterface();
}
}
else
{
AfxMessageBox("Fail to send to NMC");
}
if (IFInitInterface(3, 1, "10.33.2.144 5018 5000")) //IP地址 端口号 超时时间
{
//Login("njwggj", "njwggj");
if (!Login("njwggj_1", "njwggj_1"))
{
theApp.Login=0;
AfxMessageBox("Fail to login into smc!");
IFExitInterface();
return ;
}
else
{
//AfxMessageBox("Success to login in");
theApp.Login=1;
}
}
else
{
theApp.Login=0;
AfxMessageBox("Fail to initialize interface");
return ;
}
// TODO: Add your control notification handler code here
}
BOOL CMESSAGE::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
((CEdit*)GetDlgItem(IDC_EDIT1))->SetLimitText(500);
_variant_t Holder, strQuery;
strQuery = "select * from user_info ";
theApp.ADOExecute(theApp.m_pADOSet, strQuery);
jkcount = theApp.m_pADOSet->GetRecordCount();
theApp.m_pADOSet->MoveFirst();
for( int i=0;i<jkcount;i++)
{ Holder=theApp.m_pADOSet->GetCollect("changhao");
mobilenum[i]=(Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
theApp.m_pADOSet->MoveNext();
}
// Set Caption Font
//CFont m_Font;
return TRUE;
}
void CMESSAGE::CharASCII(CString m_input,CString * output,int & longth,int howlongth)
{
CString strtemp,strtemp1;
CString m_output;
int y=0;
int x=0;
int b=0;
LONG len,k;
len=m_input.GetLength();
m_output= _T("");
int isto=0;
for(k=0;k<len;k++)
{
char bt=m_input.GetAt(k);
strtemp.Format("%02X ",bt);
int lentemp=strtemp.GetLength();
if(lentemp==3)
{output[longth]+=m_input.GetAt(k);
x++;
}
else
{
isto++;//double bit (High /low)
b=isto/2;
if((isto%2!=0)&&(y>howlongth))
output[longth+1]+=m_input.GetAt(k);
else
{output[longth]+=m_input.GetAt(k);
}
}
y=x+b;
if(y>=howlongth)
{y=0;//reset the Count for Per line
x=0;
b=0;
isto=0;
longth++;// add count for line
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -