Ejemplo n.º 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, "权限保存成功。"));
        }
Ejemplo n.º 2
0
 /// <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));
 }
Ejemplo n.º 3
0
 public void Insert(int index, OrgPositionOperationDeny entity)
 {
     base.Insert(index, entity);
 }
Ejemplo n.º 4
0
 public int IndexOf(OrgPositionOperationDeny entity)
 {
     return(base.IndexOf(entity));
 }
Ejemplo n.º 5
0
 public bool Contains(OrgPositionOperationDeny entity)
 {
     return(base.Contains(entity));
 }
Ejemplo n.º 6
0
 public void Add(OrgPositionOperationDeny entity)
 {
     base.Add(entity);
 }
Ejemplo n.º 7
0
 public bool Remove(OrgPositionOperationDeny entity)
 {
     return(base.Remove(entity));
 }