Beispiel #1
0
 /// <summary>
 /// 根据短信实体判断短信实体是否符合标准
 /// 符合返回true,
 /// 不符合返回false
 /// </summary>
 /// <param name="smsdata"></param>
 /// <returns></returns>
 public bool SendBeforeCheck(SMSModel_Send smsdata)
 {
     if (smsdata.account.Length < 1 & smsdata.account.Length < 1 & smsdata.sign.Length < 1 & smsdata.phones.Length < 1 & smsdata.content.Length < 1)
     {
         return false;
     }
     else
     {
         return true;
     }
 }
Beispiel #2
0
 /// <summary>
 /// 
 /// 将短信发送对象转成xml格式
 /// </summary>
 /// <param name="smsdata"></param>
 /// <returns></returns>
 public static string Model2Xml_FormatSend(SMSModel_Send smsdata)
 {
     //合成请求信息
     var _data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                   + "<message>"
                       + "<account>" + smsdata.account + "</account>"
                       + "<password>" + Encryption.MD5Encryption(smsdata.password) + "</password>"
                       + "<msgid>" + smsdata.msgid + "</msgid>"
                       + "<phones>" + string.Join(",", smsdata.phones) + "</phones>"
                       + "<content>" + smsdata.content + "</content>"
                       + "<sign>" + smsdata.sign + "</sign>"
                       + "<subcode>" + smsdata.subcode + "</subcode>"
                       + "<sendtime>" + smsdata.sendtime.ToString("yyyyMMddHHmm") + "</sendtime>"
                   + "</message>";
     return _data;
 }
Beispiel #3
0
        public bool SendMsg(SMSModel_Send smsdata, out SMSModel_Receive receiveModel)
        {
            String _data = null;//XML文本
            String _serverURL = "http://wt.3tong.net/http/sms/Submit";//服务器地址
            string returnMsg;

            //1 判断参数是否足够
            if (!SendBeforeCheck(smsdata))
            {
                receiveModel = new SMSModel_Receive()
                {
                    desc = "参数不全",
                    msgid = smsdata.msgid,
                    failPhones = smsdata.phones,
                    result = SMSDictionary.GetResponseCode()[101]
                };

                return false;
            }
            _data = ObjTransform.Model2Xml_FormatSend(smsdata);
            //2.1 http方式发送
            returnMsg = httpInvoke(_serverURL, _data);
            //解析服务器反馈信息
            if (returnMsg.Length < 1)
            {

                returnMsg = "未收到服务器返回信息";
                receiveModel = new SMSModel_Receive()
                {
                    desc = returnMsg,
                    msgid = smsdata.msgid,
                    failPhones = smsdata.phones,
                    result = SMSDictionary.GetResponseCode()[101]
                };
                return false;
            }
            //2.2 将接收到的短信发送回执转换为对象
            receiveModel = ObjTransform.Xml2Model_ReceiveMsg(returnMsg);

            //等待信息发送完成后
            //System.Threading.Thread.Sleep(10000);//10秒
            ////自动重发
            //vipResend();
            return true;
        }
Beispiel #4
0
        /// <summary>
        /// 步骤三 获取短信内容
        /// 封装要提交至联通接口的发送对象(含联系人电话号码)
        /// </summary>
        /// <param name="model">短信对象</param>
        /// <param name="list_phones"></param>
        /// <returns></returns>
        public SMSModel_Send ToSendModel(PMS.Model.ViewModel.ViewModel_Message model,List<string> list_phones)
        {
            /*步骤三
                    获取短信内容
                    封装要提交至联通接口的发送对象
                    (含联系人电话号码)
            */
            //2 获取短信内容
            var content = model.Content;

            //2.1 设置发送对象相关参数
            string subCode = "";//短信子码"74431",接收回馈信息用
            string sign = "【国家海洋预报台】"; //短信签名,!仅在!发送短信时用= "【国家海洋预报台】";
            //短信发送与查询所需参数
            string smsContent = content;//短信内容
            string sendTime;//计划发送时间,为空则立即发送
                            //3 对短信内容进行校验——先暂时不做

            //6月27日新增将List电话集合转成用,拼接的字符串
            //查询时不需要联系人电话
            SMSModel_Send sendMsg = new SMSModel_Send()
            {
                account = "dh74381",
                password = "******",
                content = content,
                phones = list_phones.ToArray(),
                sendtime = DateTime.Now
            };
            return sendMsg;
        }