コード例 #1
0
        protected override Result ExecuteCore()
        {
            var orgPosition = RF.Find <OrgPosition>().GetById(this.OrgPositionId) as OrgPosition;

            if (orgPosition == null)
            {
                return("没有找到对应的岗位。");
            }

            var curModule = RF.Find <ModuleAC>().GetById(this.ModuleId) as ModuleAC;
            var moduleKey = curModule.KeyLabel;

            var ids = this.DenyOperationIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
                      .Select(strId => Convert.ToInt32(strId)).ToArray();

            //清空当前模块在 denyList 中的数据
            var denyList         = orgPosition.OrgPositionOperationDenyList;
            var moduleOperations = denyList.Cast <OrgPositionOperationDeny>().Where(d => d.ModuleKey == moduleKey).ToArray();

            foreach (var item in moduleOperations)
            {
                denyList.Remove(item);
            }

            //根据当前的选择项把数据重新加入到 denyList 中。
            var toDeny = ids.Select(id => curModule.OperationACList.FirstOrDefault(op => op.Id.Equals(id)))
                         .Where(op => op != null).ToArray();
            var moduleScopeTranslated = OperationAC.ModuleScope.Translate();

            foreach (OperationAC item in toDeny)
            {
                var deny = new OrgPositionOperationDeny
                {
                    ModuleKey    = moduleKey,
                    OperationKey = item.OperationKey
                };
                if (item.ScopeKeyLabel != moduleScopeTranslated)
                {
                    deny.BlockKey = item.ScopeKeyLabel;
                }

                denyList.Add(deny);
            }

            //保存到数据库中。
            RF.Save(orgPosition);

            return(new Result(true, "权限保存成功。"));
        }
コード例 #2
0
ファイル: OperationAC.cs プロジェクト: SmartCloud2025/Rafy
 /// <summary>
 /// 判断当前的这个操作是否和指定的禁用操作是同一个操作。
 /// </summary>
 /// <param name="deny"></param>
 /// <returns></returns>
 public bool IsSame(OrgPositionOperationDeny deny)
 {
     //模块名、功能名、所属界面块同时相同
     return(deny.ModuleKey.Translate() == this.ModuleAC.KeyLabel && deny.OperationKey == this.OperationKey &&
            (string.IsNullOrEmpty(deny.BlockKey) && this.ScopeKeyLabel == OperationAC.ModuleScope.Translate() || deny.BlockKey.Translate() == this.ScopeKeyLabel));
 }
コード例 #3
0
 public void Insert(int index, OrgPositionOperationDeny entity)
 {
     base.Insert(index, entity);
 }
コード例 #4
0
 public int IndexOf(OrgPositionOperationDeny entity)
 {
     return(base.IndexOf(entity));
 }
コード例 #5
0
 public bool Contains(OrgPositionOperationDeny entity)
 {
     return(base.Contains(entity));
 }
コード例 #6
0
 public void Add(OrgPositionOperationDeny entity)
 {
     base.Add(entity);
 }
コード例 #7
0
 public bool Remove(OrgPositionOperationDeny entity)
 {
     return(base.Remove(entity));
 }