forked from ddrilling/AsbCloudServer
Merge branch 'dev' of https://bitbucket.org/autodrilling/asbcloudserver into dev
This commit is contained in:
commit
84cb9f6d3b
@ -6,7 +6,7 @@ namespace AsbCloudApp.Data
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Url { get; set; }
|
||||
public FileInfoDto File { get; set; }
|
||||
public int IdWell { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public DateTimeOffset Begin { get; set; }
|
||||
|
@ -128,9 +128,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
[Obsolete]
|
||||
Task<List<ReportPropertiesDto>> IReportService.GetSuitableReportsAsync(int idWell, DateTime begin, DateTime end, int stepSeconds, int format, CancellationToken token) =>
|
||||
public Task<List<ReportPropertiesDto>> GetSuitableReportsAsync(int idWell, DateTime begin, DateTime end, int stepSeconds, int format, CancellationToken token) =>
|
||||
(from r in db.ReportProperties.Include(r => r.File)
|
||||
where r.IdWell == idWell
|
||||
&& r.Begin >= begin
|
||||
@ -141,7 +139,16 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
Id = r.Id,
|
||||
Name = r.File.Name,
|
||||
Url = fileService.GetUrl(r.IdFile),
|
||||
File = new FileInfoDto{
|
||||
Id = r.File.Id,
|
||||
Author = null,
|
||||
IdAuthor = r.File.IdAuthor??0,
|
||||
IdCategory = r.File.IdCategory,
|
||||
IdWell = r.File.IdWell,
|
||||
Name = r.File.Name,
|
||||
Size = r.File.Size,
|
||||
UploadDate = r.File.UploadDate,
|
||||
},
|
||||
IdWell = r.IdWell,
|
||||
Date = r.File.UploadDate,
|
||||
Begin = r.Begin,
|
||||
@ -160,9 +167,17 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
Id = r.Id,
|
||||
Name = r.File.Name,
|
||||
#pragma warning disable IDE0057 // Use range operator
|
||||
Url = fileService.GetUrl(r.IdWell, ReportCategoryId, r.File.Id, r.File.Name.Substring(r.File.Name.LastIndexOf(".") > 0 ? r.File.Name.LastIndexOf(".") : r.File.Name.Length)),
|
||||
#pragma warning restore IDE0057 // Use range operator
|
||||
File = new FileInfoDto
|
||||
{
|
||||
Id = r.File.Id,
|
||||
Author = null,
|
||||
IdAuthor = r.File.IdAuthor ?? 0,
|
||||
IdCategory = r.File.IdCategory,
|
||||
IdWell = r.File.IdWell,
|
||||
Name = r.File.Name,
|
||||
Size = r.File.Size,
|
||||
UploadDate = r.File.UploadDate,
|
||||
},
|
||||
IdWell = r.IdWell,
|
||||
Date = r.File.UploadDate,
|
||||
Begin = r.Begin,
|
||||
|
@ -88,6 +88,9 @@ namespace AsbCloudInfrastructure.Services
|
||||
if (dateBegin == default)
|
||||
dateBegin = DateTime.Now.AddSeconds(-intervalSec);
|
||||
|
||||
if (dateBegin.Kind == DateTimeKind.Unspecified)
|
||||
dateBegin = DateTime.SpecifyKind(dateBegin, DateTimeKind.Utc);
|
||||
|
||||
var datEnd = dateBegin.AddSeconds(intervalSec);
|
||||
var dbSet = db.Set<TModel>();
|
||||
|
||||
@ -109,8 +112,11 @@ namespace AsbCloudInfrastructure.Services
|
||||
query = query.Where(d => d.Id % m == 0);
|
||||
}
|
||||
|
||||
var entities = await query.AsNoTracking()
|
||||
.ToListAsync(token).ConfigureAwait(false);
|
||||
var entities = await query
|
||||
.OrderBy(d=>d.Date)
|
||||
.AsNoTracking()
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dtos = entities.Select(e => Convert(e));
|
||||
|
||||
|
@ -79,15 +79,24 @@ namespace AsbCloudWebApi.Controllers
|
||||
public virtual async Task<IActionResult> GetDataAsync(int idWell, DateTime begin = default,
|
||||
int intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default)
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null)
|
||||
return Forbid();
|
||||
|
||||
bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false);
|
||||
|
||||
if (!isCompanyOwnsWell)
|
||||
return Forbid();
|
||||
|
||||
if (begin == default)
|
||||
begin = DateTime.Now.AddSeconds(-intervalSec);
|
||||
|
||||
var content = await telemetryDataService.GetAsync(idWell, begin,
|
||||
intervalSec, approxPointsCount, token).ConfigureAwait(false);
|
||||
|
||||
if (content is null || !content.Any())
|
||||
return NoContent();
|
||||
|
||||
return Ok(null);
|
||||
return Ok(content);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -113,10 +122,10 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (!isCompanyOwnsWell)
|
||||
return Forbid();
|
||||
|
||||
DatesRangeDto dataDatesRange = await telemetryDataService.GetDataDatesRangeAsync(idWell,
|
||||
var dataDatesRange = await telemetryDataService.GetDataDatesRangeAsync(idWell,
|
||||
token).ConfigureAwait(false);
|
||||
|
||||
return Ok(null);
|
||||
return Ok(dataDatesRange);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user