Beispiel #1
0
        public T_UserInfo GetUserInfo(T_User User)
        {
            T_UserInfo model;
            model = CacheManagement.Instance.Get<T_UserInfo>("T_UserInfo", User.ID); ;
            if ( model == null )
            {
                model = new T_UserInfo();
                List<int> t_userrolesidls = GetAllNoCache<T_UserRoles>().Where(p => p.UserID == User.ID).Select(p => p.RoleID).ToList();

               

                List<T_RoleNavBtns> t_rolenavbtnsls = GetAllNoCache<T_RoleNavBtns>().Where(p => t_userrolesidls.Contains(p.RoleID)).ToList();

                List<int> navidls = t_rolenavbtnsls.Select(p => p.NavID).Distinct().ToList();

                var allbut = GetAllNoCache<T_Button>().ToList();
                model.T_User = User;
                model.T_Rolels = GetAllNoCache<T_Role>().Where(p => t_userrolesidls.Contains(p.ID)).ToList();

                List<T_Navigation> T_Navigationls = new List<T_Navigation>();
                foreach ( var item in navidls )
                {
                    var nav = GetAllNoCache<T_Navigation>().Where(p => p.ID == item && p.IsDelete != true && p.IsVisible == true).FirstOrDefault();
                    if ( nav != null )
                    {
                        var btnidls = t_rolenavbtnsls.Where(p => p.NavID == item && p.IsDelete != true).Select(p => p.BtnID);
                        // var navbtnsls = GetAllNoCache<T_NavButtons>().Where(p => p.NavId == item && p.IsDelete != true).Select(p => p.ButtonId);

                        nav.ButtonHtmlList = allbut.Where(p => btnidls.Contains(p.ID) && p.IsDelete != true && p.ButtonTag != "browser").Select(p => p.ButtonHtml).ToList();
                        // nav.AllButtonHtmlList = allbut.Where(p => navbtnsls.Contains(p.ID) && p.IsDelete != true).Select(p => p.ButtonHtml).ToList();
                    }
                    T_Navigationls.Add(nav);
                }

                List<T_Navigation> AllT_Navigationls = GetAllNoCache<T_Navigation>().Where(p => p.IsDelete != true && p.IsVisible == true).ToList().Select(
                (p) =>
                {
                    var navbtnsls = GetAllNoCache<T_NavButtons>().Where(z => z.NavId == p.ID && z.IsDelete != true).Select(z => z.ButtonId);
                    T_Navigation navmodel = p;
                    navmodel.AllButtonHtmlList = allbut.Where(z => navbtnsls.Contains(z.ID) && z.IsDelete != true && z.ButtonTag != "browser").Select(z => z.ButtonHtml).ToList();
                    return navmodel;
                    //return new T_Navigation { ID = p.ID, AllButtonHtmlList = allbut.Where(z => navbtnsls.Contains(z.ID) && z.IsDelete != true).Select(z => z.ButtonHtml).ToList(), Sortnum=p.Sortnum , ParentID=p.ParentID , iconUrl =p.iconUrl , Linkurl =p.Linkurl , iconCls =p.iconCls , NavTitle=p.NavTitle , BigImageUrl=p.BigImageUrl , ButtonHtmlList =p.ButtonHtmlList, IsDelete=p.IsDelete ,IsSys=p.IsSys , IsVisible=p.IsVisible , NavTag=p.NavTag , OwnedBut=p.OwnedBut , children=p.children  };
                }).ToList();
                model.AllT_Navigationls = AllT_Navigationls;

                model.T_Navigationls = T_Navigationls;
                //    List<int> btnsidls = t_rolenavbtnsls.Select(p => p.BtnID).ToList();
                 
                CacheManagement.Instance.Add("T_UserInfo", User.ID, model);
            }
            return model;
        }
Beispiel #2
0
 public JsonResult Update(T_User model)
 {
     bool Success = false;
     string Message = "修改失败请联系管理员!";
     model.Password = EncryptionMD5.GetMd5Hash(model.Password);
     int result = iUser.Edit(model);
     if (result > 0)
     {
         Success = true;
         Message = "成功";
     }
     return Json(new { Success = Success, Message = Message }, JsonRequestBehavior.AllowGet);
 }
        public ActionResult Index(T_User usermodel)
        {
            if ( usermodel.UserName==null||usermodel.UserName.Length==0 )
            {
                 ModelState.AddModelError("Message", "用户名不能为空!");
            } else
            if ( usermodel.Password == null || usermodel.Password.Length == 0 )
            {
                ModelState.AddModelError("Message", "密码不能为空!");
            }
            else
            if ( ILogin.SearchForName(usermodel.UserName) )
            {
               usermodel= ILogin.SearchForNameorPwd(usermodel.UserName,   EncryptionMD5.GetMd5Hash( usermodel.Password));
               if ( usermodel!=null )
                {
                    CacheManagement.Instance.RemoveByID("T_UserInfo", usermodel.ID);

                    Session["userinfo"] = IUserInfo.GetUserInfo(usermodel);
                    System.Web.HttpCookie newcookie = new HttpCookie("user");
                    newcookie.Values["userid"] = usermodel.ID.ToString();

                    //DataCache.RemoveCache(usermodel.ID.ToString());

                    newcookie.Expires = DateTime.Now.AddDays(365);
                    Response.AppendCookie(newcookie); 

                    return RedirectToRoute("Admin_default", new
                    {
                        controller = "AdminHome",
                        action = "Index"
                    });

                }
                else
                {
                    ModelState.AddModelError("Message", "密码错误!");
                }
               
            }
            else
            {
                ModelState.AddModelError("Message", "用户不存在!");
            }

            return View();
        }
Beispiel #4
0
 public JsonResult Add(T_User model)
 {
     bool Success = false;
     string Message = "添加失败请联系管理员!";
     model.Password = EncryptionMD5.GetMd5Hash(model.Password);
     int State = iUser.Add(model);
     if (State > 0)
     {
         Success = true;
         Message = "成功";
     }
     else if ((CRUDState)State == CRUDState.UniqueErro)
     {
         Message = "用户名已存在,不能重复添加!";
     }
     return Json(new { Success = Success, Message = Message }, JsonRequestBehavior.AllowGet);
 }