Смена типов дат для SetpointsRequestDto и всё, что с ним связано

This commit is contained in:
Olga Nemt 2024-03-25 09:29:44 +05:00
parent 9e4761f97b
commit 488b8ec674
4 changed files with 8 additions and 11 deletions

View File

@ -33,7 +33,7 @@ namespace AsbCloudApp.Data.SAUB
/// <summary>
/// отметка времени создания запроса
/// </summary>
public DateTime UploadDate { get; set; } = DateTime.Now;
public DateTimeOffset UploadDate { get; set; } = DateTimeOffset.Now;
/// <summary>
/// время в секундах актуальности этого запроса

View File

@ -24,7 +24,7 @@ namespace AsbCloudInfrastructure.Repository
this.wellService = wellService;
}
public async Task<IEnumerable<ScheduleDto>> GetAsync(int idWell, DateTime workTime, CancellationToken token)
public async Task<IEnumerable<ScheduleDto>> GetAsync(int idWell, DateTimeOffset workTime, CancellationToken token)
{
var entities = await BuildQuery(idWell, workTime)
.AsNoTracking()
@ -33,7 +33,7 @@ namespace AsbCloudInfrastructure.Repository
return entities.Select(Convert);
}
public async Task<DrillerDto?> GetOrDefaultDrillerAsync(int idWell, DateTime workTime, CancellationToken token)
public async Task<DrillerDto?> GetOrDefaultDrillerAsync(int idWell, DateTimeOffset workTime, CancellationToken token)
{
var entities = await BuildQuery(idWell, workTime)
.AsNoTracking()
@ -43,8 +43,7 @@ namespace AsbCloudInfrastructure.Repository
return null;
var hoursOffset = wellService.GetTimezone(idWell).Hours;
var remoteDate = workTime.ToUtcDateTimeOffset(hoursOffset).ToRemoteDateTime(hoursOffset);
var time = new TimeOnly(remoteDate.Hour, remoteDate.Minute, remoteDate.Second);
var time = new TimeOnly(workTime.Hour, workTime.Minute, workTime.Second);
var entity = entities.FirstOrDefault(s =>
s.ShiftStart > s.ShiftEnd ^
@ -69,11 +68,11 @@ namespace AsbCloudInfrastructure.Repository
}
private IQueryable<Schedule> BuildQuery(int idWell, DateTime workTime)
private IQueryable<Schedule> BuildQuery(int idWell, DateTimeOffset workTime)
{
var hoursOffset = wellService.GetTimezone(idWell).Hours;
var workTimeDateTime = workTime.ToUtcDateTimeOffset(hoursOffset);
var workTimeDateTime = workTime.ToUniversalTime();
return GetQuery().Where(s => s.IdWell == idWell
&& s.DrillStart <= workTimeDateTime

View File

@ -50,15 +50,14 @@ namespace AsbCloudInfrastructure.Repository
{
var result = base.Convert(src);
var timezoneOffsetHours = wellService.GetTimezone(src.IdWell).Hours;
result.UploadDate = src.UploadDate.ToRemoteDateTime(timezoneOffsetHours);
result.UploadDate = src.UploadDate.ToOffset(TimeSpan.FromHours(timezoneOffsetHours));
return result;
}
protected override SetpointsRequest Convert(SetpointsRequestDto src)
{
var result = base.Convert(src);
var timezoneOffsetHours = wellService.GetTimezone(src.IdWell).Hours;
result.UploadDate = src.UploadDate.ToUtcDateTimeOffset(timezoneOffsetHours);
result.UploadDate = src.UploadDate.ToUniversalTime();
return result;
}
}

View File

@ -72,7 +72,6 @@ namespace AsbCloudInfrastructure.Services.SAUB
foreach (var item in filtered)
{
item.IdState = 2;
item.UploadDate = DateTime.SpecifyKind(item.UploadDate, DateTimeKind.Utc);
}
await setpointsRepository.UpdateRangeAsync(filtered, token);