From 3a325f6c94233e8ac50af6256b78966063bed0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Mon, 9 Aug 2021 15:41:42 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=87=D0=B8=D1=81=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B8=20=D0=B0=D0=BD=D0=B0=D0=BB=D0=B8=D0=B7=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudApp/Data/ClusterStatDto.cs | 8 ++----- AsbCloudApp/Data/WellOperationDto.cs | 8 +------ AsbCloudApp/Data/WellSectionDto.cs | 2 +- AsbCloudApp/Services/IAnalyticsService.cs | 4 ++-- AsbCloudApp/Services/IFileService.cs | 6 ++--- AsbCloudApp/Services/IReportService.cs | 8 +++---- AsbCloudApp/Services/ISaubDataCache.cs | 4 ++-- AsbCloudDb/Model/AsbCloudDbContext.cs | 6 +++-- AsbCloudDb/Model/IAsbCloudDbContext.cs | 2 +- AsbCloudDb/Model/RelationCompanyWell.cs | 2 -- AsbCloudDb/Model/User.cs | 4 ++-- AsbCloudInfrastructure/DependencyInjection.cs | 4 ++-- AsbCloudInfrastructure/MapsterExtension.cs | 3 --- .../ReportDataSourcePgCloud.cs | 13 +++++----- .../Services/AnalyticsService.cs | 14 +++++------ .../Services/Cache/CacheTable.cs | 2 +- .../Services/CrudService.cs | 8 +++---- .../Services/DataService.cs | 8 +++---- .../Services/FileService.cs | 22 ++++++++--------- .../Services/LastDataService.cs | 10 ++++---- .../Services/MessageService.cs | 24 +++++++++---------- .../Services/TelemetryOperationDetector.cs | 4 ++-- .../TelemetryOperationDetectorService.cs | 4 ++-- .../Services/WellService.cs | 6 ++--- .../Services/СlusterService.cs | 21 +++++++++------- .../Controllers/AnalyticsController.cs | 2 +- AsbCloudWebApi/Controllers/CrudController.cs | 7 +++--- AsbCloudWebApi/Controllers/FileController.cs | 14 +++++------ AsbCloudWebApi/Controllers/FluidController.cs | 8 +++---- .../Controllers/LastDataController.cs | 4 ++-- .../Controllers/MudDiagramController.cs | 6 ++--- .../Controllers/NnbDataController.cs | 6 ++--- .../Controllers/ReportController.cs | 4 ++-- AsbCloudWebApi/Controllers/WellController.cs | 2 +- .../Controllers/WellSectionController.cs | 7 +----- ConsoleApp1/Program.cs | 3 --- 36 files changed, 120 insertions(+), 140 deletions(-) diff --git a/AsbCloudApp/Data/ClusterStatDto.cs b/AsbCloudApp/Data/ClusterStatDto.cs index 32731cf1..70c79fbc 100644 --- a/AsbCloudApp/Data/ClusterStatDto.cs +++ b/AsbCloudApp/Data/ClusterStatDto.cs @@ -1,12 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace AsbCloudApp.Data { - public class ClusterStatDto: ClusterDto + public class ClusterStatDto : ClusterDto { public IEnumerable WellsStat { get; set; } } diff --git a/AsbCloudApp/Data/WellOperationDto.cs b/AsbCloudApp/Data/WellOperationDto.cs index 384789da..a4e3ca9f 100644 --- a/AsbCloudApp/Data/WellOperationDto.cs +++ b/AsbCloudApp/Data/WellOperationDto.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AsbCloudApp.Data +namespace AsbCloudApp.Data { public class WellOperationDto : IId { diff --git a/AsbCloudApp/Data/WellSectionDto.cs b/AsbCloudApp/Data/WellSectionDto.cs index 6d7a476c..1b72d36c 100644 --- a/AsbCloudApp/Data/WellSectionDto.cs +++ b/AsbCloudApp/Data/WellSectionDto.cs @@ -1,6 +1,6 @@ namespace AsbCloudApp.Data { - public class WellSectionDto: IId + public class WellSectionDto : IId { public int Id { get; set; } /// diff --git a/AsbCloudApp/Services/IAnalyticsService.cs b/AsbCloudApp/Services/IAnalyticsService.cs index 88b3c753..16d22f1c 100644 --- a/AsbCloudApp/Services/IAnalyticsService.cs +++ b/AsbCloudApp/Services/IAnalyticsService.cs @@ -6,8 +6,8 @@ namespace AsbCloudApp.Services { public interface IAnalyticsService { - PaginationContainer GetOperationsByWell(int idWell, - IEnumerable categoryids = default, DateTime begin = default, + PaginationContainer GetOperationsByWell(int idWell, + IEnumerable categoryids = default, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32); IEnumerable GetWellDepthToDay(int idWell); IEnumerable GetWellDepthToInterval(int idWell, diff --git a/AsbCloudApp/Services/IFileService.cs b/AsbCloudApp/Services/IFileService.cs index d31efd84..fabec6eb 100644 --- a/AsbCloudApp/Services/IFileService.cs +++ b/AsbCloudApp/Services/IFileService.cs @@ -1,13 +1,13 @@ -using System; +using AsbCloudApp.Data; +using System; using System.Collections.Generic; -using AsbCloudApp.Data; namespace AsbCloudApp.Services { public interface IFileService { string RootPath { get; } - IDictionary SaveFilesPropertiesToDb(int idWell, + IDictionary SaveFilesPropertiesToDb(int idWell, int idCategory, IEnumerable<(string fileName, int idWell, int idCategory, DateTime date, int idUser)> filesInfo); diff --git a/AsbCloudApp/Services/IReportService.cs b/AsbCloudApp/Services/IReportService.cs index 49060aa7..4137f399 100644 --- a/AsbCloudApp/Services/IReportService.cs +++ b/AsbCloudApp/Services/IReportService.cs @@ -7,13 +7,13 @@ namespace AsbCloudApp.Services public interface IReportService { int ReportCategoryId { get; } - int CreateReport(int idWell, int idUser, int stepSeconds, + int CreateReport(int idWell, int idUser, int stepSeconds, int format, DateTime begin, DateTime end, - Action handleReportProgress, + Action handleReportProgress, Action handleReportName); - int GetReportPagesCount(int idWell, DateTime begin, DateTime end, + int GetReportPagesCount(int idWell, DateTime begin, DateTime end, int stepSeconds, int format); - IEnumerable GetSuitableReports(int idWell, + IEnumerable GetSuitableReports(int idWell, DateTime begin, DateTime end, int stepSeconds, int format); DatesRangeDto GetReportsDatesRange(int idWell); } diff --git a/AsbCloudApp/Services/ISaubDataCache.cs b/AsbCloudApp/Services/ISaubDataCache.cs index a1474615..8d509bca 100644 --- a/AsbCloudApp/Services/ISaubDataCache.cs +++ b/AsbCloudApp/Services/ISaubDataCache.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; -using AsbCloudApp.Data; +using AsbCloudApp.Data; +using System.Collections.Generic; namespace AsbCloudApp.Services { diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index 974fbac8..8d17ee04 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -139,7 +139,8 @@ namespace AsbCloudDb.Model .HasConstraintName("t_well_t_telemetry_id_fk"); }); - modelBuilder.Entity(entity => { + modelBuilder.Entity(entity => + { entity.HasKey(nameof(RelationCompanyWell.IdCompany), nameof(RelationCompanyWell.IdWell)); @@ -298,7 +299,8 @@ namespace AsbCloudDb.Model }); }); - modelBuilder.Entity(entity => { + modelBuilder.Entity(entity => + { entity.HasData(new List { new RelationCompanyWell{ IdWell = 1, IdCompany = 1}, new RelationCompanyWell{ IdWell = 2, IdCompany = 1}, diff --git a/AsbCloudDb/Model/IAsbCloudDbContext.cs b/AsbCloudDb/Model/IAsbCloudDbContext.cs index 789466cf..b61f505e 100644 --- a/AsbCloudDb/Model/IAsbCloudDbContext.cs +++ b/AsbCloudDb/Model/IAsbCloudDbContext.cs @@ -35,7 +35,7 @@ namespace AsbCloudDb.Model Task SaveChangesAsync(CancellationToken cancellationToken); DbSet Set(string name) where TEntity : class; - + DbSet Set() where TEntity : class; IQueryable GetWellsForCompany(int idCompany); diff --git a/AsbCloudDb/Model/RelationCompanyWell.cs b/AsbCloudDb/Model/RelationCompanyWell.cs index efcf6aac..854401a0 100644 --- a/AsbCloudDb/Model/RelationCompanyWell.cs +++ b/AsbCloudDb/Model/RelationCompanyWell.cs @@ -1,6 +1,4 @@ using Microsoft.EntityFrameworkCore; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; #nullable disable diff --git a/AsbCloudDb/Model/User.cs b/AsbCloudDb/Model/User.cs index 76edc5e0..6304b437 100644 --- a/AsbCloudDb/Model/User.cs +++ b/AsbCloudDb/Model/User.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs index e0c2b3c0..cf7d964f 100644 --- a/AsbCloudInfrastructure/DependencyInjection.cs +++ b/AsbCloudInfrastructure/DependencyInjection.cs @@ -36,8 +36,8 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); - - + + services.AddTransient, LastDataService>(); services.AddTransient, LastDataService>(); services.AddTransient, LastDataService>(); diff --git a/AsbCloudInfrastructure/MapsterExtension.cs b/AsbCloudInfrastructure/MapsterExtension.cs index 988d545d..7b8020bc 100644 --- a/AsbCloudInfrastructure/MapsterExtension.cs +++ b/AsbCloudInfrastructure/MapsterExtension.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Mapster { diff --git a/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs b/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs index 82f934c6..1810194b 100644 --- a/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs +++ b/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs @@ -59,13 +59,13 @@ namespace AsbSaubReport public AnalyzeResult Analyze() { - var messagesQuery = from item in context.Messages - where item.IdTelemetry == idTelemetry - select item; + var messagesQuery = from item in context.Messages + where item.IdTelemetry == idTelemetry + select item; var messagesCount = messagesQuery.Count(); - var messagesMinDate = messagesQuery.Min(e=>e.Date); - var messagesMaxDate = messagesQuery.Max(e=>e.Date); + var messagesMinDate = messagesQuery.Min(e => e.Date); + var messagesMaxDate = messagesQuery.Max(e => e.Date); var dataQuery = from item in context.DataSaubBases where item.IdTelemetry == idTelemetry @@ -74,7 +74,8 @@ namespace AsbSaubReport var dataMinDate = dataQuery.Min(e => e.Date); var dataMaxDate = dataQuery.Max(e => e.Date); - var result = new AnalyzeResult { + var result = new AnalyzeResult + { MaxDate = dataMinDate < messagesMinDate ? dataMinDate : messagesMinDate, MinDate = dataMaxDate > messagesMaxDate ? dataMaxDate : messagesMaxDate, MessagesCount = messagesCount, diff --git a/AsbCloudInfrastructure/Services/AnalyticsService.cs b/AsbCloudInfrastructure/Services/AnalyticsService.cs index 6d279833..f67c2a35 100644 --- a/AsbCloudInfrastructure/Services/AnalyticsService.cs +++ b/AsbCloudInfrastructure/Services/AnalyticsService.cs @@ -2,11 +2,11 @@ using AsbCloudApp.Services; using AsbCloudDb.Model; using AsbCloudInfrastructure.Services.Cache; +using Mapster; +using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; -using Microsoft.EntityFrameworkCore; -using Mapster; namespace AsbCloudInfrastructure.Services { @@ -84,8 +84,8 @@ namespace AsbCloudInfrastructure.Services return wellDepthToIntervalData; } - public PaginationContainer GetOperationsByWell(int idWell, - IEnumerable categoryIds = default, DateTime begin = default, + public PaginationContainer GetOperationsByWell(int idWell, + IEnumerable categoryIds = default, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32) { var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell); @@ -94,7 +94,7 @@ namespace AsbCloudInfrastructure.Services return null; var operations = from a in db.TelemetryAnalysis.Include(t => t.Operation) - where a.IdTelemetry == telemetryId + where a.IdTelemetry == telemetryId select a; if ((categoryIds != default) && (categoryIds.Any())) @@ -130,7 +130,7 @@ namespace AsbCloudInfrastructure.Services if (operationsList.Count == 0) return result; - foreach(var operation in operations) + foreach (var operation in operations) { var operationDto = new TelemetryOperationDto { @@ -160,7 +160,7 @@ namespace AsbCloudInfrastructure.Services var unixEnd = (end - new DateTime(1970, 1, 1)).TotalSeconds; var operations = (from a in db.TelemetryAnalysis - where a.IdTelemetry == telemetryId && + where a.IdTelemetry == telemetryId && a.UnixDate > unixBegin && a.UnixDate < unixEnd join o in db.Operations on a.IdOperation equals o.Id group a by new { a.IdOperation, o.Name } into g diff --git a/AsbCloudInfrastructure/Services/Cache/CacheTable.cs b/AsbCloudInfrastructure/Services/Cache/CacheTable.cs index 2fefe662..735a0295 100644 --- a/AsbCloudInfrastructure/Services/Cache/CacheTable.cs +++ b/AsbCloudInfrastructure/Services/Cache/CacheTable.cs @@ -24,7 +24,7 @@ namespace AsbCloudInfrastructure.Services.Cache public int Refresh() { - if(cached.Any()) + if (cached.Any()) cached.Clear(); var dbEntities = context.Set().ToList(); cached.AddRange(dbEntities); diff --git a/AsbCloudInfrastructure/Services/CrudService.cs b/AsbCloudInfrastructure/Services/CrudService.cs index 257d8bb5..9d3f7e81 100644 --- a/AsbCloudInfrastructure/Services/CrudService.cs +++ b/AsbCloudInfrastructure/Services/CrudService.cs @@ -1,13 +1,13 @@ -using System.Collections.Generic; -using System.Linq; +using AsbCloudApp.Services; using AsbCloudDb.Model; -using AsbCloudApp.Services; using Mapster; using Microsoft.EntityFrameworkCore; +using System.Collections.Generic; +using System.Linq; namespace AsbCloudInfrastructure.Services { - public class CrudService : ICrudService + public class CrudService : ICrudService where TModel : class, AsbCloudDb.Model.IId where Tdto : AsbCloudApp.Data.IId { diff --git a/AsbCloudInfrastructure/Services/DataService.cs b/AsbCloudInfrastructure/Services/DataService.cs index 233d4cfc..1181253c 100644 --- a/AsbCloudInfrastructure/Services/DataService.cs +++ b/AsbCloudInfrastructure/Services/DataService.cs @@ -43,9 +43,9 @@ namespace AsbCloudInfrastructure.Services var datEnd = dateBegin.AddSeconds(intervalSec); var query = from data in db.DataSaubBases - where data.IdTelemetry == telemetry.Id - && data.Date >= dateBegin && data.Date < datEnd - select data; + where data.IdTelemetry == telemetry.Id + && data.Date >= dateBegin && data.Date < datEnd + select data; var fullDataCount = query.Count(); @@ -83,7 +83,7 @@ namespace AsbCloudInfrastructure.Services if (oldDataSaubBase.Any()) db.DataSaubBases.RemoveRange(oldDataSaubBase); - + foreach (var dto in dtos) { diff --git a/AsbCloudInfrastructure/Services/FileService.cs b/AsbCloudInfrastructure/Services/FileService.cs index 36bad845..5fcd953b 100644 --- a/AsbCloudInfrastructure/Services/FileService.cs +++ b/AsbCloudInfrastructure/Services/FileService.cs @@ -1,10 +1,10 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore; -using AsbCloudApp.Data; +using AsbCloudApp.Data; using AsbCloudApp.Services; using AsbCloudDb.Model; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; namespace AsbCloudInfrastructure.Services { @@ -12,22 +12,20 @@ namespace AsbCloudInfrastructure.Services { public string RootPath { get; private set; } private readonly IAsbCloudDbContext db; - private readonly ITelemetryService telemetryService; - public FileService(IAsbCloudDbContext db, ITelemetryService telemetryService) + public FileService(IAsbCloudDbContext db) { RootPath = "files"; this.db = db; - this.telemetryService = telemetryService; } - public IDictionary SaveFilesPropertiesToDb(int idWell, int idCategory, + public IDictionary SaveFilesPropertiesToDb(int idWell, int idCategory, IEnumerable<(string fileName, int idWell, int idCategory, DateTime date, int idUser)> filesInfo) { var fileIdsToNames = new Dictionary(); - foreach(var fileInfo in filesInfo) - { + foreach (var fileInfo in filesInfo) + { var file = new File() { Name = fileInfo.fileName, @@ -46,7 +44,7 @@ namespace AsbCloudInfrastructure.Services } public PaginationContainer 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) { var filesInfoQuery = db.Files.Include(f => f.User) diff --git a/AsbCloudInfrastructure/Services/LastDataService.cs b/AsbCloudInfrastructure/Services/LastDataService.cs index 41b71218..02c0ce2d 100644 --- a/AsbCloudInfrastructure/Services/LastDataService.cs +++ b/AsbCloudInfrastructure/Services/LastDataService.cs @@ -1,7 +1,7 @@ -using System.Linq; +using AsbCloudApp.Services; using AsbCloudDb.Model; -using AsbCloudApp.Services; using Mapster; +using System.Linq; using System.Text.Json; namespace AsbCloudInfrastructure.Services @@ -17,7 +17,7 @@ namespace AsbCloudInfrastructure.Services public Tdto Get(int idWell, int idCategory) { - var entity = db.LastData.FirstOrDefault(e => + var entity = db.LastData.FirstOrDefault(e => e.IdWell == idWell && e.IdCategory == idCategory); if (entity is null) @@ -41,8 +41,8 @@ namespace AsbCloudInfrastructure.Services } else { - var newLastData = new LastData - { + var newLastData = new LastData + { IdWell = idWell, IdCategory = idCategory, Data = model diff --git a/AsbCloudInfrastructure/Services/MessageService.cs b/AsbCloudInfrastructure/Services/MessageService.cs index 01326b23..ffebb274 100644 --- a/AsbCloudInfrastructure/Services/MessageService.cs +++ b/AsbCloudInfrastructure/Services/MessageService.cs @@ -26,12 +26,12 @@ namespace AsbCloudInfrastructure.Services } public PaginationContainer GetMessages( - int idWell, - IEnumerable categoryids = default, - DateTime begin = default, - DateTime end = default, - string searchString = default, - int skip = 0, + int idWell, + IEnumerable categoryids = default, + DateTime begin = default, + DateTime end = default, + string searchString = default, + int skip = 0, int take = 32) { var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell); @@ -45,7 +45,7 @@ namespace AsbCloudInfrastructure.Services var messages = db.Messages.Where(m => m.IdTelemetry == telemetryId); - if((categoryids?.Any() == true) || !string.IsNullOrEmpty(searchString)) + if ((categoryids?.Any() == true) || !string.IsNullOrEmpty(searchString)) { if (!string.IsNullOrEmpty(searchString)) events = events.Where(e => e.MessageTemplate.Contains(searchString, StringComparison.OrdinalIgnoreCase)); @@ -53,7 +53,7 @@ namespace AsbCloudInfrastructure.Services if (categoryids?.Any() == true) events = events.Where(e => categoryids.ToList().Contains(e.IdCategory)); - var eventIds = events.Select(e=> e.IdEvent); + var eventIds = events.Select(e => e.IdEvent); if (!eventIds.Any()) return null; @@ -70,10 +70,10 @@ namespace AsbCloudInfrastructure.Services messages = messages.Where(m => m.Date <= end); var result = new PaginationContainer - { - Skip = skip, - Take = take, - Count = messages.Count() + { + Skip = skip, + Take = take, + Count = messages.Count() }; if (skip > 0) diff --git a/AsbCloudInfrastructure/Services/TelemetryOperationDetector.cs b/AsbCloudInfrastructure/Services/TelemetryOperationDetector.cs index 38c174bd..aecbc8ae 100644 --- a/AsbCloudInfrastructure/Services/TelemetryOperationDetector.cs +++ b/AsbCloudInfrastructure/Services/TelemetryOperationDetector.cs @@ -1,5 +1,5 @@ -using AsbCloudDb.Model; -using AsbCloudApp.Data; +using AsbCloudApp.Data; +using AsbCloudDb.Model; using System; namespace AsbCloudInfrastructure.Services diff --git a/AsbCloudInfrastructure/Services/TelemetryOperationDetectorService.cs b/AsbCloudInfrastructure/Services/TelemetryOperationDetectorService.cs index 05e369fd..8a106ca7 100644 --- a/AsbCloudInfrastructure/Services/TelemetryOperationDetectorService.cs +++ b/AsbCloudInfrastructure/Services/TelemetryOperationDetectorService.cs @@ -1,5 +1,5 @@ -using AsbCloudDb.Model; -using AsbCloudApp.Data; +using AsbCloudApp.Data; +using AsbCloudDb.Model; using System.Collections.Generic; using System.Linq; diff --git a/AsbCloudInfrastructure/Services/WellService.cs b/AsbCloudInfrastructure/Services/WellService.cs index 3a625b5e..f198f38f 100644 --- a/AsbCloudInfrastructure/Services/WellService.cs +++ b/AsbCloudInfrastructure/Services/WellService.cs @@ -43,7 +43,7 @@ namespace AsbCloudInfrastructure.Services public bool IsCompanyInvolvedInWell(int idCompany, int idWell) => cacheRelationCompaniesWells.Contains(r => r.IdWell == idWell && r.IdCompany == idCompany); - + public IEnumerable GetSections(int idWell) { var entities = db @@ -52,8 +52,8 @@ namespace AsbCloudInfrastructure.Services .ToList(); var dtos = entities.Adapt( - (s, d) => { d.SectionType = s.WellSectionType.Caption;}); - + (s, d) => { d.SectionType = s.WellSectionType.Caption; }); + return dtos; } diff --git a/AsbCloudInfrastructure/Services/СlusterService.cs b/AsbCloudInfrastructure/Services/СlusterService.cs index 2b655865..1ae8c076 100644 --- a/AsbCloudInfrastructure/Services/СlusterService.cs +++ b/AsbCloudInfrastructure/Services/СlusterService.cs @@ -18,13 +18,13 @@ namespace AsbCloudInfrastructure.Services public IEnumerable GetDeposits(int idCompany) { - var wellEntities = (from well in db.Wells + var wellEntities = (from well in db.Wells .Include(w => w.RelationCompaniesWells) .Include(w => w.WellType) - .Include(w=>w.Cluster) + .Include(w => w.Cluster) .ThenInclude(c => c.Deposit) - where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany) - select well).ToList(); + where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany) + select well).ToList(); var gDepositEntities = wellEntities .GroupBy(w => w.Cluster) @@ -37,13 +37,15 @@ namespace AsbCloudInfrastructure.Services Latitude = gDeposit.Key.Latitude, Longitude = gDeposit.Key.Longitude, Description = "", - Clusters = gDeposit.Select(gCluster=>new ClusterDto { + Clusters = gDeposit.Select(gCluster => new ClusterDto + { Id = gCluster.Key.Id, Caption = gCluster.Key.Caption, Latitude = gCluster.Key.Latitude, Longitude = gCluster.Key.Longitude, Description = "", - Wells = gCluster.Select(well => new WellDto { + Wells = gCluster.Select(well => new WellDto + { Id = well.Id, Caption = well.Caption, Latitude = well.Latitude, @@ -117,8 +119,8 @@ namespace AsbCloudInfrastructure.Services public ClusterStatDto GetStat(int idCompany, int idCluster) { var wellEntities = from w in db.Wells - where w.IdCluster == idCluster && w.RelationCompaniesWells.Any(c => c.IdCompany == idCompany) - select w; + where w.IdCluster == idCluster && w.RelationCompaniesWells.Any(c => c.IdCompany == idCompany) + select w; var wellStatDtos = wellEntities.Select(e => new WellStatDto { @@ -169,7 +171,8 @@ namespace AsbCloudInfrastructure.Services var clusterById = db.Clusters.FirstOrDefault(c => c.Id == idCluster); - return new ClusterStatDto { + return new ClusterStatDto + { Id = clusterById.Id, Description = "", Caption = clusterById.Caption, diff --git a/AsbCloudWebApi/Controllers/AnalyticsController.cs b/AsbCloudWebApi/Controllers/AnalyticsController.cs index 0e25e482..93c0d07c 100644 --- a/AsbCloudWebApi/Controllers/AnalyticsController.cs +++ b/AsbCloudWebApi/Controllers/AnalyticsController.cs @@ -35,7 +35,7 @@ namespace AsbCloudWebApi.Controllers [HttpGet] [Route("{idWell}/operationsByWell")] [ProducesResponseType(typeof(PaginationContainer), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetOperationsByWell(int idWell, int skip = 0, int take = 32, + public IActionResult GetOperationsByWell(int idWell, int skip = 0, int take = 32, [FromQuery] IEnumerable categoryIds = default, DateTime begin = default, DateTime end = default) { int? idCompany = User.GetCompanyId(); diff --git a/AsbCloudWebApi/Controllers/CrudController.cs b/AsbCloudWebApi/Controllers/CrudController.cs index 55ef87f4..ed05edc3 100644 --- a/AsbCloudWebApi/Controllers/CrudController.cs +++ b/AsbCloudWebApi/Controllers/CrudController.cs @@ -1,7 +1,6 @@ -using Microsoft.AspNetCore.Mvc; -using System.Collections.Generic; -using AsbCloudApp.Data; +using AsbCloudApp.Data; using AsbCloudApp.Services; +using Microsoft.AspNetCore.Mvc; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 @@ -9,7 +8,7 @@ namespace AsbCloudWebApi.Controllers { [ApiController] public abstract class CrudController : ControllerBase - where T: IId + where T : IId { protected readonly ICrudService service; diff --git a/AsbCloudWebApi/Controllers/FileController.cs b/AsbCloudWebApi/Controllers/FileController.cs index 7b7be3d7..ff0c3204 100644 --- a/AsbCloudWebApi/Controllers/FileController.cs +++ b/AsbCloudWebApi/Controllers/FileController.cs @@ -1,11 +1,11 @@ -using System; -using System.Linq; -using System.IO; -using AsbCloudApp.Data; +using AsbCloudApp.Data; using AsbCloudApp.Services; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.IO; +using System.Linq; namespace AsbCloudWebApi.Controllers { @@ -90,7 +90,7 @@ namespace AsbCloudWebApi.Controllers if (idCompany is null || !wellService.IsCompanyInvolvedInWell((int)idCompany, idWell)) return Forbid(); - var filesInfo = fileService.GetFilesInfo(idWell, idCategory, + var filesInfo = fileService.GetFilesInfo(idWell, idCategory, begin, end, skip, take); if (filesInfo is null || !filesInfo.Items.Any()) @@ -126,7 +126,7 @@ namespace AsbCloudWebApi.Controllers throw new FileNotFoundException(); // TODO: словарь content typoв - var relativePath = Path.Combine(fileService.RootPath, $"{idWell}", $"{fileInfo.Value.IdCategory}", + var relativePath = Path.Combine(fileService.RootPath, $"{idWell}", $"{fileInfo.Value.IdCategory}", $"{fileInfo.Value.Id}" + Path.GetExtension($"{fileInfo.Value.Name}")); return PhysicalFile(Path.GetFullPath(relativePath), "application/octet-stream", fileInfo.Value.Name); } diff --git a/AsbCloudWebApi/Controllers/FluidController.cs b/AsbCloudWebApi/Controllers/FluidController.cs index a567517b..46550cf7 100644 --- a/AsbCloudWebApi/Controllers/FluidController.cs +++ b/AsbCloudWebApi/Controllers/FluidController.cs @@ -1,7 +1,7 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Authorization; -using AsbCloudApp.Data; +using AsbCloudApp.Data; using AsbCloudApp.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; namespace AsbCloudWebApi.Controllers { @@ -10,7 +10,7 @@ namespace AsbCloudWebApi.Controllers [Authorize] public class FluidController : LastDataController { - public FluidController(ILastDataService lastDataService, + public FluidController(ILastDataService lastDataService, IWellService wellService) : base(lastDataService, wellService) { } } diff --git a/AsbCloudWebApi/Controllers/LastDataController.cs b/AsbCloudWebApi/Controllers/LastDataController.cs index 27f8894d..cabdc0ca 100644 --- a/AsbCloudWebApi/Controllers/LastDataController.cs +++ b/AsbCloudWebApi/Controllers/LastDataController.cs @@ -1,6 +1,6 @@ -using Microsoft.AspNetCore.Mvc; +using AsbCloudApp.Services; using Microsoft.AspNetCore.Authorization; -using AsbCloudApp.Services; +using Microsoft.AspNetCore.Mvc; namespace AsbCloudWebApi.Controllers { diff --git a/AsbCloudWebApi/Controllers/MudDiagramController.cs b/AsbCloudWebApi/Controllers/MudDiagramController.cs index f5f70dbc..48551e9f 100644 --- a/AsbCloudWebApi/Controllers/MudDiagramController.cs +++ b/AsbCloudWebApi/Controllers/MudDiagramController.cs @@ -1,7 +1,7 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Authorization; -using AsbCloudApp.Data; +using AsbCloudApp.Data; using AsbCloudApp.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; namespace AsbCloudWebApi.Controllers { diff --git a/AsbCloudWebApi/Controllers/NnbDataController.cs b/AsbCloudWebApi/Controllers/NnbDataController.cs index e69f90ea..67403b37 100644 --- a/AsbCloudWebApi/Controllers/NnbDataController.cs +++ b/AsbCloudWebApi/Controllers/NnbDataController.cs @@ -1,7 +1,7 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Authorization; -using AsbCloudApp.Data; +using AsbCloudApp.Data; using AsbCloudApp.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; namespace AsbCloudWebApi.Controllers { diff --git a/AsbCloudWebApi/Controllers/ReportController.cs b/AsbCloudWebApi/Controllers/ReportController.cs index 3e278a9e..2d6f76ab 100644 --- a/AsbCloudWebApi/Controllers/ReportController.cs +++ b/AsbCloudWebApi/Controllers/ReportController.cs @@ -75,7 +75,7 @@ namespace AsbCloudWebApi.Controllers if (!wellService.IsCompanyInvolvedInWell((int)idCompany, idWell)) return Forbid(); - var id = reportService.CreateReport(idWell, idUser, + var id = reportService.CreateReport(idWell, idUser, stepSeconds, format, begin, end, HandleReportProgressAsync, HandleReportNameAsync); return Ok(id); @@ -102,7 +102,7 @@ namespace AsbCloudWebApi.Controllers if (!wellService.IsCompanyInvolvedInWell((int)idCompany, idWell)) return Forbid(); // TODO: словарь content typoв - var relativePath = Path.Combine(fileService.RootPath, $"{idWell}", + var relativePath = Path.Combine(fileService.RootPath, $"{idWell}", $"{reportService.ReportCategoryId}", reportName); return PhysicalFile(Path.GetFullPath(relativePath), "application/pdf", reportName); } diff --git a/AsbCloudWebApi/Controllers/WellController.cs b/AsbCloudWebApi/Controllers/WellController.cs index fa95451f..42e9c1fd 100644 --- a/AsbCloudWebApi/Controllers/WellController.cs +++ b/AsbCloudWebApi/Controllers/WellController.cs @@ -44,7 +44,7 @@ namespace AsbCloudWebApi.Controllers { var idCompany = User.GetCompanyId(); - if (idCompany is null) + if (idCompany is null) return NoContent(); if (!wellService.IsCompanyInvolvedInWell((int)idCompany, idWell)) diff --git a/AsbCloudWebApi/Controllers/WellSectionController.cs b/AsbCloudWebApi/Controllers/WellSectionController.cs index bbc375e6..65ebb3dc 100644 --- a/AsbCloudWebApi/Controllers/WellSectionController.cs +++ b/AsbCloudWebApi/Controllers/WellSectionController.cs @@ -1,12 +1,7 @@ using AsbCloudApp.Data; using AsbCloudApp.Services; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace AsbCloudWebApi.Controllers { @@ -16,7 +11,7 @@ namespace AsbCloudWebApi.Controllers public class WellSectionController : CrudController { public WellSectionController(ICrudService service) - :base(service) + : base(service) { } diff --git a/ConsoleApp1/Program.cs b/ConsoleApp1/Program.cs index 6beec835..cb075929 100644 --- a/ConsoleApp1/Program.cs +++ b/ConsoleApp1/Program.cs @@ -6,9 +6,6 @@ //using AutoMapper; //using Microsoft.EntityFrameworkCore; using System; -using System.Collections.Generic; -using System.IO; -using Mapster; namespace ConsoleApp1 {