Example #1
0
        // GET: /Home/

        public ActionResult Index()
        {
            UserEntity user = new UserBll().getCurUser();
            ViewBag.User = user;
            #region 菜单呈现
            List<string> urights = new List<string>();
            List<MenuEntity> menus = new List<MenuEntity>();
            if (user != null)
            {

                IEnumerable<PluginEntity> pluginEntities = HuberPluginHandle.getEntityForMenu();
                if (pluginEntities.Any())
                {
                    #region 用户的权限
                    List<RoleEntity> uroles = new RoleBll().GetRoles(user.RolesIds);
                    string[] rightRange = null;
                    string[] splitchar = new string[] { "," };
                    if (uroles != null)
                        foreach (RoleEntity role in uroles)
                        {
                            rightRange = role.RightIds.Split(splitchar, StringSplitOptions.RemoveEmptyEntries);
                            if (rightRange != null)
                            {
                                urights.AddRange(rightRange);
                            }
                        }
                    #endregion
                    List<RightEntity> rightEntities = new RightBll().GetAllMenu(urights, user.Uid == UserBll.SuperAdminID);
                    foreach (PluginEntity pluginEntity in pluginEntities)
                    {
                        RightEntity rightEntity = rightEntities.SingleOrDefault(m => m.Category == pluginEntity.Id && m.ParentId == 0);
                        if (rightEntity == null)
                            continue;
                        MenuEntity menuEntity = GetMenu(rightEntity, pluginEntity);
                        menus.Add(menuEntity);
                    }
                }
                #region 添加系统菜单
                if (user.Uid == UserBll.SuperAdminID)
                {
                    MenuEntity CoreMenu = new MenuEntity(-1, "系统管理", string.Empty, true, "fa fa-cog");
                    CoreMenu.Children.Add(new MenuEntity(-1, "用户管理", "/user/index", true));
                    CoreMenu.Children.Add(new MenuEntity(-1, "权限管理", "/right/index", true));
                    CoreMenu.Children.Add(new MenuEntity(-1, "角色管理", "/role/index", true));
                    CoreMenu.Children.Add(new MenuEntity(-1, "模块管理", "/module/index", true));
                    menus.Add(CoreMenu);
                    //menus.Add(CoreMenu);
                    //menus.Add(CoreMenu);
                    //menus.Add(CoreMenu);
                    //menus.Add(CoreMenu);
                }
                #endregion
            }
            #endregion



            ViewBag.Menus = menus;
            return View();
        }
Example #2
0
 public string AddUser(UserEntity userEntity, string Pwd)
 {
     UserBll userBll = new UserBll();
     userEntity.Photo = "/Content/img/photo/photo16.jpg" ;
     int result = userBll.AddUser(userEntity, Pwd);
     return result.ToString();
 }
Example #3
0
 public PartialViewResult UserList(int pageindex, int pagesize, string callback, string userName)
 {
     UserBll userBll = new UserBll();
     int count = 0;
     List<UserEntity> modellist = userBll.GetUsers(pageindex, pagesize, userName, out count);
     ViewBag.PageIndex = pageindex;
     ViewBag.PageCount = count % pagesize == 0 ? count / pagesize : (count / pagesize) + 1;
     ViewBag.callback = callback;
     return PartialView(modellist);
 }
Example #4
0
 public ActionResult disableUser(string uid)
 {
     int result;
     if (UserBll.SuperAdminID == uid)
     {
         result = -2;
     }
     else
     {
         UserBll userBll = new UserBll();
         if (userBll.SetUserStatus(uid, 0))
         {
             new UserBll().delLoginSign(uid);
         }
         result = userBll.SetUserStatus(uid, 0) ? 1 : -1;
     }
     return Json(result);
 }
Example #5
0
        /// <summary>获取当前用户的账号和姓名
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="uname"></param>
        /// <returns></returns>
        public UserEntity getCurUser()
        {
            UserEntity result = null;

            string sign = CookieFunc.ReadCookie(CoSignKey);
            if (sign != null && sign != string.Empty)
            {
                string uid = string.Empty;
                string pwd = string.Empty;
                DateTime dt = DateTime.Now;
                if (design(sign, ref uid, ref pwd, ref dt))
                {
                    result = new UserBll().GetUser(uid);
                }
            }
            return result;
        }
Example #6
0
 public int modifyUserName(string uid, string name)
 {
     if (string.IsNullOrEmpty(uid) || string.IsNullOrEmpty(name) )
         return -1;
     UserBll userBll = new UserBll();
     return userBll.UpdateName(uid, name) ? 1 : -1;
 }
Example #7
0
 public bool enableUser(string uid)
 {
     UserBll userBll = new UserBll();
     return userBll.SetUserStatus(uid, 1);
 }
Example #8
0
        /// <summary>修改用户头像
        /// </summary>
        /// <param name="uid"></param>
        /// <returns>1 成功 -1 失败</returns>
        public int modifyUserPhoto()
        {
            UserEntity user = new UserBll().getCurUser();
            MemoryStream stream = new MemoryStream(Convert.FromBase64String(Request.Form["data"]));
            Bitmap img = new Bitmap(stream);
            string dirName = AppDomain.CurrentDomain.BaseDirectory + "Photo\\";
            string file = dirName + user.Uid + ".jpg";
            if (!Directory.Exists(dirName))
            {
                if (!Directory.Exists(dirName))
                {
                    Directory.CreateDirectory(dirName);
                }
            }

            img.Save(file);
            if (user.Photo.ToLower() == "/content/img/photo/photo16.jpg")
            {
                UserBll userBll = new UserBll();
                userBll.UpdatePhoto(user.Uid, "/Photo/" + user.Uid + ".jpg");
            }
            //fileBase.SaveAs(file);//保存文件
            //savePhoto(Request.Files[0],user.Uid );
            return 1;
        }
Example #9
0
 public ActionResult UpdateRights(string userId, string roleIds)
 {
     UserBll userBll = new UserBll();
     bool rsult = userBll.UpdateRoles(userId, roleIds);
     return Json(rsult);
 }
Example #10
0
 public ActionResult AddRoles(string uId, string roleIds)
 {
     UserBll userBll = new UserBll();
     bool result = userBll.AddRole(uId, roleIds);
     return Json(result);
 }
Example #11
0
 public ActionResult RemoveUserRole(string uId, int roleId)
 {
     UserBll userBll = new UserBll();
     bool result = userBll.DeleteRole(uId, roleId);
     return Json(result);
 }
Example #12
0
 /// <summary>修改密码密码
 /// </summary>
 /// <param name="opwd"></param>
 /// <param name="pwd"></param>
 /// <returns>1 修改成功 0 密码不匹配 -1 失败</returns>
 public int modifyPwd(string opwd, string pwd)
 {
     UserEntity user = new UserBll().getCurUser();
     return new UserBll().UpdatePassWord(user.Uid, opwd, pwd);
 }
Example #13
0
 public int resetPwd(string uid, string pwd)
 {
     UserBll userBll = new UserBll();
     bool result = userBll.UpdatePassWord(uid, pwd);
     return result ? 1 : 0;
 }
Example #14
0
 public ActionResult DeleteUser(string id)
 {
     int result;
     if (UserBll.SuperAdminID == id)
     {
         result = -2;
     }
     else
     {
         UserBll userBll = new UserBll();
         result = userBll.DeleteUser(id);
         new UserBll().delLoginSign(id);
     }
     return Json(result);
 }
Example #15
0
        public ActionResult Login(string uid, string pwd, bool remember)
        {

            int result = new UserBll().login(uid, pwd, remember);
            return Json(result);
        }
Example #16
0
        // 请求拦截
        private void Application_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication application = sender as HttpApplication;
            HttpResponse respond = application.Response;
            HttpRequest request = application.Request;
            string url = request.Url.AbsolutePath.ToString();
            //如果请求以“/plugins/”开头,表面我们需要对该请求做拦截处理了。
            if (url.ToLower().StartsWith("/plugins/"))
            {
                string action = url.Substring(url.LastIndexOf("/") + 1);
                //如果是非静态文件,即是action
                if (action.IndexOf(".") < 0)
                {
                    #region 匹配controller和action

                    var urlEntity = HuberPluginHandle.getUrlPathEntity(url.Substring(8), true);
                    #endregion
                    if (urlEntity != null && urlEntity.controller != null)
                    {
                        #region 获取路径中的插件名称等信息

                        #endregion
                        SandBoxDynamicLoader sandBox = HuberPluginHandle.getSandBox(urlEntity.pluginname, urlEntity.pluginversion);

                        if (sandBox != null)
                        {
                            List<RightEntity> userRight = new List<RightEntity>();
                            string uid = string.Empty;
                            int login = new UserBll().chekLogin(ref uid, false, userRight);
                            if (login == 2)//验证用户是否具有访问的权限
                            {
                                RefRequestEntity paras = new RefRequestEntity();
                                paras.PageRights = userRight;
                                paras.UserID = uid;
                                #region 获取http参数
                                RequestHandle.FillCorRefEntity(paras, request);
                                #endregion
                                //sandBox.InvokeMothod(urlEntity.controller, "InitChannel", paras)
                                var result = sandBox.InvokeMothod(urlEntity.controller, urlEntity.action, paras);
                                RequestHandle.ResposeResult(respond, result);

                            }
                            else if (login == 1)
                            {
                                RequestHandle.ResponseNoRight(request, respond);
                            }
                            else
                            {
                                RequestHandle.ResponseNoLogin(request, respond);
                            }

                        }
                    }
                    else
                    {
                        RequestHandle.ResponseNotfound(request, respond); ;
                    }

                    respond.End();
                }
            }
            else
            {
                if (!url.ToLower().Equals("/user/login"))
                {
                    string action = url.Substring(url.LastIndexOf("/") + 1);
                    if (action.IndexOf(".") < 0)
                    {
                        List<RightEntity> userRight = new List<RightEntity>();
                        string uid = string.Empty;
                        int login = new UserBll().chekLogin(ref uid, false, userRight);
                        if (login == 2)//验证用户是否具有访问的权限
                        {

                        }
                        else if (login == 1)
                        {
                            RequestHandle.ResponseNoRight(request, respond);
                        }
                        else
                        {
                            RequestHandle.ResponseNoLogin(request, respond);
                        }
                    }
                       
                }
            }

        }
Example #17
0
 /// <summary>修改用户头像
 /// </summary>
 /// <param name="uid"></param>
 /// <returns>1 成功 -1 失败</returns>
 public ActionResult modifyUserPhotoV2()
 {
     UserEntity user = new UserBll().getCurUser();
     ViewBag.User = user;
     return View();
 }