Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions FMS.Domain/Dto/Event/EventReportDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using DocumentFormat.OpenXml.Office.Y2022.FeaturePropertyBag;
using FMS.Domain.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FMS.Domain.Dto
{
public class EventReportDto
{
public EventReportDto(Event eventNew)
{
Id = eventNew.Id;
FacilityId = eventNew.FacilityId;
ParentId = eventNew.ParentId;
EventType = eventNew.EventType;
ActionTaken = eventNew.ActionTaken;
StartDate = eventNew.StartDate;
DueDate = eventNew.DueDate;
CompletionDate = eventNew.CompletionDate;
ComplianceOfficer = eventNew.ComplianceOfficer;
EventAmount = eventNew.EventAmount;
EventContractor = eventNew.EventContractor;
Comment = eventNew.Comment;
}

public Guid Id { get; set; }

public Guid FacilityId { get; set; }

public Guid? ParentId { get; set; }

public string FacilityNumber { get; set; }

public string FacilityName { get; set; }

public EventType EventType { get; set; }

public ActionTaken ActionTaken { get; set; }

public DateOnly? StartDate { get; set; }

public DateOnly? DueDate { get; set; }

public DateOnly? CompletionDate { get; set; }

public ComplianceOfficer ComplianceOfficer { get; set; }

public OrganizationalUnit OrganizationalUnit { get; set; }

[DataType(DataType.Currency)]
public decimal? EventAmount { get; set; }

public EventContractor EventContractor { get; set; }

public string Comment { get; set; }
}
}
17 changes: 17 additions & 0 deletions FMS.Domain/Dto/Event/EventReportSort.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FMS.Domain.Dto
{
public enum EventReportType
{
Pending,
Compliance,
Completed,
CompletedOutstanding,
CompletedByCO,
}
}
2 changes: 1 addition & 1 deletion FMS.Domain/Dto/Reports/DelistedReportByDateDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Text;
using System.Threading.Tasks;

namespace FMS.Domain.Dto.Reports
namespace FMS.Domain.Dto
{
public class DelistedReportByDateDto
{
Expand Down
2 changes: 1 addition & 1 deletion FMS.Domain/Dto/Reports/DelistedReportByDateRangeDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Text;
using System.Threading.Tasks;

namespace FMS.Domain.Dto.Reports
namespace FMS.Domain.Dto
{
public class DelistedReportByDateRangeDto
{
Expand Down
12 changes: 12 additions & 0 deletions FMS.Domain/Dto/Reports/EventsActivityCompletedByCOReportDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FMS.Domain.Dto
{
public class EventsActivityCompletedByCOReportDto
{
}
}
12 changes: 12 additions & 0 deletions FMS.Domain/Dto/Reports/EventsCompletedOutstandingReportDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FMS.Domain.Dto
{
public class EventsCompletedOutstandingReportDto
{
}
}
12 changes: 12 additions & 0 deletions FMS.Domain/Dto/Reports/EventsCompletedReportDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FMS.Domain.Dto
{
public class EventsCompletedReportDto
{
}
}
12 changes: 12 additions & 0 deletions FMS.Domain/Dto/Reports/EventsComplianceReportDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FMS.Domain.Dto
{
public class EventsComplianceReportDto
{
}
}
51 changes: 51 additions & 0 deletions FMS.Domain/Dto/Reports/EventsPendingReportDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using ClosedXML.Attributes;
using FMS.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FMS.Domain.Dto
{
public class EventsPendingReportDto
{
public EventsPendingReportDto() {}

public EventsPendingReportDto(EventReportDto reportEvent)
{
HSIID = reportEvent.FacilityNumber;
FacilityName = reportEvent.FacilityName;
EventTypeName = reportEvent.EventType?.Name;
EventStartDate = reportEvent.StartDate;
EventDueDate = reportEvent.DueDate;
ComplianceOfficerName = reportEvent.ComplianceOfficer?.Name;
UnitName = reportEvent.OrganizationalUnit?.Name;
ActivityComment = reportEvent.Comment;
}

[XLColumn(Header = "HSI ID")]
public string HSIID { get; set; }

[XLColumn(Header = "Facility Name")]
public string FacilityName { get; set; }

[XLColumn(Header = "Event Type")]
public string EventTypeName { get; set; }

[XLColumn(Header = "Event Start Date")]
public DateOnly? EventStartDate { get; set; }

[XLColumn(Header = "Event Due Date")]
public DateOnly? EventDueDate { get; set; }

[XLColumn(Header = "Compliance Officer")]
public string ComplianceOfficerName { get; set; }

[XLColumn(Header = "Unit")]
public string UnitName { get; set; }

[XLColumn(Header = "Activity Comment")]
public string ActivityComment { get; set; }
}
}
3 changes: 2 additions & 1 deletion FMS.Domain/Repositories/IReportingRepository.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FMS.Domain.Dto;
using FMS.Domain.Dto.Reports;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down Expand Up @@ -30,6 +29,8 @@ public interface IReportingRepository : IDisposable

#region Events Reports

Task<IReadOnlyList<EventReportDto>> GetEventsReportsAsync(EventReportType eventReportType);

#endregion
}
}
50 changes: 47 additions & 3 deletions FMS.Infrastructure/Repositories/ReportingRepository.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using FMS.Domain.Dto;
using FMS.Domain.Dto.Reports;
using DocumentFormat.OpenXml.Office2010.Excel;
using FMS.Domain.Dto;
using FMS.Domain.Entities;
using FMS.Domain.Repositories;
using FMS.Infrastructure.Contexts;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;

Expand Down Expand Up @@ -174,11 +176,53 @@
return reportDto;
}


#endregion

#region Events Reports

public async Task<IReadOnlyList<EventReportDto>> GetEventsReportsAsync(EventReportType eventReportType)
{
List<EventReportDto> facilityList = await _context.Facilities.AsNoTracking()
.Include(e => e.County)
.Include(e => e.FacilityStatus)
.Include(e => e.HsrpFacilityProperties)
.Include(e => e.HsrpFacilityProperties.ComplianceOfficer)
.Include(e => e.FacilityType)
.Include(e => e.Events)
.Include(e => e.ComplianceOfficer)
.Include(e => e.OrganizationalUnit)
.Where(e => (e.FacilityType.Name == "HSI" || e.FacilityType.Name == "VRP"))
.SelectMany(e => e.Events.Where(ev => ev.Active)
.Select(ev => new EventReportDto(ev)))
.ToListAsync();

List<EventReportDto> reportDto;

switch (eventReportType)
{
case EventReportType.Pending:
reportDto = facilityList.Where(e => e.Status == "Pending").ToList();

Check failure on line 204 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Run unit tests

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 204 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Run unit tests

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 204 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Analyze with SonarCloud

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 204 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Analyze with SonarCloud

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)
break;
case EventReportType.Compliance:
reportDto = facilityList.Where(e => e.Status == "Compliance").ToList();

Check failure on line 207 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Run unit tests

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 207 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Run unit tests

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 207 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Analyze with SonarCloud

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 207 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Analyze with SonarCloud

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)
break;
case EventReportType.Completed:
reportDto = facilityList.Where(e => e.Status == "Completed").ToList();

Check failure on line 210 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Run unit tests

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 210 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Run unit tests

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 210 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Analyze with SonarCloud

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 210 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Analyze with SonarCloud

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)
break;
case EventReportType.CompletedOutstanding:
reportDto = facilityList.Where(e => e.Status == "CompletedOutstanding").ToList();

Check failure on line 213 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Run unit tests

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 213 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Run unit tests

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 213 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Analyze with SonarCloud

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 213 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Analyze with SonarCloud

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)
break;
case EventReportType.CompletedByCO:
reportDto = facilityList.Where(e => e.Status == "CompletedByCO").ToList();

Check failure on line 216 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Run unit tests

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 216 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Run unit tests

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 216 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Analyze with SonarCloud

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 216 in FMS.Infrastructure/Repositories/ReportingRepository.cs

View workflow job for this annotation

GitHub Actions / Analyze with SonarCloud

'EventReportDto' does not contain a definition for 'Status' and no accessible extension method 'Status' accepting a first argument of type 'EventReportDto' could be found (are you missing a using directive or an assembly reference?)
break;
default:
reportDto = facilityList;
break;
}

return reportDto;
}

#endregion

#region IDisposable Support
Expand Down
66 changes: 66 additions & 0 deletions FMS/Helpers/EventSortHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,71 @@ public static IEnumerable<EventSummaryDto> OrderEventQuery(
_ => events.OrderBy(e => e.StartDate)
.ThenByDescending(e => e.DueDate)
};


public static IList<EventReportDto> SortReportEvents(IList<EventReportDto> events, EventSort sortBy)
{
var sortedList = new List<EventReportDto>();

// Get top-level parents
var topLevelParents = events.Where(e => e.ParentId == Guid.Empty || e.ParentId == null).OrderReportEventQuery(sortBy);

foreach (var parent in topLevelParents)
{
sortedList.Add(parent);
AddReportChildrenRecursively(parent, events, sortedList, sortBy);
}

return sortedList;
}

private static void AddReportChildrenRecursively(EventReportDto parent, IList<EventReportDto> allEvents, List<EventReportDto> sortedList, EventSort sortBy)
{
var children = allEvents.Where(c => c.ParentId == parent.Id).OrderReportEventQuery(sortBy);
foreach (var child in children)
{
sortedList.Add(child);
AddReportChildrenRecursively(child, allEvents, sortedList, sortBy);
}
}

public static IEnumerable<EventReportDto> OrderReportEventQuery(
this IEnumerable<EventReportDto> events, EventSort sortBy) =>
sortBy switch
{
EventSort.EventType => events.OrderBy(e => e.EventType.Name)
.ThenByDescending(e => e.StartDate),
EventSort.EventTypeDesc => events.OrderByDescending(e => e.EventType.Name)
.ThenByDescending(e => e.StartDate),
EventSort.ActionTaken => events.OrderBy(e => e.ActionTaken.Name)
.ThenBy(e => e.StartDate),
EventSort.ActionTakenDesc => events.OrderByDescending(e => e.ActionTaken.Name)
.ThenByDescending(e => e.StartDate),
EventSort.StartDateDesc => events.OrderByDescending(e => e.StartDate)
.ThenByDescending(e => e.DueDate),
EventSort.DueDate => events.OrderBy(e => e.DueDate)
.ThenBy(e => e.StartDate),
EventSort.DueDateDesc => events.OrderByDescending(e => e.DueDate)
.ThenBy(e => e.StartDate),
EventSort.CompletionDate => events.OrderByDescending(e => e.CompletionDate)
.ThenBy(e => e.EventType.Name),
EventSort.CompletionDateDesc => events.OrderBy(e => e.CompletionDate)
.ThenBy(e => e.EventType.Name),
EventSort.ComplianceOfficer => events.OrderBy(e => e.ComplianceOfficer.Name)
.ThenBy(e => e.EventType.Name),
EventSort.ComplianceOfficerDesc => events.OrderByDescending(e => e.ComplianceOfficer.Name)
.ThenBy(e => e.EventType.Name),
EventSort.EventAmount => events.OrderBy(e => e.EventAmount)
.ThenBy(e => e.EventType.Name),
EventSort.EventAmountDesc => events.OrderByDescending(e => e.EventAmount)
.ThenByDescending(e => e.EventType.Name),
EventSort.EventContractor => events.OrderByDescending(e => e.EventContractor?.Name)
.ThenBy(e => e.EventType.Name),
EventSort.EventContractorDesc => events.OrderBy(e => e.EventContractor?.Name)
.ThenBy(e => e.EventType.Name),
// EventSort.StartDate
_ => events.OrderBy(e => e.StartDate)
.ThenByDescending(e => e.DueDate)
};
}
}
4 changes: 4 additions & 0 deletions FMS/Helpers/ExportHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public static byte[] ExportExcelAsByteArray<T>(this IEnumerable<T> list, ReportT
table.ShowTotalsRow = true;
table.Field("Acres").TotalsRowFunction = XLTotalsRowFunction.Sum;
}
if (reportType == ReportType.Event)
{

}


wb.SaveAs(ms);
Expand Down
3 changes: 2 additions & 1 deletion FMS/Pages/Reporting/Delisted/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@
<span asp-validation-for="StartDate" class="text-danger"></span>
</div>
<div class="col-md-2">
<label asp-for="EndDate" class="form-label"></label>
<label asp-for="EndDate" class="form-label">End Date <span class="text-danger">*</span></label>
<input asp-for="EndDate" class="form-control datepicker" type="date" placeholder="" />
<span asp-validation-for="EndDate" class="text-danger"></span>
</div>
</div>
<p><span class="text-danger">* denotes required field</span></p>
</form>
Loading
Loading