/// <summary> /// 添加一个权限 /// </summary> /// <returns></returns> public int Add() { ActionDAL dal = new ActionDAL(connectionString); _actionid = dal.Add(_actionname, _actioncolumnid, _actionstr, _link); return(_actionid); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int userId = GetUserId; if (userId != 0) { DataSet dsActionStruct = TablesBLL.GetTableFields("Action", null); //操作表结构数据集 ViewState["dsActionStruct"] = dsActionStruct; DataSet dsMyActionStruct = TablesBLL.GetTableFields("User_Action", null); //用户-操作表结构数据集 ViewState["dsMyActionStruct"] = dsMyActionStruct; DataSet dsMetaData = MetaDataDAL.GetGroupMetaData(); ViewState["dsMetaData"] = dsMetaData; DataSet myActions = ActionDAL.GetUserActionByUserID(userId); ViewState["myActions"] = myActions; DataSet sysActions = ActionDAL.GetAllActions(); ViewState["sysActions"] = sysActions; DataTable dt = GetBindData(userId, myActions, sysActions, dsMetaData, dsActionStruct, dsMyActionStruct); BindGV(gvActions, dt); } else { lbErr.Text = "请先登录"; } //btnClose.Click += btnClose_Click; } btnSave.Click += btnSave_Click; }
public List <ActionInfo> GetActionsByMenuRoleFid(Guid menuFid) { List <MenuActionInfo> list = dal.GetList("and [VALID_FLAG] = 1 and [MENU_FID] = '" + menuFid + "'", string.Empty); if (list.Count == 0) { return(new List <ActionInfo>()); } List <ActionInfo> actionList = new ActionDAL().GetList("and [VALID_FLAG] = 1 " + "and [FID] in ('" + string.Join("','", list.Select(d => d.ActionFid.GetValueOrDefault()).ToArray()) + "')" , string.Empty); foreach (var actionInfo in actionList) { var info = list.SingleOrDefault(d => d.ActionFid == actionInfo.Fid); if (info == null) { continue; } actionInfo.DisplayOrder = info.ActionOrder.GetValueOrDefault(); actionInfo.ClientJs = info.ClientJs; actionInfo.Fid = info.Fid; } return(actionList.OrderBy(d => d.DisplayOrder).ToList()); }
/// <summary> /// 返回所有的权限列表(静态方法) /// </summary> /// <returns></returns> public static ArrayList GetActions() { //从配置文件web.config中读取连接字符串 AppSettingsReader configurationAppSettings = new AppSettingsReader(); string connString = ((string)(configurationAppSettings.GetValue("ConStr", typeof(string)))); ActionDAL dal = new ActionDAL(connString); return(dal.GetActions()); }
/// <summary> /// 更新权限 /// </summary> /// <returns></returns> public bool Update() { if (_actionid == -1) { return(false); } ActionDAL dal = new ActionDAL(connectionString); return(dal.Update(_actionid, _actionname, _actioncolumnid, _actionstr, _link)); }
/// <summary> /// 页面加载与控件事件绑定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { //btnSetAction.Click += BtnSetActions_Click;//设计计划的操作 btnSubmit.Click += BtnSubmit_Click;//提交计划保存 btnCancel.Click += BtnCancel_Click; btnAddSingle.Click += BtnAddSingle_Click; btnAddMulti.Click += BtnAddMulti_Click; ddlPlanAction.SelectedIndexChanged += DdlPlanAction_SelectedIndexChanged; //btnSaveToPlan.Click += BtnSaveToPlan_Click; btnSaveToList.Click += BtnSaveToList_Click; btnCancelToList.Click += BtnCancelToList_Click; gvPlans.RowDataBound += GvPlans_RowDataBound; gvActions.RowDataBound += GvActions_RowDataBound; gvPlans.RowCommand += GvPlans_RowCommand; if (!IsPostBack) { int userId = VSDLL.Common.Users.UserID; if (userId == 0) { divList.Visible = false; divPlan.Visible = false; divAction.Visible = false; lbPTitle.Visible = false; lbErr.Text = "你尚未登录,无法管理个人计划!"; } else { lbPTitle.Visible = true; lbErr.Text = ""; try { //获取计划列表 DataSet dsPlans = TaskDAL.GetDailyTask(userId); DataTable dtPlans = dsPlans.Tables[0]; ViewState["dtPlans"] = dtPlans; //获取操作列表 DataSet dsActions = ActionDAL.GetAllActions(0); DataTable dtActions = dsActions.Tables[0]; ViewState["dtActions"] = dtActions; //获取操作关系列表 DataSet dsRelations = ActionDAL.GetActionRelation(); DataTable dtRelations = dsRelations.Tables[0]; ViewState["dtRelations"] = dtRelations; //绑定计划列表 BindgvPlans(dtPlans); } catch (Exception ex) { lbErr.Text = ex.ToString(); } } } }
/// <summary> /// 添加一个权限分配 /// </summary> /// <param name="groupID"></param> /// <returns></returns> public bool AddGrant(int groupID) { if (_actionid == -1) { return(false); } ActionDAL dal = new ActionDAL(connectionString); return(dal.AddPermissionGrant(_actionid, groupID)); }
/// <summary> /// 删除权限 /// </summary> /// <returns></returns> public bool Delete() { ActionDAL dal = new ActionDAL(connectionString); bool result = dal.Delete(_actionid); if (result) //删除后把ID设置为-1 { _actionid = -1; } return(result); }
public List <ActionInfo> GetActionsByMenuRoleFid(Guid menuFid, Guid roleFid) { List <MenuActionInfo> list = dal.GetList("and [MENU_FID] = '" + menuFid + "'", string.Empty); if (list.Count == 0) { return(new List <ActionInfo>()); } List <Guid> notNeedAuthFids = list.Where(d => !d.NeedAuth.GetValueOrDefault()).Select(d => d.ActionFid.GetValueOrDefault()).ToList(); ///权限 List <Guid> sourceFids = new RoleAuthDAL().GetAuthSourceFidsByRoleFidAuthTypeInSourceFids(roleFid , 2 , "'" + string.Join("','", list.Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "'"); string actionFidCondition = string.Empty; if (sourceFids.Count > 0) { List <Guid> actionFids = list.Where(d => sourceFids.Contains(d.Fid.GetValueOrDefault())).Select(d => d.ActionFid.GetValueOrDefault()).ToList(); if (actionFids.Count > 0) { actionFidCondition += ",'" + string.Join("','", actionFids.ToArray()) + "'"; } } if (notNeedAuthFids.Count > 0) { actionFidCondition += ",'" + string.Join("','", notNeedAuthFids.ToArray()) + "'"; } if (string.IsNullOrEmpty(actionFidCondition)) { return(new List <ActionInfo>()); } List <ActionInfo> actionList = new ActionDAL().GetList("and [FID] in (" + actionFidCondition.Substring(1) + ")" , string.Empty); foreach (var actionInfo in actionList) { var info = list.SingleOrDefault(d => d.ActionFid == actionInfo.Fid); if (info == null) { continue; } actionInfo.DisplayOrder = info.ActionOrder.GetValueOrDefault(); actionInfo.ClientJs = info.ClientJs; actionInfo.Fid = info.Fid; } return(actionList.OrderBy(d => d.DisplayOrder).ToList()); }
/// <summary> /// 获取指定权限的详细信息 /// </summary> /// <param name="actionid"></param> public ActionBLL(int actionid) : base() { _actionid = -1; ActionDAL dal = new ActionDAL(connectionString); RADinfo_MIS_COST.Model.Action model = dal.GetDetails(actionid); if (model != null) { _actionid = model.ActionId; _actionname = model.ActionName; _actionstr = model.ActionStr; _actioncolumnid = model.ActionColumnid; _link = model.Link; } }
// Uppdaterar ändringar för vald åtgärd i databasen public void SaveAction(Action action) { // Validering ICollection <ValidationResult> validationResults; if (!action.Validate(out validationResults)) { var ex = new ValidationException("Objektet klarade inte valideringen."); ex.Data.Add("ValidationResults", validationResults); throw ex; } if (action.ÅtgID == 0) { ActionDAL.InsertAction(action); } else { ActionDAL.UpdateAction(action); } }
/// <summary> /// 获取所有需要授权的项目,其中IS_AUTH=TRUE表示已经授权 /// </summary> /// <param name="roleFid"></param> /// <returns></returns> public List <RoleAuthInfo> GetRoleAuthList(Guid roleFid) { ///需要授权的菜单 List <MenuInfo> menus = new MenuDAL().GetList("and [VALID_FLAG] <> 0", string.Empty); ///需要授权的功能项 List <MenuActionInfo> menuactions = new MenuActionDAL().GetList("and [VALID_FLAG] <> 0", string.Empty); ///功能项 List <ActionInfo> actions = new ActionDAL().GetList("and [VALID_FLAG] <> 0", string.Empty); ///需要授权的报表 List <ReportInfo> reports = new ReportDAL().GetList("and [VALID_FLAG] <> 0", string.Empty); ///需要授权的图表 List <ChartInfo> charts = new ChartDAL().GetList("and [VALID_FLAG] <> 0", string.Empty); ///角色对应已授权的项目 List <RoleAuthInfo> roleauths = new RoleAuthDAL().GetList("and [ROLE_FID] = '" + roleFid + "' and [IS_AUTH] <> 0 and [VALID_FLAG] <> 0", string.Empty); List <RoleAuthInfo> list = new List <RoleAuthInfo>(); ///菜单 foreach (var item in menus) { RoleAuthInfo info = new RoleAuthInfo(); info.AuthSourceFid = item.Fid; info.AuthSourceName = item.MenuName + "|" + item.MenuNameCn; info.AuthType = 1; info.AuthTypeName = "菜单"; info.DisplayOrder = item.DisplayOrder.GetValueOrDefault(); if (item.NeedAuth.GetValueOrDefault()) { var roleauth = roleauths.FirstOrDefault(d => d.AuthSourceFid == item.Fid && d.AuthType == 1); info.IsAuth = roleauth == null ? false : true; } else { info.IsAuth = true; } info.ParentSourceFid = item.ParentMenuFid.GetValueOrDefault(); list.Add(info); } ///功能 foreach (var item in menuactions) { RoleAuthInfo info = new RoleAuthInfo(); info.AuthSourceFid = item.Fid; var action = actions.FirstOrDefault(d => d.Fid == item.ActionFid); if (action == null) { continue; } info.AuthSourceName = action.ActionName + "|" + action.ActionNameCn; info.AuthType = 2; info.AuthTypeName = "功能"; info.DisplayOrder = item.ActionOrder.GetValueOrDefault(); if (item.NeedAuth.GetValueOrDefault()) { var roleauth = roleauths.FirstOrDefault(d => d.AuthSourceFid == item.Fid && d.AuthType == 2); info.IsAuth = roleauth == null ? false : true; } else { info.IsAuth = true; } info.ParentSourceFid = item.MenuFid.GetValueOrDefault(); var menuinfo = list.FirstOrDefault(d => d.AuthType == 1 && d.AuthSourceFid == item.MenuFid); if (menuinfo == null) { continue; } list.Add(info); } RoleAuthInfo reportauth = new RoleAuthInfo(); reportauth.AuthSourceFid = Guid.Parse("2238F7AD-9196-4B53-A0D0-81460FDA1F4C"); reportauth.AuthSourceName = "REPORT|报表"; reportauth.AuthType = 1; reportauth.AuthTypeName = "菜单"; reportauth.IsAuth = true; reportauth.DisplayOrder = int.MaxValue - 1; reportauth.ParentSourceFid = Guid.Empty; list.Add(reportauth); ///报表 foreach (var item in reports) { RoleAuthInfo info = new RoleAuthInfo(); info.AuthSourceFid = item.Fid; info.AuthSourceName = item.NameEn + "|" + item.Name; info.AuthType = 3; info.AuthTypeName = "报表"; if (item.IsAuth.GetValueOrDefault()) { var roleauth = roleauths.FirstOrDefault(d => d.AuthSourceFid == item.Fid && d.AuthType == 3); info.IsAuth = roleauth == null ? false : true; } else { info.IsAuth = true; } info.ParentSourceFid = reportauth.AuthSourceFid.GetValueOrDefault(); list.Add(info); } RoleAuthInfo chartauth = new RoleAuthInfo(); chartauth.AuthSourceFid = Guid.Parse("6E714DD6-2D41-45AE-88C2-433EEF1973E9"); chartauth.AuthSourceName = "CHART|图表"; chartauth.AuthType = 1; chartauth.AuthTypeName = "菜单"; chartauth.IsAuth = true; chartauth.DisplayOrder = int.MaxValue; chartauth.ParentSourceFid = Guid.Empty; list.Add(chartauth); ///图表 foreach (var item in charts) { RoleAuthInfo info = new RoleAuthInfo(); info.AuthSourceFid = item.Fid; info.AuthSourceName = item.NameEn + "|" + item.Name; info.AuthType = 4; info.AuthTypeName = "图表"; if (item.IsAuth.GetValueOrDefault()) { var roleauth = roleauths.FirstOrDefault(d => d.AuthSourceFid == item.Fid && d.AuthType == 4); info.IsAuth = roleauth == null ? false : true; } else { info.IsAuth = true; } info.ParentSourceFid = chartauth.AuthSourceFid.GetValueOrDefault(); list.Add(info); } return(list.OrderBy(d => d.DisplayOrder).ToList()); }
// Hämtar vald åtgärd från databasen public Action GetAction(int actionId) { return(ActionDAL.GetAction(actionId)); }
// Hämtar vald åtgärd från databasen med FelanmID public List <Action> GetActionByCaseId(int caseId) { return(ActionDAL.GetActionByCaseId(caseId)); }
// Hämtar alla åtgärder som finns lagrade i databasen public IEnumerable <Action> GetActions() { return(ActionDAL.GetActionList()); }
/// <summary> /// 返回未分配权限的角色 /// </summary> /// <returns></returns> public ArrayList GetExcludeRoles() { ActionDAL dal = new ActionDAL(connectionString); return(dal.GetExcludeRoles(_actionid)); }
/// <summary> /// 只获取弹出窗体的授权动作 /// </summary> /// <param name="menuFid"></param> /// <param name="roleFid"></param> /// <param name="entityName"></param> /// <param name="formEditWidth"></param> /// <param name="formEditHeight"></param> /// <param name="formUrl"></param> /// <returns></returns> public List <ActionInfo> GetFormActions(Guid menuFid, Guid roleFid, string entityName, out int formEditWidth, out int formEditHeight, out string formUrl) { ///out默认值 formEditWidth = 800; formEditHeight = 480; formUrl = string.Empty; ///弹出窗体,在菜单管理中限制同级菜单名称不能重复 MenuInfo formMenuInfo = new MenuDAL().GetInfo(entityName, menuFid); if (formMenuInfo == null) { throw new Exception("MC:0x00000028");///菜单数据错误 } ///窗体属性 formEditWidth = formMenuInfo.EditFormWidth.GetValueOrDefault(); formEditHeight = formMenuInfo.EditFormHeight.GetValueOrDefault(); formUrl = formMenuInfo.LinkUrl; ///所有按钮,后期按MENU_FID区分 List <MenuActionInfo> menuAtions = dal.GetList("[MENU_FID] = N'" + formMenuInfo.Fid.GetValueOrDefault() + "'", string.Empty); ///无按钮 if (menuAtions.Count == 0) { return(new List <ActionInfo>()); } ///不需要授权页面按钮的FID List <Guid> menuActionFids = menuAtions.Where(d => !d.NeedAuth.GetValueOrDefault()).Select(d => d.Fid.GetValueOrDefault()).ToList(); ///获取已授权的按钮GUID List <Guid> sourceFids = new RoleAuthDAL().GetAuthSourceFidsByRoleFidAuthTypeInSourceFids(roleFid , (int)AuthTypeConstants.ACTION///授权类型为按钮 , menuAtions.Count(d => d.NeedAuth.GetValueOrDefault()) == 0 ? string.Empty : "'" + string.Join("','", menuAtions.Where(d => d.NeedAuth.GetValueOrDefault()).Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "'"); ///可以显示的页面按钮 menuActionFids.AddRange(sourceFids); if (menuActionFids.Count == 0) { return(new List <ActionInfo>()); } ///获取所有的动作按钮 List <ActionInfo> actionList = new ActionDAL().GetList("[FID] in ('" + string.Join("','", menuAtions.Where(d => menuActionFids.Contains(d.Fid.GetValueOrDefault())).Select(d => d.ActionFid.GetValueOrDefault()).ToArray()) + "')", string.Empty); List <ActionInfo> actionInfos = new List <ActionInfo>(); foreach (var menuActionFid in menuActionFids) { MenuActionInfo menuActionInfo = menuAtions.FirstOrDefault(d => d.Fid.GetValueOrDefault() == menuActionFid); if (menuActionInfo == null) { continue; } ActionInfo actionInfo = actionList.FirstOrDefault(d => d.Fid.GetValueOrDefault() == menuActionInfo.ActionFid.GetValueOrDefault()).Clone(); if (actionInfo == null) { continue; } actionInfo.IsListAction = false; actionInfo.DisplayOrder = menuActionInfo.ActionOrder.GetValueOrDefault(); actionInfo.ClientJs = menuActionInfo.ClientJs; actionInfo.Fid = menuActionInfo.Fid; actionInfo.DetailFlag = menuActionInfo.DetailFlag.GetValueOrDefault(); actionInfos.Add(actionInfo); } return(actionInfos.OrderBy(d => d.DisplayOrder).ToList()); }
public void DeleteAction(int actionId) { ActionDAL.DeleteAction(actionId); }