Правка типа дат для ReportParametersRequest

This commit is contained in:
Olga Nemt 2024-03-21 17:16:16 +05:00
parent 0bbbb43802
commit 820e383e5b
3 changed files with 11 additions and 11 deletions

View File

@ -24,12 +24,12 @@ public class ReportParametersRequest: IValidatableObject
/// <summary>
/// Дата начала интервала
/// </summary>
public DateTime Begin { get; set; } = default;
public DateTimeOffset Begin { get; set; } = default;
/// <summary>
/// Дата окончания интервала
/// </summary>
public DateTime End { get; set; } = default;
public DateTimeOffset End { get; set; } = default;
/// <inheritdoc/>
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
@ -37,7 +37,7 @@ public class ReportParametersRequest: IValidatableObject
if (End < Begin)
yield return new("End mast be less then begin");
if (Begin < new DateTime(2000, 1, 1))
if (Begin < new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero))
yield return new("Begin mast be > 2000-1-1");
}
}

View File

@ -46,7 +46,7 @@ namespace AsbCloudApp.Services
/// <param name="stepSeconds"></param>
/// <param name="format"></param>
/// <returns></returns>
int GetReportPagesCount(int idWell, DateTime begin, DateTime end,
int GetReportPagesCount(int idWell, DateTimeOffset begin, DateTimeOffset end,
int stepSeconds, int format);
/// <summary>

View File

@ -64,11 +64,11 @@ public class ReportService : IReportService
return work.Id;
}
public int GetReportPagesCount(int idWell, DateTime begin, DateTime end, int stepSeconds, int format)
public int GetReportPagesCount(int idWell, DateTimeOffset begin, DateTimeOffset end, int stepSeconds, int format)
{
var timezoneOffset = wellService.GetTimezone(idWell).Hours;
var beginRemote = begin.ToTimeZoneOffsetHours(timezoneOffset);
var endRemote = end.ToTimeZoneOffsetHours(timezoneOffset);
var beginRemote = begin.DateTime.ToTimeZoneOffsetHours(timezoneOffset);
var endRemote = end.DateTime.ToTimeZoneOffsetHours(timezoneOffset);
var generator = GetReportGenerator(idWell, beginRemote, endRemote, stepSeconds, format, db);
var pagesCount = generator.GetPagesCount();
@ -127,10 +127,10 @@ public class ReportService : IReportService
CancellationToken token)
{
var timezoneOffset = wellService.GetTimezone(idWell).Hours;
var beginRemote = request.Begin.ToTimeZoneOffsetHours(timezoneOffset);
var endRemote = request.End.ToTimeZoneOffsetHours(timezoneOffset);
var beginUtc = request.Begin.ToUtcDateTimeOffset(timezoneOffset);
var endUtc = request.End.ToUtcDateTimeOffset(timezoneOffset);
var beginRemote = request.Begin.DateTime;
var endRemote = request.End.DateTime;
var beginUtc = request.Begin.ToUniversalTime();
var endUtc = request.End.ToUniversalTime();
var tempDir = Path.Combine(Path.GetTempPath(), "report");