Пример #1
0
        /// <summary>
        /// 发送验证码-带业务名称
        /// </summary>
        public SendSMSlogEntity SendSMSVerify(string tenantId, string telephone, string verificationCode, string business)
        {
            var model = new SendSMSlogEntity();

            try
            {
                string TemplateCode = "SMS_148860775";

                //您当前正在办理${name},操作码是${code},该操作码5分钟内有效,请勿泄漏于他人!
                IDictionary <string, string> TemplateParam = new Dictionary <string, string>();
                TemplateParam.Add("name", business);
                TemplateParam.Add("code", verificationCode);

                model.Id               = Guid.NewGuid().ToString();
                model.TenantId         = tenantId;
                model.Phone            = telephone;
                model.VerificationCode = verificationCode;
                model.CreateTime       = DateTime.Now;

                var res = AliYunSendSms(telephone, TemplateCode, TemplateParam, model.Id).Result;
                model.State     = res.success;
                model.Response  = res.response;
                model.StateCode = "200";
            }
            catch (Exception ex)
            {
                model.State   = false;
                model.Remarks = ex.Message;
            }
            return(model);
        }
Пример #2
0
        /// <summary>
        /// 发送验证码
        /// </summary>
        public SendSMSlogEntity SendSMSVerify(string tenantId, string telephone, string verificationCode)
        {
            var model = new SendSMSlogEntity();

            try
            {
                string TemplateCode = "SMS_159135074";
                IDictionary <string, string> TemplateParam = new Dictionary <string, string>();
                TemplateParam.Add("code", verificationCode);

                model.Id               = Guid.NewGuid().ToString();
                model.TenantId         = tenantId;
                model.Phone            = telephone;
                model.VerificationCode = verificationCode;
                model.CreateTime       = DateTime.Now;

                var res = AliYunSendSms(telephone, TemplateCode, TemplateParam, model.Id).Result;
                model.State     = res.success;
                model.Response  = res.response;
                model.StateCode = "200";
            }
            catch (Exception ex)
            {
                model.State   = false;
                model.Remarks = ex.Message;
            }
            return(model);
        }
Пример #3
0
        /// <summary>
        /// 发送验证码-带业务名称
        /// </summary>
        /// <param name="companyId">商户ID</param>
        /// <param name="telephone">手机号</param>
        /// <param name="verificationCode">验证码</param>
        /// <param name="business">业务介绍</param>
        public SendSMSlogEntity SendSMSVerify(string tenantId, string telephone, string verificationCode, string business)
        {
            //http://www.yuntongxun.com/
            CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK();

            bool isInit = api.init("app.cloopen.com", "8883");

            api.setAccount(AccountSid, AccountToken);
            api.setAppId(AppId);

            var model = new SendSMSlogEntity();

            if (!isInit)
            {
                model.State = false;
                return(model);
            }

            Dictionary <string, object> retData = null;

            try
            {
                string[] phoneList = telephone.Split(new char[] { ',' });

                foreach (string phone in phoneList)
                {
                    if (phone == "" || phone.Length != 11)
                    {
                        continue;
                    }

                    retData        = api.SendTemplateSMS(telephone, "318597", new string[] { business, verificationCode });
                    model.Response = getDictionaryData(retData);

                    model.Id               = Guid.NewGuid().ToString();
                    model.TenantId         = tenantId;
                    model.Phone            = telephone;
                    model.VerificationCode = verificationCode;
                    model.CreateTime       = DateTime.Now;
                    model.State            = true;
                    model.StateCode        = "200";
                    model.Remarks          = "您" + business + ",验证码是{2}。提示:请勿泄露验证码给他人";
                }
            }
            catch (Exception ex)
            {
                model.State   = false;
                model.Remarks = ex.Message;
            }
            return(model);
        }
Пример #4
0
        /// <summary>
        /// 发送业务提醒,含手机短信信息、手机APP端信息
        /// </summary>
        public List <SendSMSlogEntity> SendSMSInfo(string tenantId, string telephone, string business, string msg)
        {
            var modelList = new List <SendSMSlogEntity>();

            string TemplateCode = "SMS_164680880";

            //您的${mtname}申请已于${submittime}审批${type},特此通知。
            IDictionary <string, string> TemplateParam = new Dictionary <string, string>();

            TemplateParam.Add("mtname", business);
            TemplateParam.Add("submittime", DateTime.Now.ToString());
            TemplateParam.Add("type", msg);

            string Msg = "您的" + business + "申请已于" + DateTime.Now.ToString() + "审批" + msg + ",特此通知。";

            //发送手机APP端信息
            //SeedMsgHandler.ExecutePush(ref errors, companyId, telephone, Msg);

            string[] phoneList = telephone.Split(new char[] { ',' });
            foreach (string phone in phoneList)
            {
                if (phone == "" || phone.Length != 11)
                {
                    continue;
                }

                SendSMSlogEntity model = new SendSMSlogEntity();
                try
                {
                    model.Id         = Guid.NewGuid().ToString();
                    model.TenantId   = tenantId;
                    model.Phone      = phone;
                    model.Remarks    = Msg;
                    model.CreateTime = DateTime.Now;

                    var res = AliYunSendSms(phone, TemplateCode, TemplateParam, model.Id).Result;
                    model.State    = res.success;
                    model.Response = res.response;

                    model.StateCode = "200";
                }
                catch (Exception ex)
                {
                    model.State   = false;
                    model.Remarks = ex.Message;
                }
                modelList.Add(model);
            }
            return(modelList);
        }
Пример #5
0
        public List <SendSMSlogEntity> SendSMSInfo(string tenantId, string telephone, string business, string msg)
        {
            var modelList = new List <SendSMSlogEntity>();

            //您的${mtname}申请已于${submittime}审批${type},特此通知。
            string PhoneNumbers = telephone;
            //string SignName = "自由创客";
            //string TemplateCode = "SMS_148861947";
            string TemplateParam = "{\"mtname\":\"" + business + "\",\"submittime\":\"" + DateTime.Now.ToString() + "\",\"type\":\"" + msg + "\"}";
            string OutId         = Guid.NewGuid().ToString();

            string Msg = "您的" + business + "申请已于" + DateTime.Now.ToString() + "审批" + msg + ",特此通知。";

            //发送手机APP端信息
            //SeedMsgHandler.ExecutePush(ref errors, companyId, telephone, Msg);

            string[] phoneList = telephone.Split(new char[] { ',' });
            foreach (string phone in phoneList)
            {
                if (phone == "" || phone.Length != 11)
                {
                    continue;
                }

                SendSMSlogEntity model = new SendSMSlogEntity();
                try
                {
                    model.Id         = OutId;
                    model.TenantId   = tenantId;
                    model.Phone      = phone;
                    model.Remarks    = "您的" + business + "申请已于" + DateTime.Now.ToString() + "审批" + msg + ",特此通知。";
                    model.CreateTime = DateTime.Now;
                    //model.State = AliYunSendSms(phone, SignName, TemplateCode, TemplateParam, OutId);
                    model.StateCode = "200";
                }
                catch (Exception ex)
                {
                    model.State   = false;
                    model.Remarks = ex.Message;
                }
                modelList.Add(model);
            }
            return(modelList);
        }