Exemplo n.º 1
0
        public ActionResult FirstLogin(string name, string pwd, string num)
        {
            ReturnData <string> ret   = new ReturnData <string>();
            AgentBll            aBll  = new AgentBll();
            UserBasicBll        uBll  = new UserBasicBll();
            UserPCBll           pcBll = new UserPCBll();

            Agent     aModel  = aBll.GetModelByPhone(num);
            UserBasic uModel  = new UserBasic();
            UserPC    pcModel = new UserPC();

            uModel.NickName     = name;
            uModel.UserType     = 1;
            uModel.EnterpriseID = aModel.EnterpriseID;
            uModel.AddTime      = DateTime.Now;
            long id = uBll.AddAndGetId(uModel);

            pcModel.UserBasicID    = id;
            pcModel.PassWord       = SimpleEncrypt.SaltMD5(pwd.Replace(" ", ""));
            pcModel.PCType         = 2;
            pcModel.RoleID         = aModel.ID;
            pcModel.Status         = 0;
            pcModel.UserName       = name;
            pcModel.AddTime        = DateTime.Now;
            pcModel.AddUserBasicID = 0;
            ret = pcBll.AddUserPc(pcModel);
            if (ret.Status == true)
            {
                aModel.Status = 0;
                aBll.EditAgent(aModel);
                return(Content(ret.Message));
            }
            return(Content(ret.Message));
        }
Exemplo n.º 2
0
        public ActionResult Login(UserPC model, bool isAuto = false)
        {
            ReturnData <string> ret = new ReturnData <string>();
            //Bll实例化放action里面 为了不让每次都实例化 产生废代码
            UserPCBll bll = new UserPCBll();

            //只要找得到记住的密码就去匹配记住的密码
            if (Request.Cookies["remember"] != null)
            {
                if (Request.Cookies["remember"]["uname"] != "" && model.PassWord == "********")
                {
                    model.Status   = 99;
                    model.PassWord = Request.Cookies["remember"]["pwd"];
                }
            }
            //ReturnData 是值类型 不需要ref来赋值传递 当传入方法里时返回时还是带有值的
            var user = bll.Login(ret, model, EnterpriseKey);

            if (user != null)
            {
                //登录成功了 才记住用户名和密码
                if (isAuto)
                {
                    Response.Cookies["remember"]["uname"] = user.UserName;
                    Response.Cookies["remember"]["pwd"]   = Convert.ToBase64String(YYYCommon.Encryption.SymmetricEncryption.Encrypt(user.PassWord + "\r" + DateTime.Now.ToString()));
                    Response.Cookies["remember"].Expires  = DateTime.Now.AddDays(7);
                }
                else
                {
                    Response.Cookies["remember"]["uname"] = "";
                }
                //保存登录信息
                Session["user"] = user;
                //设置跳转路径
                Dictionary <string, object> Identify = new Dictionary <string, object>();

                if (EnterpriseKey.ToLower() == "opera")
                {
                    Identify.Add("url", "/Operate/Areas/Index");
                }
                else
                {
                    //return RedirectToAction("WellCome");
                    Identify.Add("url", "/Login/Welcome");
                }
                ret.Identify = Identify;
            }
            return(Content(ret.GetJson()));
        }
Exemplo n.º 3
0
        public ActionResult Login(UserPC model, bool isAuto = false)
        {
            ReturnData<string> ret = new ReturnData<string>();
            //Bll实例化放action里面 为了不让每次都实例化 产生废代码
            UserPCBll bll = new UserPCBll();
            //只要找得到记住的密码就去匹配记住的密码
            if (Request.Cookies["remember"] != null)
            {
                if (Request.Cookies["remember"]["uname"] != "" && model.PassWord == "********")
                {
                    model.Status = 99;
                    model.PassWord = Request.Cookies["remember"]["pwd"];
                }
            }
            //ReturnData 是值类型 不需要ref来赋值传递 当传入方法里时返回时还是带有值的
            var user = bll.Login(ret, model, EnterpriseKey);
            if (user != null)
            {
                //登录成功了 才记住用户名和密码
                if (isAuto)
                {
                    Response.Cookies["remember"]["uname"] = user.UserName;
                    Response.Cookies["remember"]["pwd"] = Convert.ToBase64String(YYYCommon.Encryption.SymmetricEncryption.Encrypt(user.PassWord + "\r" + DateTime.Now.ToString()));
                    Response.Cookies["remember"].Expires = DateTime.Now.AddDays(7);

                }
                else
                {
                    Response.Cookies["remember"]["uname"] = "";
                }
                //保存登录信息
                Session["user"] = user;
                //设置跳转路径
                Dictionary<string, object> Identify = new Dictionary<string, object>();

                if (EnterpriseKey.ToLower() == "opera")
                {

                    Identify.Add("url", "/Operate/Areas/Index");
                }
                else
                {
                    //return RedirectToAction("WellCome");
                    Identify.Add("url", "/Login/Welcome");
                }
                ret.Identify = Identify;
            }
            return Content(ret.GetJson());
        }
Exemplo n.º 4
0
        public ActionResult EditPwd(string oldpwd, string pwd)
        {
            UserPCBll bll = new UserPCBll();

            Utility.ReturnData <string> ret = new Utility.ReturnData <string>();
            long   id       = AgentLoginUser.UserBasicID;
            UserPC model    = bll.GetModelById(id);
            string checkpwd = SimpleEncrypt.SaltMD5(oldpwd.Replace(" ", ""));

            if (model.PassWord != checkpwd)
            {
                return(Content("原始密码不正确!"));
            }
            model.PassWord = SimpleEncrypt.SaltMD5(pwd.Replace(" ", ""));
            bll.Update(model);

            return(Content("修改成功!"));
        }
Exemplo n.º 5
0
        public ActionResult EditPwd(string oldpwd, string pwd)
        {
            UserPCBll bll = new UserPCBll();
            Utility.ReturnData<string> ret = new Utility.ReturnData<string>();
            long id = AgentLoginUser.UserBasicID;
            UserPC model = bll.GetModelById(id);
            string checkpwd = SimpleEncrypt.SaltMD5(oldpwd.Replace(" ", ""));
            if (model.PassWord != checkpwd)
            {
                return Content("原始密码不正确!");
            }
            model.PassWord = SimpleEncrypt.SaltMD5(pwd.Replace(" ", ""));
            bll.Update(model);

            return Content("修改成功!");



        }
Exemplo n.º 6
0
        public ActionResult FirstLogin(string name, string pwd, string num)
        {
            ReturnData<string> ret = new ReturnData<string>();
            AgentBll aBll = new AgentBll();
            UserBasicBll uBll = new UserBasicBll();
            UserPCBll pcBll = new UserPCBll();

            Agent aModel = aBll.GetModelByPhone(num);
            UserBasic uModel = new UserBasic();
            UserPC pcModel = new UserPC();

            uModel.NickName = name;
            uModel.UserType = 1;
            uModel.EnterpriseID = aModel.EnterpriseID;
            uModel.AddTime = DateTime.Now;
            long id = uBll.AddAndGetId(uModel);

            pcModel.UserBasicID = id;
            pcModel.PassWord = SimpleEncrypt.SaltMD5(pwd.Replace(" ", ""));
            pcModel.PCType = 2;
            pcModel.RoleID = aModel.ID;
            pcModel.Status = 0;
            pcModel.UserName = name;
            pcModel.AddTime = DateTime.Now;
            pcModel.AddUserBasicID = 0;
            ret = pcBll.AddUserPc(pcModel);
            if (ret.Status == true)
            {
                aModel.Status = 0;
                aBll.EditAgent(aModel);
                return Content(ret.Message);

            }
            return Content(ret.Message);
        }