コード例 #1
0
        public async Task <FileDto> GetProjectsToExcel(GetAllProjectsForExcelInput input)
        {
            var filteredProjects = _projectRepository.GetAll()
                                   .Include(e => e.AccountFk)
                                   .Include(e => e.TeamFk)
                                   .Include(e => e.SysStatusFk)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.Filter), e => false || e.Name.Contains(input.Filter) || e.Description.Contains(input.Filter) || e.Remark.Contains(input.Filter))
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.NameFilter), e => e.Name == input.NameFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.DescriptionFilter), e => e.Description == input.DescriptionFilter)
                                   .WhereIf(input.MinStartDateFilter != null, e => e.StartDate >= input.MinStartDateFilter)
                                   .WhereIf(input.MaxStartDateFilter != null, e => e.StartDate <= input.MaxStartDateFilter)
                                   .WhereIf(input.MinEndDateFilter != null, e => e.EndDate >= input.MinEndDateFilter)
                                   .WhereIf(input.MaxEndDateFilter != null, e => e.EndDate <= input.MaxEndDateFilter)
                                   .WhereIf(input.IsApproveFilter > -1, e => (input.IsApproveFilter == 1 && e.IsApprove) || (input.IsApproveFilter == 0 && !e.IsApprove))
                                   .WhereIf(input.IsActiveFilter > -1, e => (input.IsActiveFilter == 1 && e.IsActive) || (input.IsActiveFilter == 0 && !e.IsActive))
                                   .WhereIf(input.PublishFilter > -1, e => (input.PublishFilter == 1 && e.Publish) || (input.PublishFilter == 0 && !e.Publish))
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.RemarkFilter), e => e.Remark == input.RemarkFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.AccountNameFilter), e => e.AccountFk != null && e.AccountFk.Name == input.AccountNameFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.TeamNameFilter), e => e.TeamFk != null && e.TeamFk.Name == input.TeamNameFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.SysStatusNameFilter), e => e.SysStatusFk != null && e.SysStatusFk.Name == input.SysStatusNameFilter);

            var query = (from o in filteredProjects
                         join o1 in _lookup_accountRepository.GetAll() on o.AccountId equals o1.Id into j1
                         from s1 in j1.DefaultIfEmpty()

                         join o2 in _lookup_teamRepository.GetAll() on o.TeamId equals o2.Id into j2
                         from s2 in j2.DefaultIfEmpty()

                         join o3 in _lookup_sysStatusRepository.GetAll() on o.SysStatusId equals o3.Id into j3
                         from s3 in j3.DefaultIfEmpty()

                         select new GetProjectForViewDto()
            {
                Project = new ProjectDto
                {
                    Name = o.Name,
                    Description = o.Description,
                    StartDate = o.StartDate,
                    EndDate = o.EndDate,
                    IsApprove = o.IsApprove,
                    IsActive = o.IsActive,
                    Publish = o.Publish,
                    Remark = o.Remark,
                    Id = o.Id
                },
                AccountName = s1 == null ? "" : s1.Name.ToString(),
                TeamName = s2 == null ? "" : s2.Name.ToString(),
                SysStatusName = s3 == null ? "" : s3.Name.ToString()
            });


            var projectListDtos = await query.ToListAsync();

            return(_projectsExcelExporter.ExportToFile(projectListDtos));
        }
コード例 #2
0
ファイル: ProjectsAppService.cs プロジェクト: iatta/GEC
        public async Task <FileDto> GetProjectsToExcel(GetAllProjectsForExcelInput input)
        {
            var filteredProjects = _projectRepository.GetAll()
                                   .Include(e => e.ManagerFk)
                                   .Include(e => e.LocationFk)
                                   .Include(e => e.OrganizationUnitFk)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.Filter), e => false || e.NameAr.Contains(input.Filter) || e.NameEn.Contains(input.Filter))
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.NameArFilter), e => e.NameAr == input.NameArFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.NameEnFilter), e => e.NameEn == input.NameEnFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.UserNameFilter), e => e.ManagerFk != null && e.ManagerFk.Name == input.UserNameFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.LocationTitleEnFilter), e => e.LocationFk != null && e.LocationFk.TitleEn == input.LocationTitleEnFilter)
                                   .WhereIf(!string.IsNullOrWhiteSpace(input.OrganizationUnitDisplayNameFilter), e => e.OrganizationUnitFk != null && e.OrganizationUnitFk.DisplayName == input.OrganizationUnitDisplayNameFilter);

            var query = (from o in filteredProjects
                         join o1 in _lookup_userRepository.GetAll() on o.ManagerId equals o1.Id into j1
                         from s1 in j1.DefaultIfEmpty()

                         join o2 in _lookup_locationRepository.GetAll() on o.LocationId equals o2.Id into j2
                         from s2 in j2.DefaultIfEmpty()

                         join o3 in _lookup_organizationUnitRepository.GetAll() on o.OrganizationUnitId equals o3.Id into j3
                         from s3 in j3.DefaultIfEmpty()

                         select new GetProjectForViewDto()
            {
                Project = new ProjectDto
                {
                    NameAr = o.NameAr,
                    NameEn = o.NameEn,
                    Id = o.Id,
                    Code = o.Code,
                    Number = o.Number
                },
                UserName = s1 == null ? "" : s1.Name.ToString(),
                LocationTitleEn = s2 == null ? "" : s2.TitleEn.ToString(),
                OrganizationUnitDisplayName = s3 == null ? "" : s3.DisplayName.ToString()
            });


            var projectListDtos = await query.ToListAsync();

            return(_projectsExcelExporter.ExportToFile(projectListDtos));
        }