Exemple #1
0
        public virtual object SendValidationCode(HttpContext context)
        {
            YZRequest request        = new YZRequest(context);
            string    iddCode        = request.GetString("iddcode");
            string    phoneNumber    = request.GetString("phoneNumber");
            string    validationCode = SMS.GenValidationCode(6);
            JObject   jsmsParam      = new JObject();

            jsmsParam["code"] = validationCode;

            string url    = "http://gw.api.taobao.com/router/rest";
            string appkey = "24031655";
            string secret = "76a58b1f3739694821c2d1e83e248c12";

            ITopClient client = new DefaultTopClient(url, appkey, secret);
            //AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
            //req.Extend = "";
            //req.SmsType = "normal";
            //req.SmsFreeSignName = "公司门户";
            //req.SmsParam = jsmsParam.ToString();
            //req.RecNum = phoneNumber;
            //req.SmsTemplateCode = "SMS_70455212";

            //AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
            //if (rsp.IsError)
            //    throw new Exception(rsp.SubErrMsg);

            SMS sms = new SMS();

            sms.ItemGUID       = Guid.NewGuid().ToString("");
            sms.IDDCode        = iddCode;
            sms.PhoneNumber    = phoneNumber;
            sms.ValidationCode = validationCode;
            sms.CreateDate     = DateTime.Now;
            sms.ExpireDate     = sms.CreateDate + TimeSpan.FromSeconds(180);
            sms.CreateBy       = YZAuthHelper.LoginUserAccount;

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    SMSManager.Insert(provider, cn, sms);
                }
            }

            return(new
            {
                ItemGUID = sms.ItemGUID
            });
        }
Exemple #2
0
        public virtual object SendLoginValidationCode(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    uid     = request.GetString("uid");

            string  validationCode = SMS.GenValidationCode(6);
            JObject jsmsParam      = new JObject();

            jsmsParam["code"]    = validationCode;
            jsmsParam["product"] = Resources.YZStrings.All_MobileAppName;

            string iddCode     = null;
            string phoneNumber = null;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpenAnonymous();
                User.GetPhoneBind(cn, uid, out iddCode, out phoneNumber);
            }

            string url    = "http://gw.api.taobao.com/router/rest";
            string appkey = "24031655";
            string secret = "76a58b1f3739694821c2d1e83e248c12";

            ITopClient client = new DefaultTopClient(url, appkey, secret);

            //AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
            //req.Extend = "";
            //req.SmsType = "normal";
            //req.SmsFreeSignName = "公司门户";
            //req.SmsParam = jsmsParam.ToString();
            //req.RecNum = phoneNumber;
            //req.SmsTemplateCode = "SMS_70620129";

            //AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
            //if (rsp.IsError)
            //    throw new Exception(rsp.SubErrMsg);

            SMS sms = new SMS();

            sms.ItemGUID       = Guid.NewGuid().ToString("");
            sms.IDDCode        = iddCode;
            sms.PhoneNumber    = phoneNumber;
            sms.ValidationCode = validationCode;
            sms.CreateDate     = DateTime.Now;
            sms.ExpireDate     = sms.CreateDate + TimeSpan.FromSeconds(60);
            sms.CreateBy       = uid;

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    SMSManager.Insert(provider, cn, sms);
                }
            }

            return(new
            {
                ItemGUID = sms.ItemGUID,
                ExpireDate = sms.ExpireDate,
                PhoneNumber = phoneNumber.Remove(3, 4).Insert(3, "****")
            });
        }