/// <summary>
        /// 发送短信给用户
        /// </summary>
        public void SendSMS()
        {
            string sql = string.Format("select id from DrugsBase_Enterprise where code='{0}'", ID);

            DbCommand comm = db.GetSqlStringCommand(sql);
            DataTable dt   = db.ExecuteDataSet(comm).Tables[0];
            var       sms  = new SOSOshop.MSG.Sms();

            foreach (DataRow dr in dt.Rows)
            {
                string    sqlv3  = string.Format("select MobilePhone from memberaccount where uid in (select uid from memberinfo where Parents like('%{0}%'))", dr["id"]);
                DbCommand v3comm = v3db.GetSqlStringCommand(sqlv3);
                DataTable v3dt   = v3db.ExecuteDataSet(v3comm).Tables[0];
                foreach (DataRow dv in v3dt.Rows)
                {
                    string MobilePhone = (string)dv["MobilePhone"];
                    if (string.IsNullOrEmpty(MobilePhone))
                    {
                        string SmsMsg = "您的首营资料已经通过建档审核,已经开通您在101商城的交易权限及价格查看权限!";
                        string from   = "系统";
                        string to     = MobilePhone;
                        Sms.SendAndSaveDataBase(MobilePhone, SmsMsg, from, to);
                    }
                }
            }
        }
        /// <summary>
        /// 找回秘密时,给用户发送验证码
        /// </summary>
        /// <returns></returns>
        public string GetSms()
        {
            string ret         = BaseController.Json(-1, "抱歉,当前用户设置的手机号码可能有误或网络繁忙,你可以重新发送短信!");
            string MobilePhone = Request.Form["phone"];

            //判断用户的手机号码是否已经注册过
            if (IsUserName(MobilePhone))
            {
                bool   ok         = false;
                string smsCaptcha = Common.CheckCode.GenerateNumber();
                Session["Captcha"] = smsCaptcha;
                string          url   = "http://" + Request.Url.Host + "/include/ajax.ashx?act=updateMobilePhone&v=" + Guid.NewGuid().ToString();
                var             sms   = new SOSOshop.MSG.Sms();
                SOSOshop.BLL.Db db    = new SOSOshop.BLL.Db();
                object          phone = db.ExecuteScalar("select OfficePhone from yxs_administrators where adminid=(select Editer from memberaccount a inner join memberinfo b on a.UID=b.UID where MobilePhone='" + MobilePhone + "')");
                if (phone == null || phone.ToString().Trim() == "")
                {
                    phone = "028-66321993";
                }
                string SmsMsg = "您的账户安全验证码为:" + smsCaptcha + ",请在页面填写。如非本人操作,请致电您的专属采购顾问" + phone;
                string from   = "系统";
                string to     = MobilePhone;
                ok = SOSOshop.BLL.Sms.SendAndSaveDataBase(MobilePhone, SmsMsg, from, to);
                if (ok)
                {
                    ret = BaseController.Json(0, "ok");
                }
            }
            return(ret);
        }
示例#3
0
 /// <summary>
 /// 发送Sms消息给指定的手机,并保存到数据库
 /// </summary>
 /// <param name="mobile"></param>
 /// <param name="content"></param>
 /// <param name="from"></param>
 /// <param name="to"></param>
 /// <returns></returns>
 public static bool SendAndSaveDataBase(string mobile, string content, string from = "", string to = "")
 {
     if (System.Configuration.ConfigurationManager.AppSettings.AllKeys.Contains("isSendMsg"))
     {
         if (System.Configuration.ConfigurationManager.AppSettings["isSendMsg"] == "0")
         {
             SOSOshop.BLL.Sms.SaveDataBase(mobile, content + ":[系统屏蔽不发送]", from, to, true);
             return(true);
         }
     }
     if (!string.IsNullOrEmpty(mobile))
     {
         mobile = mobile.Replace(" ", "");
         var  sms = new SOSOshop.MSG.Sms();
         bool b   = sms.Send(mobile, content);
         return(SOSOshop.BLL.Sms.SaveDataBase(mobile, content, from, to, b));
     }
     else
     {
         mobile = "";
         return(SOSOshop.BLL.Sms.SaveDataBase(mobile, content, from, to, false));
     }
 }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // 注册用户
                bool ok  = false;
                int  UID = 0;

                //添加买家账号信息
                SOSOshop.BLL.MemberAccount   aBll = new SOSOshop.BLL.MemberAccount();
                SOSOshop.Model.MemberAccount a    = new SOSOshop.Model.MemberAccount();
                if (string.IsNullOrEmpty(model.Captcha) || !model.Captcha.Equals(Convert.ToString(Session["Captcha"]), StringComparison.CurrentCultureIgnoreCase))
                {
                    ModelState.AddModelError("", "提供的验证码不正确。");
                }
                else
                {
                    if (!string.IsNullOrEmpty(model.UserName) &&
                        !string.IsNullOrEmpty(model.PassWord) &&
                        model.PassWord.Equals(model.ConfirmPassword) &&
                        !string.IsNullOrEmpty(model.LinkMan) &&
                        !string.IsNullOrEmpty(model.Email))
                    {
                        int i = new SOSOshop.BLL.MemberAccount().GetUserIdNameClass(model.UserName);
                        if (i == 2)
                        {
                            a.UserId      = "";
                            a.MobilePhone = model.UserName;
                            a.Email       = model.Email;
                        }
                        //else if (i == 3)
                        //{
                        //    a.UserId = "";
                        //    a.MobilePhone = "";
                        //    a.Email = model.UserName;
                        //}
                        //else
                        //{
                        //    a.UserId = model.UserName;
                        //    a.MobilePhone = "";
                        //    a.Email = model.Email;
                        //}
                        //Response.Write(model.PassWord+" "+i);
                        a.PassWord = ChangeHope.Common.DEncryptHelper.Encrypt(model.PassWord, 1);

                        a.Email_QQ         = model.Email.EndsWith("@qq.com") ? model.Email : "";
                        a.Question         = "";
                        a.Answer           = "";
                        a.RegisterDate     = DateTime.Now;
                        a.RegisterIP       = ChangeHope.WebPage.PageRequest.GetIP();
                        a.PeriodOfValidity = a.RegisterDate.AddYears(20);
                        a.State            = 1;
                        a.CompanyClass     = model.CompanyClass;
                        UID = aBll.Add(a);
                    }
                    //添加买家联系信息
                    if (UID > 0)
                    {
                        SOSOshop.BLL.MemberInfo   bBll = new SOSOshop.BLL.MemberInfo();
                        SOSOshop.Model.MemberInfo b    = new SOSOshop.Model.MemberInfo();
                        b.UID          = UID;
                        b.TrueName     = model.LinkMan;
                        b.Member_Class = -1;
                        b.Member_Type  = 0;
                        int area = 0; int.TryParse(Request["province"], out area);
                        b.Province = area;
                        area       = 0; int.TryParse(Request["city"], out area);
                        b.City     = area;
                        area       = 0; int.TryParse(Request["county"], out area);
                        b.Borough  = area;

                        if (model.CompanyClass == "生产企业" || model.CompanyClass == "商业公司" || model.CompanyClass == "民营医院")
                        {
                            b.Member_Class = 0;
                        }
                        else
                        {
                            b.Member_Class = 1;
                        }
                        //通知交易人员
                        //int tId = 0;//交易员ID  取消//改为数据库设置默认值 2014/2/12
                        //string tname = new SOSOshop.BLL.Administrators().GetTraderIdByRegion(b.Province, b.City, b.Borough, out tId, model.CompanyClass);//交易员姓名
                        int    oId   = 0;                                                                                                                        //外销人员(线下推广人员)ID
                        string oName = new SOSOshop.BLL.Administrators().GetOutSellPersonIdByRegion(b.Province, b.City, b.Borough, out oId, model.CompanyClass); //外销人员(线下推广人员)姓名

                        //if (tId != 0)
                        //{
                        //    string jyphone = string.Format(" SELECT zyphone FROM zhiyzl WHERE is_czy='是' and beactive='是' and zhiyname='{0}'", tname);
                        //    SOSOshop.BLL.DbBase db = new SOSOshop.BLL.Db();
                        //    db.ChangeDB("ConnectionStringERP");
                        //    DataTable dt = db.ExecuteTable(jyphone);
                        //    if (dt.Rows.Count > 0)
                        //    {
                        //        string phone = dt.Rows[0][0].ToString().Trim();
                        //        if (!string.IsNullOrEmpty(phone))
                        //        {
                        //            ok = SOSOshop.BLL.Sms.SendAndSaveDataBase(phone, "手机号为" + model.UserName + "的用户,已经在101商城前台进行注册,请尽快联系完成后续注册审核。", "系统", phone);
                        //        }
                        //    }
                        //}
                        //b.Editer = tId;
                        b.OSPId     = oId;
                        b.HandPhone = a.MobilePhone;
                        ok          = bBll.Add(b);
                        //添加权限
                        if (ok)
                        {
                            SOSOshop.BLL.MemberPermission   cBll = new SOSOshop.BLL.MemberPermission();
                            SOSOshop.Model.MemberPermission c    = new SOSOshop.Model.MemberPermission();
                            c.UID = UID;
                            c.IsMoneyAndShipping = true;//款到发货权限
                            ok = cBll.Add(c);
                        }
                        if (!ok)
                        {
                            aBll.Delete(UID);
                        }
                    }
                    if (ok)
                    {
                        //发送注册成功的短信 取消//彭宴负责交易员分配工作,后台操作后发送短信 2014/2/12
                        var    sms   = new SOSOshop.MSG.Sms();
                        object phone = aBll.ExecuteScalar("select OfficePhone from yxs_administrators where adminid=(select Editer from memberaccount a inner join memberinfo b on a.UID=b.UID where a.UID='" + UID + "')");
                        //string SmsMsg = "尊敬的" + model.LinkMan + ",您已完成注册第一步,立即致电您的专属采购顾问" + phone + "开通查看价格权限";
                        string CompanyShortName = ConfigurationManager.AppSettings["CompanyShortName"];
                        string SmsMsg           = string.Format("尊敬的用户,您在{0}医药网注册已成功,您的账户名为", CompanyShortName) + model.UserName + ",请留意保存,祝您采购愉快!";
                        string from             = "系统";
                        string to = model.UserName;
                        ok = SOSOshop.BLL.Sms.SendAndSaveDataBase(model.UserName, SmsMsg, from, to);
                        //写入登陆日志
                        new SOSOshop.BLL.MemberLoginLog().Add(UID, model.UserName, a.PassWord);
                        Session["Captcha"] = null;
                        DateTime expiration = DateTime.Now.AddHours(12);
                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                                                                                         model.UserName,
                                                                                         DateTime.Now,
                                                                                         expiration,
                                                                                         false,
                                                                                         UID.ToString(),
                                                                                         FormsAuthentication.FormsCookiePath);
                        string     encTicket = FormsAuthentication.Encrypt(ticket);
                        HttpCookie tk        = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
                        Response.Cookies.Add(tk);
                        return(RedirectToAction("RegisterOK"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "注册失败!");
                    }
                }
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(View(model));
        }