forked from ddrilling/AsbCloudServer
CS2-50: Added .ConfigureAwait(false) to all async methods.
This commit is contained in:
parent
f13b757a84
commit
ab63bc4aa1
@ -17,6 +17,7 @@ namespace AsbCloudApp.Services
|
|||||||
int idCategory, DateTime begin, DateTime end,
|
int idCategory, DateTime begin, DateTime end,
|
||||||
int skip, int take, CancellationToken token = default);
|
int skip, int take, CancellationToken token = default);
|
||||||
|
|
||||||
(int Id, string Name, int IdCategory)? GetFileInfo(int fileId);
|
Task<(int Id, string Name, int IdCategory)?> GetFileInfoAsync(int fileId,
|
||||||
|
CancellationToken token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
WellDepth = d.WellDepth ?? 0.0,
|
WellDepth = d.WellDepth ?? 0.0,
|
||||||
BitDepth = d.BitDepth ?? 0.0,
|
BitDepth = d.BitDepth ?? 0.0,
|
||||||
Date = d.Date
|
Date = d.Date
|
||||||
}).AsNoTracking().ToListAsync(token);
|
}).AsNoTracking().ToListAsync(token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<WellDepthToIntervalDto>> GetWellDepthToIntervalAsync(int idWell,
|
public async Task<IEnumerable<WellDepthToIntervalDto>> GetWellDepthToIntervalAsync(int idWell,
|
||||||
@ -75,7 +75,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var timezoneOffset = telemetryService.GetTimezoneOffsetByTelemetryId((int)telemetryId);
|
var timezoneOffset = telemetryService.GetTimezoneOffsetByTelemetryId((int)telemetryId);
|
||||||
|
|
||||||
var drillingPeriodsInfo = await db.GetDepthToIntervalAsync((int)telemetryId, intervalSeconds,
|
var drillingPeriodsInfo = await db.GetDepthToIntervalAsync((int)telemetryId, intervalSeconds,
|
||||||
workBeginSeconds, timezoneOffset, token);
|
workBeginSeconds, timezoneOffset, token).ConfigureAwait(false);
|
||||||
|
|
||||||
var wellDepthToIntervalData = drillingPeriodsInfo.Select(d => new WellDepthToIntervalDto
|
var wellDepthToIntervalData = drillingPeriodsInfo.Select(d => new WellDepthToIntervalDto
|
||||||
{
|
{
|
||||||
@ -122,14 +122,15 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
operations = operations.Where(m => (m.UnixDate + m.DurationSec) <= unixEnd);
|
operations = operations.Where(m => (m.UnixDate + m.DurationSec) <= unixEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Count = await operations.CountAsync(token);
|
result.Count = await operations.CountAsync(token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (skip > 0)
|
if (skip > 0)
|
||||||
operations = operations.Skip(skip);
|
operations = operations.Skip(skip);
|
||||||
|
|
||||||
var operationsList = await operations.Take(take)
|
var operationsList = await operations.Take(take)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.ToListAsync(token);
|
.ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (operationsList.Count == 0)
|
if (operationsList.Count == 0)
|
||||||
return result;
|
return result;
|
||||||
@ -173,7 +174,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
OperationName = g.Key.Name,
|
OperationName = g.Key.Name,
|
||||||
Duration = g.Where(g => g.DurationSec > 0)
|
Duration = g.Where(g => g.DurationSec > 0)
|
||||||
.Sum(a => a.DurationSec)
|
.Sum(a => a.DurationSec)
|
||||||
}).AsNoTracking().ToListAsync(token);
|
}).AsNoTracking().ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TelemetryOperationInfoDto>> GetOperationsToIntervalAsync(int idWell,
|
public async Task<IEnumerable<TelemetryOperationInfoDto>> GetOperationsToIntervalAsync(int idWell,
|
||||||
@ -202,7 +204,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
IntervalStart = g.Min(d => d.UnixDate),
|
IntervalStart = g.Min(d => d.UnixDate),
|
||||||
OperationName = g.Key.Name,
|
OperationName = g.Key.Name,
|
||||||
OperationsDuration = g.Sum(an => an.DurationSec)
|
OperationsDuration = g.Sum(an => an.DurationSec)
|
||||||
}).AsNoTracking().ToListAsync(token);
|
}).AsNoTracking().ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var operationsGroupedByInterval = operations.GroupBy(op => op.IntervalStart)
|
var operationsGroupedByInterval = operations.GroupBy(op => op.IntervalStart)
|
||||||
.Select(o => new TelemetryOperationInfoDto
|
.Select(o => new TelemetryOperationInfoDto
|
||||||
|
@ -41,7 +41,9 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
public async Task<UserTokenDto> LoginAsync(string login, string password,
|
public async Task<UserTokenDto> LoginAsync(string login, string password,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var identity = await GetClaimsUserAsync(login, password, token);
|
var identity = await GetClaimsUserAsync(login, password, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (identity == default)
|
if (identity == default)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@ -144,7 +146,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var user = await db
|
var user = await db
|
||||||
.GetUsersByLogin(login)
|
.GetUsersByLogin(login)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.FirstOrDefaultAsync(token);
|
.FirstOrDefaultAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (user is null)
|
if (user is null)
|
||||||
return default;
|
return default;
|
||||||
|
@ -21,9 +21,9 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (tasksQueue.TryDequeue(out var item))
|
if (tasksQueue.TryDequeue(out var item))
|
||||||
await Task.Run(() => item.action(item.id), token);
|
await Task.Run(() => item.action(item.id), token).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await Task.Delay(100, token);
|
await Task.Delay(100, token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public override async Task StopAsync(CancellationToken token)
|
public override async Task StopAsync(CancellationToken token)
|
||||||
{
|
{
|
||||||
await base.StopAsync(token);
|
await base.StopAsync(token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
.Include(w => w.Cluster)
|
.Include(w => w.Cluster)
|
||||||
.ThenInclude(c => c.Deposit)
|
.ThenInclude(c => c.Deposit)
|
||||||
where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany)
|
where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany)
|
||||||
select well).AsNoTracking().ToListAsync(token);
|
select well).ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var gDepositEntities = wellEntities
|
var gDepositEntities = wellEntities
|
||||||
.GroupBy(w => w.Cluster)
|
.GroupBy(w => w.Cluster)
|
||||||
@ -70,7 +71,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
.Select(e => e.Cluster)
|
.Select(e => e.Cluster)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.ToListAsync(token);
|
.ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var dtos = entities.Select(e => new ClusterDto
|
var dtos = entities.Select(e => new ClusterDto
|
||||||
{
|
{
|
||||||
@ -91,7 +93,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
.Where(e => e.IdDeposit == depositId)
|
.Where(e => e.IdDeposit == depositId)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.ToListAsync(token);
|
.ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var dtos = entities.Select(e => new ClusterDto
|
var dtos = entities.Select(e => new ClusterDto
|
||||||
{
|
{
|
||||||
@ -110,7 +113,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var entities = await db.GetWellsForCompany(idCompany)
|
var entities = await db.GetWellsForCompany(idCompany)
|
||||||
.Where(e => e.IdCluster == idCluster)
|
.Where(e => e.IdCluster == idCluster)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.ToListAsync(token);
|
.ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var dtos = entities.Select(e => new WellDto
|
var dtos = entities.Select(e => new WellDto
|
||||||
{
|
{
|
||||||
@ -174,12 +178,15 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
CompanyType = c.Company.CompanyType.Caption,
|
CompanyType = c.Company.CompanyType.Caption,
|
||||||
}),
|
}),
|
||||||
WellType = e.WellType.Caption,
|
WellType = e.WellType.Caption,
|
||||||
}).AsNoTracking().ToListAsync(token);
|
}).AsNoTracking().ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (!wellStatDtos.Any())
|
if (!wellStatDtos.Any())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var clusterById = await db.Clusters.AsNoTracking().FirstOrDefaultAsync(c => c.Id == idCluster, token);
|
var clusterById = await db.Clusters.AsNoTracking()
|
||||||
|
.FirstOrDefaultAsync(c => c.Id == idCluster, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
return new ClusterStatDto
|
return new ClusterStatDto
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
&& data.Date >= dateBegin && data.Date < datEnd
|
&& data.Date >= dateBegin && data.Date < datEnd
|
||||||
select data;
|
select data;
|
||||||
|
|
||||||
var fullDataCount = await query.CountAsync(token);
|
var fullDataCount = await query.CountAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (fullDataCount == 0)
|
if (fullDataCount == 0)
|
||||||
return default;
|
return default;
|
||||||
@ -64,7 +65,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
query = query.Where(d => d.Id % m == 0);
|
query = query.Where(d => d.Id % m == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
var entities = await query.AsNoTracking().ToListAsync(token);
|
var entities = await query.AsNoTracking()
|
||||||
|
.ToListAsync(token).ConfigureAwait(false);
|
||||||
|
|
||||||
var dtos = entities.Adapt<DataSaubBaseDto>();
|
var dtos = entities.Adapt<DataSaubBaseDto>();
|
||||||
|
|
||||||
@ -85,7 +87,9 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
where d.IdTelemetry == telemetryId
|
where d.IdTelemetry == telemetryId
|
||||||
&& d.Date > dtoMinDate
|
&& d.Date > dtoMinDate
|
||||||
&& d.Date < dtoMaxDate
|
&& d.Date < dtoMaxDate
|
||||||
select d).AsNoTracking().ToListAsync(token);
|
select d).AsNoTracking()
|
||||||
|
.ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (oldDataSaubBase.Any())
|
if (oldDataSaubBase.Any())
|
||||||
db.DataSaubBases.RemoveRange(oldDataSaubBase);
|
db.DataSaubBases.RemoveRange(oldDataSaubBase);
|
||||||
@ -111,7 +115,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
if (telemetryId is null)
|
if (telemetryId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var (From, To) = await db.GetDatesRangeAsync<DataSaubBase>((int)telemetryId, token);
|
var (From, To) = await db.GetDatesRangeAsync<DataSaubBase>((int)telemetryId, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
return new DatesRangeDto { From = From, To = To };
|
return new DatesRangeDto { From = From, To = To };
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
IdCategory = dto.IdCategory,
|
IdCategory = dto.IdCategory,
|
||||||
MessageTemplate = dto.Message
|
MessageTemplate = dto.Message
|
||||||
});
|
});
|
||||||
await cacheEvents.UpsertAsync(entities, token);
|
await cacheEvents.UpsertAsync(entities, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,12 +64,15 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
if (end != default)
|
if (end != default)
|
||||||
filesInfoQuery = filesInfoQuery.Where(m => m.Date <= end).AsNoTracking();
|
filesInfoQuery = filesInfoQuery.Where(m => m.Date <= end).AsNoTracking();
|
||||||
|
|
||||||
result.Count = await filesInfoQuery.CountAsync(token);
|
result.Count = await filesInfoQuery.CountAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (skip > 0)
|
if (skip > 0)
|
||||||
filesInfoQuery = filesInfoQuery.Skip(skip).AsNoTracking();
|
filesInfoQuery = filesInfoQuery.Skip(skip).AsNoTracking();
|
||||||
|
|
||||||
var filesInfoList = await filesInfoQuery.OrderBy(f => f.Date).Take(take).ToListAsync(token);
|
var filesInfoList = await filesInfoQuery.OrderBy(f => f.Date)
|
||||||
|
.Take(take).ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (filesInfoList.Count == 0)
|
if (filesInfoList.Count == 0)
|
||||||
return result;
|
return result;
|
||||||
@ -91,9 +94,12 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public (int Id, string Name, int IdCategory)? GetFileInfo(int fileId)
|
public async Task<(int Id, string Name, int IdCategory)?> GetFileInfoAsync(int fileId,
|
||||||
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var fileInfo = db.Files.AsNoTracking().FirstOrDefault(f => f.Id == fileId);
|
var fileInfo = await db.Files.AsNoTracking()
|
||||||
|
.FirstOrDefaultAsync(f => f.Id == fileId, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (fileInfo is null)
|
if (fileInfo is null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -21,7 +21,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var entity = await db.LastData.AsNoTracking().FirstOrDefaultAsync(e =>
|
var entity = await db.LastData.AsNoTracking().FirstOrDefaultAsync(e =>
|
||||||
e.IdWell == idWell && e.IdCategory == idCategory, token);
|
e.IdWell == idWell && e.IdCategory == idCategory, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (entity is null)
|
if (entity is null)
|
||||||
return new Tdto();
|
return new Tdto();
|
||||||
@ -37,7 +38,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
var entity = await db.LastData.AsNoTracking()
|
var entity = await db.LastData.AsNoTracking()
|
||||||
.FirstOrDefaultAsync(ld => ld.IdWell == idWell &&
|
.FirstOrDefaultAsync(ld => ld.IdWell == idWell &&
|
||||||
ld.IdCategory == idCategory, token);
|
ld.IdCategory == idCategory, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (entity is not null)
|
if (entity is not null)
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
query = query.Skip(skip);
|
query = query.Skip(skip);
|
||||||
|
|
||||||
var messagesList = await query.Take(take).AsNoTracking()
|
var messagesList = await query.Take(take).AsNoTracking()
|
||||||
.ToListAsync(token);
|
.ToListAsync(token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (messagesList.Count == 0)
|
if (messagesList.Count == 0)
|
||||||
return result;
|
return result;
|
||||||
@ -120,7 +120,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
if (telemetryId is null)
|
if (telemetryId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var (From, To) = await db.GetDatesRangeAsync<TelemetryMessage>((int)telemetryId, token);
|
var (From, To) = await db.GetDatesRangeAsync<TelemetryMessage>((int)telemetryId, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
return new DatesRangeDto { From = From, To = To };
|
return new DatesRangeDto { From = From, To = To };
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
public async Task<IEnumerable<ReportPropertiesDto>> GetSuitableReportsAsync(int idWell,
|
public async Task<IEnumerable<ReportPropertiesDto>> GetSuitableReportsAsync(int idWell,
|
||||||
DateTime begin, DateTime end, int stepSeconds, int format, CancellationToken token = default)
|
DateTime begin, DateTime end, int stepSeconds, int format, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var suitableReportsFromDb = await GetSuitableReportsFromDbAsync(idWell, begin, end, stepSeconds, format);
|
var suitableReportsFromDb = await GetSuitableReportsFromDbAsync(idWell,
|
||||||
|
begin, end, stepSeconds, format, token).ConfigureAwait(false);
|
||||||
|
|
||||||
var suitableReportsProperties = suitableReportsFromDb.Select(r => new ReportPropertiesDto
|
var suitableReportsProperties = suitableReportsFromDb.Select(r => new ReportPropertiesDto
|
||||||
{
|
{
|
||||||
@ -134,7 +135,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
From = g.Min(),
|
From = g.Min(),
|
||||||
To = g.Max()
|
To = g.Max()
|
||||||
}).OrderBy(gr => gr.From)
|
}).OrderBy(gr => gr.From)
|
||||||
.FirstOrDefaultAsync(token);
|
.FirstOrDefaultAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
return new DatesRangeDto
|
return new DatesRangeDto
|
||||||
{
|
{
|
||||||
@ -155,7 +157,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
&& r.Format == format
|
&& r.Format == format
|
||||||
select r).OrderBy(o => o.File.Date)
|
select r).OrderBy(o => o.File.Date)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Take(512).ToListAsync(token);
|
.Take(512).ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
return suitableReportsNames;
|
return suitableReportsNames;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public async Task<WellSectionDto> InsertAsync(WellSectionDto item, int idWell, CancellationToken token = default)
|
public async Task<WellSectionDto> InsertAsync(WellSectionDto item, int idWell, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var sectionType = await GetWellSectionTypeFromCacheAndAssert(item.SectionType);
|
var sectionType = await GetWellSectionTypeFromCacheAndAssertAsync(item.SectionType);
|
||||||
|
|
||||||
var entity = item.Adapt<WellSection>();
|
var entity = item.Adapt<WellSection>();
|
||||||
entity.Id = default;
|
entity.Id = default;
|
||||||
@ -96,7 +96,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
for (int i = 0; i < dbEntities.Length; i++)
|
for (int i = 0; i < dbEntities.Length; i++)
|
||||||
{
|
{
|
||||||
var sectionType = await GetWellSectionTypeFromCacheAndAssert(items.ElementAt(i).SectionType);
|
var sectionType = await GetWellSectionTypeFromCacheAndAssertAsync(items.ElementAt(i).SectionType, token);
|
||||||
var item = items.ElementAt(i).Adapt<WellSection>();
|
var item = items.ElementAt(i).Adapt<WellSection>();
|
||||||
item.IdWell = idWell;
|
item.IdWell = idWell;
|
||||||
item.IdWellSectionType = sectionType.Id;
|
item.IdWellSectionType = sectionType.Id;
|
||||||
@ -117,7 +117,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public async Task<WellSectionDto> UpdateAsync(WellSectionDto item, int idSection, int idWell, CancellationToken token = default)
|
public async Task<WellSectionDto> UpdateAsync(WellSectionDto item, int idSection, int idWell, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var sectionType = await GetWellSectionTypeFromCacheAndAssert(item.SectionType);
|
var sectionType = await GetWellSectionTypeFromCacheAndAssertAsync(item.SectionType, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var entity = item.Adapt<WellSection>();
|
var entity = item.Adapt<WellSection>();
|
||||||
entity.Id = idSection;
|
entity.Id = idSection;
|
||||||
@ -138,7 +139,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return context.SaveChangesAsync(token);
|
return context.SaveChangesAsync(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<WellSectionType> GetWellSectionTypeFromCacheAndAssert(string wellSectionType, CancellationToken token = default)
|
private async Task<WellSectionType> GetWellSectionTypeFromCacheAndAssertAsync(string wellSectionType, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(wellSectionType))
|
if (string.IsNullOrEmpty(wellSectionType))
|
||||||
throw new ArgumentException("Тип секции должен быть указан", nameof(WellSectionDto.SectionType));
|
throw new ArgumentException("Тип секции должен быть указан", nameof(WellSectionDto.SectionType));
|
||||||
|
@ -34,7 +34,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
wells = await db.GetWellsForCompany(idCompany)
|
wells = await db.GetWellsForCompany(idCompany)
|
||||||
.Where(w => activeTelemetriesUids.Contains(w.Telemetry.RemoteUid))
|
.Where(w => activeTelemetriesUids.Contains(w.Telemetry.RemoteUid))
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.ToListAsync(token);
|
.ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
return wells.Select(w => From(w));
|
return wells.Select(w => From(w));
|
||||||
}
|
}
|
||||||
@ -47,13 +48,14 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public async Task<bool> IsCompanyInvolvedInWellAsync(int idCompany, int idWell, CancellationToken token)
|
public async Task<bool> IsCompanyInvolvedInWellAsync(int idCompany, int idWell, CancellationToken token)
|
||||||
=> await cacheRelationCompaniesWells.ContainsAsync(r => r.IdWell == idWell &&
|
=> await cacheRelationCompaniesWells.ContainsAsync(r => r.IdWell == idWell &&
|
||||||
r.IdCompany == idCompany, token);
|
r.IdCompany == idCompany, token).ConfigureAwait(false);
|
||||||
|
|
||||||
public async Task<IEnumerable<WellOperationDto>> GetOperationsAsync(int idWell, CancellationToken token)
|
public async Task<IEnumerable<WellOperationDto>> GetOperationsAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
var entities = await db.WellOperations.Where(o => o.IdWell == idWell)
|
var entities = await db.WellOperations.Where(o => o.IdWell == idWell)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.ToListAsync(token);
|
.ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var dtos = entities.Adapt<WellOperationDto>();
|
var dtos = entities.Adapt<WellOperationDto>();
|
||||||
|
|
||||||
|
@ -44,10 +44,12 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, idWell, token))
|
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
return Forbid();
|
idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
var analytics = await analyticsService.GetOperationsByWellAsync(idWell, categoryIds, begin, end, skip, take, token);
|
var analytics = await analyticsService.GetOperationsByWellAsync(idWell, categoryIds, begin, end, skip, take, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (analytics is null || analytics.Count == 0)
|
if (analytics is null || analytics.Count == 0)
|
||||||
return NoContent();
|
return NoContent();
|
||||||
@ -69,10 +71,12 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, idWell, token))
|
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
return Forbid();
|
idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
var wellDepthToDayData = await analyticsService.GetWellDepthToDayAsync(idWell, token);
|
var wellDepthToDayData = await analyticsService.GetWellDepthToDayAsync(idWell, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (wellDepthToDayData is null || !wellDepthToDayData.Any())
|
if (wellDepthToDayData is null || !wellDepthToDayData.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
@ -97,11 +101,11 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
idWell, token))
|
idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var wellDepthToIntervalData = await analyticsService.GetWellDepthToIntervalAsync(idWell,
|
var wellDepthToIntervalData = await analyticsService.GetWellDepthToIntervalAsync(idWell,
|
||||||
intervalSeconds, workBeginSeconds, token);
|
intervalSeconds, workBeginSeconds, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (wellDepthToIntervalData is null || !wellDepthToIntervalData.Any())
|
if (wellDepthToIntervalData is null || !wellDepthToIntervalData.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
@ -125,10 +129,12 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, idWell, token))
|
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
return Forbid();
|
idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
var analytics = await analyticsService .GetOperationsSummaryAsync(idWell, begin, end, token);
|
var analytics = await analyticsService .GetOperationsSummaryAsync(idWell,
|
||||||
|
begin, end, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (analytics is null || !analytics.Any())
|
if (analytics is null || !analytics.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
@ -152,11 +158,12 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync ((int)idCompany, idWell, token))
|
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync ((int)idCompany,
|
||||||
return Forbid();
|
idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
var analytics = await analyticsService.GetOperationsToIntervalAsync(idWell,
|
var analytics = await analyticsService.GetOperationsToIntervalAsync(idWell,
|
||||||
intervalSeconds, workBeginSeconds, token);
|
intervalSeconds, workBeginSeconds, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (analytics is null || !analytics.Any())
|
if (analytics is null || !analytics.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
@ -32,7 +32,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[ProducesResponseType(typeof(UserTokenDto), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(UserTokenDto), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> LoginAsync([FromBody] AuthDto auth, CancellationToken token = default)
|
public async Task<IActionResult> LoginAsync([FromBody] AuthDto auth, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var userToken = await authService.LoginAsync(auth.Login, auth.Password, token);
|
var userToken = await authService.LoginAsync(auth.Login,
|
||||||
|
auth.Password, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (userToken is null)
|
if (userToken is null)
|
||||||
BadRequest();//"wrong login or password"
|
BadRequest();//"wrong login or password"
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await clusterService.GetClustersAsync((int)idCompany, token);
|
var result = await clusterService.GetClustersAsync((int)idCompany,
|
||||||
|
token).ConfigureAwait(false);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +57,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await clusterService.GetWellsAsync((int)idCompany, idCluster, token);
|
var result = await clusterService.GetWellsAsync((int)idCompany,
|
||||||
|
idCluster, token).ConfigureAwait(false);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +77,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await clusterService.GetStatAsync((int)idCompany, idCluster, token);
|
var result = await clusterService.GetStatAsync((int)idCompany,
|
||||||
|
idCluster, token).ConfigureAwait(false);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (begin == default)
|
if (begin == default)
|
||||||
begin = DateTime.Now.AddSeconds(-intervalSec);
|
begin = DateTime.Now.AddSeconds(-intervalSec);
|
||||||
var content = await telemetryDataService.GetAsync(idWell, begin,
|
var content = await telemetryDataService.GetAsync(idWell, begin,
|
||||||
intervalSec, approxPointsCount, token);
|
intervalSec, approxPointsCount, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (content is null || !content.Any())
|
if (content is null || !content.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
@ -72,13 +72,13 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
idWell, token);
|
idWell, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (!isCompanyOwnsWell)
|
if (!isCompanyOwnsWell)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
DatesRangeDto dataDatesRange = await telemetryDataService.GetDataDatesRangeAsync(idWell,
|
DatesRangeDto dataDatesRange = await telemetryDataService.GetDataDatesRangeAsync(idWell,
|
||||||
token);
|
token).ConfigureAwait(false);
|
||||||
|
|
||||||
return Ok(dataDatesRange);
|
return Ok(dataDatesRange);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await clusterService.GetDepositsAsync((int)idCompany, token);
|
var result = await clusterService.GetDepositsAsync((int)idCompany,
|
||||||
|
token).ConfigureAwait(false);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +58,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await clusterService.GetClustersAsync((int)idCompany, depositId, token);
|
var result = await clusterService.GetClustersAsync((int)idCompany,
|
||||||
|
depositId, token).ConfigureAwait(false);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, idWell, token))
|
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
return Forbid();
|
idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
var fileInfoCollection = files.Select(f =>
|
var fileInfoCollection = files.Select(f =>
|
||||||
(f.FileName, idWell, idCategory, DateTime.Now, idUser));
|
(f.FileName, idWell, idCategory, DateTime.Now, idUser));
|
||||||
@ -92,11 +93,11 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
idWell, token))
|
idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var filesInfo = await fileService.GetFilesInfoAsync(idWell, idCategory,
|
var filesInfo = await fileService.GetFilesInfoAsync(idWell, idCategory,
|
||||||
begin, end, skip, take, token);
|
begin, end, skip, take, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (filesInfo is null || !filesInfo.Items.Any())
|
if (filesInfo is null || !filesInfo.Items.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
@ -124,10 +125,11 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, idWell, token))
|
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
return Forbid();
|
idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
var fileInfo = fileService.GetFileInfo(fileId);
|
var fileInfo = await fileService.GetFileInfoAsync(fileId, token);
|
||||||
|
|
||||||
if (fileInfo is null)
|
if (fileInfo is null)
|
||||||
throw new FileNotFoundException();
|
throw new FileNotFoundException();
|
||||||
|
@ -25,10 +25,12 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, idWell, token))
|
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
return Forbid();
|
idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
var result = await lastDataService.GetAsync(idWell, idCategory, token);
|
var result = await lastDataService.GetAsync(idWell,
|
||||||
|
idCategory, token).ConfigureAwait(false);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,10 +40,12 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, idWell, token))
|
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
return Forbid();
|
idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
await lastDataService.UpsertAsync(idWell, idCategory, data, token);
|
await lastDataService.UpsertAsync(idWell,
|
||||||
|
idCategory, data, token).ConfigureAwait(false);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
|
|
||||||
var result = await messageService.GetMessagesAsync(idWell,
|
var result = await messageService.GetMessagesAsync(idWell,
|
||||||
categoryids, begin, end, searchString,
|
categoryids, begin, end, searchString,
|
||||||
skip, take, token);
|
skip, take, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (result is null || result.Count == 0)
|
if (result is null || result.Count == 0)
|
||||||
return NoContent();
|
return NoContent();
|
||||||
@ -76,7 +76,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
idWell, token);
|
idWell, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (!isCompanyOwnsWell)
|
if (!isCompanyOwnsWell)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
@ -39,7 +39,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
reportsHubContext.Clients.Group($"Report_{id}").SendAsync(
|
reportsHubContext.Clients.Group($"Report_{id}").SendAsync(
|
||||||
nameof(IReportHubClient.GetReportProgress),
|
nameof(IReportHubClient.GetReportProgress),
|
||||||
new { Progress = progress, Operation = operation, ReportName = "" }
|
new { Progress = progress, Operation = operation, ReportName = "" }
|
||||||
);
|
).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
private void HandleReportNameAsync(string reportName, int groupId) =>
|
private void HandleReportNameAsync(string reportName, int groupId) =>
|
||||||
@ -48,7 +48,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
reportsHubContext.Clients.All.SendAsync(
|
reportsHubContext.Clients.All.SendAsync(
|
||||||
nameof(IReportHubClient.GetReportProgress),
|
nameof(IReportHubClient.GetReportProgress),
|
||||||
new { Progress = 100, Operation = "Отчет успешно создан", ReportName = reportName }
|
new { Progress = 100, Operation = "Отчет успешно создан", ReportName = reportName }
|
||||||
);
|
).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -75,8 +75,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, idWell, token))
|
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
return Forbid();
|
idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
var id = reportService.CreateReport(idWell, idUser,
|
var id = reportService.CreateReport(idWell, idUser,
|
||||||
stepSeconds, format, begin, end, HandleReportProgressAsync, HandleReportNameAsync);
|
stepSeconds, format, begin, end, HandleReportProgressAsync, HandleReportNameAsync);
|
||||||
@ -104,8 +105,10 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, idWell, token))
|
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
return Forbid();
|
idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
// TODO: словарь content typoв
|
// TODO: словарь content typoв
|
||||||
var relativePath = Path.Combine(fileService.RootPath, $"{idWell}",
|
var relativePath = Path.Combine(fileService.RootPath, $"{idWell}",
|
||||||
$"{reportService.ReportCategoryId}", reportName);
|
$"{reportService.ReportCategoryId}", reportName);
|
||||||
@ -136,7 +139,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var suitableReportsNames = await reportService.GetSuitableReportsAsync(idWell,
|
var suitableReportsNames = await reportService.GetSuitableReportsAsync(idWell,
|
||||||
begin, end, stepSeconds, format, token);
|
begin, end, stepSeconds, format, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (suitableReportsNames is null || !suitableReportsNames.Any())
|
if (suitableReportsNames is null || !suitableReportsNames.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
@ -166,8 +169,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, idWell, token))
|
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
return Forbid();
|
idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
int reportSize = reportService.GetReportPagesCount(idWell,
|
int reportSize = reportService.GetReportPagesCount(idWell,
|
||||||
begin, end, stepSeconds, format);
|
begin, end, stepSeconds, format);
|
||||||
@ -192,11 +196,12 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, idWell, token))
|
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
return Forbid();
|
idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
DatesRangeDto wellReportsDatesRange = await reportService.GetReportsDatesRangeAsync(idWell,
|
DatesRangeDto wellReportsDatesRange = await reportService.GetReportsDatesRangeAsync(idWell,
|
||||||
token);
|
token).ConfigureAwait(false);
|
||||||
|
|
||||||
return Ok(wellReportsDatesRange);
|
return Ok(wellReportsDatesRange);
|
||||||
}
|
}
|
||||||
|
@ -71,10 +71,11 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var idWell = telemetryService.GetidWellByTelemetryUid(uid);
|
var idWell = telemetryService.GetidWellByTelemetryUid(uid);
|
||||||
await DataService.UpdateDataAsync(uid, dtos, token);
|
await DataService.UpdateDataAsync(uid, dtos, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (idWell != null && dtos.Any())
|
if (idWell != null && dtos.Any())
|
||||||
await Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}").SendAsync(nameof(ITelemetryHubClient.ReceiveDataSaub), dtos), token);
|
await Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}")
|
||||||
|
.SendAsync(nameof(ITelemetryHubClient.ReceiveDataSaub), dtos), token).ConfigureAwait(false);
|
||||||
|
|
||||||
telemetryTracker.SaveRequestDate(uid);
|
telemetryTracker.SaveRequestDate(uid);
|
||||||
return Ok();
|
return Ok();
|
||||||
@ -93,10 +94,11 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var idWell = telemetryService.GetidWellByTelemetryUid(uid);
|
var idWell = telemetryService.GetidWellByTelemetryUid(uid);
|
||||||
await messageService.InsertAsync(uid, dtos, token);
|
await messageService.InsertAsync(uid, dtos, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (dtos.Any())
|
if (dtos.Any())
|
||||||
await Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}").SendAsync(nameof(ITelemetryHubClient.ReceiveMessages), dtos), token);
|
await Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}")
|
||||||
|
.SendAsync(nameof(ITelemetryHubClient.ReceiveMessages), dtos), token).ConfigureAwait(false);
|
||||||
|
|
||||||
telemetryTracker.SaveRequestDate(uid);
|
telemetryTracker.SaveRequestDate(uid);
|
||||||
return Ok();
|
return Ok();
|
||||||
@ -114,7 +116,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
public async Task<IActionResult> PostEventsAsync(string uid, [FromBody] List<EventDto> events,
|
public async Task<IActionResult> PostEventsAsync(string uid, [FromBody] List<EventDto> events,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
await eventService.UpsertAsync(uid, events, token);
|
await eventService.UpsertAsync(uid, events, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
telemetryTracker.SaveRequestDate(uid);
|
telemetryTracker.SaveRequestDate(uid);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
var wells = await wellService.GetWellsByCompanyAsync((int)idCompany, token);
|
var wells = await wellService.GetWellsByCompanyAsync((int)idCompany,
|
||||||
|
token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (wells is null || !wells.Any())
|
if (wells is null || !wells.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
@ -49,10 +50,12 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, idWell, token))
|
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
return Forbid();
|
idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
var dto = await wellService.GetOperationsAsync(idWell, token);
|
var dto = await wellService.GetOperationsAsync(idWell,
|
||||||
|
token).ConfigureAwait(false);
|
||||||
|
|
||||||
return Ok(dto);
|
return Ok(dto);
|
||||||
}
|
}
|
||||||
@ -66,7 +69,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
var transmittingWells = await wellService.GetTransmittingWellsAsync((int)idCompany, token);
|
var transmittingWells = await wellService.GetTransmittingWellsAsync((int)idCompany,
|
||||||
|
token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (transmittingWells is null || !transmittingWells.Any())
|
if (transmittingWells is null || !transmittingWells.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
@ -26,7 +26,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
public async Task<IActionResult> GetAllAsync(int idWell, int skip = 0, int take = 32,
|
public async Task<IActionResult> GetAllAsync(int idWell, int skip = 0, int take = 32,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if(!await CanUserAccessToWellAsync(idWell, token))
|
if(!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await sectionsService.GetAllByWellIdAsync(idWell, skip, take, token).ConfigureAwait(false);
|
var result = await sectionsService.GetAllByWellIdAsync(idWell, skip, take, token).ConfigureAwait(false);
|
||||||
@ -38,7 +38,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
public async Task<IActionResult> GetAsync(int idSection, int idWell,
|
public async Task<IActionResult> GetAsync(int idSection, int idWell,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell, token))
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await sectionsService.GetAsync(idSection, token).ConfigureAwait(false);
|
var result = await sectionsService.GetAsync(idSection, token).ConfigureAwait(false);
|
||||||
@ -49,7 +49,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
public async Task<IActionResult> InsertAsync(int idWell, [FromBody] IEnumerable<WellSectionDto> values,
|
public async Task<IActionResult> InsertAsync(int idWell, [FromBody] IEnumerable<WellSectionDto> values,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell, token))
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await sectionsService.InsertRangeAsync(values, idWell, token).ConfigureAwait(false);
|
var result = await sectionsService.InsertRangeAsync(values, idWell, token).ConfigureAwait(false);
|
||||||
@ -59,7 +59,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
public async Task<IActionResult> PutAsync(int id, int idWell, [FromBody] WellSectionDto value, CancellationToken token = default)
|
public async Task<IActionResult> PutAsync(int id, int idWell, [FromBody] WellSectionDto value, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell, token))
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await sectionsService.UpdateAsync(value, id, idWell, token).ConfigureAwait(false);
|
var result = await sectionsService.UpdateAsync(value, id, idWell, token).ConfigureAwait(false);
|
||||||
@ -69,8 +69,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
public async Task<IActionResult> DeleteAsync(int id, int idWell, CancellationToken token = default)
|
public async Task<IActionResult> DeleteAsync(int id, int idWell, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell, token))
|
if (!await CanUserAccessToWellAsync(idWell,
|
||||||
return Forbid();
|
token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
var result = await sectionsService.DeleteAsync(new int[] { id }, token).ConfigureAwait(false);
|
var result = await sectionsService.DeleteAsync(new int[] { id }, token).ConfigureAwait(false);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
@ -79,7 +80,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default)
|
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, idWell, token);
|
return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
|
idWell, token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user