📄 gsms.cpp
字号:
// GSMS.cpp : implementation file
//
#include "stdafx.h"
#include "SMS.h"
#include "GSMS.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGSMS dialog
CGSMS::CGSMS(CWnd* pParent /*=NULL*/)
: CDialog(CGSMS::IDD, pParent)
{
//{{AFX_DATA_INIT(CGSMS)
m_makegroup = _T("");
m_content = _T("");
//}}AFX_DATA_INIT
}
void CGSMS::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGSMS)
DDX_Control(pDX, IDC_COMBO1, m_make);
DDX_CBString(pDX, IDC_COMBO1, m_makegroup);
DDX_Text(pDX, IDC_EDIT1, m_content);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGSMS, CDialog)
//{{AFX_MSG_MAP(CGSMS)
ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGSMS message handlers
void CGSMS::OnOK()
{
// TODO: Add extra validation here
_variant_t strQuery,Holder;
UpdateData(true);
CEdit *pEDit=((CEdit*)GetDlgItem(IDC_EDIT2));
CString outstring[20];
int longth=0;
int Countbit=68;
CString name=theApp.m_sCurrentUser;
name.TrimRight(" ");
CTime nowSMS=CTime::GetCurrentTime();
CString s=nowSMS.Format("%Y-%m-%d %H:%M");
if(""==m_makegroup)
{ AfxMessageBox(_T("请选择短信发送组"), MB_ICONEXCLAMATION);
return;
}
if(""==m_content)
{
AfxMessageBox(_T("请填写短信内容"), MB_ICONEXCLAMATION);
return;
}
CString message=name+":"+m_content;
CharASCII(message,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<=miCount;i++)
{ theApp.submitSM(outstring[j],"04410",mobilenm[i]);
}
}
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 ;
}
strQuery="insert information (name,content,sbdate) values('"+theApp.m_sCurrentUser+"','"+m_content+"','"+s+"')";
if ( theApp.ADOExecute(theApp.m_pADOSet, strQuery) )
{
AfxMessageBox(_T("短信发送完毕!"), MB_ICONINFORMATION);
return;
}
else
{
AfxMessageBox(_T("添加记录失败!"), MB_ICONEXCLAMATION);
return;
}
CDialog::OnOK();
}
BOOL CGSMS::OnInitDialog()
{
CDialog::OnInitDialog();
CComboBox* pComb=(CComboBox*)this->GetDlgItem(IDC_COMBO1);
_variant_t strQuery,Holder;
strQuery="select *from gname";
theApp.ADOExecute(theApp.m_pADOSet, strQuery);
iCount=theApp.m_pADOSet->GetRecordCount();
if (iCount>0)
{
theApp.m_pADOSet->MoveFirst();
for (int i=0;i<iCount;i++)
{Holder=theApp.m_pADOSet->GetCollect("groupname");
strText=(Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
pComb->AddString(strText);
theApp.m_pADOSet->MoveNext();
}
}
// TODO: Add extra initialization here
return true; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CGSMS::OnSelchangeCombo1()
{
_variant_t strQuery,Holder;
m_make.GetLBText (m_make.GetCurSel(),list);
strQuery ="select *from guser where gname='"+list+"'";
theApp.ADOExecute(theApp.m_pADOSet, strQuery);
miCount = theApp.m_pADOSet->GetRecordCount();
if (miCount>0 )
{
for(int i=0;i<miCount;i++)
{
Holder=theApp.m_pADOSet->GetCollect("gmobilenumber");
mobilenm[i]=(Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
theApp.m_pADOSet->MoveNext();
}
}
else {return;}
list="";
// TODO: Add your control notification handler code here
}
void CGSMS::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 + -