wellId rename to idWell

This commit is contained in:
Фролов 2021-07-27 14:43:30 +05:00
parent 8e62cb4748
commit 16e52cacf5
29 changed files with 245 additions and 205 deletions

View File

@ -7,7 +7,7 @@ namespace AsbCloudApp.Data
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string FullName { get; set; } public string FullName { get; set; }
public int WellId { get; set; } public int idWell { get; set; }
public DateTime Date { get; set; } public DateTime Date { get; set; }
public DateTimeOffset Begin { get; set; } public DateTimeOffset Begin { get; set; }
public DateTimeOffset End { get; set; } public DateTimeOffset End { get; set; }

View File

@ -7,15 +7,15 @@ namespace AsbCloudApp.Services
{ {
public interface IAnalyticsService public interface IAnalyticsService
{ {
PaginationContainer<TelemetryOperationDto> GetOperationsByWell(int wellId, PaginationContainer<TelemetryOperationDto> GetOperationsByWell(int idWell,
IEnumerable<int> categoryids = default, DateTime begin = default, IEnumerable<int> categoryids = default, DateTime begin = default,
DateTime end = default, int skip = 0, int take = 32); DateTime end = default, int skip = 0, int take = 32);
IEnumerable<WellDepthToDayDto> GetWellDepthToDay(int wellId); IEnumerable<WellDepthToDayDto> GetWellDepthToDay(int idWell);
IEnumerable<WellDepthToIntervalDto> GetWellDepthToInterval(int wellId, IEnumerable<WellDepthToIntervalDto> GetWellDepthToInterval(int idWell,
int intervalHoursTimestamp, int workBeginTimestamp); int intervalHoursTimestamp, int workBeginTimestamp);
IEnumerable<TelemetryOperationDurationDto> GetOperationsSummary(int wellId, IEnumerable<TelemetryOperationDurationDto> GetOperationsSummary(int idWell,
DateTime begin = default, DateTime end = default); DateTime begin = default, DateTime end = default);
IEnumerable<TelemetryOperationInfoDto> GetOperationsToInterval(int wellId, IEnumerable<TelemetryOperationInfoDto> GetOperationsToInterval(int idWell,
int intervalHoursTimestamp, int workBeginTimestamp); int intervalHoursTimestamp, int workBeginTimestamp);
void SaveAnalytics(DataSaubBase dataSaub); void SaveAnalytics(DataSaubBase dataSaub);
} }

View File

@ -6,9 +6,9 @@ namespace AsbCloudApp.Services
{ {
public interface IDataService public interface IDataService
{ {
IEnumerable<DataSaubBaseDto> Get(int wellId, DateTime dateBegin = default, double intervalSec = 600d, int approxPointsCount = 1024); IEnumerable<DataSaubBaseDto> Get(int idWell, DateTime dateBegin = default, double intervalSec = 600d, int approxPointsCount = 1024);
void UpdateData(string uid, IEnumerable<DataSaubBaseDto> dtos); void UpdateData(string uid, IEnumerable<DataSaubBaseDto> dtos);
DatesRangeDto GetDataDatesRange(int wellId); DatesRangeDto GetDataDatesRange(int idWell);
} }
} }

View File

@ -7,11 +7,11 @@ namespace AsbCloudApp.Services
public interface IFileService public interface IFileService
{ {
string RootPath { get; } string RootPath { get; }
IDictionary<string, int> SaveFilesPropertiesToDb(int wellId, IDictionary<string, int> SaveFilesPropertiesToDb(int idWell,
int idCategory, IEnumerable<(string fileName, int idWell, int idCategory, int idCategory, IEnumerable<(string fileName, int idWell, int idCategory,
DateTime date, int idUser)> filesInfo); DateTime date, int idUser)> filesInfo);
PaginationContainer<FilePropertiesDto> GetFilesInfo(int wellId, PaginationContainer<FilePropertiesDto> GetFilesInfo(int idWell,
int idCategory, DateTime begin, DateTime end, int idCategory, DateTime begin, DateTime end,
int skip, int take); int skip, int take);

View File

@ -6,8 +6,8 @@ namespace AsbCloudApp.Services
{ {
public interface IMessageService public interface IMessageService
{ {
PaginationContainer<MessageDto> GetMessages(int wellId, IEnumerable<int> categoryids = null, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32); PaginationContainer<MessageDto> GetMessages(int idWell, IEnumerable<int> categoryids = null, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32);
DatesRangeDto GetMessagesDatesRange(int wellId); DatesRangeDto GetMessagesDatesRange(int idWell);
void Insert(string uid, IEnumerable<TelemetryMessageDto> dtos); void Insert(string uid, IEnumerable<TelemetryMessageDto> dtos);
} }
} }

View File

@ -7,10 +7,10 @@ namespace AsbCloudApp.Services
public interface IReportService public interface IReportService
{ {
string RootPath { get; } string RootPath { get; }
int CreateReport(int wellId, int stepSeconds, int format, DateTime begin, DateTime end, int CreateReport(int idWell, int stepSeconds, int format, DateTime begin, DateTime end,
Action<float, string, int> handleReportProgress, Action<string, int> handleReportName); Action<float, string, int> handleReportProgress, Action<string, int> handleReportName);
int GetReportPagesCount(int wellId, DateTime begin, DateTime end, int stepSeconds, int format); int GetReportPagesCount(int idWell, DateTime begin, DateTime end, int stepSeconds, int format);
IEnumerable<ReportPropertiesDto> GetSuitableReports(int wellId, DateTime begin, DateTime end, int stepSeconds, int format); IEnumerable<ReportPropertiesDto> GetSuitableReports(int idWell, DateTime begin, DateTime end, int stepSeconds, int format);
DatesRangeDto GetReportsDatesRange(int wellId); DatesRangeDto GetReportsDatesRange(int idWell);
} }
} }

View File

@ -5,10 +5,10 @@ namespace AsbCloudApp.Services
{ {
public interface ITelemetryService public interface ITelemetryService
{ {
int? GetWellIdByTelemetryUid(string uid); int? GetidWellByTelemetryUid(string uid);
int GetOrCreateTemetryIdByUid(string uid); int GetOrCreateTemetryIdByUid(string uid);
double GetTimezoneOffsetByTelemetryId(int idTelemetry); double GetTimezoneOffsetByTelemetryId(int idTelemetry);
void UpdateInfo(string uid, TelemetryInfoDto info); void UpdateInfo(string uid, TelemetryInfoDto info);
Telemetry GetTelemetryByWellId(int wellId); Telemetry GetTelemetryByidWell(int idWell);
} }
} }

View File

@ -7,8 +7,8 @@ namespace AsbCloudApp.Services
{ {
IEnumerable<WellDto> GetWellsByCompany(int idCompany); IEnumerable<WellDto> GetWellsByCompany(int idCompany);
IEnumerable<WellDto> GetTransmittingWells(int idCompany); IEnumerable<WellDto> GetTransmittingWells(int idCompany);
bool IsCompanyOwnsWell(int idCompany, int wellId); bool IsCompanyOwnsWell(int idCompany, int idWell);
IEnumerable<WellSectionDto> GetSections(int wellId); IEnumerable<WellSectionDto> GetSections(int idWell);
object GetOperations(int wellId); IEnumerable<WellOperationDto> GetOperations(int idWell);
} }
} }

View File

@ -12,24 +12,24 @@ namespace AsbCloudDb.Model
//Scaffold-DbContext "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True" Npgsql.EntityFrameworkCore.PostgreSQL -OutputDir Model -DataAnnotations //Scaffold-DbContext "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True" Npgsql.EntityFrameworkCore.PostgreSQL -OutputDir Model -DataAnnotations
public partial class AsbCloudDbContext : DbContext, IAsbCloudDbContext public partial class AsbCloudDbContext : DbContext, IAsbCloudDbContext
{ {
//private readonly string connectionString;
public virtual DbSet<Cluster> Clusters { get; set; } public virtual DbSet<Cluster> Clusters { get; set; }
public virtual DbSet<Company> Companies { get; set; } public virtual DbSet<Company> Companies { get; set; }
public virtual DbSet<DataSaubBase> DataSaubBases { get; set; } public virtual DbSet<DataSaubBase> DataSaubBases { get; set; }
public virtual DbSet<Deposit> Deposits { get; set; } public virtual DbSet<Deposit> Deposits { get; set; }
public virtual DbSet<Event> Events { get; set; } public virtual DbSet<Event> Events { get; set; }
public virtual DbSet<Message> Messages { get; set; } public virtual DbSet<Message> Messages { get; set; }
public virtual DbSet<Telemetry> Telemetries { get; set; }
public virtual DbSet<TelemetryUser> TelemetryUsers { get; set; }
public virtual DbSet<User> Users { get; set; } public virtual DbSet<User> Users { get; set; }
public virtual DbSet<UserRole> UserRoles { get; set; } public virtual DbSet<UserRole> UserRoles { get; set; }
public virtual DbSet<Well> Wells { get; set; }
public virtual DbSet<Report> Reports { get; set; } public virtual DbSet<Report> Reports { get; set; }
public virtual DbSet<File> Files { get; set; } public virtual DbSet<File> Files { get; set; }
public virtual DbSet<FileCategory> FileCategories { get; set; } public virtual DbSet<FileCategory> FileCategories { get; set; }
public virtual DbSet<Telemetry> Telemetries { get; set; }
public virtual DbSet<TelemetryUser> TelemetryUsers { get; set; }
public virtual DbSet<TelemetryOperation> Operations { get; set; } public virtual DbSet<TelemetryOperation> Operations { get; set; }
public virtual DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; } public virtual DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
public virtual DbSet<WellSection> SectionAnalysis { get; set; } public virtual DbSet<Well> Wells { get; set; }
public virtual DbSet<WellSection> WellSections { get; set; }
public virtual DbSet<WellOperation> WellOperations { get; set; }
public virtual DbSet<WellType> WellTypes { get; set; } public virtual DbSet<WellType> WellTypes { get; set; }
//public AsbCloudDbContext(string connectionString = "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True") //public AsbCloudDbContext(string connectionString = "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")

View File

@ -15,16 +15,19 @@ namespace AsbCloudDb.Model
DbSet<Deposit> Deposits { get; set; } DbSet<Deposit> Deposits { get; set; }
DbSet<Event> Events { get; set; } DbSet<Event> Events { get; set; }
DbSet<Message> Messages { get; set; } DbSet<Message> Messages { get; set; }
DbSet<Telemetry> Telemetries { get; set; }
DbSet<TelemetryUser> TelemetryUsers { get; set; }
DbSet<User> Users { get; set; } DbSet<User> Users { get; set; }
DbSet<Well> Wells { get; set; }
DbSet<UserRole> UserRoles { get; set; } DbSet<UserRole> UserRoles { get; set; }
DbSet<Report> Reports { get; set; } DbSet<Report> Reports { get; set; }
DbSet<File> Files { get; set; } DbSet<File> Files { get; set; }
DbSet<FileCategory> FileCategories { get; set; } DbSet<FileCategory> FileCategories { get; set; }
DbSet<Telemetry> Telemetries { get; set; }
DbSet<TelemetryUser> TelemetryUsers { get; set; }
DbSet<TelemetryOperation> Operations { get; set; } DbSet<TelemetryOperation> Operations { get; set; }
DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; } DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
DbSet<Well> Wells { get; set; }
DbSet<WellSection> WellSections { get; set; }
DbSet<WellOperation> WellOperations { get; set; }
DbSet<WellType> WellTypes { get; set; }
int SaveChanges(); int SaveChanges();
int SaveChanges(bool acceptAllChangesOnSuccess); int SaveChanges(bool acceptAllChangesOnSuccess);

View File

@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
#nullable disable
namespace AsbCloudDb.Model
{
[Table("t_well_operation"), Comment("Операции по скважине")]
public class WellOperation
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("id_well")]
public int IdWell { get; set; }
[Column("caption")]
public string Caption { get; set; }
[Column("description")]
public string Description { get; set; }
[Column("casing_section")]
public double CasingSection { get; set; }
[Column("well_depth")]
public double WellDepth { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdWell))]
public virtual Well Well { get; set; }
}
}

View File

@ -23,7 +23,7 @@ namespace AsbSaubReport
{3, "Информация"}, {3, "Информация"},
}; };
public ReportDataSourcePgCloud(AsbCloudDbContext context, int wellId) public ReportDataSourcePgCloud(AsbCloudDbContext context, int idWell)
{ {
this.context = context; this.context = context;
var well = context.Wells var well = context.Wells
@ -32,11 +32,11 @@ namespace AsbSaubReport
.Include(w => w.RelationCompaniesWells) .Include(w => w.RelationCompaniesWells)
.ThenInclude(r => r.Company) .ThenInclude(r => r.Company)
.Include(w => w.Telemetry) .Include(w => w.Telemetry)
.FirstOrDefault(w => w.Id == wellId); .FirstOrDefault(w => w.Id == idWell);
idTelemetry = well?.IdTelemetry; idTelemetry = well?.IdTelemetry;
if (idTelemetry is null) if (idTelemetry is null)
throw new ArgumentException($"Well {wellId} doesn't contain telemetry", nameof(wellId)); throw new ArgumentException($"Well {idWell} doesn't contain telemetry", nameof(idWell));
events = context.Events events = context.Events
.Where(e => e.IdTelemetry == idTelemetry) .Where(e => e.IdTelemetry == idTelemetry)

View File

@ -29,9 +29,9 @@ namespace AsbCloudInfrastructure.Services
operationDetectorService = new TelemetryOperationDetectorService(operations); operationDetectorService = new TelemetryOperationDetectorService(operations);
} }
public IEnumerable<WellDepthToDayDto> GetWellDepthToDay(int wellId) public IEnumerable<WellDepthToDayDto> GetWellDepthToDay(int idWell)
{ {
var telemetry = telemetryService.GetTelemetryByWellId(wellId); var telemetry = telemetryService.GetTelemetryByidWell(idWell);
if (telemetry is null) if (telemetry is null)
return null; return null;
@ -59,12 +59,12 @@ namespace AsbCloudInfrastructure.Services
}).ToList(); }).ToList();
} }
public IEnumerable<WellDepthToIntervalDto> GetWellDepthToInterval(int wellId, public IEnumerable<WellDepthToIntervalDto> GetWellDepthToInterval(int idWell,
int intervalSeconds, int workBeginSeconds) int intervalSeconds, int workBeginSeconds)
{ {
intervalSeconds = intervalSeconds == 0 ? 86400 : intervalSeconds; intervalSeconds = intervalSeconds == 0 ? 86400 : intervalSeconds;
var telemetry = telemetryService.GetTelemetryByWellId(wellId); var telemetry = telemetryService.GetTelemetryByidWell(idWell);
if (telemetry is null) if (telemetry is null)
return null; return null;
@ -83,11 +83,11 @@ namespace AsbCloudInfrastructure.Services
return wellDepthToIntervalData; return wellDepthToIntervalData;
} }
public PaginationContainer<TelemetryOperationDto> GetOperationsByWell(int wellId, public PaginationContainer<TelemetryOperationDto> GetOperationsByWell(int idWell,
IEnumerable<int> categoryIds = default, DateTime begin = default, IEnumerable<int> categoryIds = default, DateTime begin = default,
DateTime end = default, int skip = 0, int take = 32) DateTime end = default, int skip = 0, int take = 32)
{ {
var telemetry = telemetryService.GetTelemetryByWellId(wellId); var telemetry = telemetryService.GetTelemetryByidWell(idWell);
if (telemetry is null) if (telemetry is null)
return null; return null;
@ -147,10 +147,10 @@ namespace AsbCloudInfrastructure.Services
return result; return result;
} }
public IEnumerable<TelemetryOperationDurationDto> GetOperationsSummary(int wellId, public IEnumerable<TelemetryOperationDurationDto> GetOperationsSummary(int idWell,
DateTime begin = default, DateTime end = default) DateTime begin = default, DateTime end = default)
{ {
var telemetry = telemetryService.GetTelemetryByWellId(wellId); var telemetry = telemetryService.GetTelemetryByidWell(idWell);
if (telemetry is null) if (telemetry is null)
return null; return null;
@ -173,12 +173,12 @@ namespace AsbCloudInfrastructure.Services
return operations; return operations;
} }
public IEnumerable<TelemetryOperationInfoDto> GetOperationsToInterval(int wellId, public IEnumerable<TelemetryOperationInfoDto> GetOperationsToInterval(int idWell,
int intervalSeconds, int workBeginSeconds) int intervalSeconds, int workBeginSeconds)
{ {
intervalSeconds = intervalSeconds == 0 ? 86400 : intervalSeconds; intervalSeconds = intervalSeconds == 0 ? 86400 : intervalSeconds;
var telemetry = telemetryService.GetTelemetryByWellId(wellId); var telemetry = telemetryService.GetTelemetryByidWell(idWell);
if (telemetry is null) if (telemetry is null)
return null; return null;

View File

@ -30,9 +30,9 @@ namespace AsbCloudInfrastructure.Services
cacheWells = cacheDb.GetCachedTable<Well>((AsbCloudDbContext)db); cacheWells = cacheDb.GetCachedTable<Well>((AsbCloudDbContext)db);
} }
public IEnumerable<DataSaubBaseDto> Get(int wellId, DateTime dateBegin = default, double intervalSec = 600d, int approxPointsCount = 1024) public IEnumerable<DataSaubBaseDto> Get(int idWell, DateTime dateBegin = default, double intervalSec = 600d, int approxPointsCount = 1024)
{ {
var well = cacheWells.FirstOrDefault(w => w.Id == wellId); var well = cacheWells.FirstOrDefault(w => w.Id == idWell);
if (well is null) if (well is null)
return default; return default;
@ -103,9 +103,9 @@ namespace AsbCloudInfrastructure.Services
db.SaveChanges(); db.SaveChanges();
} }
public DatesRangeDto GetDataDatesRange(int wellId) public DatesRangeDto GetDataDatesRange(int idWell)
{ {
var telemetry = telemetryService.GetTelemetryByWellId(wellId); var telemetry = telemetryService.GetTelemetryByidWell(idWell);
if (telemetry is null) if (telemetry is null)
return null; return null;

View File

@ -21,7 +21,7 @@ namespace AsbCloudInfrastructure.Services
this.telemetryService = telemetryService; this.telemetryService = telemetryService;
} }
public IDictionary<string, int> SaveFilesPropertiesToDb(int wellId, int idCategory, public IDictionary<string, int> SaveFilesPropertiesToDb(int idWell, int idCategory,
IEnumerable<(string fileName, int idWell, int idCategory, DateTime date, int idUser)> filesInfo) IEnumerable<(string fileName, int idWell, int idCategory, DateTime date, int idUser)> filesInfo)
{ {
var fileIdsToNames = new Dictionary<string, int>(); var fileIdsToNames = new Dictionary<string, int>();
@ -45,16 +45,16 @@ namespace AsbCloudInfrastructure.Services
return fileIdsToNames; return fileIdsToNames;
} }
public PaginationContainer<FilePropertiesDto> GetFilesInfo(int wellId, public PaginationContainer<FilePropertiesDto> GetFilesInfo(int idWell,
int idCategory, DateTime begin = default, DateTime end = default, int idCategory, DateTime begin = default, DateTime end = default,
int skip = 0, int take = 32) int skip = 0, int take = 32)
{ {
var telemetry = telemetryService.GetTelemetryByWellId(wellId); var telemetry = telemetryService.GetTelemetryByidWell(idWell);
if (telemetry is null) if (telemetry is null)
return null; return null;
var filesInfoQuery = db.Files.Include(f => f.User) var filesInfoQuery = db.Files.Include(f => f.User)
.Where(f => f.IdWell == wellId && .Where(f => f.IdWell == idWell &&
f.IdCategory == idCategory); f.IdCategory == idCategory);
if (!filesInfoQuery.Any()) if (!filesInfoQuery.Any())

View File

@ -27,9 +27,9 @@ namespace AsbCloudInfrastructure.Services
cacheTUsers = cacheDb.GetCachedTable<TelemetryUser>((AsbCloudDbContext)db); cacheTUsers = cacheDb.GetCachedTable<TelemetryUser>((AsbCloudDbContext)db);
} }
public PaginationContainer<MessageDto> GetMessages(int wellId, IEnumerable<int> categoryids = default, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32) public PaginationContainer<MessageDto> GetMessages(int idWell, IEnumerable<int> categoryids = default, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32)
{ {
var telemetry = telemetryService.GetTelemetryByWellId(wellId); var telemetry = telemetryService.GetTelemetryByidWell(idWell);
if (telemetry is null) if (telemetry is null)
return null; return null;
@ -98,9 +98,9 @@ namespace AsbCloudInfrastructure.Services
return result; return result;
} }
public DatesRangeDto GetMessagesDatesRange(int wellId) public DatesRangeDto GetMessagesDatesRange(int idWell)
{ {
var telemetry = telemetryService.GetTelemetryByWellId(wellId); var telemetry = telemetryService.GetTelemetryByidWell(idWell);
if (telemetry is null) if (telemetry is null)
return null; return null;

View File

@ -30,7 +30,7 @@ namespace AsbCloudInfrastructure.Services
public string RootPath { get; private set; } public string RootPath { get; private set; }
public int CreateReport(int wellId, int stepSeconds, int format, DateTime begin, public int CreateReport(int idWell, int stepSeconds, int format, DateTime begin,
DateTime end, Action<float, string, int> progressHandler, Action<string, int> reportNameHandler) DateTime end, Action<float, string, int> progressHandler, Action<string, int> reportNameHandler)
{ {
var newReportId = queue.EnqueueTask((id) => var newReportId = queue.EnqueueTask((id) =>
@ -40,7 +40,7 @@ namespace AsbCloudInfrastructure.Services
using (var context = new AsbCloudDbContext(optionsBuilder.Options)) using (var context = new AsbCloudDbContext(optionsBuilder.Options))
{ {
var generator = GetReportGenerator(wellId, begin, end, stepSeconds, format, context); var generator = GetReportGenerator(idWell, begin, end, stepSeconds, format, context);
generator.OnProgress += (s, e) => progressHandler.Invoke(e.progress, e.operation, id); generator.OnProgress += (s, e) => progressHandler.Invoke(e.progress, e.operation, id);
var newReportName = generator.Make(); var newReportName = generator.Make();
if (newReportName is not null) if (newReportName is not null)
@ -51,7 +51,7 @@ namespace AsbCloudInfrastructure.Services
var newReportProperties = new Report var newReportProperties = new Report
{ {
Name = newReportName, Name = newReportName,
IdWell = wellId, IdWell = idWell,
Date = DateTime.Now, Date = DateTime.Now,
Begin = begin, Begin = begin,
End = end, End = end,
@ -66,23 +66,23 @@ namespace AsbCloudInfrastructure.Services
return newReportId; return newReportId;
} }
public int GetReportPagesCount(int wellId, DateTime begin, DateTime end, int stepSeconds, int format) public int GetReportPagesCount(int idWell, DateTime begin, DateTime end, int stepSeconds, int format)
{ {
var generator = GetReportGenerator(wellId, begin, end, stepSeconds, format, (AsbCloudDbContext)db); var generator = GetReportGenerator(idWell, begin, end, stepSeconds, format, (AsbCloudDbContext)db);
return generator.GetPagesCount(); return generator.GetPagesCount();
} }
public IEnumerable<ReportPropertiesDto> GetSuitableReports(int wellId, DateTime begin, DateTime end, int stepSeconds, int format) public IEnumerable<ReportPropertiesDto> GetSuitableReports(int idWell, DateTime begin, DateTime end, int stepSeconds, int format)
{ {
var suitableReportsFromDb = GetSuitableReportsFromDb(wellId, begin, end, stepSeconds, format); var suitableReportsFromDb = GetSuitableReportsFromDb(idWell, begin, end, stepSeconds, format);
var suitableReportsProperties = suitableReportsFromDb.Select(r => new ReportPropertiesDto var suitableReportsProperties = suitableReportsFromDb.Select(r => new ReportPropertiesDto
{ {
Id = r.Id, Id = r.Id,
Name = Path.GetFileName(r.Name), Name = Path.GetFileName(r.Name),
FullName = r.Name, FullName = r.Name,
WellId = r.IdWell, idWell = r.IdWell,
Date = r.Date, Date = r.Date,
Begin = r.Begin, Begin = r.Begin,
End = r.End, End = r.End,
@ -93,9 +93,9 @@ namespace AsbCloudInfrastructure.Services
return suitableReportsProperties; return suitableReportsProperties;
} }
public DatesRangeDto GetReportsDatesRange(int wellId) public DatesRangeDto GetReportsDatesRange(int idWell)
{ {
var telemetry = telemetryService.GetTelemetryByWellId(wellId); var telemetry = telemetryService.GetTelemetryByidWell(idWell);
if (telemetry is null) if (telemetry is null)
return null; return null;
@ -119,10 +119,10 @@ namespace AsbCloudInfrastructure.Services
}; };
} }
private IEnumerable<Report> GetSuitableReportsFromDb(int wellId, DateTime begin, DateTime end, int stepSeconds, int format) private IEnumerable<Report> GetSuitableReportsFromDb(int idWell, DateTime begin, DateTime end, int stepSeconds, int format)
{ {
var suitableReportsNames = (from r in db.Reports var suitableReportsNames = (from r in db.Reports
where r.IdWell == wellId where r.IdWell == idWell
&& r.Begin >= begin && r.Begin >= begin
&& r.End <= end && r.End <= end
&& r.Step <= stepSeconds && r.Step <= stepSeconds
@ -132,9 +132,9 @@ namespace AsbCloudInfrastructure.Services
return suitableReportsNames; return suitableReportsNames;
} }
private IReportGenerator GetReportGenerator(int wellId, DateTime begin, DateTime end, int stepSeconds, int format, AsbCloudDbContext context) private IReportGenerator GetReportGenerator(int idWell, DateTime begin, DateTime end, int stepSeconds, int format, AsbCloudDbContext context)
{ {
var dataSource = new ReportDataSourcePgCloud(context, wellId); var dataSource = new ReportDataSourcePgCloud(context, idWell);
IReportGenerator generator; IReportGenerator generator;
switch (format) switch (format)
@ -148,7 +148,7 @@ namespace AsbCloudInfrastructure.Services
break; break;
} }
generator.ReportDirectory = Path.Combine(RootPath, $"{wellId}"); generator.ReportDirectory = Path.Combine(RootPath, $"{idWell}");
generator.Begin = begin; generator.Begin = begin;
generator.End = end; generator.End = end;
generator.Step = TimeSpan.FromSeconds(stepSeconds); generator.Step = TimeSpan.FromSeconds(stepSeconds);

View File

@ -22,7 +22,7 @@ namespace AsbCloudInfrastructure.Services
public int GetOrCreateTemetryIdByUid(string uid) public int GetOrCreateTemetryIdByUid(string uid)
=> GetOrCreateTelemetryByUid(uid).Id; => GetOrCreateTelemetryByUid(uid).Id;
public int? GetWellIdByTelemetryUid(string uid) public int? GetidWellByTelemetryUid(string uid)
=> GetWellByTelemetryUid(uid)?.Id; => GetWellByTelemetryUid(uid)?.Id;
public double GetTimezoneOffsetByTelemetryId(int idTelemetry) => public double GetTimezoneOffsetByTelemetryId(int idTelemetry) =>
@ -35,9 +35,9 @@ namespace AsbCloudInfrastructure.Services
cacheTelemetry.Upsert(telemetry); cacheTelemetry.Upsert(telemetry);
} }
public Telemetry GetTelemetryByWellId(int wellId) public Telemetry GetTelemetryByidWell(int idWell)
{ {
var well = cacheWells.FirstOrDefault(w => w.Id == wellId); var well = cacheWells.FirstOrDefault(w => w.Id == idWell);
if (well is null) if (well is null)
return null; return null;

View File

@ -43,6 +43,19 @@ namespace AsbCloudInfrastructure.Services
public bool IsCompanyOwnsWell(int idCompany, int idWell) public bool IsCompanyOwnsWell(int idCompany, int idWell)
=> cacheRelationCompaniesWells.Contains(r => r.IdWell == idWell && r.IdCompany == idCompany); => cacheRelationCompaniesWells.Contains(r => r.IdWell == idWell && r.IdCompany == idCompany);
public IEnumerable<WellSectionDto> GetSections(int idWell)
{
var query = from s in db.WellSections
where s.IdWell ==
return ;
}
public IEnumerable<WellOperationDto> GetOperations(int idWell)
{
throw new NotImplementedException();
}
private static WellDto From(Well well) private static WellDto From(Well well)
{ {
var wellDto = new WellDto var wellDto = new WellDto
@ -55,15 +68,5 @@ namespace AsbCloudInfrastructure.Services
return wellDto; return wellDto;
} }
public IEnumerable<WellSectionDto> GetSections(int wellId)
{
return null;
}
public object GetOperations(int wellId)
{
throw new NotImplementedException();
}
} }
} }

View File

@ -25,7 +25,7 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Возвращает список операций на скважине за все время /// Возвращает список операций на скважине за все время
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="categoryIds">список категорий</param> /// <param name="categoryIds">список категорий</param>
/// <param name="begin">дата начала</param> /// <param name="begin">дата начала</param>
/// <param name="end">окончание</param> /// <param name="end">окончание</param>
@ -33,17 +33,17 @@ namespace AsbCloudWebApi.Controllers
/// <param name="take">для пагинации кол-во записей </param> /// <param name="take">для пагинации кол-во записей </param>
/// <returns>Список операций на скважине за все время</returns> /// <returns>Список операций на скважине за все время</returns>
[HttpGet] [HttpGet]
[Route("{wellId}/operationsByWell")] [Route("{idWell}/operationsByWell")]
[ProducesResponseType(typeof(PaginationContainer<TelemetryOperationDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(PaginationContainer<TelemetryOperationDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetOperationsByWell(int wellId, int skip = 0, int take = 32, public IActionResult GetOperationsByWell(int idWell, int skip = 0, int take = 32,
[FromQuery] IEnumerable<int> categoryIds = default, DateTime begin = default, DateTime end = default) [FromQuery] IEnumerable<int> categoryIds = default, DateTime begin = default, DateTime end = default)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
var analytics = analyticsService.GetOperationsByWell(wellId, categoryIds, begin, end, skip, take); var analytics = analyticsService.GetOperationsByWell(idWell, categoryIds, begin, end, skip, take);
if (analytics is null || analytics.Count == 0) if (analytics is null || analytics.Count == 0)
return NoContent(); return NoContent();
@ -54,19 +54,19 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Возвращает данные по скважине "глубина-день" /// Возвращает данные по скважине "глубина-день"
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <returns>Коллекцию данных по скважине "глубина-день"</returns> /// <returns>Коллекцию данных по скважине "глубина-день"</returns>
[HttpGet] [HttpGet]
[Route("{wellId}/wellDepthToDay")] [Route("{idWell}/wellDepthToDay")]
[ProducesResponseType(typeof(IEnumerable<WellDepthToDayDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<WellDepthToDayDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetWellDepthToDay(int wellId) public IActionResult GetWellDepthToDay(int idWell)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
var wellDepthToDayData = analyticsService.GetWellDepthToDay(wellId); var wellDepthToDayData = analyticsService.GetWellDepthToDay(idWell);
if (wellDepthToDayData is null || !wellDepthToDayData.Any()) if (wellDepthToDayData is null || !wellDepthToDayData.Any())
return NoContent(); return NoContent();
@ -77,22 +77,22 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Возвращает данные по глубине скважины за период /// Возвращает данные по глубине скважины за период
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="intervalSeconds">количество секунд в необходимом интервале времени</param> /// <param name="intervalSeconds">количество секунд в необходимом интервале времени</param>
/// <param name="workBeginSeconds">количество секунд в времени начала смены</param> /// <param name="workBeginSeconds">количество секунд в времени начала смены</param>
/// <returns>Коллекцию данных по глубине скважины за период</returns> /// <returns>Коллекцию данных по глубине скважины за период</returns>
[HttpGet] [HttpGet]
[Route("{wellId}/wellDepthToInterval")] [Route("{idWell}/wellDepthToInterval")]
[ProducesResponseType(typeof(IEnumerable<WellDepthToIntervalDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<WellDepthToIntervalDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetWellDepthToInterval(int wellId, public IActionResult GetWellDepthToInterval(int idWell,
int intervalSeconds, int workBeginSeconds) int intervalSeconds, int workBeginSeconds)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
var wellDepthToIntervalData = analyticsService.GetWellDepthToInterval(wellId, var wellDepthToIntervalData = analyticsService.GetWellDepthToInterval(idWell,
intervalSeconds, workBeginSeconds); intervalSeconds, workBeginSeconds);
if (wellDepthToIntervalData is null || !wellDepthToIntervalData.Any()) if (wellDepthToIntervalData is null || !wellDepthToIntervalData.Any())
@ -104,21 +104,21 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Возвращает данные по операциям на скважине "операции-время" /// Возвращает данные по операциям на скважине "операции-время"
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="begin">дата начала интервала</param> /// <param name="begin">дата начала интервала</param>
/// <param name="end">дата окончания интервала</param> /// <param name="end">дата окончания интервала</param>
/// <returns>Коллекцию операций на скважине</returns> /// <returns>Коллекцию операций на скважине</returns>
[HttpGet] [HttpGet]
[Route("{wellId}/operationsSummary")] [Route("{idWell}/operationsSummary")]
[ProducesResponseType(typeof(IEnumerable<TelemetryOperationDurationDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<TelemetryOperationDurationDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetOperationsSummary(int wellId, DateTime begin = default, DateTime end = default) public IActionResult GetOperationsSummary(int idWell, DateTime begin = default, DateTime end = default)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
var analytics = analyticsService.GetOperationsSummary(wellId, begin, end); var analytics = analyticsService.GetOperationsSummary(idWell, begin, end);
if (analytics is null || !analytics.Any()) if (analytics is null || !analytics.Any())
return NoContent(); return NoContent();
@ -129,22 +129,22 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Возвращает детальные данные по операциям на скважине за период /// Возвращает детальные данные по операциям на скважине за период
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="intervalSeconds">количество секунд в необходимом интервале времени</param> /// <param name="intervalSeconds">количество секунд в необходимом интервале времени</param>
/// <param name="workBeginSeconds">количество секунд в времени начала смены</param> /// <param name="workBeginSeconds">количество секунд в времени начала смены</param>
/// <returns>Коллекцию операций на скважине</returns> /// <returns>Коллекцию операций на скважине</returns>
[HttpGet] [HttpGet]
[Route("{wellId}/operationsToInterval")] [Route("{idWell}/operationsToInterval")]
[ProducesResponseType(typeof(IEnumerable<TelemetryOperationDurationDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<TelemetryOperationDurationDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetOperationsToInterval(int wellId, public IActionResult GetOperationsToInterval(int idWell,
int intervalSeconds, int workBeginSeconds) int intervalSeconds, int workBeginSeconds)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
var analytics = analyticsService.GetOperationsToInterval(wellId, intervalSeconds, workBeginSeconds); var analytics = analyticsService.GetOperationsToInterval(idWell, intervalSeconds, workBeginSeconds);
if (analytics is null || !analytics.Any()) if (analytics is null || !analytics.Any())
return NoContent(); return NoContent();

View File

@ -29,19 +29,19 @@ namespace AsbCloudWebApi.Controllers
/// Возвращает данные САУБ по скважине. /// Возвращает данные САУБ по скважине.
/// По умолчанию за последние 10 минут. /// По умолчанию за последние 10 минут.
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="begin">дата начала выборки. По умолчанию: текущее время - intervalSec</param> /// <param name="begin">дата начала выборки. По умолчанию: текущее время - intervalSec</param>
/// <param name="intervalSec">интервал времени даты начала выборки, секунды</param> /// <param name="intervalSec">интервал времени даты начала выборки, секунды</param>
/// <param name="approxPointsCount">желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена.</param> /// <param name="approxPointsCount">желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена.</param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
[Route("{wellId}/data")] [Route("{idWell}/data")]
[ProducesResponseType(typeof(IEnumerable<DataSaubBaseDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<DataSaubBaseDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetData(int wellId, DateTime begin = default, int intervalSec = 600, int approxPointsCount = 1024) public IActionResult GetData(int idWell, DateTime begin = default, int intervalSec = 600, int approxPointsCount = 1024)
{ {
if (begin == default) if (begin == default)
begin = DateTime.Now.AddSeconds(-intervalSec); begin = DateTime.Now.AddSeconds(-intervalSec);
var content = telemetryDataService.Get(wellId, begin, intervalSec, approxPointsCount); var content = telemetryDataService.Get(idWell, begin, intervalSec, approxPointsCount);
if (content is null || !content.Any()) if (content is null || !content.Any())
return NoContent(); return NoContent();
@ -50,21 +50,21 @@ namespace AsbCloudWebApi.Controllers
} }
[HttpGet] [HttpGet]
[Route("{wellId}/dataDatesRange")] [Route("{idWell}/dataDatesRange")]
[ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetDataDatesRange(int wellId) public IActionResult GetDataDatesRange(int idWell)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
if (idCompany is null) if (idCompany is null)
return Forbid(); return Forbid();
bool isCompanyOwnsWell = wellService.IsCompanyOwnsWell((int)idCompany, wellId); bool isCompanyOwnsWell = wellService.IsCompanyOwnsWell((int)idCompany, idWell);
if (!isCompanyOwnsWell) if (!isCompanyOwnsWell)
return Forbid(); return Forbid();
DatesRangeDto dataDatesRange = telemetryDataService.GetDataDatesRange(wellId); DatesRangeDto dataDatesRange = telemetryDataService.GetDataDatesRange(idWell);
return Ok(dataDatesRange); return Ok(dataDatesRange);
} }

View File

@ -26,15 +26,15 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Сохраняет переданные файлы и информацию о них /// Сохраняет переданные файлы и информацию о них
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="idCategory">id категории файла</param> /// <param name="idCategory">id категории файла</param>
/// <param name="idUser">id отправившего файл пользователя</param> /// <param name="idUser">id отправившего файл пользователя</param>
/// <param name="files">Коллекция файлов</param> /// <param name="files">Коллекция файлов</param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("{wellId}/files")] [Route("{idWell}/files")]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public IActionResult SaveFiles(int wellId, int idCategory, int idUser, public IActionResult SaveFiles(int idWell, int idCategory, int idUser,
[FromForm] IFormFileCollection files) [FromForm] IFormFileCollection files)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
@ -42,13 +42,13 @@ namespace AsbCloudWebApi.Controllers
if (idCompany is null) if (idCompany is null)
return Forbid(); return Forbid();
if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (!wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
var fileInfoCollection = files.Select(f => var fileInfoCollection = files.Select(f =>
(f.FileName, wellId, idCategory, DateTime.Now, idUser)); (f.FileName, idWell, idCategory, DateTime.Now, idUser));
var fileNamesAndIds = fileService.SaveFilesPropertiesToDb(wellId, var fileNamesAndIds = fileService.SaveFilesPropertiesToDb(idWell,
idCategory, fileInfoCollection); idCategory, fileInfoCollection);
foreach (var file in files) foreach (var file in files)
@ -57,7 +57,7 @@ namespace AsbCloudWebApi.Controllers
var fileId = fileNamesAndIds[file.FileName]; var fileId = fileNamesAndIds[file.FileName];
var relativePath = Path.Combine(fileService.RootPath, $"{wellId}", var relativePath = Path.Combine(fileService.RootPath, $"{idWell}",
$"{idCategory}", $"{fileId}" + $"{fileExtension}"); $"{idCategory}", $"{fileId}" + $"{fileExtension}");
Directory.CreateDirectory(Path.GetDirectoryName(relativePath)); Directory.CreateDirectory(Path.GetDirectoryName(relativePath));
@ -71,7 +71,7 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Возвращает информацию о файлах для скважины в выбраной категории /// Возвращает информацию о файлах для скважины в выбраной категории
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="idCategory">id категории файла</param> /// <param name="idCategory">id категории файла</param>
/// <param name="begin">дата начала</param> /// <param name="begin">дата начала</param>
/// <param name="end">дата окончания</param> /// <param name="end">дата окончания</param>
@ -79,18 +79,18 @@ namespace AsbCloudWebApi.Controllers
/// <param name="take">для пагинации кол-во записей взять </param> /// <param name="take">для пагинации кол-во записей взять </param>
/// <returns>Список информации о файлах в этой категории</returns> /// <returns>Список информации о файлах в этой категории</returns>
[HttpGet] [HttpGet]
[Route("{wellId}")] [Route("{idWell}")]
[ProducesResponseType(typeof(PaginationContainer<FilePropertiesDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(PaginationContainer<FilePropertiesDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetFilesInfo([FromRoute] int wellId, public IActionResult GetFilesInfo([FromRoute] int idWell,
int skip = 0, int take = 32, int idCategory = default, int skip = 0, int take = 32, int idCategory = default,
DateTime begin = default, DateTime end = default) DateTime begin = default, DateTime end = default)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
var filesInfo = fileService.GetFilesInfo(wellId, idCategory, var filesInfo = fileService.GetFilesInfo(idWell, idCategory,
begin, end, skip, take); begin, end, skip, take);
if (filesInfo is null || !filesInfo.Items.Any()) if (filesInfo is null || !filesInfo.Items.Any())
@ -102,13 +102,13 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Возвращает файл с диска на сервере /// Возвращает файл с диска на сервере
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="fileId">id запрашиваемого файла</param> /// <param name="fileId">id запрашиваемого файла</param>
/// <returns>Запрашиваемый файл</returns> /// <returns>Запрашиваемый файл</returns>
[HttpGet] [HttpGet]
[Route("{wellId}/{fileId}")] [Route("{idWell}/{fileId}")]
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetFile([FromRoute] int wellId, int fileId) public IActionResult GetFile([FromRoute] int idWell, int fileId)
{ {
try try
{ {
@ -117,7 +117,7 @@ namespace AsbCloudWebApi.Controllers
if (idCompany is null) if (idCompany is null)
return Forbid(); return Forbid();
if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (!wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
var fileInfo = fileService.GetFileInfo(fileId); var fileInfo = fileService.GetFileInfo(fileId);
@ -126,7 +126,7 @@ namespace AsbCloudWebApi.Controllers
throw new FileNotFoundException(); throw new FileNotFoundException();
// TODO: словарь content typoв // TODO: словарь content typoв
var relativePath = Path.Combine(fileService.RootPath, $"{wellId}", $"{fileInfo.Value.IdCategory}", var relativePath = Path.Combine(fileService.RootPath, $"{idWell}", $"{fileInfo.Value.IdCategory}",
$"{fileInfo.Value.Id}" + Path.GetExtension($"{fileInfo.Value.Name}")); $"{fileInfo.Value.Id}" + Path.GetExtension($"{fileInfo.Value.Name}"));
return PhysicalFile(Path.GetFullPath(relativePath), "application/octet-stream", fileInfo.Value.Name); return PhysicalFile(Path.GetFullPath(relativePath), "application/octet-stream", fileInfo.Value.Name);
} }

View File

@ -22,7 +22,7 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Выдает список сообщений по скважине /// Выдает список сообщений по скважине
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="categoryids">список категорий</param> /// <param name="categoryids">список категорий</param>
/// <param name="begin">дата начала</param> /// <param name="begin">дата начала</param>
/// <param name="end">окончание</param> /// <param name="end">окончание</param>
@ -30,9 +30,9 @@ namespace AsbCloudWebApi.Controllers
/// <param name="take">для пагинации кол-во записей </param> /// <param name="take">для пагинации кол-во записей </param>
/// <returns>список сообщений по скважине</returns> /// <returns>список сообщений по скважине</returns>
[HttpGet] [HttpGet]
[Route("{wellId}/message")] [Route("{idWell}/message")]
[ProducesResponseType(typeof(PaginationContainer<MessageDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(PaginationContainer<MessageDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetMessage(int wellId, int skip = 0, int take = 32, [FromQuery] IEnumerable<int> categoryids = default, DateTime begin = default, DateTime end = default) public IActionResult GetMessage(int idWell, int skip = 0, int take = 32, [FromQuery] IEnumerable<int> categoryids = default, DateTime begin = default, DateTime end = default)
{ {
if (take > 1024) if (take > 1024)
return BadRequest("limit mast be less then 1024"); return BadRequest("limit mast be less then 1024");
@ -40,7 +40,7 @@ namespace AsbCloudWebApi.Controllers
if (begin > DateTime.Now) if (begin > DateTime.Now)
begin = default; begin = default;
var result = messageService.GetMessages(wellId, categoryids, begin, end, skip, take); var result = messageService.GetMessages(idWell, categoryids, begin, end, skip, take);
if (result is null || result.Count == 0) if (result is null || result.Count == 0)
return NoContent(); return NoContent();
@ -49,21 +49,21 @@ namespace AsbCloudWebApi.Controllers
} }
[HttpGet] [HttpGet]
[Route("{wellId}/messagesDatesRange")] [Route("{idWell}/messagesDatesRange")]
[ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetMessagesDateRange(int wellId) public IActionResult GetMessagesDateRange(int idWell)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
if (idCompany is null) if (idCompany is null)
return Forbid(); return Forbid();
bool isCompanyOwnsWell = wellService.IsCompanyOwnsWell((int)idCompany, wellId); bool isCompanyOwnsWell = wellService.IsCompanyOwnsWell((int)idCompany, idWell);
if (!isCompanyOwnsWell) if (!isCompanyOwnsWell)
return Forbid(); return Forbid();
DatesRangeDto wellMessagesDatesRange = messageService.GetMessagesDatesRange(wellId); DatesRangeDto wellMessagesDatesRange = messageService.GetMessagesDatesRange(idWell);
return Ok(wellMessagesDatesRange); return Ok(wellMessagesDatesRange);
} }

View File

@ -51,16 +51,16 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Создает отчет по скважине с указанными параметрами /// Создает отчет по скважине с указанными параметрами
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="stepSeconds">шаг интервала</param> /// <param name="stepSeconds">шаг интервала</param>
/// <param name="format">формат отчета (0-PDF, 1-LAS)</param> /// <param name="format">формат отчета (0-PDF, 1-LAS)</param>
/// <param name="begin">дата начала интервала</param> /// <param name="begin">дата начала интервала</param>
/// <param name="end">дата окончания интервала</param> /// <param name="end">дата окончания интервала</param>
/// <returns>id фоновой задачи формирования отчета</returns> /// <returns>id фоновой задачи формирования отчета</returns>
[HttpPost] [HttpPost]
[Route("{wellId}/report")] [Route("{idWell}/report")]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public IActionResult CreateReport(int wellId, int stepSeconds, int format, public IActionResult CreateReport(int idWell, int stepSeconds, int format,
DateTime begin = default, DateTime end = default) DateTime begin = default, DateTime end = default)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
@ -68,10 +68,10 @@ namespace AsbCloudWebApi.Controllers
if (idCompany is null) if (idCompany is null)
return Forbid(); return Forbid();
if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (!wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
var id = reportService.CreateReport(wellId, stepSeconds, format, begin, end, HandleReportProgressAsync, HandleReportNameAsync); var id = reportService.CreateReport(idWell, stepSeconds, format, begin, end, HandleReportProgressAsync, HandleReportNameAsync);
return Ok(id); return Ok(id);
} }
@ -79,13 +79,13 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Возвращает файл-отчет с диска на сервере /// Возвращает файл-отчет с диска на сервере
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="reportName">имя запрашиваемого файла (отчета)</param> /// <param name="reportName">имя запрашиваемого файла (отчета)</param>
/// <returns>файл с отчетом</returns> /// <returns>файл с отчетом</returns>
[HttpGet] [HttpGet]
[Route("{wellId}/{reportName}")] [Route("{idWell}/{reportName}")]
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetReport([FromRoute] int wellId, string reportName) public IActionResult GetReport([FromRoute] int idWell, string reportName)
{ {
try try
{ {
@ -94,10 +94,10 @@ namespace AsbCloudWebApi.Controllers
if (idCompany is null) if (idCompany is null)
return Forbid(); return Forbid();
if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (!wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
// TODO: словарь content typoв // TODO: словарь content typoв
var relativePath = Path.Combine(reportService.RootPath, $"{wellId}", reportName); var relativePath = Path.Combine(reportService.RootPath, $"{idWell}", reportName);
return PhysicalFile(Path.GetFullPath(relativePath), "application/pdf", reportName); return PhysicalFile(Path.GetFullPath(relativePath), "application/pdf", reportName);
} }
catch (FileNotFoundException ex) catch (FileNotFoundException ex)
@ -110,19 +110,19 @@ namespace AsbCloudWebApi.Controllers
/// Возвращает имена отчетов, хранящихся на диске, /// Возвращает имена отчетов, хранящихся на диске,
/// которые подходят под указанные параметры /// которые подходят под указанные параметры
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="stepSeconds">шаг интервала</param> /// <param name="stepSeconds">шаг интервала</param>
/// <param name="format">формат отчета (0-PDF, 1-LAS)</param> /// <param name="format">формат отчета (0-PDF, 1-LAS)</param>
/// <param name="begin">дата начала интервала</param> /// <param name="begin">дата начала интервала</param>
/// <param name="end">дата окончания интервала</param> /// <param name="end">дата окончания интервала</param>
/// <returns>Список имен существующих отчетов (отчетов)</returns> /// <returns>Список имен существующих отчетов (отчетов)</returns>
[HttpGet] [HttpGet]
[Route("{wellId}/suitableReports")] [Route("{idWell}/suitableReports")]
[ProducesResponseType(typeof(IEnumerable<string>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<string>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetSuitableReportsNames(int wellId, int stepSeconds, int format, public IActionResult GetSuitableReportsNames(int idWell, int stepSeconds, int format,
DateTime begin = default, DateTime end = default) DateTime begin = default, DateTime end = default)
{ {
var suitableReportsNames = reportService.GetSuitableReports(wellId, begin, end, stepSeconds, format); var suitableReportsNames = reportService.GetSuitableReports(idWell, begin, end, stepSeconds, format);
if (suitableReportsNames is null || !suitableReportsNames.Any()) if (suitableReportsNames is null || !suitableReportsNames.Any())
return NoContent(); return NoContent();
@ -133,26 +133,26 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Возвращает прогнозируемое количество страниц будущего отчета /// Возвращает прогнозируемое количество страниц будущего отчета
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="begin">дата начала интервала</param> /// <param name="begin">дата начала интервала</param>
/// <param name="end">дата окончания интервала</param> /// <param name="end">дата окончания интервала</param>
/// <param name="stepSeconds">шаг интервала</param> /// <param name="stepSeconds">шаг интервала</param>
/// <param name="format">формат отчета (0-PDF, 1-LAS)</param> /// <param name="format">формат отчета (0-PDF, 1-LAS)</param>
/// <returns>прогнозируемое кол-во страниц отчета</returns> /// <returns>прогнозируемое кол-во страниц отчета</returns>
[HttpGet] [HttpGet]
[Route("{wellId}/reportSize")] [Route("{idWell}/reportSize")]
[ProducesResponseType(typeof(string), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(string), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetReportSize(int wellId, int stepSeconds, int format, DateTime begin = default, DateTime end = default) public IActionResult GetReportSize(int idWell, int stepSeconds, int format, DateTime begin = default, DateTime end = default)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
if (idCompany is null) if (idCompany is null)
return Forbid(); return Forbid();
if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (!wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
int reportSize = reportService.GetReportPagesCount(wellId, begin, end, stepSeconds, format); int reportSize = reportService.GetReportPagesCount(idWell, begin, end, stepSeconds, format);
return Ok(reportSize); return Ok(reportSize);
} }
@ -160,22 +160,22 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Возвращает даты самого старого и самого свежего отчетов в БД /// Возвращает даты самого старого и самого свежего отчетов в БД
/// </summary> /// </summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <returns>Даты самого старого и самого свежего отчетов в БД</returns> /// <returns>Даты самого старого и самого свежего отчетов в БД</returns>
[HttpGet] [HttpGet]
[Route("{wellId}/reportsDatesRange")] [Route("{idWell}/reportsDatesRange")]
[ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetReportsDateRange(int wellId) public IActionResult GetReportsDateRange(int idWell)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
if (idCompany is null) if (idCompany is null)
return Forbid(); return Forbid();
if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (!wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
DatesRangeDto wellReportsDatesRange = reportService.GetReportsDatesRange(wellId); DatesRangeDto wellReportsDatesRange = reportService.GetReportsDatesRange(idWell);
return Ok(wellReportsDatesRange); return Ok(wellReportsDatesRange);
} }

View File

@ -67,11 +67,11 @@ namespace AsbCloudWebApi.Controllers
[Route("{uid}/data")] [Route("{uid}/data")]
public IActionResult PostData(string uid, [FromBody] IEnumerable<DataSaubBaseDto> dtos) public IActionResult PostData(string uid, [FromBody] IEnumerable<DataSaubBaseDto> dtos)
{ {
var wellId = telemetryService.GetWellIdByTelemetryUid(uid); var idWell = telemetryService.GetidWellByTelemetryUid(uid);
DataService.UpdateData(uid, dtos); DataService.UpdateData(uid, dtos);
if (wellId != null && dtos.Any()) if (idWell != null && dtos.Any())
Task.Run(() => telemetryHubContext.Clients.Group($"well_{wellId}").SendAsync(nameof(ITelemetryHubClient.ReceiveDataSaub), dtos)); Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}").SendAsync(nameof(ITelemetryHubClient.ReceiveDataSaub), dtos));
telemetryTracker.SaveRequestDate(uid); telemetryTracker.SaveRequestDate(uid);
return Ok(); return Ok();
@ -87,11 +87,11 @@ namespace AsbCloudWebApi.Controllers
[Route("{uid}/message")] [Route("{uid}/message")]
public IActionResult PostMessages(string uid, [FromBody] IEnumerable<TelemetryMessageDto> dtos) public IActionResult PostMessages(string uid, [FromBody] IEnumerable<TelemetryMessageDto> dtos)
{ {
var wellId = telemetryService.GetWellIdByTelemetryUid(uid); var idWell = telemetryService.GetidWellByTelemetryUid(uid);
messageService.Insert(uid, dtos); messageService.Insert(uid, dtos);
if (dtos.Any()) if (dtos.Any())
Task.Run(() => telemetryHubContext.Clients.Group($"well_{wellId}").SendAsync(nameof(ITelemetryHubClient.ReceiveMessages), dtos)); Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}").SendAsync(nameof(ITelemetryHubClient.ReceiveMessages), dtos));
telemetryTracker.SaveRequestDate(uid); telemetryTracker.SaveRequestDate(uid);
return Ok(); return Ok();

View File

@ -38,36 +38,36 @@ namespace AsbCloudWebApi.Controllers
return Ok(wells); return Ok(wells);
} }
[HttpGet("{wellId}/sections")] [HttpGet("{idWell}/sections")]
[ProducesResponseType(typeof(IEnumerable<WellSectionDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<WellSectionDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetSections(int wellId) public IActionResult GetSections(int idWell)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
if (idCompany is null) if (idCompany is null)
return NoContent(); return NoContent();
if (wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
var dto = wellService.GetSections(wellId); var dto = wellService.GetSections(idWell);
return Ok(dto); return Ok(dto);
} }
[HttpGet("{wellId}/operations")] [HttpGet("{idWell}/operations")]
[ProducesResponseType(typeof(IEnumerable<WellSectionDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<WellOperationDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetOperations(int wellId) public IActionResult GetOperations(int idWell)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
if (idCompany is null) if (idCompany is null)
return NoContent(); return NoContent();
if (wellService.IsCompanyOwnsWell((int)idCompany, wellId)) if (wellService.IsCompanyOwnsWell((int)idCompany, idWell))
return Forbid(); return Forbid();
var dto = wellService.GetOperations(wellId); var dto = wellService.GetOperations(idWell);
return Ok(dto); return Ok(dto);
} }
@ -79,9 +79,7 @@ namespace AsbCloudWebApi.Controllers
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
if (idCompany is null) if (idCompany is null)
{
return NoContent(); return NoContent();
}
var transmittingWells = wellService.GetTransmittingWells((int)idCompany); var transmittingWells = wellService.GetTransmittingWells((int)idCompany);

View File

@ -345,34 +345,34 @@ namespace ConsoleApp1.OpenAPIService
partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response);
/// <summary>Возвращает данные САУБ по скважине. /// <summary>Возвращает данные САУБ по скважине.
/// По умолчанию за последние 10 минут.</summary> /// По умолчанию за последние 10 минут.</summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="begin">дата начала выборки. По умолчанию: текущее время - intervalSec</param> /// <param name="begin">дата начала выборки. По умолчанию: текущее время - intervalSec</param>
/// <param name="intervalSec">интервал времени даты начала выборки, секунды</param> /// <param name="intervalSec">интервал времени даты начала выборки, секунды</param>
/// <param name="approxPointsCount">желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена.</param> /// <param name="approxPointsCount">желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена.</param>
/// <returns>Success</returns> /// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception> /// <exception cref="ApiException">A server side error occurred.</exception>
public System.Threading.Tasks.Task<System.Collections.Generic.ICollection<DataSaubBaseDto>> DataAsync(int wellId, System.DateTimeOffset? begin, int? intervalSec, int? approxPointsCount) public System.Threading.Tasks.Task<System.Collections.Generic.ICollection<DataSaubBaseDto>> DataAsync(int idWell, System.DateTimeOffset? begin, int? intervalSec, int? approxPointsCount)
{ {
return DataAsync(wellId, begin, intervalSec, approxPointsCount, System.Threading.CancellationToken.None); return DataAsync(idWell, begin, intervalSec, approxPointsCount, System.Threading.CancellationToken.None);
} }
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <summary>Возвращает данные САУБ по скважине. /// <summary>Возвращает данные САУБ по скважине.
/// По умолчанию за последние 10 минут.</summary> /// По умолчанию за последние 10 минут.</summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="begin">дата начала выборки. По умолчанию: текущее время - intervalSec</param> /// <param name="begin">дата начала выборки. По умолчанию: текущее время - intervalSec</param>
/// <param name="intervalSec">интервал времени даты начала выборки, секунды</param> /// <param name="intervalSec">интервал времени даты начала выборки, секунды</param>
/// <param name="approxPointsCount">желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена.</param> /// <param name="approxPointsCount">желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена.</param>
/// <returns>Success</returns> /// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception> /// <exception cref="ApiException">A server side error occurred.</exception>
public async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<DataSaubBaseDto>> DataAsync(int wellId, System.DateTimeOffset? begin, int? intervalSec, int? approxPointsCount, System.Threading.CancellationToken cancellationToken) public async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<DataSaubBaseDto>> DataAsync(int idWell, System.DateTimeOffset? begin, int? intervalSec, int? approxPointsCount, System.Threading.CancellationToken cancellationToken)
{ {
if (wellId == null) if (idWell == null)
throw new System.ArgumentNullException("wellId"); throw new System.ArgumentNullException("idWell");
var urlBuilder_ = new System.Text.StringBuilder(); var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/well/{wellId}/data?"); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/well/{idWell}/data?");
urlBuilder_.Replace("{wellId}", System.Uri.EscapeDataString(ConvertToString(wellId, System.Globalization.CultureInfo.InvariantCulture))); urlBuilder_.Replace("{idWell}", System.Uri.EscapeDataString(ConvertToString(idWell, System.Globalization.CultureInfo.InvariantCulture)));
if (begin != null) if (begin != null)
{ {
urlBuilder_.Append(System.Uri.EscapeDataString("begin") + "=").Append(System.Uri.EscapeDataString(begin.Value.ToString("s", System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Append(System.Uri.EscapeDataString("begin") + "=").Append(System.Uri.EscapeDataString(begin.Value.ToString("s", System.Globalization.CultureInfo.InvariantCulture))).Append("&");
@ -447,7 +447,7 @@ namespace ConsoleApp1.OpenAPIService
} }
/// <summary>Выдает список сообщений по скважине</summary> /// <summary>Выдает список сообщений по скважине</summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="skip">для пагинации кол-во записей пропустить</param> /// <param name="skip">для пагинации кол-во записей пропустить</param>
/// <param name="take">для пагинации кол-во записей</param> /// <param name="take">для пагинации кол-во записей</param>
/// <param name="categoryids">список категорий</param> /// <param name="categoryids">список категорий</param>
@ -455,14 +455,14 @@ namespace ConsoleApp1.OpenAPIService
/// <param name="end">окончание</param> /// <param name="end">окончание</param>
/// <returns>Success</returns> /// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception> /// <exception cref="ApiException">A server side error occurred.</exception>
public System.Threading.Tasks.Task<MessageDtoPaginationContainer> MessageAsync(int wellId, int? skip, int? take, System.Collections.Generic.IEnumerable<int> categoryids, System.DateTimeOffset? begin, System.DateTimeOffset? end) public System.Threading.Tasks.Task<MessageDtoPaginationContainer> MessageAsync(int idWell, int? skip, int? take, System.Collections.Generic.IEnumerable<int> categoryids, System.DateTimeOffset? begin, System.DateTimeOffset? end)
{ {
return MessageAsync(wellId, skip, take, categoryids, begin, end, System.Threading.CancellationToken.None); return MessageAsync(idWell, skip, take, categoryids, begin, end, System.Threading.CancellationToken.None);
} }
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <summary>Выдает список сообщений по скважине</summary> /// <summary>Выдает список сообщений по скважине</summary>
/// <param name="wellId">id скважины</param> /// <param name="idWell">id скважины</param>
/// <param name="skip">для пагинации кол-во записей пропустить</param> /// <param name="skip">для пагинации кол-во записей пропустить</param>
/// <param name="take">для пагинации кол-во записей</param> /// <param name="take">для пагинации кол-во записей</param>
/// <param name="categoryids">список категорий</param> /// <param name="categoryids">список категорий</param>
@ -470,14 +470,14 @@ namespace ConsoleApp1.OpenAPIService
/// <param name="end">окончание</param> /// <param name="end">окончание</param>
/// <returns>Success</returns> /// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception> /// <exception cref="ApiException">A server side error occurred.</exception>
public async System.Threading.Tasks.Task<MessageDtoPaginationContainer> MessageAsync(int wellId, int? skip, int? take, System.Collections.Generic.IEnumerable<int> categoryids, System.DateTimeOffset? begin, System.DateTimeOffset? end, System.Threading.CancellationToken cancellationToken) public async System.Threading.Tasks.Task<MessageDtoPaginationContainer> MessageAsync(int idWell, int? skip, int? take, System.Collections.Generic.IEnumerable<int> categoryids, System.DateTimeOffset? begin, System.DateTimeOffset? end, System.Threading.CancellationToken cancellationToken)
{ {
if (wellId == null) if (idWell == null)
throw new System.ArgumentNullException("wellId"); throw new System.ArgumentNullException("idWell");
var urlBuilder_ = new System.Text.StringBuilder(); var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/well/{wellId}/message?"); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/well/{idWell}/message?");
urlBuilder_.Replace("{wellId}", System.Uri.EscapeDataString(ConvertToString(wellId, System.Globalization.CultureInfo.InvariantCulture))); urlBuilder_.Replace("{idWell}", System.Uri.EscapeDataString(ConvertToString(idWell, System.Globalization.CultureInfo.InvariantCulture)));
if (skip != null) if (skip != null)
{ {
urlBuilder_.Append(System.Uri.EscapeDataString("skip") + "=").Append(System.Uri.EscapeDataString(ConvertToString(skip, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Append(System.Uri.EscapeDataString("skip") + "=").Append(System.Uri.EscapeDataString(ConvertToString(skip, System.Globalization.CultureInfo.InvariantCulture))).Append("&");

View File

@ -73,7 +73,7 @@
} }
} }
}, },
"/api/well/{wellId}/data": { "/api/well/{idWell}/data": {
"get": { "get": {
"tags": [ "tags": [
"Data" "Data"
@ -82,7 +82,7 @@
"operationId": "GetData", "operationId": "GetData",
"parameters": [ "parameters": [
{ {
"name": "wellId", "name": "idWell",
"in": "path", "in": "path",
"required": true, "required": true,
"description": "id скважины", "description": "id скважины",
@ -154,7 +154,7 @@
} }
} }
}, },
"/api/well/{wellId}/message": { "/api/well/{idWell}/message": {
"get": { "get": {
"tags": [ "tags": [
"Message" "Message"
@ -163,7 +163,7 @@
"operationId": "GetMessage", "operationId": "GetMessage",
"parameters": [ "parameters": [
{ {
"name": "wellId", "name": "idWell",
"in": "path", "in": "path",
"required": true, "required": true,
"description": "id скважины", "description": "id скважины",

View File

@ -21,11 +21,11 @@ namespace ConsoleApp1
// .Options; // .Options;
//var context = new AsbCloudDbContext(options); //var context = new AsbCloudDbContext(options);
//var wellId = 1; //var idWell = 1;
//var dataSource = new ReportDataSourcePgCloud(context, wellId); //var dataSource = new ReportDataSourcePgCloud(context, idWell);
//var generator = new PdfGenerator(dataSource) //var generator = new PdfGenerator(dataSource)
//{ //{
// ReportDirectory = $"{wellId}", // ReportDirectory = $"{idWell}",
// Begin = DateTime.Now.AddYears(-30), // Begin = DateTime.Now.AddYears(-30),
// End = DateTime.Now.AddYears(30), // End = DateTime.Now.AddYears(30),
// Step = TimeSpan.FromDays(1), // Step = TimeSpan.FromDays(1),