示例#1
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <returns></returns>
        public ActionResult SendMsg()
        {
            JsonSMsg msg    = new JsonSMsg();
            string   mobile = Request["mobile"];

            Random r   = new Random();
            int    num = r.Next(100000, 999999);
            //string message = string.Format("本次微信平台获取的验证码是:" + num);
            string message = string.Format("本次微信平台获取的验证码是:"
                                           + num + "。如非本人操作,请致电400-821-6188");

            dt_SMSInsert_req req = new dt_SMSInsert_req();

            req.SMS_ITEM = new SMS_ITEM[] { new SMS_ITEM()
                                            {
                                                CONTENT   = message,
                                                MESSAGEID = "0000001", MESSAGETYPE = "BC_WX_SMS",
                                                MOBILE    = mobile, MSGFORMAT = "8", SRCNUMBER = "106900291033"
                                            } };

            dt_SMSInsert_res res = WebApiHelp.OldSMSInsert(req);

            if (res.zstatus == "1")
            {
                msg.Data    = num;
                msg.Status  = 1;
                msg.Message = "发送成功";
                return(Json(msg));
            }
            msg.Data    = 0;
            msg.Status  = 0;
            msg.Message = "发送失败";
            return(Json(msg));
        }
示例#2
0
文件: WebApiHelp.cs 项目: Thn123/hmj
        /// <summary>
        /// (old)发送短信接口
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public static dt_SMSInsert_res OldSMSInsert(dt_SMSInsert_req req)
        {
            try
            {
                string   reqStr    = js.Serialize(req);
                DateTime timeStart = DateTime.Now;
                logger.Info("si_SMSInsert_real_obService请求信息new:" + reqStr + "\r\n");

                si_SMSInsert_real_obService web = new si_SMSInsert_real_obService();

                dt_SMSInsert_res res = web.si_SMSInsert_real_ob(req);

                string   resStr  = js.Serialize(res);
                DateTime timeEnd = DateTime.Now;
                logger.Info("响应信息" + resStr + "\r\n");


                datalog.DataInfo(reqStr, resStr, timeStart, timeEnd, 0, "si_SMSInsert_real_obService", "发送短信接口");
                return(res);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                Random r       = new Random();
                int    num     = r.Next(100000, 999999);
                string message = string.Format("您的验证码为:"
                                               + num + "此验证码10分钟内有效,如非本人操作,请联系上海家化华美家微信后台。");

                dt_SMSInsert_req req = new dt_SMSInsert_req
                {
                    SMS_ITEM = new SMS_ITEM[] { new SMS_ITEM()
                                                {
                                                    CONTENT     = message,
                                                    MESSAGEID   = "0000001",
                                                    MESSAGETYPE = "BC_WX_SMS",
                                                    MOBILE      = "13661450526",
                                                    MSGFORMAT   = "8",
                                                    SRCNUMBER   = "1069048560003"
                                                } }
                };

                dt_SMSInsert_res res = WebApiHelp.SMSInsert(req, true);

                if (res != null && res.zstatus == "1")
                {
                    this.TextBox1.Text = res.zstatus == "1" ? "成功" : "失败";
                }
            }
            catch (Exception ex) {
                this.TextBox1.Text = ex.Message;
            }
        }
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public static dt_SMSInsert_res SMSInsert(dt_SMSInsert_req req,
                                                 bool isdebug = false)
        {
            string        reqStr    = js.Serialize(req);
            string        resStr    = string.Empty;
            DateTime?     timeStart = null;
            DateTime?     timeEnd   = null;
            string        isok      = "OK";
            SystemService _set      = new SystemService();

            try
            {
                timeStart = DateTime.Now;
                _set.AddLog(new SPACRM.Entity.WXLOG()
                {
                    CON  = "发送短信si_SMSInsert_real_obService请求信息" + timeStart + ":" + reqStr,
                    TIME = DateTime.Now
                });
                si_SMSInsert_real_obService web = new si_SMSInsert_real_obService();

                dt_SMSInsert_res res = web.si_SMSInsert_real_ob(req);

                resStr  = js.Serialize(res);
                timeEnd = DateTime.Now;
                _set.AddLog(new SPACRM.Entity.WXLOG()
                {
                    CON  = "发送短信响应信息" + timeStart + ":" + resStr + "\r\n",
                    TIME = DateTime.Now
                });
                if (res == null)
                {
                    isok = "NO";
                }

                return(res);
            }
            catch (Exception ex)
            {
                resStr = ex.Message;
                isok   = "NO";
                _set.AddLog(new SPACRM.Entity.WXLOG()
                {
                    CON  = "发送短信响应信息" + timeStart + ":" + resStr + "\r\n",
                    TIME = DateTime.Now
                });
                throw ex;
            }
            finally
            {
                if (!isdebug)
                {
                    //datalog.DataInfo(reqStr, resStr, timeStart, timeEnd, 0, SystemCode.SMSInsert.ToString(), isok);
                }
            }
        }
示例#5
0
        public static int SendMessage(string message, string mobile, string TgId = null)
        {
            XYHCoupon2TGService xYHCoupon = new XYHCoupon2TGService();
            dt_SMSInsert_req    req       = new dt_SMSInsert_req
            {
                //      dt_SMSInsert_req req = new dt_SMSInsert_req();
                //req.SMS_ITEM = new SMS_ITEM[] { new SMS_ITEM() { CONTENT = message,
                //    MESSAGEID = "0000001", MESSAGETYPE = "BC_WX_SMS",
                //    MOBILE = mobile, MSGFORMAT = "8", SRCNUMBER = "106900291033" } };

                SMS_ITEM = new SMS_ITEM[] { new SMS_ITEM()
                                            {
                                                CONTENT     = message,
                                                MESSAGEID   = "0000001",
                                                MESSAGETYPE = "BC_WX_SMS",
                                                MOBILE      = mobile,
                                                MSGFORMAT   = "8",
                                                SRCNUMBER   = "106900291033" // 1069048560003 -上海家化
                                            } }
            };

            dt_SMSInsert_res res = WebApiHelp.SMSInsert(req, true);

            if (res != null && res.zstatus == "1")
            {
                long ret = xYHCoupon.InsertMessageHis(new Entity.MessageHis()
                {
                    Mobile   = mobile,
                    Content  = message,
                    TgId     = (TgId == null ? 0 : int.Parse(TgId)),
                    IsSend   = 1,
                    SendTime = DateTime.Now,
                    Result   = 1
                });
                return(1);
            }
            else
            {
                long ret = xYHCoupon.InsertMessageHis(new Entity.MessageHis()
                {
                    Mobile   = mobile,
                    Content  = message,
                    TgId     = (TgId == null ? 0 : int.Parse(TgId)),
                    IsSend   = 1,
                    SendTime = DateTime.Now,
                    Result   = 0
                });
                return(0);
            }
        }
示例#6
0
        /// <summary>
        /// 发送短息
        /// </summary>
        /// <param name="arg"></param>
        /// <returns></returns>
        private dynamic SendMsg(dynamic arg)
        {
            try
            {
                //得到请求参数
                string mobile = base.GetValue <string>("MOBILE");

                if (string.IsNullOrEmpty(mobile))
                {
                    return(ResponseJson(false, "手机号不能是空"));
                }

                Random r   = new Random();
                int    num = r.Next(100000, 999999);
                //string message = string.Format("本次微信平台获取的验证码是:" + num);
                //【上海家化】您的验证码为:620384。
                //此验证码10分钟内有效,如非本人操作,请联系Jahwa华美家微信后台。
                string message = string.Format("您的验证码为:"
                                               + num + "此验证码10分钟内有效,如非本人操作,请联系上海家化华美家微信后台。");

                dt_SMSInsert_req req = new dt_SMSInsert_req
                {
                    SMS_ITEM = new SMS_ITEM[] { new SMS_ITEM()
                                                {
                                                    CONTENT     = message,
                                                    MESSAGEID   = "0000001",
                                                    MESSAGETYPE = "BC_WX_SMS",
                                                    MOBILE      = mobile,
                                                    MSGFORMAT   = "8",
                                                    SRCNUMBER   = "1069048560003"
                                                } }
                };

                dt_SMSInsert_res res = WebHmjApiHelp.SMSInsert(req, true);

                if (res.zstatus == "1")
                {
                    return(ResponseJson(true, "发送成功", num));
                }

                return(ResponseJson(false, "发送失败"));
            }
            catch (Exception ex)
            {
                WriteLog("发送验证码", ex);
                return(ResponseJsonError(false, error_message, ex));
            }
        }
示例#7
0
文件: HmjTest.cs 项目: Thn123/hmj
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button15_Click(object sender, EventArgs e)
        {
            Random r   = new Random();
            int    num = r.Next(100000, 999999);
            //string message = string.Format("本次微信平台获取的验证码是:" + num);
            string message = string.Format("本次微信平台获取的验证码是:"
                                           + num + "。如非本人操作,请致电400-821-6188");

            dt_SMSInsert_req req = new dt_SMSInsert_req();

            req.SMS_ITEM = new SMS_ITEM[] { new SMS_ITEM()
                                            {
                                                CONTENT   = message,
                                                MESSAGEID = "0000001", MESSAGETYPE = "BC_WX_SMS",
                                                MOBILE    = "18721170080", MSGFORMAT = "8", SRCNUMBER = "1069048560003"
                                            } };

            dt_SMSInsert_res res = WebHmjApiHelp.SMSInsert(req, true);
        }
示例#8
0
        /// <summary>
        /// 会员状态调整
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public static dt_SMSInsert_res SMSInsert(dt_SMSInsert_req req,
                                                 bool isdebug = false)
        {
            string   reqStr    = js.Serialize(req);
            string   resStr    = string.Empty;
            DateTime?timeStart = null;
            DateTime?timeEnd   = null;
            string   isok      = "OK";

            try
            {
                timeStart = DateTime.Now;
                logger.Info("发送短信si_SMSInsert_real_obService请求信息:" + reqStr);
                si_SMSInsert_real_obService web = new si_SMSInsert_real_obService();

                dt_SMSInsert_res res = web.si_SMSInsert_real_ob(req);

                resStr  = js.Serialize(res);
                timeEnd = DateTime.Now;
                logger.Info("响应信息" + resStr + "\r\n");

                if (res == null)
                {
                    isok = "NO";
                }

                return(res);
            }
            catch (Exception ex)
            {
                resStr = ex.Message;
                isok   = "NO";
                return(null);
            }
            finally
            {
                if (!isdebug)
                {
                    datalog.DataInfo(reqStr, resStr, timeStart, timeEnd, 0, SystemCode.SMSInsert.ToString(), isok);
                }
            }
        }
示例#9
0
        public string SendMsg(string mobile)
        {
            WriteTxt("发送验证码:mobile=" + mobile);
            try
            {
                //得到请求参数
                if (string.IsNullOrEmpty(mobile))
                {
                    response.Status  = 0;
                    response.Message = "手机号不能是空";
                    return(JsonHelper.ToJSON(response));
                }

                Random r   = new Random();
                int    num = r.Next(100000, 999999);
                //string message = string.Format("本次微信平台获取的验证码是:" + num);
                //【上海家化】您的验证码为:620384。
                //此验证码10分钟内有效,如非本人操作,请联系Jahwa华美家微信后台。
                string message = string.Format("您的验证码为:"
                                               + num + "此验证码10分钟内有效,如非本人操作,请联系华美家微信后台。");

                dt_SMSInsert_req req = new dt_SMSInsert_req
                {
                    //SMS_ITEM = new SMS_ITEM[] { new SMS_ITEM() {
                    //    CONTENT = message,
                    //    MESSAGEID = "0000001",
                    //    MESSAGETYPE = "BC_WX_SMS",
                    //    MOBILE = mobile,
                    //    MSGFORMAT = "8",
                    //    SRCNUMBER = "1069048560003"
                    //    }
                    //}
                    SMS_ITEM = new SMS_ITEM[] { new SMS_ITEM()
                                                {
                                                    CONTENT     = message,
                                                    MESSAGEID   = "0000001",
                                                    MESSAGETYPE = "BC_WX_SMS",
                                                    MOBILE      = mobile,
                                                    MSGFORMAT   = "8",
                                                    SRCNUMBER   = "106900291033" // 1069048560003 -上海家化
                                                } }
                };

                dt_SMSInsert_res res = WebApiHelp.SMSInsert(req, true);

                if (res != null && res.zstatus == "1")
                {
                    response.Status  = 1;
                    response.Message = "发送成功";
                    response.Data    = num;
                    return(JsonHelper.ToJSON(response));
                }

                response.Status  = 0;
                response.Message = "发送失败";
                response.Data    = num;
                return(JsonHelper.ToJSON(response));
            }
            catch (Exception ex)
            {
                response.Status  = 0;
                response.Message = "发送异常";
                response.Data    = ex.Message;
                return(JsonHelper.ToJSON(response));
            }
        }