Example #1
0
 public HttpResponseMessage ApplicationInquiries(ApplicationInquiriesDTO appInquiriesDTO, int page)
 {
     try
     {
         var appList = repository.ApplicationInquiriesByPage(appInquiriesDTO, page);
         return(ResponseWrapper.SuccessResponse(appList));
     }
     catch (Exception e)
     {
         return(ResponseWrapper.ExceptionResponse(e));
     }
 }
Example #2
0
 public HttpResponseMessage ApplicationInquiries(ApplicationInquiriesDTO appInquiriesDTO)
 {
     try
     {
         var        appList = repository.ApplicationInquiries(appInquiriesDTO);
         string[][] strs    = new string[appList.Count + 1][];
         strs[0] = new string[18];
         for (int titleIndex = 0; titleIndex < UserHelper.ApplicationExportTableHeader.Count(); titleIndex++)
         {
             UserHelper.ApplicationExportTableHeader.TryGetValue(titleIndex, out strs[0][titleIndex]);
         }
         int i = 1;
         foreach (GetApplicationInquiriesDTO item in appList)
         {
             strs[i] = new string[18];
             int j = 0;
             strs[i][j++] = item.ApplicationId;
             strs[i][j++] = item.ProjectName;
             strs[i][j++] = item.Period;
             strs[i][j++] = item.ProjectTypeName;
             strs[i][j++] = item.SupportCategoryName;
             strs[i][j++] = item.InstituteName;
             strs[i][j++] = item.LeaderName;
             strs[i][j++] = item.LeaderPhone;
             strs[i][j++] = item.LeaderEmail;
             strs[i][j++] = item.ContactPhone;
             strs[i][j++] = item.ContactEmail;
             strs[i][j++] = item.TotalBudget.ToString();
             strs[i][j++] = item.FirstYearBudget.ToString();
             strs[i][j++] = item.YearCreated.ToString();
             strs[i][j++] = item.CurrentYear.ToString();
             strs[i][j++] = item.AbstractContent;
             strs[i][j++] = item.DeleageType == DelegateType.DIRECTIONAL ? "定向项目":"非定向项目";
             UserHelper.ApplicationStatusTransform.TryGetValue(item.Status, out strs[i][j++]);
             i++;
         }
         return(_excelExportRepository.DownloadExportExcel(strs, "申请书综合查询"));
     }
     catch (Exception e)
     {
         return(ResponseWrapper.ExceptionResponse(e));
     }
 }
        /// <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);
            }
        }
        /// <summary>
        /// 申请书综合查询(不分页)
        /// </summary>
        /// <param name="dto"></param>
        public List <GetApplicationInquiriesDTO> ApplicationInquiries(ApplicationInquiriesDTO dto)
        {
            using (var ctx = new AspodesDB())
            {
                IQueryable <Application> query = ctx.Applications;
                //var query = ctx.Applications;
                if (dto.ProjectName != null && !"".Equals(dto.ProjectName))
                {
                    query.Where(a => a.ProjectName.Contains(dto.ProjectName));
                }
                if (dto.Period != null && dto.Period.Length != 0)
                {
                    query.Where(a => dto.Period.Contains(a.Period.Value));
                }
                if (dto.ProjectType != null && dto.ProjectType.Length != 0)
                {
                    query.Where(a => dto.Period.Contains(a.ProjectTypeId.Value));
                }
                if (dto.Institute != null && dto.Institute.Length != 0)
                {
                    query.Where(a => dto.Period.Contains(a.InstituteId.Value));
                }
                if (dto.LeaderName != null && !"".Equals(dto.LeaderName))
                {
                    query.Where(a => a.Leader.Name.Contains(dto.LeaderName));
                }
                if (dto.StartYearCreated != null)
                {
                    query.Where(a => a.YearCreated >= dto.StartYearCreated);
                }
                if (dto.EndYearCreated != null)
                {
                    query.Where(a => a.YearCreated <= dto.EndYearCreated);
                }
                if (dto.StartTotalBudget != null)
                {
                    query.Where(a => a.TotalBudget >= dto.StartTotalBudget);
                }
                if (dto.EndTotalBudget != null)
                {
                    query.Where(a => a.TotalBudget <= dto.EndTotalBudget);
                }
                if (dto.EndTotalBudget != null)
                {
                    query.Where(a => a.TotalBudget <= dto.EndTotalBudget);
                }
                if (dto.Status != null && dto.Status.Length != 0)
                {
                    query.Where(a => dto.Status.Contains((int)a.Status));
                }
                if (dto.DelegateType != null)
                {
                    query.Where(a => (int)a.DeleageType == dto.DelegateType);
                }
                if (dto.StartTotalScore != null)
                {
                    query.Where(a => a.TotalScore != null && a.TotalScore >= dto.StartTotalScore);
                }
                if (dto.EndTotalScore != null)
                {
                    query.Where(a => a.TotalScore != null && a.TotalScore <= dto.EndTotalScore);
                }

                return(query.Select(Mapper.Map <GetApplicationInquiriesDTO>).ToList());
            }
        }