示例#1
0
文件: SMSAPI.cs 项目: radtek/crm
        /// <summary>
        /// 阿里大鱼
        /// </summary>
        /// <param name="pSign"></param>
        /// <param name="pSMSContent"></param>
        /// <param name="pMobileNO"></param>
        /// <param name="pSmsTemplateCode"></param>
        /// <returns></returns>
        private static AlibabaAliqinFcSmsNumSendResponse AlidatySendMessage(string pSign, string pSMSContent, string pMobileNO, string pSmsTemplateCode)
        {
            string appKey = WebConfigurationManager.AppSettings["AlidayuAppKey"].ToString();
            string secret = WebConfigurationManager.AppSettings["AlidayuSecret"].ToString();
            string url    = WebConfigurationManager.AppSettings["AlidayuURL"].ToString();
            //短信发送日志
            SMSSendBLL bll = new SMSSendBLL(new JIT.Utility.BasicUserInfo());

            ITopClient client = new DefaultTopClient(url, appKey, secret);
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.SmsType         = "normal";
            req.SmsFreeSignName = pSign;     //签名
            req.SmsParam        = pSMSContent;
            req.RecNum          = pMobileNO; //手机号
            req.SmsTemplateCode = pSmsTemplateCode;
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);

            string[] temp = pMobileNO.Split(',');
            foreach (var i in temp)
            {
                var entity = new SMSSendEntity()
                {
                    MobileNO = i,
                    Sign     = pSign,
                };

                if (rsp.Result != null)
                {
                    entity.Status            = 1;
                    entity.SendCount         = (entity.SendCount ?? 0) + 1;
                    entity.RegularlySendTime = DateTime.Now;
                    var debug = new DebugLogInfo()
                    {
                        Message = "【发送成功】{0}【手机号】:{1}{0}【内容】:{2}{0}【返回码】:{3}".Fmt(Environment.NewLine, entity.MobileNO, rsp.Result.Msg, rsp.Result.ErrCode)
                    };
                    Loggers.Debug(debug);
                }
                else
                {
                    entity.SendCount = (entity.SendCount ?? 0) + 1;
                    rsp.Result       = new BizResult()
                    {
                        ErrCode = rsp.ErrCode,
                        Msg     = rsp.SubErrMsg,
                        Success = false,
                    };
                    var debug = new DebugLogInfo()
                    {
                        Message = "【发送失败】{0}【手机号】:{1}{0}【内容】:{2}{0}【错误信息】:{3}".Fmt(Environment.NewLine, entity.MobileNO, rsp.SubErrCode, rsp.ErrCode)
                    };
                    Loggers.Debug(debug);
                }
                //保存数据库
                bll.Create(entity);
            }

            return(rsp);
        }
示例#2
0
    public override void CopyInfo(SerializedClass info)
    {
        DebugLogInfo i = (DebugLogInfo)info;

        message = i.Message;
    }