コード例 #1
0
ファイル: DataConditionBLL.cs プロジェクト: JiaHangIT/GMDS
        /// <summary>
        /// 将数据权限值 构建成一颗树
        /// </summary>
        private ConditionValue BuilderValuesTree(List <ConditionRawValue> data, ConditionRawValue parent)
        {
            ConditionValue conditionValue = new ConditionValue()
            {
                ConditionId   = parent.ConditionId,
                ParentCode    = parent.ParentCode,
                Id            = parent.Code,
                ConditionName = parent.ConditionName,
                SortValue     = parent.SortValue
            };
            //移除自身
            List <ConditionRawValue> childs = data.Where(e => e.ParentCode == parent.Code).ToList();

            if (childs.Count == 0)
            {
                return(conditionValue);
            }
            ConditionRawValue parent_entity = data.FirstOrDefault(e => e.Code == parent.Code);

            if (parent_entity != null)
            {
                data.Remove(parent_entity);
            }
            foreach (ConditionRawValue child in childs)
            {
                conditionValue.Children.Add(BuilderValuesTree(data.Where(e => e.ParentCode == child.Code).ToList(), child));
            }
            return(conditionValue);
        }
コード例 #2
0
ファイル: DataConditionBLL.cs プロジェクト: JiaHangIT/GMDS
        ///// <summary>
        ///// 获取当前用户 在该控制器下所拥有的数据权限
        ///// </summary>
        ///// <param name="currentUserId"></param>
        ///// <param name="controllerId"></param>
        ///// <param name="conditionId">若该值不为null,则返回该值下的数据权限,否则返回该用户下的所有数据权限</param>
        ///// <returns>返回List</returns>
        //public List<ConditionValueObject> GetCurrentUserConditionList(string currentUserId, string controllerId, string conditionId = null)
        //{
        //    if (_context.SysUserInfo.FirstOrDefault(e => e.UserId == currentUserId && e.UserAccount == "admin") != null)
        //    {
        //        var list = GetConditionRawValueList();
        //        return list.Where(e => e.ConditionId == conditionId || string.IsNullOrWhiteSpace(conditionId)).Select(c => new ConditionValueObject
        //        {
        //            ConditionId = c.ConditionId,
        //            ConditionName = c.ConditionName,
        //            ConditionValue = c.Code,
        //        }).Distinct().ToList();
        //    }

        //    //获取用户所属的用户组
        //    var groupsid = _context.SysUserGroupRelation.Where(e => e.UserId == currentUserId).Select(e => e.UserGroupId);
        //    var group_data = _context.UserDataCondition
        //        .Where(e => groupsid.Contains(e.UserGroupId)
        //    && e.ControllerId == controllerId
        //    && (string.IsNullOrWhiteSpace(conditionId) || e.ConditionId == conditionId))
        //    .Select(c => new ConditionValueObject
        //    {
        //        ConditionId = c.ConditionId,
        //        ConditionName = c.ConditionName,
        //        ConditionValue = c.ConditionValue
        //    }).ToList();
        //    var data = _context.UserDataCondition
        //        .Where(e => e.UserId == currentUserId
        //    && e.ControllerId == controllerId
        //    && (string.IsNullOrWhiteSpace(conditionId) || e.ConditionId == conditionId))
        //    .Select(c => new ConditionValueObject
        //    {
        //        ConditionId = c.ConditionId,
        //        ConditionName = c.ConditionName,
        //        ConditionValue = c.ConditionValue,
        //    }).ToList();
        //    group_data.AddRange(data);
        //    return group_data.Distinct().ToList();
        //}

        private List <ConditionValue> AcquisitionGetValue(List <ConditionValue> ConditionValues, List <string> codes, bool isbind)
        {
            List <ConditionValue> result = new List <ConditionValue>();

            if (ConditionValues.Count <= 0)
            {
                return(result);
            }

            foreach (ConditionValue obj in ConditionValues)
            {
                if (codes.Contains(obj.Id) == isbind)
                {
                    ConditionValue c = new ConditionValue()
                    {
                        Id            = obj.Id,
                        ConditionId   = obj.ConditionId,
                        ParentCode    = obj.ParentCode,
                        ConditionName = obj.ConditionName,
                        SortValue     = obj.SortValue
                    };
                    if (obj.Children.Count > 0)
                    {
                        c.Children = AcquisitionGetValue(obj.Children, codes, isbind);
                    }
                    result.Add(c);
                }
                else
                {
                    if (obj.Children.Count > 0)
                    {
                        List <ConditionValue> childrens = AcquisitionGetValue(obj.Children, codes, isbind);
                        if (childrens.Count > 0)
                        {
                            result.AddRange(childrens);
                        }
                    }
                }
            }
            return(result);
        }
コード例 #3
0
ファイル: DataConditionBLL.cs プロジェクト: JiaHangIT/GMDS
        private List <ConditionValue> AcquisitionGetValue(List <ConditionValue> ConditionValues, List <MathModel> codes, bool isbind)
        {
            List <ConditionValue> result = new List <ConditionValue>();

            if (ConditionValues == null || ConditionValues.Count <= 0)
            {
                return(result);
            }

            foreach (ConditionValue obj in ConditionValues)
            {
                MathModel code = codes.FirstOrDefault(e => e.ConditionValue == obj.Id);
                if (code != null)
                {
                    ConditionValue c = new ConditionValue()
                    {
                        Id              = obj.Id,
                        ConditionId     = obj.ConditionId,
                        ParentCode      = obj.ParentCode,
                        ConditionName   = obj.ConditionName,
                        UserConditionId = code.UserConditionId,
                        SortValue       = obj.SortValue,
                    };
                    if (obj.Children.Count > 0)
                    {
                        c.Children = AcquisitionGetValue(obj.Children, codes, isbind);
                    }
                    result.Add(c);
                }
                else
                {
                    if (obj.Children.Count > 0)
                    {
                        List <ConditionValue> childrens = AcquisitionGetValue(obj.Children, codes, isbind);
                        if (childrens.Count > 0)
                        {
                            result.AddRange(childrens);
                        }
                    }
                }

                //if (codes.Contains(obj.Id) == isbind)
                //{
                //    var c = new ConditionValue()
                //    {
                //        Id = obj.Id,
                //        ConditionId = obj.ConditionId,
                //        ParentCode = obj.ParentCode,
                //        ConditionName = obj.ConditionName
                //    };
                //    if (obj.Children.Count > 0)
                //    {
                //        c.Children = AcquisitionGetValue(obj.Children, codes, isbind);
                //    }
                //    result.Add(c);
                //}
                //else
                //{
                //    if (obj.Children.Count > 0)
                //    {
                //        var childrens = AcquisitionGetValue(obj.Children, codes, isbind);
                //        if (childrens.Count > 0) result.AddRange(childrens);
                //    }
                //}
            }
            return(result);
        }