/// <summary>
        ///     创建用户页面
        ///     zhoub 20150707
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Create(long?id)
        {
            AC_UserModel model  = null;
            var          result = new ResultModel();

            if (id.HasValue)
            {
                result = _acUserService.GetAC_UserById(id.Value);
                if (result.Data != null)
                {
                    model = result.Data;
                }
            }
            if (model == null)
            {
                model = new AC_UserModel();
            }

            var ac_Department = _acDepartmentService.GetAC_DepartmentsBy().Data;

            ViewData["ID"] = ac_Department;

            var ac_Role = _acRoleService.GetAC_RolesBy().Data;

            ViewData["RoleID"] = ac_Role;

            return(PartialView(model));
        }
        public ActionResult Create(AC_UserModel model)
        {
            ResultModel resultModel = resultModel = new ResultModel();
            string      opera       = "";

            if (model.UserID == 0)
            {
                model.UserID     = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                model.LoginTimes = 0;
                model.CreateUser = UserInfo.CurrentUserName;
                model.CreateDT   = DateTime.Now;
                model.Password   = FormsAuthentication.HashPasswordForStoringInConfigFile(model.Password, "MD5");
                resultModel      = _acUserService.AddAC_User(model);
                opera            = string.Format("系统用户添加:{0},操作结果:{1}", JsonConverts.ToJson(model), "操作成功");
                LogPackage.InserAC_OperateLog(opera, "System--User-Add");
            }
            else
            {
                model.UpdateUser     = UserInfo.CurrentUserName;
                model.UpdateDt       = DateTime.Now;
                resultModel          = _acUserService.UpdateAC_User(model);
                resultModel.Messages = new List <string> {
                    "Edit user success"
                };
                opera = string.Format("系统用户修改:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);
                LogPackage.InserAC_OperateLog(opera, "System--User-Edit");
            }
            return(Json(resultModel, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        /// <summary>
        /// 更新用户
        /// </summary>
        /// <param name="model">用户模型</param>
        /// <returns>是否修改成功</returns>
        public ResultModel UpdateAC_User(AC_UserModel model)
        {
            var result = new ResultModel();

            _database.Db.AC_User.UpdateByUserID(UserID: model.UserID, RealName: model.RealName, IDNumber: model.IDNumber, UserMode: model.UserMode, ID: model.ID, RoleID: model.RoleID, UpdateUser: model.UpdateUser, UpdateDt: model.UpdateDt, Sex: model.Sex);
            return(result);
        }
예제 #4
0
        /// <summary>
        /// 保存登陆信息和日记
        /// </summary>
        /// <param name="model"></param>
        public void GetAC_UserByUserName(AC_UserModel model)
        {
            UserInfoModel info = new UserInfoModel();

            info.UserID         = model.UserID;
            info.UserName       = model.UserName;
            info.RoleID         = model.RoleID;
            Session["UserInfo"] = info;//登陆成功保存用户信息

            //插入登陆时间日记
            var result = LogPackage.InserUserLoginLog("Thailand Mall Backgroud", 1);
        }
예제 #5
0
        public ActionResult UpdatePass(long?UserID)
        {
            AC_UserModel model = new AC_UserModel();

            if (UserID.HasValue)
            {
                model.UserID = UserID.Value;
            }



            return(PartialView(model));
        }
        public ActionResult Edit(AC_UserModel model)
        {
            ResultModel resultModel = resultModel = new ResultModel();

            model.UpdateUser = "******";
            model.UpdateDt   = DateTime.Now;
            var result = _acUserService.UpdateAC_User(model);

            resultModel.Messages = new List <string> {
                "Edit user success"
            };
            string opera = string.Format("系统用户修改:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);

            LogPackage.InserAC_OperateLog(opera, "System--User-Edit");
            return(Json(resultModel, JsonRequestBehavior.AllowGet));
        }
예제 #7
0
        public JsonResult IsLogin()
        {
            var    UserName = Request["UserName"];
            var    PassWord = Request["PassWord"];
            string type     = "1";//用户不存在
            string Messages = "Users do not exist";

            try
            {
                AC_UserModel model = this._ac_UserService.GetAC_UserByUserName(UserName).Data;

                if (model != null)
                {
                    if (MD5.Equals(model.Password, FormsAuthentication.HashPasswordForStoringInConfigFile(PassWord, "MD5")) && model.UserMode == 1)
                    {
                        type     = "3";//登陆成功
                        Messages = "Login success";
                        GetAC_UserByUserName(model);
                    }
                    else
                    {
                        type     = "2";//密码不正确
                        Messages = "Password wrong or account locked";
                    }
                }
                var data = new
                {
                    logintype = type,
                    Messages  = Messages,
                };
                return(Json(data));
            }
            catch (Exception ex)
            {
                var data = new
                {
                    logintype = type,
                    Messages  = Messages,
                };

                var opera = string.Format("登录错误-用户名:{0},错误结果:{1}", UserName, ex.Message);
                LogPackage.InserAC_OperateLog(opera, "Login error");

                return(Json(data));
            }
        }
        public void AC_UserService_Add_Test()
        {
            var model = new AC_UserModel
            {
                RealName = "ddd",
                //RoleID = 0,
                UserName   = "******",
                Password   = "******",
                IDNumber   = "sss",
                CreateUser = "******",
                UpdateUser = "******",
                CreateDT   = DateTime.Now,
                //LastLoginTime = DateTime.Now,
                UserID = (int)MemCacheFactory.GetCurrentMemCache().Increment("commonId"),
                //AC_Role = new AC_RoleModel()
                //{
                //    //RoleID = 1,
                //    RoleName = "ddd",
                //    RoleModuleValue = "dddd",
                //    RoleDescription = "dddd",
                //    RoleFuctionValue = "ddd",
                //    CreateDT = DateTime.Now,
                //    CreateUser = "******",
                //    UpdateDt = DateTime.Now,
                //    UpdateUser = "******"
                //},
                //AC_Department = new AC_DepartmentModel()
                //{
                //    ParentID = 0,
                //    CreateBy = "ddd",
                //   // CreateDT = DateTime.Now,
                //    DeptName = "sss",
                //    IsActive = 0,
                //    OrderNumber = 24214,
                //    UpdateBy = "ssss",
                //    //UpdateDT = DateTime.Now
                //}
            };

            var result = this._acUserService.AddAC_User(model);

            Assert.IsTrue(result.IsValid);
        }
예제 #9
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="model">用户模型</param>
        public ResultModel AddAC_User(AC_UserModel model)
        {
            ResultModel result = new ResultModel();
            var         count  = _database.Db.AC_User.GetCount(_database.Db.AC_User.UserName == model.UserName);

            if (count > 0)
            {
                result.IsValid  = false;
                result.Messages = new List <string> {
                    "User name already exists."
                };                                                                 //用户名已经存在.
            }
            else
            {
                result.Data     = _database.Db.AC_User.Insert(model);
                result.Messages = new List <string> {
                    "Add user success"
                };                                                        //添加用户成功
            }
            return(result);
        }
예제 #10
0
        public ActionResult UpdatePass(AC_UserModel model)
        {
            ViewBag.ErrorMegess = "";
            var          resultModel = new ResultModel();
            AC_UserModel acmodel     = _acUserService.GetAC_UserById(model.UserID).Data;

            if (MD5.Equals(acmodel.Password, FormsAuthentication.HashPasswordForStoringInConfigFile(model.PasswordOld, "MD5")) && acmodel.UserMode == 1)
            {
                var password = FormsAuthentication.HashPasswordForStoringInConfigFile(model.Password, "MD5");
                var result   = _acUserService.ReSetAC_UserPassword(model.UserID, password).Data;
                resultModel.IsValid  = true;
                resultModel.Messages = new List <string> {
                    "Upadate password success"
                };
                return(Json(resultModel, JsonRequestBehavior.AllowGet));
            }
            else
            {
                ViewBag.ErrorMegess = "The original password is not correct";
            }
            return(PartialView(model));
        }
예제 #11
0
 public static AC_User ToEntity(this AC_UserModel model)
 {
     return(Mapper.Map <AC_User>(model));
 }