Beispiel #1
0
        public List <string> GetTreeParentIds(VirgoContext KnifeVirgo, List <DataPrivilege> dps)
        {
            var ids      = dps.Where(x => x.TableName == this.ModelName).Select(x => x.RelateId).ToList();
            var idscheck = ids.GetContainIdExpression <T>();
            var modified = KnifeVirgo.DC.Set <T>().Where(idscheck).CheckNotNull("ParentId").DynamicSelect("ParentId").Select(x => x.ToLower());
            var skipids  = modified.ToList();

            return(skipids);
        }
Beispiel #2
0
        /// <summary>
        /// 获取数据权限的下拉菜单
        /// </summary>
        /// <param name="KnifeVirgo">wtm context</param>
        /// <param name="filter">filter</param>
        /// <returns>数据权限关联表的下拉菜单</returns>
        public List <ComboSelectListItem> GetItemList(VirgoContext KnifeVirgo, string filter = null, List <string> ids = null)
        {
            var user = KnifeVirgo?.LoginUserInfo;

            Expression <Func <T, bool> > where = null;

            if (ids != null)
            {
                where = ids.GetContainIdExpression <T>();
            }
            else
            {
                if (string.IsNullOrEmpty(filter) == false)
                {
                    ChangePara          cp = new ChangePara();
                    ParameterExpression pe = Expression.Parameter(typeof(T));
                    // var toString = Expression.Call(cp.Change(_displayField.Body, pe), "ToString", new Type[] { });
                    var tolower = Expression.Call(cp.Change(_displayField.Body, pe), "ToLower", new Type[] { });
                    var exp     = Expression.Call(tolower, "Contains", null, Expression.Constant(filter.ToLower()));
                    where = Expression.Lambda <Func <T, bool> >(exp, pe);
                    if (_where != null)
                    {
                        var temp     = cp.Change(_where.Body, pe);
                        var together = Expression.And(where.Body, temp);
                        where = Expression.Lambda <Func <T, bool> >(together, pe);
                    }
                }
                else
                {
                    where = _where;
                }
                if (where == null)
                {
                    where = x => 1 == 1;
                }
            }
            List <ComboSelectListItem> rv = new List <ComboSelectListItem>();

            if (user.Roles?.Where(x => x.RoleCode == "001").FirstOrDefault() == null && user.DataPrivileges?.Where(x => x.RelateId == null).FirstOrDefault() == null)
            {
                rv = KnifeVirgo.DC.Set <T>().Where(x => user.DataPrivileges.Select(y => y.RelateId).Contains(x.ID.ToString())).Where(where).GetSelectListItems(null, _displayField, null, ignorDataPrivilege: true);
            }
            else
            {
                rv = KnifeVirgo.DC.Set <T>().Where(where).GetSelectListItems(null, _displayField, null, ignorDataPrivilege: true);
            }
            return(rv);
        }
Beispiel #3
0
        public List <string> GetTreeSubIds(VirgoContext KnifeVirgo, List <string> pids)
        {
            Expression <Func <TreePoco, object> > parentid = x => x.ParentId;

            return(KnifeVirgo.DC.Set <T>().Where(pids.GetContainIdExpression <T>(parentid.Body)).DynamicSelect("ID").ToList());
        }