Example #1
0
        public List <RoleEntity> GetRoles()
        {
            RoleDal           roleDal      = new RoleDal();
            List <RoleEntity> roleEntities = roleDal.GetRoles();

            return(roleEntities);
        }
Example #2
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(Username.Text) || string.IsNullOrEmpty(Pwd.Text))
        {
            msg.Visible = true;
            return;
        }
        var ok = Security.Login(Username.Text, Pwd.Text, ckb.Checked.ToString());

        if (ok)
        {
            var ret = Request["ret"];
            Session["Menu"]  = null;
            Session["Roles"] = null;

            var roleList = RoleDal.SelectRoleByUsername(Username.Text);
            Session["Roles"] = roleList;

            var homeUrl = "/lib/pages/Home/Guest.aspx";
            if (roleList.Any())
            {
                homeUrl = roleList[0].HomeUrl;
            }

            Response.Redirect(string.IsNullOrEmpty(ret) ? homeUrl : Server.UrlDecode(ret));
        }
        else
        {
            msg.Visible = true;
        }
    }
Example #3
0
        public List <Role> GetAllRole()
        {
            RoleDal roleDal = new RoleDal();

            roleDal.GetAll();
            roleDal.ReturnUnitToPool();
            return(roleDal.list_Role);
        }
Example #4
0
        /// <summary>获得角色列表
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public List <RoleEntity> GetRoles(int pageIndex, int pageSize, string RoleName, out int count)
        {
            int               skip         = (pageIndex - 1) * pageSize;
            RoleDal           roleDal      = new RoleDal();
            List <RoleEntity> roleEntities = roleDal.GetRoles(skip, pageSize, RoleName, out count);

            return(roleEntities);
        }
Example #5
0
        private void userRolesWindow_Loaded(object sender, RoutedEventArgs e)
        {
            RoleDal roles = new RoleDal(RoleUtil.connString);

            RoleUtil.appRoles      = roles.GetAll();
            RoleUtil.appRolesCodes = RoleUtil.appRoles.Select(s => s.RoleCode).ToList();
            //lstUnassignedRoles.ItemsSource = RoleUtil.AppRolesCodes;
            LoadUsersIntoUI();
        }
Example #6
0
 public static Role RoleToOrm(RoleDal roleDal)
 {
     return(new Role()
     {
         Description = roleDal.Description,
         Id = roleDal.Id,
         RoleName = roleDal.RoleName
     });
 }
Example #7
0
        /// <summary>获得角色列表
        /// </summary>
        /// <param name="roleIdList"></param>
        /// <returns></returns>
        public List <RoleEntity> GetRoles(List <int> roleIdList)
        {
            if (roleIdList == null || !roleIdList.Any())
            {
                return(new List <RoleEntity>());
            }
            roleIdList = roleIdList.Distinct().ToList();
            RoleDal roleDal = new RoleDal();

            return(roleDal.GetRoles(roleIdList));
        }
Example #8
0
        //public void GenerateNotConnected()
        //{
        //    _context.GenerateNotConnected();

        //}
        //public void GenerateStoredProcedureNotFound()
        //{
        //    _context.GenerateStoredProcedureNotFound();
        //}
        //public void GenerateParameterNotIncluded()
        //{
        //    _context.GenerateParameterNotIncluded();
        //}
        //Role
        public RoleBLL FindRoleByID(int RoleID)
        {
            RoleBLL ProposedReturnValue = null;
            RoleDal DataLayerObject     = _context.FindRoleByID(RoleID);

            if (null != DataLayerObject)
            {
                ProposedReturnValue = new RoleBLL(DataLayerObject);
            }
            return(ProposedReturnValue);
        }
Example #9
0
        /// <summary>删除角色
        /// </summary>
        /// <param name="roleId">角色Id</param>
        /// <returns></returns>
        public bool DeleteRole(int roleId)
        {
            RoleDal roleDal = new RoleDal();

            if (roleDal.DeleteRole(roleId))
            {
                UserDal userDal = new UserDal();
                return(userDal.RemoveRole(roleId));
            }
            return(false);
        }
Example #10
0
 /// <summary>
 /// Deleted a role
 /// </summary>
 /// <param name="id"></param>
 /// <param name="objContex"></param>
 public static void Delete(short id, ModelUnibookContainer objContex)
 {
     try
     {
         RoleDal.Delete(id, objContex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #11
0
 /// <summary>
 /// Update changes in the context
 /// </summary>
 /// <param name="role"></param>
 /// <param name="objContex"></param>
 public static void Update(RoleDto roleDto, ModelUnibookContainer objContex)
 {
     try
     {
         Role role = RoleBrl.Get(roleDto.RoleId, objContex);;
         role.Name    = roleDto.Name;
         role.Deleted = roleDto.Deleted;
         RoleDal.Update(role, objContex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #12
0
        /// <summary>删除权限,真删,同时移出角色表中的权限
        /// </summary>
        /// <param name="rightId"></param>
        /// <returns></returns>
        public bool DeleteRightRel(List <int> rightIds)
        {
            foreach (var item in rightIds)
            {
                //在角色表中移出权限
                RoleDal roleDal = new RoleDal();
                roleDal.RemoveRight(item);
            }

            //删除权限
            RightDal rightDal = new RightDal();

            return(rightDal.DeleteRightRel(rightIds));
        }
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="role">角色信息</param>
        /// <param name="user">用户信息</param>
        /// <returns>是否注册成功</returns>
        public bool Register(Role role, UserInfo user)
        {
            RoleDal roleDal = new RoleDal();

            if (roleDal.Add(ref role))
            {
                role        = roleDal.GetRole(role.userNum);
                user.userId = role.id;
                return(new UserInfoDal().Add(user));
            }
            else
            {
                throw new Exception("注册失败!");
            }
        }
Example #14
0
        /// <summary>
        /// Get a role with identifier
        /// </summary>
        /// <param name="id"></param>
        /// <param name="objContex"></param>
        /// <returns></returns>
        public static Role Get(short id, ModelUnibookContainer objContex)
        {
            Role role = null;

            try
            {
                role = RoleDal.Get(id, objContex);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(role);
        }
Example #15
0
 /// <summary>
 /// Create a new role
 /// </summary>
 /// <param name="role"></param>
 /// <param name="objContex"></param>
 public static void Insert(RoleDto roleDto, ModelUnibookContainer objContex)
 {
     try
     {
         Role role = new Role();
         role.Name    = roleDto.Name;
         role.RoleId  = roleDto.RoleId;
         role.Deleted = roleDto.Deleted;
         RoleDal.Insert(role, objContex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #16
0
        public void TestRole()
        {
            RoleDal role = new RoleDal();
            //role.Insert(new Role {Rid = 1,Rname = "hahaha", Rscore = 3.3 });
            //role.Delete(new Role {Rname = "hahaha"});
            var result = role.GetEntities(p => p.Rscore <= 8);

            using (StreamWriter writer =
                       new StreamWriter(@"C:\Users\lenovo\Desktop\t.txt", true))
            {
                foreach (var q in result)
                {
                    writer.WriteLine(q.Rname);
                }
            }
        }
Example #17
0
        public ResponseStatus GetSecondAuth(HttpCookieCollection cookies, Container_Authority_Msg auth)
        {
            if (cookies[GLB.userId] == null)
            {
                auth.isAdd    = false;
                auth.isDelete = false;
                auth.isUpdate = false;
                return(ResponseStatus.SUCCESS);
            }
            auth.isVisit = false;
            string  userId  = cookies[GLB.userId].Value.ToString();
            RoleDal roleDal = new RoleDal();
            //Container_Authority_Msg auth = new Container_Authority_Msg();
            ResponseStatus resp = roleDal.GetSecondAuth(userId, auth);

            roleDal.ReturnUnitToPool();
            return(resp);
        }
Example #18
0
        /// <summary>
        /// Get a role with identifier
        /// </summary>
        /// <param name="id"></param>
        /// <param name="objContex"></param>
        /// <returns></returns>
        public static RoleDto GetDto(short id, ModelUnibookContainer objContex)
        {
            RoleDto roleDto = null;

            try
            {
                Role role = RoleDal.Get(id, objContex);
                roleDto         = new RoleDto();
                roleDto.RoleId  = role.RoleId;
                roleDto.Name    = role.Name;
                roleDto.Deleted = roleDto.Deleted;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(roleDto);
        }
Example #19
0
        string getRoleByUsername(string _Username)
        {
            StringBuilder  sb   = new StringBuilder();
            RoleCollection list = RoleDal.SelectAllByUsernameCQ(_Username);

            if (list.Count > 0)
            {
                foreach (Role item in list)
                {
                    sb.AppendFormat(@"<input type=""checkbox"" _role=""{0}"" _username=""{1}"" {2} > {3}<br/>"
                                    , item.ID, _Username, item.Active ? "checked=\"checked\"" : "", item.Ten);
                }
            }
            else
            {
                sb.Append("0");
            }
            return(sb.ToString());
        }
Example #20
0
        public int RoleAdd(Role model)
        {
            model.ModifyUserId   = ManageProvider.Provider.Current().UserId;
            model.ModifyUserName = ManageProvider.Provider.Current().Account;
            model.ModifyDate     = DateTime.Now;

            if (model.RoleId == 0)
            {
                model.CreateUserId   = ManageProvider.Provider.Current().UserId;
                model.CreateUserName = ManageProvider.Provider.Current().Account;
                model.CreateTime     = DateTime.Now;

                int newid = RoleDal.GetInstance().RoleAdd(model);

                if (newid > 0)
                {
                    model.RoleId = newid;
                    sysLogBll.WriteLog <Role>(model, OperationType.Add, (int)LogSatus.Success, "角色添加");
                }
                else
                {
                    sysLogBll.WriteLog <Role>(model, OperationType.Add, (int)LogSatus.fail, "角色添加");
                }
                return(newid);
            }
            else
            {
                Role OldRole = RoleDal.GetInstance().GetModel(model.RoleId);
                model.CreateTime = OldRole.CreateTime;
                int newid = RoleDal.GetInstance().RoleEdit(model);

                if (newid > 0)
                {
                    sysLogBll.WriteLog <Role>(OldRole, model, OperationType.Update, (int)LogSatus.Success, "角色修改");
                }
                else
                {
                    sysLogBll.WriteLog <Role>(OldRole, model, OperationType.Update, (int)LogSatus.fail, "角色修改");
                }
                return(newid);
            }
        }
Example #21
0
        /// <summary>
        /// Get list role
        /// </summary>
        /// <param name="objContex">Get table to object</param>
        /// <returns></returns>
        public static List <RoleDto> GetAll(ModelUnibookContainer objContex)
        {
            try
            {
                List <RoleDto> roleList = new List <RoleDto>();
                foreach (var item in RoleDal.GetAll(objContex))
                {
                    roleList.Add(RoleBrl.GetDto(item.RoleId, objContex));
                }

                return(roleList);
            }
            catch (DbEntityValidationException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var         HomePageUrl = string.Empty;
        var         roles       = Session["Roles"];
        List <Role> roleList;

        if (roles == null)
        {
            roleList         = RoleDal.SelectRoleByUsername(Security.Username);
            Session["Roles"] = roleList;
        }
        else
        {
            roleList = (List <Role>)roles;
        }

        if (roleList.Any())
        {
            HomePageUrl = roleList[0].HomeUrl;
            Response.Redirect(HomePageUrl);
        }
    }
Example #23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Security.IsAuthenticated())
        {
            return;
        }

        var list = Session["Menu"];

        List = (List <Function>)Session["list"];
        if (List == null || !List.Any())
        {
            List            = GetTree(FunctionDal.SelectByUser(Security.Username, "0"));
            Session["Menu"] = List;
        }
        else
        {
            List = (List <Function>)Session["list"];
        }

        var         roles = Session["Roles"];
        List <Role> roleList;

        if (roles == null)
        {
            roleList         = RoleDal.SelectRoleByUsername(Security.Username);
            Session["Roles"] = roleList;
        }
        else
        {
            roleList = (List <Role>)roles;
        }

        if (roleList.Any())
        {
            HomePageUrl = roleList[0].HomeUrl;
        }
    }
Example #24
0
        /*Create a new role for activity.*/
        public bool CreateRole(Role role)
        {
            bool res = true;

            try
            {
                var rdl = new RoleDal();
                rdl.Insert(role);
            }
            catch (Exception e)
            {
                res = false;
                using (StreamWriter writer =
                           new StreamWriter(@"C:\Users\JJH\Desktop\log.txt", true))
                {
                    writer.WriteLine(DateTime.Now.ToString());
                    writer.WriteLine(e.ToString());
                    //writer.WriteLine(e.StackTrace);
                }
            }

            return(res);
        }
Example #25
0
        /// <summary>
        /// 带有分页的列表信息查询
        /// </summary>
        /// <param name="queryParam">传过来的所有查询参数信息</param>
        /// <param name="pagination">分页的相关控制信息</param>
        /// <returns></returns>
        public override List <UserModel> FindPageList(Dictionary <string, string> queryParam, Pagination pagination)
        {
            List <UserModel> tempUserModel = base.FindPageList(queryParam, pagination);
            OrganizeDal      organizeDal   = new OrganizeDal();
            RoleDal          roleDal       = new RoleDal();

            foreach (UserModel userModel in tempUserModel)
            {
                if (!string.IsNullOrEmpty(userModel.F_DepartmentId))
                {
                    userModel.F_DepartmentId = organizeDal.FindForm(userModel.F_DepartmentId).F_Name;
                }
                if (!string.IsNullOrEmpty(userModel.F_OrganizeId))
                {
                    userModel.F_OrganizeId = organizeDal.FindForm(userModel.F_OrganizeId).F_Name;
                }
                if (!string.IsNullOrEmpty(userModel.F_RoleId))
                {
                    userModel.F_RoleId = roleDal.FindForm(userModel.F_RoleId).F_Name;
                }
            }

            return(tempUserModel);
        }
Example #26
0
 public List <Role> GetRoleList()
 {
     return(RoleDal.GetInstance().GetRoleList());
 }
Example #27
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder       sb = new StringBuilder();
            ClientScriptManager cs = this.Page.ClientScript;
            string _ID             = Request["ID"];
            string _CQ_ID          = Request["CQ_ID"];
            string _Ten            = Request["Ten"];
            string _q        = Request["q"];
            string _Loai_Ten = Request["Loai_Ten"];
            string _Loai_ID  = Request["Loai_ID"];
            var    _HomeUrl  = Request["HomeUrl"];

            switch (subAct)
            {
            case "get":
                #region Lấy danh sách
                if (string.IsNullOrEmpty(jgrsidx))
                {
                    jgrsidx = "ID";
                }
                if (string.IsNullOrEmpty(jgrsord))
                {
                    jgrsord = "asc";
                }
                RoleCollection  ListGet = RoleDal.TreeByUsername(Security.Username, _q, _CQ_ID, "ROLE_" + jgrsidx + " " + jgrsord);
                List <jgridRow> ListRow = new List <jgridRow>();
                foreach (Role item in ListGet)
                {
                    ListRow.Add(new jgridRow(item.ID.ToString()
                                             , new string[] {
                        item.ID.ToString(),
                        item.Ten,
                        item.Loai_Ten,
                        item._CoQuan.Ten
                    }));
                }
                jgrid grid = new jgrid("1", "1", ListGet.Count.ToString(), ListRow);
                sb.Append(JavaScriptConvert.SerializeObject(grid));
                break;

                #endregion
            case "del":
                #region Xóa
                if (!string.IsNullOrEmpty(_ID))
                {
                    RoleDal.DeleteById(_ID);
                }
                break;

                #endregion
            case "edit":
                #region chỉnh sửa
                if (!string.IsNullOrEmpty(_ID))
                {
                    sb.Append("(" + JavaScriptConvert.SerializeObject(RoleDal.SelectById(Convert.ToInt32(_ID))) + ")");
                }
                break;

                #endregion
            case "save":
                #region Lưu
                var ItemSave = new Role();
                if (!string.IsNullOrEmpty(_ID))
                {
                    ItemSave = RoleDal.SelectById(Convert.ToInt32(_ID));
                }
                ItemSave.Ten         = _Ten;
                ItemSave.HomeUrl     = _HomeUrl;
                ItemSave.CQ_ID       = Convert.ToInt32(_CQ_ID);
                ItemSave.NgayCapNhat = DateTime.Now;
                ItemSave.Active      = true;
                ItemSave.HeThong     = true;
                if (!string.IsNullOrEmpty(_Loai_ID))
                {
                    ItemSave.Loai_ID = new Guid(_Loai_ID);
                }
                ItemSave.Loai_Ten = _Loai_Ten;
                if (!string.IsNullOrEmpty(_ID))
                {
                    ItemSave = RoleDal.Update(ItemSave);
                }
                else
                {
                    ItemSave.NgayTao  = DateTime.Now;
                    ItemSave.NguoiTao = Security.Username;
                    ItemSave.RowId    = Guid.NewGuid();
                    ItemSave          = RoleDal.Insert(ItemSave);
                }
                sb.Append("1");
                break;

                #endregion
            case "getFunction":
                #region Lấy function theo role
                if (!string.IsNullOrEmpty(_ID))
                {
                    FunctionCollection ListFnByRole = FunctionDal.SelectAllFunctionByRole(_ID);
                    if (ListFnByRole.Count > 0)
                    {
                        sb.Append(getTop(ListFnByRole));
                    }
                    else
                    {
                        sb.Append("0");
                    }
                }
                break;

                #endregion
            case "updateFunction":
                #region Cập nhật thay đổi
                RoleFunctionDal.UpdateByRoleIdFunctionList(_ID, Request["UpdateList"], Security.Username);
                sb.Append("1");
                break;

                #endregion
            case "getUserByRole":
                #region Lấy thành viên trong nhóm
                if (!string.IsNullOrEmpty(_ID))
                {
                    MemberCollection ListUserByRole = MemberDal.SelectByRole(_ID);
                    if (ListUserByRole.Count > 0)
                    {
                        foreach (Member item in ListUserByRole)
                        {
                            sb.AppendFormat(@"<input type=""checkbox"" _username=""{0}"" {2} > <b>{0}</b> [ {1} ] <br/>"
                                            , item.Username, item.Ten, item.Khoa ? @"checked=""checked""" : "");
                        }
                    }
                    else
                    {
                        sb.Append("0");
                    }
                }
                break;

                #endregion
            case "updateUsers":
                #region Lưu thay đổi thành viên trong nhóm
                if (!string.IsNullOrEmpty(_ID))
                {
                    MemberRoleDal.UpdateUserListRole(Request["UpdateList"], _ID, Security.Username);
                    sb.AppendFormat("1");
                }
                break;

                #endregion
            default:
                #region nạp
                FunctionCollection ListFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                sb.Append(@"<div class=""mdl-head"">
<span class=""mdl-head-searchPnl ui-state-default ui-corner-all"">
<a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
<input type=""text"" class=""mdl-head-txt mdl-head-search mdl-head-search-quanLyQuyen"" />
</span>
<a class=""mdl-head-btn mdl-head-add"" id=""quanLyQuyenMdl-addBtn"" href=""javascript:quanLyQuyen.add();"">Thêm</a>
<a class=""mdl-head-btn mdl-head-edit"" id=""quanLyQuyenMdl-editBtn"" href=""javascript:quanLyQuyen.edit();"">Sửa</a>
<a class=""mdl-head-btn mdl-head-del"" id=""quanLyQuyenMdl-delBtn"" href=""javascript:quanLyQuyen.del();"">Xóa</a>
<span class=""mdl-head-filterPnl ui-state-default ui-corner-all"">
<a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
<input type=""text"" _value="""" class=""mdl-head-filter mdl-head-filterQuanLyQuyenByCQID""/>
</span>
</div>
<table id=""quanLyQuyenMdl-List"" class=""mdl-list"">
</table>
<div id=""quanLyQuyenMdl-Pager""></div>

<div class=""sub-mdl quanLyQuyenMdl-subMdl"">
    <ul>
        <li>
            <a id=""quanLyQuyenMdl-functionmdl-subMdlBtn"" href=""#quanLyQuyenMdl-subMdl-mdl1"">Quyền</a>
        </li>
        <li>
            <a id=""quanLyQuyenMdl-usermdl-subMdlBtn"" href=""#quanLyQuyenMdl-subMdl-mdl2"">Người dùng thuộc nhóm</a>
        </li>
    </ul>
    <div id=""quanLyQuyenMdl-subMdl-mdl1"">
        <div id=""quanLyQuyenMdl-functionmdl-roleFnMdl"">
        </div>
    </div>
    <div id=""quanLyQuyenMdl-subMdl-mdl2"">
        <div id=""quanLyQuyenMdl-functionmdl-UserInRoleMdl"">
        </div>
    </div>
</div>

");
                sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.hethong.quanLyQuyen.JScript1.js")
                                , "{quanLyQuyen.loadgrid();}");
                sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(ListFn));
                break;
                #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
Example #28
0
 public static String GetRoleName(UInt32 rol_id)
 {
     return(RoleDal.Load(rol_id).rol_name);
 }
Example #29
0
 public override void getCurrentDal()
 {
     GetCurrentDal = new RoleDal();
 }
Example #30
0
 public Role GetModel(int roleId)
 {
     return(RoleDal.GetInstance().GetModel(roleId));
 }