/// <summary>
        /// 获取专家评审意见列表
        /// </summary>
        /// <param name="predicate">评审意见的查询条件</param>
        /// <param name="page">页码</param>
        /// <returns></returns>
        public PagingListDTO <GetReviewCommentDTO> GetPagingReviewCommentList(Func <ReviewAssignment, bool> predicate, int page)
        {
            PagingListDTO <GetReviewCommentDTO> pagingList = new PagingListDTO <GetReviewCommentDTO>();

            using (var ctx = new AspodesDB())
            {
                var assignmentIds = ctx.ReviewAssignments.Where(predicate).Select(ra => ra.ReviewAssignmentId);
                pagingList.TotalNum     = ctx.ReviwerComments.Count(rc => assignmentIds.Contains(rc.ReviewAssignmentId));
                pagingList.TotalPageNum = (pagingList.TotalNum + SystemConfig.ReviewCommentPageCount - 1) / SystemConfig.ReviewCommentPageCount;
                if (pagingList.TotalPageNum <= 0)
                {
                    pagingList.TotalPageNum = 1;
                }
                pagingList.NowPage = page <= 0 ? 1 : page;

                pagingList.ItemDTOs = ctx.ReviwerComments
                                      .Where(rc => assignmentIds.Contains(rc.ReviewAssignmentId))
                                      .Select(Mapper.Map <GetReviewCommentDTO>)
                                      .OrderBy(rcd => rcd.ProjectName)
                                      .OrderBy(rcd => rcd.ExpertName)
                                      .Skip((pagingList.NowPage - 1) * SystemConfig.ReviewCommentPageCount)
                                      .Take(SystemConfig.ReviewCommentPageCount)
                                      .ToList();

                pagingList.NowNum = pagingList.ItemDTOs.Count();
                return(pagingList);
            }
        }
        /// <summary>
        /// 获取申请书的评审意见列表
        /// </summary>
        /// <param name="predicate">申请书检索条件</param>
        /// <param name="year">评审年份</param>
        /// <param name="page">页码</param>
        /// <returns></returns>
        public PagingListDTO <GetApplicationReviewCommentDTO> GetPagingApplicationReviewCommentList(Func <Application, bool> predicate, int page)
        {
            PagingListDTO <GetApplicationReviewCommentDTO> pagingList = new PagingListDTO <GetApplicationReviewCommentDTO>();

            using (var ctx = new AspodesDB())
            {
                var applicationReviewComments = ctx.Applications.Include("ReviewComments")
                                                .Where(predicate)
                                                .Where(a => a.ReviewComments.Count() > 0)
                                                .Select(Mapper.Map <GetApplicationReviewCommentDTO>);

                pagingList.TotalNum     = applicationReviewComments.Count();
                pagingList.TotalPageNum = (pagingList.TotalNum + SystemConfig.ApplicationPageCount - 1) / SystemConfig.ApplicationPageCount;
                if (pagingList.TotalPageNum <= 0)
                {
                    pagingList.TotalPageNum = 1;
                }
                pagingList.NowPage  = page <= 0 ? 1 : page;
                pagingList.ItemDTOs = applicationReviewComments
                                      .OrderByDescending(arc => arc.TotalScore)
                                      .Skip((pagingList.NowPage - 1) * SystemConfig.ApplicationPageCount)
                                      .Take(SystemConfig.ApplicationPageCount)
                                      .ToList();

                pagingList.NowNum = pagingList.ItemDTOs.Count();
                return(pagingList);
            }
        }
示例#3
0
        /// <summary>
        /// 根据人员角色获取人员列表
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <returns></returns>
        public PagingListDTO <GetPersonDTO> GetPagingPersonListByRole(int roleId, int instId, int page)
        {
            PagingListDTO <GetPersonDTO> pagingList = new PagingListDTO <GetPersonDTO>();

            using (var ctx = new AspodesDB())
            {
                var instRolePerson = from authorize in ctx.Authorizes
                                     join user in ctx.Users on authorize.UserId equals user.UserId
                                     where (instId == 0 || user.InstituteId == instId) && authorize.RoleId == roleId
                                     select user.Person;
                var result = instRolePerson.Where(p => p.Status == "C");


                pagingList.TotalNum     = result.Count();
                pagingList.NowPage      = page <= 0 ? 1 : page;
                pagingList.TotalPageNum = (pagingList.TotalNum + SystemConfig.PersonPageCount - 1) / SystemConfig.PersonPageCount;
                if (pagingList.TotalPageNum <= 0)
                {
                    pagingList.TotalPageNum = 1;
                }

                pagingList.ItemDTOs = result
                                      .OrderBy(nrp => nrp.Name)
                                      .Skip(((pagingList.NowPage - 1)) * SystemConfig.PersonPageCount)
                                      .Take(SystemConfig.PersonPageCount)
                                      .Select(Mapper.Map <GetPersonDTO>)
                                      .ToList();

                pagingList.NowNum = pagingList.ItemDTOs.Count();
                return(pagingList);
            }
        }
示例#4
0
        /// <summary>
        /// 获取公告列表
        /// </summary>
        /// <param name="predicate">选择条件</param>
        /// <returns></returns>
        public PagingListDTO <GetAnnouncementComboDTO> GetAnnoucementList(Func <Announcement, bool> predicate, int page)
        {
            PagingListDTO <GetAnnouncementComboDTO> pagingList = new PagingListDTO <GetAnnouncementComboDTO>();

            page = page <= 0 ? 1 : page;
            using (var ctx = new AspodesDB())
            {
                pagingList.TotalNum     = ctx.Announcements.Where(predicate).Count();
                pagingList.TotalPageNum = (pagingList.TotalNum + SystemConfig.AnnouncementPageCount - 1) / SystemConfig.AnnouncementPageCount;
                if (pagingList.TotalPageNum <= 0)
                {
                    pagingList.TotalPageNum = 1;
                }
                pagingList.NowPage = page;

                pagingList.ItemDTOs = ctx.Announcements
                                      .Where(predicate)
                                      .OrderByDescending(a => a.PublishDate)
                                      .Skip((page - 1) * SystemConfig.AnnouncementPageCount)
                                      .Take(SystemConfig.AnnouncementPageCount)
                                      .Select(Mapper.Map <GetAnnouncementComboDTO>)
                                      .ToList();

                pagingList.NowNum = pagingList.ItemDTOs.Count();
            }
            return(pagingList);
        }
示例#5
0
        /// <summary>
        /// 获取未进行专家推荐的人员列表
        /// </summary>
        /// <param name="instId"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public PagingListDTO <GetPersonDTO> GetPagingUnRecommendationList(int instId, int page)
        {
            PagingListDTO <GetPersonDTO> pagingList = new PagingListDTO <GetPersonDTO>();

            using (var ctx = new AspodesDB())
            {
                //因修改bug比较着急,以后要写成委托方法
                pagingList.TotalNum = ctx.Users.Where(u => u.InstituteId == instId)
                                      .Where(u => !(ctx.Recommendations.Where(r => r.InstituteId == instId)
                                                    .Where(r => r.Adopt == null || r.Adopt == true)
                                                    .Select(r => r.CandidateId))
                                             .Contains(u.UserId)).Count();
                pagingList.TotalPageNum = (pagingList.TotalNum + SystemConfig.RecommendationPageCount - 1) / SystemConfig.RecommendationPageCount;
                if (pagingList.TotalPageNum <= 0)
                {
                    pagingList.TotalPageNum = 1;
                }
                pagingList.NowPage = page <= 0 ? 1 : page;

                pagingList.ItemDTOs = ctx.Users.Where(u => u.InstituteId == instId)
                                      .Where(u => !(ctx.Recommendations.Where(r => r.InstituteId == instId)
                                                    .Where(r => r.Adopt == null || r.Adopt == true)
                                                    .Select(r => r.CandidateId))
                                             .Contains(u.UserId))
                                      .Where(u => u.Person.Status == "C" && u.Person.Email != "*****@*****.**")
                                      .Select(Mapper.Map <GetPersonDTO>)
                                      .OrderBy(pd => pd.Name)
                                      .Skip((pagingList.NowPage - 1) * SystemConfig.RecommendationPageCount)
                                      .Take(SystemConfig.RecommendationPageCount)
                                      .ToList();
                pagingList.NowNum = pagingList.ItemDTOs.Count();
                return(pagingList);
            }
        }
示例#6
0
        /// <summary>
        /// 从正常人员中查询,分页
        /// </summary>
        /// <param name="predicate">查询条件</param>
        /// <param name="page">页码</param>
        /// <returns></returns>
        public PagingListDTO <GetPersonDTO> GetPagingPersonList(Func <Person, bool> predicate, int page)
        {
            page = page <= 0 ? 1 : page;
            PagingListDTO <GetPersonDTO> pagingList = new PagingListDTO <GetPersonDTO>();

            using (var ctx = new AspodesDB())
            {
                pagingList.TotalNum     = ctx.Persons.Count <Person>(predicate);
                pagingList.TotalPageNum = (pagingList.TotalNum + SystemConfig.PersonPageCount - 1) / SystemConfig.PersonPageCount;
                if (pagingList.TotalPageNum <= 0)
                {
                    pagingList.TotalPageNum = 1;
                }
                pagingList.NowPage = page;

                pagingList.ItemDTOs = ctx.Persons
                                      .Where(predicate)
                                      .Select(Mapper.Map <GetPersonDTO>)
                                      .OrderBy(p => p.InstituteId)
                                      .ThenBy(p => p.Name)
                                      .Skip((page - 1) * SystemConfig.PersonPageCount)
                                      .Take(SystemConfig.PersonPageCount)
                                      .ToList();
                pagingList.NowNum = pagingList.ItemDTOs.Count();
            }
            return(pagingList);
        }
示例#7
0
        /// <summary>
        /// 获取专家推荐列表
        /// </summary>
        /// <param name="predicate"></param>
        /// <returns></returns>
        public PagingListDTO <GetRecommendationDTO> GetPagingRecommendationList(Func <Recommendation, bool> predicate, int page)
        {
            PagingListDTO <GetRecommendationDTO> pagingList = new PagingListDTO <GetRecommendationDTO>();

            using (var ctx = new AspodesDB())
            {
                pagingList.TotalNum     = ctx.Recommendations.Count(predicate);
                pagingList.TotalPageNum = (pagingList.TotalNum + SystemConfig.RecommendationPageCount - 1) / SystemConfig.RecommendationPageCount;
                if (pagingList.TotalPageNum <= 0)
                {
                    pagingList.TotalPageNum = 1;
                }
                pagingList.NowPage = page <= 0 ? 1 : page;

                pagingList.ItemDTOs = ctx.Recommendations
                                      .Where(predicate)
                                      .Select(Mapper.Map <GetRecommendationDTO>)
                                      .OrderBy(rd => rd.Time)
                                      .Skip((pagingList.NowPage - 1) * SystemConfig.RecommendationPageCount)
                                      .Take(SystemConfig.RecommendationPageCount)
                                      .ToList();

                pagingList.NowNum = pagingList.ItemDTOs.Count();
                return(pagingList);
            }
        }
        /// <summary>
        /// 获取专家指派的列表,按研究子领域筛选
        /// </summary>
        /// <returns></returns>
        public PagingListDTO <GetApplicationReviwAssignmentDTO> GetPagingReviewAssignmentList(string fieldId, string subFieldId, Func <Application, bool> predicate, int page)
        {
            PagingListDTO <GetApplicationReviwAssignmentDTO> pagingList = new PagingListDTO <GetApplicationReviwAssignmentDTO>();
            var userInfo = UserHelper.GetCurrentUser();

            pagingList.NowPage = page <= 0 ? 1 : page;
            using (var ctx = new AspodesDB())
            {
                List <string> subFields = new List <string>();
                if (fieldId == "all")
                {
                    subFields.AddRange(ctx.SubFields.Select(sf => sf.SubFieldName).ToList());
                }
                else if (subFieldId == "all")
                {
                    subFields.AddRange(ctx.SubFields.Where(sf => sf.ParentName == fieldId).Select(sf => sf.SubFieldName).ToList());
                }
                else
                {
                    subFields.Add(subFieldId);
                }

                var applicationIds = from applicationField in ctx.ApplicationFields
                                     where subFields.Contains(applicationField.SubFieldId)
                                     select applicationField.ApplicationId;

                var applications = from application in ctx.Applications
                                   where applicationIds.Contains(application.ApplicationId) && userInfo.ProjectTypeIds.Contains(application.ProjectTypeId)
                                   select application;

                pagingList.TotalNum     = applications.Count(predicate);
                pagingList.TotalPageNum = (pagingList.TotalNum + SystemConfig.ReviewAssignmentPageCount - 1) / SystemConfig.ReviewAssignmentPageCount;
                if (pagingList.TotalPageNum <= 0)
                {
                    pagingList.TotalPageNum = 1;
                }

                pagingList.ItemDTOs = applications
                                      .Where(predicate)
                                      .Skip((pagingList.NowPage - 1) * SystemConfig.ReviewAssignmentPageCount)
                                      .Take(SystemConfig.ReviewAssignmentPageCount)
                                      .Select(Mapper.Map <GetApplicationReviwAssignmentDTO>)
                                      .ToList();

                pagingList.NowNum = pagingList.ItemDTOs.Count();
                return(pagingList);
            }
        }
示例#9
0
        public static PagingListDTO <T> PagingWrapper <T>(IEnumerable <T> items, int page, int limit)
        {
            PagingListDTO <T> pagingList = new PagingListDTO <T>();

            pagingList.TotalNum     = items.Count();
            pagingList.TotalPageNum = (pagingList.TotalNum + limit - 1) / limit;
            if (pagingList.TotalPageNum <= 0)
            {
                pagingList.TotalPageNum = 1;
            }
            pagingList.NowNum   = limit;
            pagingList.NowPage  = page;
            pagingList.ItemDTOs = items
                                  .Skip((page - 1) * limit)
                                  .Take(limit)
                                  .ToList();
            return(pagingList);
        }
示例#10
0
        public HttpResponseMessage GetInstPersonsSearch(int page, SearchPersonDTO PersonDTO)
        {
            try
            {
                var user = UserHelper.GetCurrentUser();
                PagingListDTO <GetPersonDTO> pagingList = null;
                if (!string.IsNullOrEmpty(PersonDTO.Types.Trim()) && !string.IsNullOrEmpty(PersonDTO.KeyWords.Trim()))
                {
                    switch (PersonDTO.Types.Trim().ToLower())
                    {
                    case "name":    //姓名
                        pagingList = repository.GetPagingPersonList(p => p.InstituteId == user.InstId && p.Status == "C" && p.Email != "*****@*****.**" && p.Name.Contains(PersonDTO.KeyWords), page);
                        break;

                    case "idcard":    //身份证
                        pagingList = repository.GetPagingPersonList(p => p.InstituteId == user.InstId && p.Status == "C" && p.Email != "*****@*****.**" && p.IDCard.ToLower().Contains(PersonDTO.KeyWords.ToLower()), page);
                        break;

                    case "phone":    //手机
                        pagingList = repository.GetPagingPersonList(p => p.InstituteId == user.InstId && p.Status == "C" && p.Email != "*****@*****.**" && p.Phone.Contains(PersonDTO.KeyWords), page);
                        break;

                    case "email":    //邮箱
                        pagingList = repository.GetPagingPersonList(p => p.InstituteId == user.InstId && p.Status == "C" && p.Email != "*****@*****.**" && p.Email.ToLower().Contains(PersonDTO.KeyWords.ToLower()), page);
                        break;

                    default:
                        pagingList = repository.GetPagingPersonList(p => p.InstituteId == user.InstId && p.Status == "C" && p.Email != "*****@*****.**", page);
                        break;
                    }
                }
                else
                {
                    pagingList = repository.GetPagingPersonList(p => p.InstituteId == user.InstId && p.Status == "C" && p.Email != "*****@*****.**", page);
                }
                return(ResponseWrapper.SuccessResponse(pagingList));
            }
            catch (Exception e)
            {
                return(ResponseWrapper.ExceptionResponse(e));
            }
        }
示例#11
0
        /// <summary>
        /// 获取分页的申请书列表
        /// </summary>
        /// <param name="predicate"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public PagingListDTO <GetApplicationDTO> GetPagingApplicationList(Func <Application, bool> predicate, int page)
        {
            PagingListDTO <GetApplicationDTO> pagingList = new PagingListDTO <GetApplicationDTO>();

            using (var ctx = new AspodesDB())
            {
                pagingList.TotalNum     = ctx.Applications.Where(predicate).Count();
                pagingList.TotalPageNum = (pagingList.TotalNum + SystemConfig.ApplicationPageCount - 1) / SystemConfig.ApplicationPageCount;
                if (pagingList.TotalNum <= 0)
                {
                    pagingList.TotalPageNum = 1;
                }

                pagingList.NowPage = page <= 0 ? 1 : page;

                var applications = ctx.Applications
                                   .Where(predicate)
                                   .OrderByDescending(a => a.EditTime)
                                   .Skip((pagingList.NowPage - 1) * SystemConfig.ApplicationPageCount)
                                   .Take(SystemConfig.ApplicationPageCount);

                //如果不需要PDF预览功能,删除下面的循环
                foreach (var application in applications)
                {
                    var applicationDTO = Mapper.Map <GetApplicationDTO>(application);
                    var pdf            = ctx.ApplicationDocs.FirstOrDefault(ad => ad.ApplicationId == application.ApplicationId && ad.Type == ApplicationDocType.PDF);
                    if (pdf != null)
                    {
                        applicationDTO.PDF = pdf.RelativeURL.Replace("~", "");
                    }
                    pagingList.ItemDTOs.Add(applicationDTO);
                }

                pagingList.NowNum = pagingList.ItemDTOs.Count();
            }

            return(pagingList);
        }
示例#12
0
        /// <summary>
        /// 获取专家列表,按研究领域,单位筛选,分页
        /// </summary>
        /// <param name="instId"></param>
        /// <param name="fieldId"></param>
        /// <param name="subFieldId"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public PagingListDTO <GetExpertInfoDTO> GetPagingExpertList(int instId, string fieldId, string subFieldId, int page)
        {
            PagingListDTO <GetExpertInfoDTO> pagingList = new PagingListDTO <GetExpertInfoDTO>();

            using (var ctx = new AspodesDB())
            {
                List <string> subFields = new List <string>();
                if (fieldId == "all")
                {
                    subFields.AddRange(ctx.SubFields.Select(sf => sf.SubFieldName).ToList());
                }
                else if (subFieldId == "all")
                {
                    subFields.AddRange(ctx.SubFields.Where(sf => sf.ParentName == fieldId).Select(sf => sf.SubFieldName).ToList());
                }
                else
                {
                    subFields.Add(subFieldId);
                }

                var fieldExpertIds = from expertField in ctx.ExpertFields
                                     join authorize in ctx.Authorizes on expertField.UserId equals authorize.UserId
                                     where authorize.RoleId == 5 && subFields.Contains(expertField.SubFieldId)
                                     select expertField.UserId;

                //领域和单位筛选专家
                var expertList = ctx.Users.Include("ExpertFields")
                                 .Where(c => fieldExpertIds.Contains(c.UserId))
                                 .Where(u => instId == 0 || u.InstituteId == instId)
                                 .OrderBy(e => e.Name);

                pagingList.NowPage      = page <= 0 ? 1 : page;
                pagingList.TotalNum     = expertList.Count();
                pagingList.TotalPageNum = (pagingList.TotalNum + SystemConfig.ApplicationPageCount - 1) / SystemConfig.ApplicationPageCount;
                if (pagingList.TotalPageNum <= 0)
                {
                    pagingList.TotalPageNum = 1;
                }

                var query = expertList
                            .Skip((page - 1) * SystemConfig.ApplicationPageCount)
                            .Take(SystemConfig.ApplicationPageCount)
                            .ToList()
                            .Select(expert => new GetExpertInfoDTO
                {
                    UserId              = expert.UserId,
                    Name                = expert.Name,
                    InstituteId         = expert.InstituteId.Value,
                    InstituteName       = expert.Institute.Name,
                    PersonId            = expert.PersonId.Value,
                    FirstExpertFieldId  = expert.ExpertFields.First().ExpertFieldId.Value,
                    FirstSubFieldId     = expert.ExpertFields.First().SubFieldId,
                    SecondExpertFieldId = expert.ExpertFields.Last().ExpertFieldId.Value,
                    SecondSubFieldId    = expert.ExpertFields.Last().SubFieldId
                });

                pagingList.ItemDTOs = query.ToList();

                pagingList.NowNum = pagingList.ItemDTOs.Count;
            }
            return(pagingList);
        }
示例#13
0
        /// <summary>
        /// 申请书综合查询(分页)
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="page"></param>
        public PagingListDTO <GetApplicationInquiriesDTO> ApplicationInquiriesByPage(ApplicationInquiriesDTO dto, int page)
        {
            PagingListDTO <GetApplicationInquiriesDTO> pagingList = new PagingListDTO <GetApplicationInquiriesDTO>();

            using (var ctx = new AspodesDB())
            {
                IQueryable <Application> query = ctx.Applications;
                //var query = ctx.Applications;
                if (dto.ProjectName != null && !"".Equals(dto.ProjectName))
                {
                    query = query.Where(a => a.ProjectName.Contains(dto.ProjectName));
                }
                if (dto.Period != null && dto.Period.Length != 0)
                {
                    query = query.Where(a => dto.Period.Contains(a.Period.Value));
                }
                if (dto.ProjectType != null && dto.ProjectType.Length != 0)
                {
                    query = query.Where(a => dto.ProjectType.Contains(a.ProjectTypeId.Value));
                }
                if (dto.Institute != null && dto.Institute.Length != 0)
                {
                    query = query.Where(a => dto.Institute.Contains(a.InstituteId.Value));
                }
                if (dto.LeaderName != null && !"".Equals(dto.LeaderName))
                {
                    query = query.Where(a => a.Leader.Name.Contains(dto.LeaderName));
                }
                if (dto.StartYearCreated != null)
                {
                    query = query.Where(a => a.YearCreated >= dto.StartYearCreated);
                }
                if (dto.EndYearCreated != null)
                {
                    query = query.Where(a => a.YearCreated <= dto.EndYearCreated);
                }
                if (dto.StartTotalBudget != null)
                {
                    query = query.Where(a => a.TotalBudget >= dto.StartTotalBudget);
                }
                if (dto.EndTotalBudget != null)
                {
                    query = query.Where(a => a.TotalBudget <= dto.EndTotalBudget);
                }
                if (dto.EndTotalBudget != null)
                {
                    query = query.Where(a => a.TotalBudget <= dto.EndTotalBudget);
                }
                if (dto.Status != null && dto.Status.Length != 0)
                {
                    query = query.Where(a => dto.Status.Contains((int)a.Status));
                }
                if (dto.DelegateType != null)
                {
                    query = query.Where(a => (int)a.DeleageType == dto.DelegateType);
                }
                if (dto.StartTotalScore != null)
                {
                    query = query.Where(a => a.TotalScore != null && a.TotalScore >= dto.StartTotalScore);
                }
                if (dto.EndTotalScore != null)
                {
                    query = query.Where(a => a.TotalScore != null && a.TotalScore <= dto.EndTotalScore);
                }

                pagingList.TotalNum     = query.Count();
                pagingList.TotalPageNum = (pagingList.TotalNum + SystemConfig.ApplicationPageCount - 1) / SystemConfig.ApplicationPageCount;
                if (pagingList.TotalNum <= 0)
                {
                    pagingList.TotalPageNum = 1;
                }
                pagingList.NowPage = page <= 0 ? 1 : page;

                pagingList.ItemDTOs = query.OrderByDescending(a => a.EditTime)
                                      .Skip((pagingList.NowPage - 1) * SystemConfig.ApplicationPageCount)
                                      .Take(SystemConfig.ApplicationPageCount)
                                      .Select(Mapper.Map <GetApplicationInquiriesDTO>)
                                      .ToList();
                pagingList.NowNum = pagingList.ItemDTOs.Count();

                return(pagingList);
            }
        }