📄 sbsms.cpp
字号:
// SBSMS.cpp : implementation file
//
#include "stdafx.h"
#include "SMS.h"
#include "SBSMS.h"
#include "SELECTG.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// SBSMS dialog
SBSMS::SBSMS(CWnd* pParent /*=NULL*/)
: CDialog(SBSMS::IDD, pParent)
{
//{{AFX_DATA_INIT(SBSMS)
m_gzrn = _T("");
m_group = _T("");
//}}AFX_DATA_INIT
}
void SBSMS::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(SBSMS)
DDX_Text(pDX, IDC_EDIT2, m_gzrn);
DDX_Text(pDX, IDC_EDIT1, m_group);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(SBSMS, CDialog)
//{{AFX_MSG_MAP(SBSMS)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// SBSMS message handlers
void SBSMS::OnButton1()
{
UpdateData(true);
CString message;
CString outstring[20];
int longth=0;
int Countbit=68;
_variant_t strQuery;
CTime nowSMS=CTime::GetCurrentTime();
CString s=nowSMS.Format("%Y-%m-%d %H:%M");
m_gzrn.TrimRight(" ");
m_group.TrimRight(" ");
CString name=theApp.m_sCurrentUser;
name.TrimRight(" ");
if(""==m_group)
{ AfxMessageBox(_T("请选择要发送短信的用户组"), MB_ICONEXCLAMATION);
return;
}
else if ( ""==m_gzrn)
{
AfxMessageBox(_T("请填写需要上报的故障内容"), MB_ICONEXCLAMATION);
return;
}
message=name+":"+m_gzrn;
for(int k=0;k<6;k++)
{
if(theApp.group[k]=="省公司领导")
{message=message+"."+"省监控报送";
break;
}
}
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<=sbcount;i++)
{ theApp.submitSM(outstring[j],"04410", theApp.mobile[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,sbperosn) values('"+theApp.m_sCurrentUser+"','"+m_gzrn+"','"+s+"','"+m_group+"')";
if ( theApp.ADOExecute(theApp.m_pADOSet, strQuery) )
{
AfxMessageBox(_T("短信发送完毕!"), MB_ICONINFORMATION);
}
else
{
AfxMessageBox(_T("添加记录失败!"), MB_ICONEXCLAMATION);
}
// TODO: Add your control notification handler code here
}
void SBSMS::OnButton2()
{
CSELECTG dlg;
dlg.pSBSMS=this;
dlg.DoModal();
// TODO: Add your control notification handler code here
}
void SBSMS::OnButton3()
{
CDialog::OnCancel();
// TODO: Add your control notification handler code here
}
BOOL SBSMS::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
((CEdit*)GetDlgItem(IDC_EDIT2))->SetLimitText(500);
CEdit* pEdit=(CEdit*)this->GetDlgItem(IDC_EDIT1);
pEdit->LockWindowUpdate();
return TRUE;
}
void SBSMS::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
}
}
}
void SBSMS::view( CString ViewGroup,int count)
{
CEdit* pEdit=(CEdit*)this->GetDlgItem(IDC_EDIT1);
pEdit->SetWindowText(ViewGroup);
sbcount=count;
m_group=ViewGroup;
pEdit->LockWindowUpdate();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -