forked from ddrilling/AsbCloudServer
CS2-22: Исправлено выпадение исключения при запросе диапазона дат
This commit is contained in:
parent
fd5871a9ec
commit
88f0453a32
@ -99,25 +99,22 @@ namespace AsbCloudInfrastructure.Services
|
||||
if (telemetry is null)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
var datesRange = (from d in db.DataSaubBases
|
||||
where d.IdTelemetry == telemetry.Id
|
||||
select d.Date).Union(
|
||||
from m in db.Messages
|
||||
where m.IdTelemetry == telemetry.Id
|
||||
select m.Date).GroupBy(g => true)
|
||||
select m.Date).DefaultIfEmpty().GroupBy(g => true)
|
||||
.Select(g => new
|
||||
{
|
||||
From = g.Min(),
|
||||
To = g.Max()
|
||||
}).FirstOrDefault();
|
||||
return new DatesRangeDto { From = datesRange.From, To = datesRange.To };
|
||||
}
|
||||
catch(InvalidOperationException)
|
||||
{
|
||||
return new DatesRangeDto { From = DateTime.MinValue, To = DateTime.MaxValue };
|
||||
}
|
||||
}).OrderBy(gr => gr.From).FirstOrDefault();
|
||||
|
||||
return new DatesRangeDto {
|
||||
From = datesRange.From,
|
||||
To = datesRange.To.Year == 1 ? DateTime.MaxValue : datesRange.To
|
||||
};
|
||||
}
|
||||
|
||||
private IEnumerable<Report> GetSuitableReportsFromDb(int wellId, DateTime begin, DateTime end, int stepSeconds, int format)
|
||||
|
Loading…
Reference in New Issue
Block a user