Example #1
0
		private void sendSMS()
		{
			string selectSql = "select sendcontent_id,sendcontent_phonenum,"
				+"sendcontent_text from sms_send_content";
			string deleteSql = "delete from sms_send_content where sendContent_sucStatus=1";

			Database db = DatabaseFactory.CreateDatabase();
			DBCommandWrapper dbComSelect = db.GetSqlStringCommandWrapper(selectSql);
			DBCommandWrapper dbComDelete = db.GetSqlStringCommandWrapper(deleteSql);

			IDataReader reder;
			
			try
			{
				reder = db.ExecuteReader(dbComSelect);

				while(reder.Read())
				{
					string spNumber = string.Empty;
					string sendMobilePhone = reder[1].ToString();

					switch(sendMobilePhone.Substring(2,1))
					{
						case "0":
							spNumber = "9002733";
							break;
						case "1":
							spNumber = "9002733";
							break;
						case "2":
							spNumber = "9002733";
							break;
						case "3":
							spNumber = "9002733";
							break;
						case "4":
							spNumber = "9002733";
							break;
						case "5":
							spNumber = "8002733";
							break;
						case "6":
							spNumber = "8002733";
							break;
						case "7":
							spNumber = "8002733";
							break;
						case "8":
							spNumber = "8002733";
							break;
						case "9":
							spNumber = "8002733";
							break;
					}

					string url = "http://202.96.236.81:7783/testDownMsg.asp?"
						+"UID=sap&psd=0F3E419C71C500FA1FC8&source="+spNumber+"&mobile="
						+sendMobilePhone+"&message="+reder[2].ToString();

					MSXML2.XMLHTTPClass xmlHttp = new MSXML2.XMLHTTPClass();
					xmlHttp.open("POST" , url , false , null , null  );          
					xmlHttp.setRequestHeader( "Accept-Lauguage" , "zh-cn" );    

					xmlHttp.send( null );          
                                    
					if(xmlHttp.status == 200)
					{
						if(xmlHttp.responseText == "0")
						{
							string log = DateTime.Now.ToString() + " Successed to Send " 
								+" One Message!";
							WriteLog(log,"短信异常");

							string updateSql = "update sms_send_content set sendContent_sucStatus=1 where sendcontent_id="
								+ reder[0].ToString();

							DBCommandWrapper dbComUpdate = db.GetSqlStringCommandWrapper(updateSql);

							db.ExecuteNonQuery(dbComUpdate);

						}
						else
						{
							string log = DateTime.Now.ToString() + " Failed to Send " 
								+" One Message!Please check the net connection or contact the "
								+"SP Provider to fix the problem";
							WriteLog(log,"短信异常");
						}
					}
				}

				db.ExecuteNonQuery(dbComDelete);

			}
			catch(Exception ex)
			{
				WriteLog(DateTime.Now.ToString()+" "+ex.Message,"短信异常");
			}
		}
Example #2
0
        private void sendSMS()
        {
            string selectSql = "select sendcontent_id,sendcontent_phonenum,"
                               + "sendcontent_text from sms_send_content";
            string deleteSql = "delete from sms_send_content where sendContent_sucStatus=1";

            Database         db          = DatabaseFactory.CreateDatabase();
            DBCommandWrapper dbComSelect = db.GetSqlStringCommandWrapper(selectSql);
            DBCommandWrapper dbComDelete = db.GetSqlStringCommandWrapper(deleteSql);

            IDataReader reder;

            try
            {
                reder = db.ExecuteReader(dbComSelect);

                while (reder.Read())
                {
                    string spNumber        = string.Empty;
                    string sendMobilePhone = reder[1].ToString();

                    switch (sendMobilePhone.Substring(2, 1))
                    {
                    case "0":
                        spNumber = "9002733";
                        break;

                    case "1":
                        spNumber = "9002733";
                        break;

                    case "2":
                        spNumber = "9002733";
                        break;

                    case "3":
                        spNumber = "9002733";
                        break;

                    case "4":
                        spNumber = "9002733";
                        break;

                    case "5":
                        spNumber = "8002733";
                        break;

                    case "6":
                        spNumber = "8002733";
                        break;

                    case "7":
                        spNumber = "8002733";
                        break;

                    case "8":
                        spNumber = "8002733";
                        break;

                    case "9":
                        spNumber = "8002733";
                        break;
                    }

                    string url = "http://202.96.236.81:7783/testDownMsg.asp?"
                                 + "UID=sap&psd=0F3E419C71C500FA1FC8&source=" + spNumber + "&mobile="
                                 + sendMobilePhone + "&message=" + reder[2].ToString();

                    MSXML2.XMLHTTPClass xmlHttp = new MSXML2.XMLHTTPClass();
                    xmlHttp.open("POST", url, false, null, null);
                    xmlHttp.setRequestHeader("Accept-Lauguage", "zh-cn");

                    xmlHttp.send(null);

                    if (xmlHttp.status == 200)
                    {
                        if (xmlHttp.responseText == "0")
                        {
                            string log = DateTime.Now.ToString() + " Successed to Send "
                                         + " One Message!";
                            WriteLog(log, "短信异常");

                            string updateSql = "update sms_send_content set sendContent_sucStatus=1 where sendcontent_id="
                                               + reder[0].ToString();

                            DBCommandWrapper dbComUpdate = db.GetSqlStringCommandWrapper(updateSql);

                            db.ExecuteNonQuery(dbComUpdate);
                        }
                        else
                        {
                            string log = DateTime.Now.ToString() + " Failed to Send "
                                         + " One Message!Please check the net connection or contact the "
                                         + "SP Provider to fix the problem";
                            WriteLog(log, "短信异常");
                        }
                    }
                }

                db.ExecuteNonQuery(dbComDelete);
            }
            catch (Exception ex)
            {
                WriteLog(DateTime.Now.ToString() + " " + ex.Message, "短信异常");
            }
        }
Example #3
0
		private void receiveSMS()
		{
			try
			{
				string urlMobile = "http://202.96.236.81:7783/shcomm/getUpMsg.asp?"
					+"UID=sap&psd=0F3E419C71C500FA1FC8&source=8002733&mo_type=0";
				string urlUnion = "http://202.96.236.81:7783/shcomm/getUpMsg.asp?"
					+"UID=sap&psd=0F3E419C71C500FA1FC8&source=9002733&mo_type=0";

				//receive reply from mobile
				MSXML2.XMLHTTPClass xmlHttp = new MSXML2.XMLHTTPClass();
				xmlHttp.open("POST" , urlMobile , false , null , null  );          
				xmlHttp.setRequestHeader( "CharSet" , "GB2312" );    

				xmlHttp.send( null );

				if(xmlHttp.status == 200)
				{
					System.Text.Encoding gb=System.Text.Encoding.GetEncoding("GB2312");
					string replys = gb.GetString((byte[])xmlHttp.responseBody);
					replys = replys.Substring(0,replys.Length-2);
					// 手机号码|?|内容|?|时间|?|<#>手机号码|?|内容|?|时间|?|
					if(replys.Length>11)
					{
						string[] reply = replys.Split(new char[]{'#'});

						foreach(string replyContents in reply)
						{
							string[] replyContent = (replyContents.Substring(0,replyContents.Length-2)).
								Split(new char[]{'?'});

							string phoneNum = replyContent[0].Replace("|","");
							phoneNum = phoneNum.Replace(">","");
							string contentText = replyContent[1].Replace("|","");
							string replyTime = replyContent[2].Replace("|","");

							string selectSql = "select count(*) from sms_reply_content where "
								+"replycontent_phonenum='"+phoneNum+"' and replycontent_date"
								+"='"+replyTime+"'";

							Database db = DatabaseFactory.CreateDatabase();
							DBCommandWrapper dbCom = db.GetSqlStringCommandWrapper(selectSql);

							int count = (int)db.ExecuteScalar(dbCom);

							if(count==0)
							{
								string insertSql = "insert into sms_reply_content(replycontent_phonenum,"
									+"replycontent_text,replycontent_date) values('"+phoneNum+"',"
									+"'"+contentText+"','"+replyTime+"')";

								DBCommandWrapper dbComInsert = db.GetSqlStringCommandWrapper(insertSql);
								db.ExecuteNonQuery(insertSql);
							}
						}
					}

				}

				//receive reply from union
				xmlHttp.open("POST" , urlUnion , false , null , null  );          
				xmlHttp.setRequestHeader( "CharSet" , "GB2312" );    

				xmlHttp.send( null );

				if(xmlHttp.status == 200)
				{
					System.Text.Encoding gb=System.Text.Encoding.GetEncoding("GB2312");
					string replys = gb.GetString((byte[])xmlHttp.responseBody);
					replys = replys.Substring(0,replys.Length-2);
					// 手机号码|?|内容|?|时间|?|<#>手机号码|?|内容|?|时间|?|
					if(replys.Length>11)
					{
						string[] reply = replys.Split(new char[]{'#'});

						foreach(string replyContents in reply)
						{
							string[] replyContent = (replyContents.Substring(0,replyContents.Length-3)).
								Split(new char[]{'?'});

							string phoneNum = replyContent[0].Replace("|","");
							phoneNum = phoneNum.Replace(">","");
							string contentText = replyContent[1].Replace("|","");
							string replyTime = replyContent[2].Replace("|","");

							string selectSql = "select count(*) from sms_reply_content where "
								+"replycontent_phonenum='"+phoneNum+"' and replycontent_date"
								+"='"+replyTime+"'";

							Database db = DatabaseFactory.CreateDatabase();
							DBCommandWrapper dbCom = db.GetSqlStringCommandWrapper(selectSql);
							
							int count = (int)db.ExecuteScalar(dbCom);

							if(count==0)
							{
								string insertSql = "insert into sms_reply_content(replycontent_phonenum,"
									+"replycontent_text,replycontent_date) values('"+phoneNum+"',"
									+"'"+contentText+"','"+replyTime+"')";

								DBCommandWrapper dbComInsert = db.GetSqlStringCommandWrapper(insertSql);
								db.ExecuteNonQuery(insertSql);
							}
						}
					}

				}
			}
			catch(Exception ex)
			{
				WriteLog(DateTime.Now.ToString()+" "+ex.Message,"短信异常");
			}
		}
Example #4
0
        private void receiveSMS()
        {
            try
            {
                string urlMobile = "http://202.96.236.81:7783/shcomm/getUpMsg.asp?"
                                   + "UID=sap&psd=0F3E419C71C500FA1FC8&source=8002733&mo_type=0";
                string urlUnion = "http://202.96.236.81:7783/shcomm/getUpMsg.asp?"
                                  + "UID=sap&psd=0F3E419C71C500FA1FC8&source=9002733&mo_type=0";

                //receive reply from mobile
                MSXML2.XMLHTTPClass xmlHttp = new MSXML2.XMLHTTPClass();
                xmlHttp.open("POST", urlMobile, false, null, null);
                xmlHttp.setRequestHeader("CharSet", "GB2312");

                xmlHttp.send(null);

                if (xmlHttp.status == 200)
                {
                    System.Text.Encoding gb = System.Text.Encoding.GetEncoding("GB2312");
                    string replys           = gb.GetString((byte[])xmlHttp.responseBody);
                    replys = replys.Substring(0, replys.Length - 2);
                    // 手机号码|?|内容|?|时间|?|<#>手机号码|?|内容|?|时间|?|
                    if (replys.Length > 11)
                    {
                        string[] reply = replys.Split(new char[] { '#' });

                        foreach (string replyContents in reply)
                        {
                            string[] replyContent = (replyContents.Substring(0, replyContents.Length - 2)).
                                                    Split(new char[] { '?' });

                            string phoneNum = replyContent[0].Replace("|", "");
                            phoneNum = phoneNum.Replace(">", "");
                            string contentText = replyContent[1].Replace("|", "");
                            string replyTime   = replyContent[2].Replace("|", "");

                            string selectSql = "select count(*) from sms_reply_content where "
                                               + "replycontent_phonenum='" + phoneNum + "' and replycontent_date"
                                               + "='" + replyTime + "'";

                            Database         db    = DatabaseFactory.CreateDatabase();
                            DBCommandWrapper dbCom = db.GetSqlStringCommandWrapper(selectSql);

                            int count = (int)db.ExecuteScalar(dbCom);

                            if (count == 0)
                            {
                                string insertSql = "insert into sms_reply_content(replycontent_phonenum,"
                                                   + "replycontent_text,replycontent_date) values('" + phoneNum + "',"
                                                   + "'" + contentText + "','" + replyTime + "')";

                                DBCommandWrapper dbComInsert = db.GetSqlStringCommandWrapper(insertSql);
                                db.ExecuteNonQuery(insertSql);
                            }
                        }
                    }
                }

                //receive reply from union
                xmlHttp.open("POST", urlUnion, false, null, null);
                xmlHttp.setRequestHeader("CharSet", "GB2312");

                xmlHttp.send(null);

                if (xmlHttp.status == 200)
                {
                    System.Text.Encoding gb = System.Text.Encoding.GetEncoding("GB2312");
                    string replys           = gb.GetString((byte[])xmlHttp.responseBody);
                    replys = replys.Substring(0, replys.Length - 2);
                    // 手机号码|?|内容|?|时间|?|<#>手机号码|?|内容|?|时间|?|
                    if (replys.Length > 11)
                    {
                        string[] reply = replys.Split(new char[] { '#' });

                        foreach (string replyContents in reply)
                        {
                            string[] replyContent = (replyContents.Substring(0, replyContents.Length - 3)).
                                                    Split(new char[] { '?' });

                            string phoneNum = replyContent[0].Replace("|", "");
                            phoneNum = phoneNum.Replace(">", "");
                            string contentText = replyContent[1].Replace("|", "");
                            string replyTime   = replyContent[2].Replace("|", "");

                            string selectSql = "select count(*) from sms_reply_content where "
                                               + "replycontent_phonenum='" + phoneNum + "' and replycontent_date"
                                               + "='" + replyTime + "'";

                            Database         db    = DatabaseFactory.CreateDatabase();
                            DBCommandWrapper dbCom = db.GetSqlStringCommandWrapper(selectSql);

                            int count = (int)db.ExecuteScalar(dbCom);

                            if (count == 0)
                            {
                                string insertSql = "insert into sms_reply_content(replycontent_phonenum,"
                                                   + "replycontent_text,replycontent_date) values('" + phoneNum + "',"
                                                   + "'" + contentText + "','" + replyTime + "')";

                                DBCommandWrapper dbComInsert = db.GetSqlStringCommandWrapper(insertSql);
                                db.ExecuteNonQuery(insertSql);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLog(DateTime.Now.ToString() + " " + ex.Message, "短信异常");
            }
        }