⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 constellation.cpp

📁 这个一个联通短信网关程序.并且在SP已经运行稳定.很有学习价值
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// Constellation.cpp : implementation file
//

#include "stdafx.h"
#include "moUniteService.h"
#include "Constellation.h"


// CConstellation

IMPLEMENT_DYNAMIC(CConstellation, CWnd)
CConstellation::CConstellation()
{
}

CConstellation::~CConstellation()
{
}
void CConstellation::ProcessMO(CString strCmd,CString strCPhone)
{
	CString strCommand		=strCmd;
	CString strClientPhone	=strCPhone;
	CADODatabase mo_db;
	CADORecordset rsc(&mo_db);
	CADORecordset rs(&mo_db);
		if(mo_db.OpenSQLServerDirect(MyReg::GetDBIP(),MyReg::GetDBUserID(),MyReg::GetDBPassword(),"ewsv3"))
		{
			CString strCode;
			CString strBirthday;
			CString strMsgC;
			strCode=strCommand.Mid(2,2).MakeUpper();
			strBirthday=strCommand.Mid(4);
			CTime time=CTime::GetCurrentTime();
			CString strCurrentTime;

			rs.Open("select * from sms_Constellation_Log where 1=0");			
			if(strCode.GetLength()>0)
			{
				//添加MO记录到日志表中
				rs.AddNew();
				rs.SetFieldValue("usermobile",strClientPhone);
				rs.SetFieldValue("code",strCode);
				rs.SetFieldValue("msgcontent",strBirthday);
				rs.Update();
				CString strSql;
				if(strBirthday.GetLength()>0)//today luck
				{
					CString strCname;
					CString strLuck;
					if(strCode=="01")
					{
						strSql="select  b.cname,d.dayluck from sms_Constellation_BaseInfo b,sms_Constellation_DayLuck d ";
						strSql+="where b.cbm=d.cbm and b.begindate<="+strBirthday+" AND "+strBirthday+"<=b.Enddate AND ";
						strSql+="CONVERT(VARCHAR(10),DAYRECORD,110)=CONVERT(VARCHAR(10),GETDATE(),110)";
						rsc.Open(strSql);
						if(rsc.IsBOF() &&rsc.IsEOF())
						{
							strMsgC="您输入信息错误。今日运程操作方法:8801生日,生日不包括年份。如查询8月9日出生的人今日运程,发短信88010809到8765即可。";
						}
						else
						{
							while(!rsc.IsEOF())
							{
								if(strMsgC.GetLength()>0)
								{
									::SGIP_Send("88",MyReg::GetUnionSPNumber(),strClientPhone,MyReg::GetUnionUsername(),
										MyReg::GetUnionPassword(),MyReg::GetUnionIP(),MyReg::GetUnionPort(),strClientPhone,strMsgC,MyReg::GetPayTypeUnion(),"60");
									rs.AddNew();
									rs.SetFieldValue("usermobile",strClientPhone);
									rs.SetFieldValue("Code",strCode);
									rs.SetFieldValue("msgcontent",strMsgC);
									rs.SetFieldValue("moormt",1);
									rs.Update();
								}
								strMsgC="";
								rsc.GetFieldValue("cname",strCname);
								rsc.GetFieldValue("dayluck",strLuck);
								strMsgC.Format("%s今日运程:%s",strCname,strLuck);
								rsc.MoveNext();
							}
						}
						rsc.Close();
					}
					else if(strCode=="02")//tomorrow luck
					{
						strSql="select  b.cname,d.dayluck from sms_Constellation_BaseInfo b,sms_Constellation_DayLuck d ";
						strSql+="where b.cbm=d.cbm and b.begindate<="+strBirthday+" AND "+strBirthday+"<=b.Enddate AND ";
						strSql+="CONVERT(VARCHAR(10),DAYRECORD,110)=CONVERT(VARCHAR(10),GETDATE()+1,110)";
						rsc.Open(strSql);
						if(rsc.IsBOF() &&rsc.IsEOF())
						{
							strMsgC="您输入信息错误。明日运程操作方法:8802生日,生日不包括年份。如查询8月9日出生的人明日运程,发短信88020809到8765即可.";
						}
						else
						{
							while(!rsc.IsEOF())
							{
								if(strMsgC.GetLength()>0)
								{									
									::SGIP_Send("88",MyReg::GetUnionSPNumber(),strClientPhone,MyReg::GetUnionUsername(),
										MyReg::GetUnionPassword(),MyReg::GetUnionIP(),MyReg::GetUnionPort(),
										strClientPhone,strMsgC,MyReg::GetPayTypeUnion(),"60");
									rs.AddNew();
									rs.SetFieldValue("usermobile",strClientPhone);
									rs.SetFieldValue("Code",strCode);
									rs.SetFieldValue("msgcontent",strMsgC);
									rs.SetFieldValue("moormt",1);
									rs.Update();
								}
								strMsgC="";
								rsc.GetFieldValue("cname",strCname);
								rsc.GetFieldValue("dayluck",strLuck);
								strMsgC.Format("%s明日运程:%s",strCname,strLuck);
								rsc.MoveNext();
							}
						}
						rsc.Close();
					}
					else if(strCode=="03")//week luck
					{
						strCurrentTime.Format("%2d%2d",time.GetMonth(),time.GetDay());
						strSql="select  b.cname,w.weekluck from sms_Constellation_BaseInfo b,sms_Constellation_WeekLuck w ";
						strSql+="where b.cbm=w.cbm and b.begindate<="+strBirthday+" AND "+strBirthday+"<=b.Enddate AND ";
						strSql+="w.beginday<="+strCurrentTime+" and w.endday>="+strCurrentTime;
						rsc.Open(strSql);
						if(rsc.IsBOF() &&rsc.IsEOF())
						{
							strMsgC="您输入信息错误。本周运程操作方法:8803生日,生日不包括年份。如查询8月9日出生的人的本周运程,发短信88030809到8765即可";
						}
						else
						{
							while(!rsc.IsEOF())
							{
								if(strMsgC.GetLength()>0)
								{
									::SGIP_Send("88",MyReg::GetUnionSPNumber(),strClientPhone,MyReg::GetUnionUsername(),
										MyReg::GetUnionPassword(),MyReg::GetUnionIP(),MyReg::GetUnionPort(),strClientPhone,
										strMsgC,MyReg::GetPayTypeUnion(),"60");
									rs.AddNew();
									rs.SetFieldValue("usermobile",strClientPhone);
									rs.SetFieldValue("Code",strCode);
									rs.SetFieldValue("msgcontent",strMsgC);
									rs.SetFieldValue("moormt",1);
									rs.Update();
								}
								strMsgC="";
								rsc.GetFieldValue("cname",strCname);
								rsc.GetFieldValue("weekluck",strLuck);
								strMsgC.Format("%s本周运程:%s",strCname,strLuck);
								rsc.MoveNext();
							}
						}
						rsc.Close();
					}
					else if(strCode=="04")//month luck
					{
						strCurrentTime.Format("%2d",time.GetMonth());
						strSql="select  b.cname,w.monthluck from sms_Constellation_BaseInfo b,sms_Constellation_monthLuck w ";
						strSql+="where b.cbm=w.cbm and b.begindate<="+strBirthday+" AND "+strBirthday+"<=b.Enddate AND ";
						strSql+="w.months="+strCurrentTime;
						rsc.Open(strSql);
						if(rsc.IsBOF() &&rsc.IsEOF())
						{
							strMsgC="您输入信息错误。本月运程操作方法:8804生日,生日不包括年份。如查询8月9日出生的人的本月运程,发短信88040809到8765即可.";
						}
						else
						{
							while(!rsc.IsEOF())
							{
								if(strMsgC.GetLength()>0)
								{
									::SGIP_Send("88",MyReg::GetUnionSPNumber(),strClientPhone,MyReg::GetUnionUsername(),
										MyReg::GetUnionPassword(),MyReg::GetUnionIP(),MyReg::GetUnionPort(),
										strClientPhone,strMsgC,MyReg::GetPayTypeUnion(),"60");
									rs.AddNew();
									rs.SetFieldValue("usermobile",strClientPhone);
									rs.SetFieldValue("Code",strCode);
									rs.SetFieldValue("msgcontent",strMsgC);
									rs.SetFieldValue("moormt",1);
									rs.Update();
								}
								strMsgC="";
								rsc.GetFieldValue("cname",strCname);
								rsc.GetFieldValue("monthluck",strLuck);
								strMsgC.Format("%s本月运程:%s",strCname,strLuck);
								rsc.MoveNext();
							}
						}
						rsc.Close();
					}
					else if(strCode=="05")//year luck
					{
						strCurrentTime.Format("%2d",time.GetYear());
						strSql="select  b.cname,w.yearluck from sms_Constellation_BaseInfo b,sms_Constellation_yearLuck w ";
						strSql+="where b.cbm=w.cbm and b.begindate<="+strBirthday+" AND "+strBirthday+"<=b.Enddate AND ";
						strSql+="w.years="+strCurrentTime;
						rsc.Open(strSql);
						if(rsc.IsBOF() &&rsc.IsEOF())
						{
							strMsgC="您输入信息错误。本年运程操作方法:8805生日,生日不包括年份。如查询8月9日出生的人的本年运程,发短信88050809到8765即可";
						}
						else
						{
							while(!rsc.IsEOF())
							{
								if(strMsgC.GetLength()>0)
								{
									::SGIP_Send("88",MyReg::GetUnionSPNumber(),strClientPhone,MyReg::GetUnionUsername(),
										MyReg::GetUnionPassword(),MyReg::GetUnionIP(),MyReg::GetUnionPort(),
										strClientPhone,strMsgC,MyReg::GetPayTypeUnion(),"60");
									rs.AddNew();
									rs.SetFieldValue("usermobile",strClientPhone);
									rs.SetFieldValue("Code",strCode);
									rs.SetFieldValue("msgcontent",strMsgC);
									rs.SetFieldValue("moormt",1);
									rs.Update();
								}
								strMsgC="";
								rsc.GetFieldValue("cname",strCname);
								rsc.GetFieldValue("yearluck",strLuck);
								strMsgC.Format("%s本年运程:%s",strCname,strLuck);
								rsc.MoveNext();
							}
						}
						rsc.Close();
					}
					else if(strCode=="08")
					{
						strSql="select  b.cname,d.prize from sms_Constellation_BaseInfo b,sms_Constellation_yearprize d ";
						strSql+="where b.cbm=d.cbm and b.begindate<="+strBirthday+" AND "+strBirthday+"<=b.Enddate";
						rsc.Open(strSql);
						if(rsc.IsBOF() &&rsc.IsEOF())
						{
							strMsgC="您输入信息错误。年终奖运程操作方法:8808+生日,生日不包括年份。如查询8月9日出生的人年终奖运程,发短信88080809到8765即可。";
						}
						else
						{
							while(!rsc.IsEOF())

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -