Exemplo n.º 1
0
        public override List <T> GetList <T>(Expression <Func <ArticleInfo, bool> > func, PageCondition page)
        {
            var total = 0;

            var list      = GetList <ArticleInfoView>(func, page.PageIndex, page.PageSize, ref total, page.SortConditions);
            var ids       = list.AsParallel().Select(x => x.Id).ToList();
            var thumbsups = _articleThumbsUpService.Repository.Entities.Where(x => ids.Contains(x.ArticleID) &&
                                                                              x.IsDeleted != true && x.Type == ThumbupType.Article.ToString()).Select(x => new { x.ArticleID }).ToList().AsParallel();

            page.RowCount = total;

            Parallel.ForEach(list, x =>
            {
                x.ThumbsUpCount = thumbsups.Count(y => y.ArticleID == x.Id);
            });

            return(list.Select(x => (T)(IViewModel)x).ToList());
        }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="CurPage"></param>
 /// <param name="PageSize"></param>
 /// <param name="iTotal"></param>
 /// <returns></returns>
 public virtual List <T1> GetListEx(Expression <Func <T0, bool> > predicate, PageCondition con)
 {
     return(_BaseService.GetList <T1>(predicate, con));
 }
Exemplo n.º 3
0
        public override List <AwardView> GetListEx(Expression <Func <AwardEntity, bool> > predicate, PageCondition con)
        {
            string strStartTime = Request["StartTime"];
            string strEndTime   = Request["EndTime"];

            int    pollingId = Convert.ToInt32(Request["pollingId"]);
            string type      = Request["type"];

            if (!string.IsNullOrEmpty(strStartTime) && !string.IsNullOrEmpty(strEndTime))
            {
                strStartTime = strStartTime + " 00:00:00";
                strEndTime   = strEndTime + " 23:59:59";
                DateTime strtime = Convert.ToDateTime(strStartTime);
                DateTime endtime = Convert.ToDateTime(strEndTime);
                predicate = x => x.PollingId == pollingId && x.Type == type && x.AccessDate >= strtime && x.AccessDate <= endtime;
            }
            else
            {
                predicate = x => x.PollingId == pollingId && x.Type == type;
            }
            con.SortConditions.Add(new SortCondition("AccessDate", System.ComponentModel.ListSortDirection.Descending));

            var list = _BaseService.GetList <AwardView>(predicate, con);

            return(list);
        }
Exemplo n.º 4
0
        public List <UserBehaviorArticleReportView> GetChanelList(DateTime begindate, DateTime endTime, string appid, PageCondition pageCondition)
        {
            Expression <Func <UserBehavior, bool> > predicate;

            if (!string.IsNullOrEmpty(appid))
            {
                var appId = Int32.Parse(appid);
                predicate = n => n.CreatedTime >= begindate && n.CreatedTime <= endTime && n.AppId == appId && n.ContentType == 10;
            }
            else
            {
                predicate = n => n.CreatedTime >= begindate && n.CreatedTime <= endTime && n.ContentType == 10;
            }

            var result = (from item in Repository.Entities.Where(predicate).ToList()
                          orderby item.Id descending
                          select new UserBehaviorArticleReportView()
            {
                Id = item.Id,
                AppId = item.AppId,
                CreatedTime = item.CreatedTime.ToShortDateString(),
                UserId = item.UserId,
                ContentType = item.ContentType
            }).ToList();

            result.ForEach(x =>
            {
                var app = CommonService.lstSysWeChatConfig.FirstOrDefault(y => y.WeixinAppId == x.AppId.ToString());
                if (app != null)
                {
                    x.AppName = app.AppName;
                }
            });
            pageCondition.RowCount  = result.Count;
            pageCondition.PageIndex = pageCondition.PageIndex == 0 ? 1 : pageCondition.PageIndex;
            result = result.Skip((pageCondition.PageIndex - 1) * pageCondition.PageSize).Take(pageCondition.PageSize).ToList();
            pageCondition.SortConditions.Add(new SortCondition("CreatedTime", System.ComponentModel.ListSortDirection.Descending));
            return(result);
        }
Exemplo n.º 5
0
        protected List <MessageView> GetListPrivate(ref Expression <Func <Message, bool> > predicate, PageCondition ConPage, string strTitle, string txtDate)
        {
            predicate = predicate.AndAlso(a => a.IsDeleted == false);

            if (!string.IsNullOrEmpty(strTitle))
            {
                predicate = predicate.AndAlso(a => a.Title.Contains(strTitle));
            }

            if (!string.IsNullOrEmpty(txtDate))
            {
                DateTime dateTime = Convert.ToDateTime(txtDate);
                DateTime dateAdd  = dateTime.AddDays(1);
                predicate = predicate.AndAlso(a => a.PublishDate >= dateTime && a.PublishDate <= dateAdd);
            }

            var q = _BaseService.GetList <MessageView>(predicate, ConPage);

            return(q);
        }
Exemplo n.º 6
0
        public override List <BarrageView> GetListEx(Expression <Func <Barrage, bool> > predicate, PageCondition ConPage)
        {
            var content = Request["FeedBackContent"];

            if (!string.IsNullOrEmpty(content))
            {
                predicate = predicate.AndAlso(a => a.FeedBackContent.Contains(content));
            }

            ConPage.SortConditions.Add(new SortCondition("CreatedDate", System.ComponentModel.ListSortDirection.Ascending));

            var q = _objService.GetList <BarrageView>(predicate, ConPage);

            q.ForEach(t => { t.FeedBackContent = QyMessageHandlers.QyCustomMessageHandler.ConvertEmotion(t.FeedBackContent); });
            return(q);
        }
Exemplo n.º 7
0
        public List <UserBehaviorArticleReportView> GetActivityList(DateTime begindate, DateTime endTime, PageCondition pageCondition)
        {
            List <UserBehaviorArticleReportView> result;

            Expression <Func <UserBehavior, bool> > predicate = n => n.CreatedTime >= begindate && n.CreatedTime <= endTime;


            var source = Repository.Entities.Where(predicate).Select(x => new { x.UserId, x.ContentType }).Where(x => x.ContentType != 9 && !string.IsNullOrEmpty(x.UserId)).GroupBy(x => x.UserId).Select(x => new { x.Key, followCount = x.Count() });

            if (pageCondition != null)
            {
                var countQuery     = source.FutureCount();
                var conditionQuery =
                    source.OrderByDescending(x => x.Key)
                    .Skip((pageCondition.PageIndex - 1) * pageCondition.PageSize)
                    .Take(pageCondition.PageSize)
                    .Future();

                pageCondition.RowCount = countQuery.Value;
                return(result =
                           conditionQuery.ToList().AsParallel()
                           .Select(x => new UserBehaviorArticleReportView {
                    UserId = x.Key, followCount = x.followCount
                })
                           .ToList());
            }


            result = source.ToList().AsParallel().Select(x => new UserBehaviorArticleReportView {
                UserId = x.Key, followCount = x.followCount
            }).ToList();

            return(result);
            //logs.GroupBy(x => x.UserId).ToList().ForEach(item =>
            //{
            //    var item1 = item.FirstOrDefault();
            //    var entity = new UserBehaviorArticleReportView
            //       {
            //           Id = item1.Id,
            //           UserId = item1.UserId,
            //           followCount = item.Count()
            //       };
            //    result.Add(entity);
            //});
            //pageCondition.RowCount = result.Count;
            //pageCondition.PageIndex = pageCondition.PageIndex == 0 ? 1 : pageCondition.PageIndex;
            //result = result.Skip((pageCondition.PageIndex - 1) * pageCondition.PageSize).Take(pageCondition.PageSize).ToList();
            //pageCondition.SortConditions.Add(new SortCondition("CreatedTime", System.ComponentModel.ListSortDirection.Descending));
            //return result;
        }
        public override List <QrCodeView> GetListEx(Expression <Func <QrCodeMPItem, bool> > predicate, PageCondition ConPage)
        {
            string strDescription = Request["txtDescription"];

            var q = GetListPrivate(ref predicate, ConPage, strDescription);

            return(q);
        }
        private List <QrCodeView> GetListPrivate(ref Expression <Func <QrCodeMPItem, bool> > predicate, PageCondition ConPage, string strDescription)
        {
            predicate = predicate.AndAlso(a => a.Deleted == false);
            if (!string.IsNullOrEmpty(strDescription))
            {
                predicate = predicate.AndAlso(a => a.Description.Contains(strDescription));
            }
            ////var q = _objService.Repository.Entities.Where(predicate).ToList().Select(a => (QrCodeView)(new QrCodeView()).ConvertAPIModel(a)).ToList();
            //var q = _BaseService.GetList<QrCodeView>(predicate, ConPage);
            //q.ForEach(a =>
            //{
            //    var historyList = _historyService.Repository.Entities.Where(h => h.QrCodeSceneId == a.Id).ToList();
            //    a.PeopleCount = historyList.Where(t => t.Status == 1).Sum(b => b.PeopleCount.Value);
            //    a.PurePeopleCount = historyList.Where(t => t.Status == 1).Sum(b => b.PurePeopleCount.Value) - historyList.Where(t => t.Status == 4).Sum(b => b.PurePeopleCount.Value);
            //});

            int total = ConPage.RowCount;
            int appId = -1;

            if (int.TryParse(Request["AppId"], out appId))
            {
                var q = (_BaseService as IQrCodeService).GetListAll(ConPage.PageIndex, ConPage.PageSize, ref total, strDescription, appId);
                ConPage.RowCount = total;
                return(q);
            }
            return(null);
        }
Exemplo n.º 10
0
        //初始化list页面
        public override List <LogsView> GetListEx(Expression <Func <LogsModel, bool> > predicate, PageCondition ConPage)
        {
            string date    = Request["txtDate"];
            string logCate = Request["txtCateLog"];

            if (!string.IsNullOrEmpty(date))
            {
                DateTime dateTime = Convert.ToDateTime(date);
                DateTime dateAdd  = dateTime.AddDays(1);
                predicate = predicate.AndAlso(a => a.CreatedDate >= dateTime && a.CreatedDate <= dateAdd);
            }

            if (!string.IsNullOrEmpty(logCate))
            {
                predicate = predicate.AndAlso(a => a.LogCate.Contains(logCate));
            }

            ConPage.SortConditions.Add(new SortCondition("Id", System.ComponentModel.ListSortDirection.Descending));

            var q = _BaseService.GetList <LogsView>(predicate, ConPage);

            return(q.ToList());
        }
        //初始化list页面
        public override List <ProjectUserView> GetListEx(Expression <Func <ProjectUser, bool> > predicate, PageCondition ConPage)
        {
            var q = _objService.GetList <ProjectUserView>(predicate.AndAlso(x => x.IsDeleted != true), ConPage);

            return(q.ToList());
        }
Exemplo n.º 12
0
 public abstract Page <T> List(PageCondition cond);
Exemplo n.º 13
0
        private void getPageSql(PageCondition pc, String columnString, String joinTable, Boolean isJoin, Boolean isCustomerOrder, String orderString, String _condition_nowhere, StringBuilder sb)
        {
            if (_entityInfo.DbType == DatabaseType.MySql)
            {
                int startRow = pc.Size * (pc.CurrentPage - 1);

                sb.Append("select ");
                sb.Append(columnString);
                sb.Append(" from ");
                sb.Append(joinTable);
                sb.Append(" ");
                sb.Append(pc.ConditionStr);
                sb.Append(" ");
                sb.Append(orderString);
                sb.Append(" limit ");
                sb.Append(startRow);
                sb.Append(", ");
                sb.Append(pc.Size);

                return;
            }

            if (isCustomerOrder == false)
            {
                sb.Append("select top ");
                sb.Append(pc.Size);
                sb.Append(" ");
                sb.Append(columnString);
                sb.Append(" from ");
                sb.Append(joinTable);

                if (pc.OrderStr == "asc")
                {
                    if (isJoin)
                    {
                        sb.Append(" where t0.Id>(select max(Id) from (select top ");
                    }
                    else
                    {
                        sb.Append(" where Id>(select max(Id) from (select top ");
                    }
                }
                else
                {
                    if (isJoin)
                    {
                        sb.Append(" where t0.Id<(select min(Id) from (select top ");
                    }
                    else
                    {
                        sb.Append(" where Id<(select min(Id) from (select top ");
                    }
                }

                sb.Append(pc.Size * (pc.CurrentPage - 1));

                if (isJoin)
                {
                    sb.Append(" t0.Id from ");
                }
                else
                {
                    sb.Append(" Id from ");
                }

                sb.Append(joinTable);
                sb.Append(pc.ConditionStr);
                sb.Append(orderString);
                sb.Append(") as t) ");
                //sb.Append( "and " );
                sb.Append(_condition_nowhere);
                sb.Append(orderString);
            }

            else if (_entityInfo.DbType == DatabaseType.Access || _entityInfo.DbType == DatabaseType.SqlServer2000)
            {
                sb.Append("select top ");
                sb.Append(pc.Size);
                sb.Append(" ");
                sb.Append(columnString);
                sb.Append(" from ");
                sb.Append(joinTable);

                if (strUtil.IsNullOrEmpty(pc.ConditionStr))
                {
                    if (isJoin)
                    {
                        sb.Append(" where  t0.Id not in ( select top ");
                    }
                    else
                    {
                        sb.Append(" where  Id not in ( select top ");
                    }
                }
                else
                {
                    sb.Append(pc.ConditionStr);

                    if (isJoin)
                    {
                        sb.Append(" and  t0.Id not in ( select top ");
                    }
                    else
                    {
                        sb.Append(" and  Id not in ( select top ");
                    }
                }

                sb.Append(pc.Size * (pc.CurrentPage - 1));

                if (isJoin)
                {
                    sb.Append(" t0.Id from ");
                }
                else
                {
                    sb.Append(" Id from ");
                }

                sb.Append(joinTable);
                sb.Append(pc.ConditionStr);
                sb.Append(orderString);
                sb.Append(" ) ");
                //sb.Append( "and " );
                sb.Append(_condition_nowhere);
                sb.Append(" ");
                sb.Append(orderString);
            }

            else
            {
                int startRow = pc.Size * (pc.CurrentPage - 1);
                int endRow   = startRow + pc.Size;

                sb.AppendFormat("select {0} from ", columnString);
                sb.Append("(");
                sb.AppendFormat("select ROW_NUMBER() over ( {0} ) as rowNumber, {1} from {2} {3}", orderString, columnString, joinTable, pc.ConditionStr);
                sb.Append(") as tmpTable ");
                sb.AppendFormat("where (rowNumber between {0} and {1}) {2}", (startRow + 1), endRow, _condition_nowhere);
            }
        }
Exemplo n.º 14
0
        public String GetPageSql(PageCondition pc)
        {
            String columnString = getColumnsByProperty(pc.Property);

            //------------------------ condition ------------------------------
            String joinTable = "";

            pc.ConditionStr = processCondition(pc.ConditionStr, new Dictionary <String, Object>(), ref joinTable);

            Boolean isJoin = false;

            if (strUtil.HasText(joinTable))
            {
                isJoin    = true;
                joinTable = _entityInfo.TableName + " t0, " + joinTable;

                // columnString中的每个columnName都要加上t0前缀
                columnString = addJoinTablePrefix(columnString, ',');
            }
            else
            {
                joinTable = _entityInfo.TableName;
            }
            joinTable = joinTable.Trim().TrimEnd(',');


            if (strUtil.HasText(pc.ConditionStr))
            {
                if (pc.ConditionStr.ToLower().Trim().StartsWith("and "))
                {
                    //"and id=7" 剔除and开头
                    pc.ConditionStr = " where " + pc.ConditionStr.Trim().Substring(3);
                }
                //"order by id" 加上一个空格
                else if (pc.ConditionStr.Trim().ToLower().StartsWith("order"))
                {
                    pc.ConditionStr = " " + pc.ConditionStr;
                }
                else
                {
                    //加上 where
                    pc.ConditionStr = " where " + pc.ConditionStr;
                }
            }

            //------------------------ order ------------------------------
            Boolean isCustomerOrder = false;

            if (pc.ConditionStr.ToLower().IndexOf(" order ") >= 0)
            {
                isCustomerOrder = true;
            }

            String orderString = "";

            pc.OrderStr = pc.OrderStr.ToLower();

            // 默认排序方式:逆序
            if (isCustomerOrder == false)
            {
                if (pc.OrderStr == "asc")
                {
                    orderString = " order by Id asc";
                }
                else
                {
                    orderString = " order by Id desc";
                }

                if (isJoin)
                {
                    orderString = orderString.Replace("Id", "t0.Id");
                }
            }
            else
            {
                // 自定义排序方式
                String newOrderString = "";

                String tempString = pc.ConditionStr;
                //此处conditionString已经不带order
                pc.ConditionStr = pc.ConditionStr.Substring(0, pc.ConditionStr.ToLower().IndexOf("order "));

                orderString = tempString.Replace(pc.ConditionStr, "");

                String[] arrOrder = orderString.Split(new char[] { ' ', ',' });
                foreach (String s in arrOrder)
                {
                    if (s.ToLower() == "asc" || s.ToLower() == "desc")
                    {
                        newOrderString += s + ", ";
                    }
                    else if (s.ToLower() != "order" && s.ToLower() != "by" && s != null && s != "")
                    {
                        if (isJoin)
                        {
                            newOrderString += "t0." + s + " ";
                        }
                        else
                        {
                            newOrderString += s + " ";
                        }
                    }
                    else
                    {
                        newOrderString += s + " ";
                    }
                }

                orderString = newOrderString.Trim().TrimEnd(',');
            }

            String _condition_nowhere = pc.ConditionStr.Trim();

            if (strUtil.HasText(_condition_nowhere) && _condition_nowhere.ToLower().StartsWith("where"))
            {
                _condition_nowhere = pc.ConditionStr.Trim().Substring(5);
                _condition_nowhere = "and " + _condition_nowhere;
            }

            String sql = "";

            String pageCountSql = "select count(*) from " + joinTable + pc.ConditionStr;

            //callback执行beginCount方法
            pc.CurrentPage = pc.beginCount(pageCountSql, pc.Pager, _entityInfo);

            // TODO:最后一页优化

            if (pc.CurrentPage == 1)
            {
                sql = "select " + columnString + " from " + joinTable + pc.ConditionStr + orderString;

                sql = _entityInfo.Dialect.GetLimit(sql, pc.Size);
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                getPageSql(pc, columnString, joinTable, isJoin, isCustomerOrder, orderString, _condition_nowhere, sb);

                sql = sb.ToString();
            }

            logger.Info(LoggerUtil.SqlPrefix + "[Page Sql] " + sql);
            return(sql);
        }
Exemplo n.º 15
0
        public override List <FamilyDayView> GetListEx(Expression <Func <FamilyDayEntity, bool> > predicate, PageCondition ConPage)
        {
            string strSearch = Request["txtSearch"];
            string strNo     = Request["txtEventNo"];

            if (!string.IsNullOrEmpty(strNo))
            {
                predicate = predicate.AndAlso(a => a.EventNo.Equals(strNo, StringComparison.CurrentCultureIgnoreCase));
            }

            if (!string.IsNullOrEmpty(strSearch))
            {
                predicate = predicate.AndAlso(a => a.Name.Contains(strSearch) || a.LillyId.Contains(strSearch));
            }

            //TODO:
            //predicate = predicate.AndAlso(a => a.AppId == AppId);

            var q = _BaseService.GetList <FamilyDayView>(predicate, ConPage).ToList();

            return(q);
        }
Exemplo n.º 16
0
        public override List <T> GetList <T>(Expression <Func <MessageText, bool> > func, PageCondition page)
        {
            //TODO: need to refactor for reducing the roundtrip between with db server
            var total = 0;

            var list = GetList <MessageTextView>(func, page.PageIndex, page.PageSize, ref total, page.SortConditions);
            var ids  = list.AsParallel().Select(x => x.Id).ToList();

            page.RowCount = total;

            var histories = (from history in _pushHistoryService.Repository.Entities.Where(
                                 x => ids.Contains(x.ContentId) && x.ContentType == ContentType.Text.ToString())
                             group history by history.ContentId
                             into groups
                             select groups.OrderByDescending(x => x.CreatedDate).Select(x => new { x.Id, x.ContentId }).FirstOrDefault()).ToList();

            Parallel.ForEach(list, x =>
            {
                var pushHistory = histories.FirstOrDefault(y => y.ContentId == x.Id);
                x.HistoryId     = pushHistory == null ? 0 : pushHistory.Id;
            });

            return(list.Select(x => (T)(IViewModel)x).ToList());
        }
        protected List <EventEntityView> GetListPrivate(ref Expression <Func <EventEntity, bool> > predicate, PageCondition ConPage)
        {
            int strNewsCate = int.Parse(Request["appId"].ToString());
            //int strNewsCate = 20;
            string name = Request["Name"];

            predicate = predicate.AndAlso(a => a.IsDeleted == false);
            if (!string.IsNullOrEmpty(name))
            {
                predicate = predicate.AndAlso(a => a.Name.Contains(name));
            }
            if (strNewsCate != 0)
            {
                predicate = predicate.AndAlso(a => a.AppId == strNewsCate);
            }
            ConPage.SortConditions.Add(new SortCondition("Id", System.ComponentModel.ListSortDirection.Descending));

            var q = _BaseService.GetList <EventEntityView>(predicate, ConPage);

            return(q);
        }
Exemplo n.º 18
0
        public async Task <PagingResponseMessage <BuildingRecommendItem> > GetMyBuildingRecommendList(UserInfo user, [FromBody] PageCondition condition)
        {
            PagingResponseMessage <BuildingRecommendItem> pagingResponse = new PagingResponseMessage <BuildingRecommendItem>();

            if (!ModelState.IsValid)
            {
                pagingResponse.Code = ResponseCodeDefines.ModelStateInvalid;
                return(pagingResponse);
            }
            return(await _buildingRecommendManager.FindMyBuildingRecommendAsync(user, condition, HttpContext.RequestAborted));
        }
        //初始化list页面
        public override List <SysUserView> GetListEx(Expression <Func <SysUser, bool> > predicate, PageCondition ConPage)
        {
            string strModeId    = Request["SearchLoadModeId"];
            string strGroup     = Request["SearchGroup"];
            string strCondition = Request["search_condition"];

            if (!string.IsNullOrEmpty(strCondition))
            {
                strCondition = strCondition.Trim().ToLower();
                predicate    = predicate.AndAlso(x => x.WeChatUserID.Contains(strCondition) ||
                                                 (x.Email != null && x.Email.ToLower().Contains(strCondition)) ||
                                                 x.UserName.ToLower().Contains(strCondition) ||
                                                 x.UserTrueName.ToLower().Contains(strCondition));
            }

            var q = _objService.GetList <SysUserView>(predicate.AndAlso(x => x.IsDeleted == false), ConPage);

            return(q.ToList());
        }
Exemplo n.º 20
0
        public async Task <PagingResponseMessage <BuildingRecommendResponse> > GetBuildingRecommendListByRegion2(UserInfo user, [FromBody] PageCondition condition)
        {
            PagingResponseMessage <BuildingRecommendResponse> pagingResponse = new PagingResponseMessage <BuildingRecommendResponse>();

            if (!ModelState.IsValid)
            {
                pagingResponse.Code = ResponseCodeDefines.ModelStateInvalid;
                return(pagingResponse);
            }
            return(await _buildingRecommendManager.SearchMainArea2(user, condition, HttpContext.RequestAborted));
        }
Exemplo n.º 21
0
        public List <UserBehaviorArticleReportView> GetArticleList(DateTime begindate, DateTime endTime, string appid, PageCondition pageCondition)
        {
            Expression <Func <UserBehavior, bool> > predicate;

            if (!string.IsNullOrEmpty(appid))
            {
                var appId = Int32.Parse(appid);
                predicate = n => n.CreatedTime >= begindate && n.CreatedTime <= endTime && n.AppId == appId && n.Content != null && n.Content != "" && (n.ContentType == 1 || n.ContentType == 2 || n.ContentType == 51 || n.ContentType == 53);
            }
            else
            {
                predicate = n => n.CreatedTime >= begindate && n.CreatedTime <= endTime && n.Content != null && n.Content != "" && (n.ContentType == 1 || n.ContentType == 2 || n.ContentType == 51 || n.ContentType == 53);
            }
            var result = (from item in Repository.Entities.Where(predicate).ToList()
                          orderby item.Id descending
                          select new UserBehaviorArticleReportView()
            {
                Id = item.Id,
                AppId = item.AppId,
                CreatedTime = item.CreatedTime.ToShortDateString(),
                UserId = item.UserId,
                ContentType = item.ContentType,
                Content = item.Content
            }).ToList();

            result.ForEach(x =>
            {
                //根据ContentType去相应的表去拿最终集合
                switch (x.ContentType)
                {
                case 1:
                    this.getNewsList(x);
                    break;

                case 2:
                    this.getMessagesList(x);
                    break;

                case 51:
                case 52:
                case 53:
                    this.getLEDList(x);
                    break;
                }
            });
            var lastResult = (from item in result where !item.NeedDelete select item).ToList();

            pageCondition.RowCount  = lastResult.Count;
            pageCondition.PageIndex = pageCondition.PageIndex == 0 ? 1 : pageCondition.PageIndex;
            lastResult = lastResult.Skip((pageCondition.PageIndex - 1) * pageCondition.PageSize).Take(pageCondition.PageSize).ToList();
            pageCondition.SortConditions.Add(new SortCondition("CreatedTime", System.ComponentModel.ListSortDirection.Descending));
            return(lastResult);
        }
Exemplo n.º 22
0
        public async Task <PagingResponseMessage <BuildingRecommendItem> > GetBuildingRecommendListByFiliale(UserInfo user, [FromBody] PageCondition condition)
        {
            PagingResponseMessage <BuildingRecommendItem> Response = new PagingResponseMessage <BuildingRecommendItem>();

            if (!ModelState.IsValid)
            {
                Response.Code = ResponseCodeDefines.ModelStateInvalid;
                Logger.Warn($"用户{user?.UserName ?? ""}({user?.Id ?? ""})获取公司级楼盘(GetBuildingRecommendListByFiliale)模型验证失败:\r\n请求的参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : ""));
                return(Response);
            }
            try
            {
                Response = await _buildingRecommendManager.SearchFiliale(user, condition, HttpContext.RequestAborted);
            }
            catch (Exception e)
            {
                Response.Code    = ResponseCodeDefines.ServiceError;
                Response.Message = "服务器发生错误:" + e.ToString();
                Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})获取公司级楼盘(GetBuildingRecommendListByFiliale)报错:\r\n{e.ToString()},\r\n请求的参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : ""));
            }
            return(Response);
        }
Exemplo n.º 23
0
        public override List <MessageView> GetListEx(Expression <Func <Message, bool> > predicate, PageCondition ConPage)
        {
            string strTitle = Request["txtArticleTitle"];
            string txtDate  = Request["txtDate"];

            predicate = predicate.AndAlso(x => string.IsNullOrEmpty(x.MessageType) || x.MessageType == MessageType.Messsage.ToString());

            var q = GetListPrivate(ref predicate, ConPage, strTitle, txtDate);

            return(q.ToList());
        }
Exemplo n.º 24
0
        /// <summary>
        /// 根据用户ID获取评论
        /// </summary>
        /// <param name="userid">请求实体</param>
        /// <param name="condition"></param>
        /// <param name="cancellationToken">验证</param>
        /// <returns></returns>
        public virtual async Task <PagingResponseMessage <CommentResponse> > ListByUserIdAsync(string userid, PageCondition condition, CancellationToken cancellationToken = default(CancellationToken))
        {
            var response = new PagingResponseMessage <CommentResponse>();
            var result   = _icommentStore.GetCommentQuery().Where(x => x.CustomerId == userid);

            response.TotalCount = await result.CountAsync(cancellationToken);

            var query = await result.OrderByDescending(x => x.CreateTime).Skip(condition.PageSize * condition.PageIndex).Take(condition.PageSize).ToListAsync(cancellationToken);

            query = query.Select(x =>
            {
                if (x.CommentFileInfo?.Count() > 0)
                {
                    var f = x.CommentFileInfo.Select(a => a.FileGuid).Distinct();
                    foreach (var item in f)
                    {
                        var f1 = x.CommentFileInfo.Where(a => a.FileGuid == item).ToList();
                        if (f1?.Count > 0)
                        {
                            x.FileList.Add(ConvertToFileItem(item, f1));
                        }
                    }
                }

                return(x);
            }).ToList();


            response.PageSize  = condition.PageSize;
            response.PageSize  = condition.PageSize;
            response.Extension = _mapper.Map <List <CommentResponse> >(query);;


            return(response);
        }
Exemplo n.º 25
0
        public override List <T> GetItemList <T>(string tableName, List <FilterCondition> where, ref PageCondition page)
        {
            IMongoCollection <T> collection = db.GetCollection <T>(tableName);
            FilterDefinition <T> filter     = FilterConditionToWhere <T>(where);
            SortDefinition <T>   sort       = FilterConditionToSort <T>(where);

            page.Total = (int)collection.CountDocuments(transaction, filter);
            List <T> list = collection.Find(transaction, filter).Sort(sort).Skip((page.PageNo - 1) * page.PageSize).Limit(page.PageSize).ToList();

            return(list);
        }
Exemplo n.º 26
0
        public override List <PageReportGroupView> GetListEx(Expression <Func <PageReportGroup, bool> > predicate, PageCondition ConPage)
        {
            var q = _BaseService.GetList <PageReportGroupView>(predicate, ConPage);

            return(q);
        }
        public List <PollingResultCustomView> Query(Expression <Func <PollingAnswerEntity, bool> > predicate, PageCondition con)
        {
            var source = Repository.Entities.Where(predicate)
                         .GroupBy(x => new { x.LillyId });

            source = source.OrderByDescending(m => m.Key.LillyId);
            var allCountQuery = source.Select(x => x.Key.LillyId).FutureCount();

            var query = source.Select(x => new
            {
                x.Key,
                x.FirstOrDefault().Dept1,
                x.FirstOrDefault().Dept2,
                x.FirstOrDefault().Dept3,
                x.FirstOrDefault().Name,
                sum = x.Where(y => y.Status).Sum(y => (decimal?)y.Score)
            }).Skip((con.PageIndex - 1) * con.PageSize).Take(con.PageSize);

            var total = allCountQuery.Value;
            var list  = query.ToList();


            con.RowCount = total;

            return(list.Select(y => new PollingAnswerEntity {
                LillyId = y.Key.LillyId, Score = y.sum ?? 0, Dept1 = y.Dept1, Dept2 = y.Dept2, Dept3 = y.Dept3, Name = y.Name
            }).ToList()
                   .Select(n => (PollingResultCustomView)(new PollingResultCustomView().ConvertAPIModel(n))).ToList());
        }
        public override List <ArticleInfoView> GetListEx(Expression <Func <ArticleInfo, bool> > predicate, PageCondition ConPage)
        {
            int appId = default(int);
            int cate  = default(int);

            if (int.TryParse(Request["wechatid"], out appId) && int.TryParse(Request["strSubCate"], out cate))
            {
                predicate = predicate.AndAlso(a => a.AppId == appId && a.CategoryId == cate && a.IsDeleted == false && a.ArticleType == 0 && a.PublishDate != null);
                if (!string.IsNullOrEmpty(Request["searchword"]))
                {
                    var searchWord = Request["searchword"];
                    predicate = predicate.AndAlso(a => a.ArticleTitle.Contains(searchWord) || a.ArticleContent.Contains(searchWord));
                }
                var q = _objService.GetList <ArticleInfoView>(predicate, ConPage);
                q.ForEach(a =>
                {
                    if (a.PublishDate.HasValue)
                    {
                        a.PublishDateFormatString = ((DateTime)a.PublishDate).ToString("yyyy-MM-dd");
                    }
                });
                return(q.ToList());
            }
            return(null);
        }
Exemplo n.º 29
0
        protected List <PollingResultCustomView> GetListPrivate1(Expression <Func <PollingAnswerEntity, bool> > predicate, PageCondition pageCondition)
        {
            var objView = new List <PollingResultCustomView>();

            predicate = rtnPredicate();
            objView   = _pollingAnswerService.Query(predicate, pageCondition);
            return(objView);
        }
        //public ArticleReportService(IUnitOfWork unitOfWork)
        //    : base(unitOfWork)
        //{

        //}

        public List <ArticleReportView> QueryTable(DateTime stardate, DateTime enddate, PageCondition pageCondition)
        {
            Expression <Func <ArticleReport, bool> > predicate = a => a.AccessDate >= stardate && a.AccessDate <= enddate;

            return(GetList <ArticleReportView>(predicate, pageCondition));
        }