コード例 #1
0
        public JsonResult List(SysDictViewModel viewModel, PageInfo pageInfo)
        {
            QueryCollection queries = new QueryCollection();

            if (!string.IsNullOrEmpty(viewModel.Name))
            {
                queries.Add(new Query {
                    Name = "Name", Operator = Query.Operators.Contains, Value = viewModel.Name
                });
            }
            else if (!string.IsNullOrEmpty(viewModel.Code))
            {
                queries.Add(new Query {
                    Name = "Code", Operator = Query.Operators.Contains, Value = viewModel.Code
                });
            }
            else if (viewModel.TypeId != 0)
            {
                queries.Add(new Query {
                    Name = "TypeId", Operator = Query.Operators.Equal, Value = viewModel.TypeId
                });
            }
            var list = SysDictService.GetListByPage(queries.AsExpression <SysDict>(), x => true, pageInfo.Limit, pageInfo.Page, out int totalCount, true).Select(x => new
            {
                x.Id,
                x.Name,
                x.Code,
                x.SortCode
            }).ToList();

            return(Json(Pager.Paging(list, totalCount), JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public JsonResult List(SysUserViewModel viewModel, PageInfo pageInfo)
        {
            QueryCollection queries = new QueryCollection();

            if (!string.IsNullOrEmpty(viewModel.UserName))
            {
                queries.Add(new Query {
                    Name = "UserName", Operator = Query.Operators.Contains, Value = viewModel.UserName
                });
            }
            if (!string.IsNullOrEmpty(viewModel.NickName))
            {
                queries.Add(new Query {
                    Name = "NickName", Operator = Query.Operators.Contains, Value = viewModel.NickName
                });
            }
            var list = SysUserService.GetListByPage(queries.AsExpression <SysUser>(), x => true, pageInfo.Limit, pageInfo.Page, out int totalCount, true).Select(x => new
            {
                x.Id,
                x.UserName,
                x.NickName,
                x.HeadIcon,
                x.MobilePhone,
                x.Email,
                x.EnabledMark
            }).ToList();

            return(Json(Pager.Paging(list, totalCount), JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public Expression <Func <T, bool> > AsExpression <T>() where T : class
        {
            QueryCollection queryCollection = new QueryCollection();
            var             properties      = typeof(T).GetTypeInfo().GetProperties();

            foreach (var item in Columns)
            {
                var p = properties.FirstOrDefault(m => m.Name.Equals(item.Data, StringComparison.OrdinalIgnoreCase));
                if (p == null)
                {
                    continue;
                }
                var    realType = Nullable.GetUnderlyingType(p.PropertyType) ?? p.PropertyType;
                string value    = null;
                if (item.Search != null && item.Search.Value.IsNotNullAndWhiteSpace())
                {
                    value = item.Search.Value;
                }
                else if (Search != null && Search.Value.IsNotNullAndWhiteSpace() && realType == typeof(string))
                {
                    value = Search.Value;
                }
                if ((item.Search.Opeartor == Query.Operators.Range && item.Search.ValueMin.IsNullOrWhiteSpace() && item.Search.ValueMax.IsNullOrWhiteSpace()) ||
                    (item.Search.Opeartor != Query.Operators.Range && value.IsNullOrWhiteSpace()))
                {
                    continue;
                }

                Query query = new Query();
                query.Name = p.Name;
                try
                {
                    query.Value    = Easy.Reflection.ClassAction.ValueConvert(p, value);
                    query.ValueMin = Easy.Reflection.ClassAction.ValueConvert(p, item.Search.ValueMin);
                    query.ValueMax = Easy.Reflection.ClassAction.ValueConvert(p, item.Search.ValueMax);

                    if (query.ValueMax != null && query.ValueMax is DateTime)
                    {
                        query.ValueMax = ((DateTime)query.ValueMax).AddDays(1).AddMilliseconds(-1);
                    }
                }
                catch
                {
                    continue;
                }

                query.Operator = item.Search.Opeartor;
                queryCollection.Add(query);
            }
            return(queryCollection.AsExpression <T>(Query.Condition.AndAlso));
        }
コード例 #4
0
        public JsonResult List(SysLogLogonViewModel viewModel, PageInfo pageInfo)
        {
            QueryCollection queries = new QueryCollection();

            if (!string.IsNullOrEmpty(viewModel.RealName))
            {
                queries.Add(new Query {
                    Name = "RealName", Operator = Query.Operators.Contains, Value = viewModel.RealName
                });
            }
            if (!string.IsNullOrEmpty(viewModel.Account))
            {
                queries.Add(new Query {
                    Name = "Account", Operator = Query.Operators.Contains, Value = viewModel.Account
                });
            }
            if (!string.IsNullOrEmpty(viewModel.StartEndDate))
            {
                queries.Add(new Query {
                    Name = "CreateTime", Operator = Query.Operators.GreaterThanOrEqual, Value = StartEndDateHelper.GteStartDate(viewModel.StartEndDate)
                });
                queries.Add(new Query {
                    Name = "CreateTime", Operator = Query.Operators.LessThanOrEqual, Value = StartEndDateHelper.GteEndDate(viewModel.StartEndDate)
                });
            }
            var list = SysLogLogonService.GetListByPage(queries.AsExpression <SysLogLogon>(), x => true, pageInfo.Limit, pageInfo.Page, out int totalCount, true).Select(x => new
            {
                x.Id,
                x.LogType,
                x.Account,
                x.RealName,
                x.Description,
                x.IPAddress,
                x.IPAddressName,
                x.CreateTime
            }).ToList();

            return(Json(Pager.Paging(list, totalCount), JsonRequestBehavior.AllowGet));
        }