forked from ddrilling/AsbCloudServer
Очистка и анализ кода
This commit is contained in:
parent
a14e5134bf
commit
3a325f6c94
@ -1,12 +1,8 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Data
|
namespace AsbCloudApp.Data
|
||||||
{
|
{
|
||||||
public class ClusterStatDto: ClusterDto
|
public class ClusterStatDto : ClusterDto
|
||||||
{
|
{
|
||||||
public IEnumerable<WellStatDto> WellsStat { get; set; }
|
public IEnumerable<WellStatDto> WellsStat { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace AsbCloudApp.Data
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Data
|
|
||||||
{
|
{
|
||||||
public class WellOperationDto : IId
|
public class WellOperationDto : IId
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace AsbCloudApp.Data
|
namespace AsbCloudApp.Data
|
||||||
{
|
{
|
||||||
public class WellSectionDto: IId
|
public class WellSectionDto : IId
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -6,8 +6,8 @@ namespace AsbCloudApp.Services
|
|||||||
{
|
{
|
||||||
public interface IAnalyticsService
|
public interface IAnalyticsService
|
||||||
{
|
{
|
||||||
PaginationContainer<TelemetryOperationDto> GetOperationsByWell(int idWell,
|
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 idWell);
|
IEnumerable<WellDepthToDayDto> GetWellDepthToDay(int idWell);
|
||||||
IEnumerable<WellDepthToIntervalDto> GetWellDepthToInterval(int idWell,
|
IEnumerable<WellDepthToIntervalDto> GetWellDepthToInterval(int idWell,
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
using System;
|
using AsbCloudApp.Data;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using AsbCloudApp.Data;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
public interface IFileService
|
public interface IFileService
|
||||||
{
|
{
|
||||||
string RootPath { get; }
|
string RootPath { get; }
|
||||||
IDictionary<string, int> SaveFilesPropertiesToDb(int idWell,
|
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);
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@ namespace AsbCloudApp.Services
|
|||||||
public interface IReportService
|
public interface IReportService
|
||||||
{
|
{
|
||||||
int ReportCategoryId { get; }
|
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,
|
int format, DateTime begin, DateTime end,
|
||||||
Action<float, string, int> handleReportProgress,
|
Action<float, string, int> handleReportProgress,
|
||||||
Action<string, int> handleReportName);
|
Action<string, int> handleReportName);
|
||||||
int GetReportPagesCount(int idWell, DateTime begin, DateTime end,
|
int GetReportPagesCount(int idWell, DateTime begin, DateTime end,
|
||||||
int stepSeconds, int format);
|
int stepSeconds, int format);
|
||||||
IEnumerable<ReportPropertiesDto> GetSuitableReports(int idWell,
|
IEnumerable<ReportPropertiesDto> GetSuitableReports(int idWell,
|
||||||
DateTime begin, DateTime end, int stepSeconds, int format);
|
DateTime begin, DateTime end, int stepSeconds, int format);
|
||||||
DatesRangeDto GetReportsDatesRange(int idWell);
|
DatesRangeDto GetReportsDatesRange(int idWell);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Data;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
|
@ -139,7 +139,8 @@ namespace AsbCloudDb.Model
|
|||||||
.HasConstraintName("t_well_t_telemetry_id_fk");
|
.HasConstraintName("t_well_t_telemetry_id_fk");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<RelationCompanyWell>(entity => {
|
modelBuilder.Entity<RelationCompanyWell>(entity =>
|
||||||
|
{
|
||||||
|
|
||||||
entity.HasKey(nameof(RelationCompanyWell.IdCompany), nameof(RelationCompanyWell.IdWell));
|
entity.HasKey(nameof(RelationCompanyWell.IdCompany), nameof(RelationCompanyWell.IdWell));
|
||||||
|
|
||||||
@ -298,7 +299,8 @@ namespace AsbCloudDb.Model
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<RelationCompanyWell>(entity => {
|
modelBuilder.Entity<RelationCompanyWell>(entity =>
|
||||||
|
{
|
||||||
entity.HasData(new List<RelationCompanyWell> {
|
entity.HasData(new List<RelationCompanyWell> {
|
||||||
new RelationCompanyWell{ IdWell = 1, IdCompany = 1},
|
new RelationCompanyWell{ IdWell = 1, IdCompany = 1},
|
||||||
new RelationCompanyWell{ IdWell = 2, IdCompany = 1},
|
new RelationCompanyWell{ IdWell = 2, IdCompany = 1},
|
||||||
|
@ -35,7 +35,7 @@ namespace AsbCloudDb.Model
|
|||||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
|
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
|
||||||
|
|
||||||
DbSet<TEntity> Set<TEntity>(string name) where TEntity : class;
|
DbSet<TEntity> Set<TEntity>(string name) where TEntity : class;
|
||||||
|
|
||||||
DbSet<TEntity> Set<TEntity>() where TEntity : class;
|
DbSet<TEntity> Set<TEntity>() where TEntity : class;
|
||||||
|
|
||||||
IQueryable<Well> GetWellsForCompany(int idCompany);
|
IQueryable<Well> GetWellsForCompany(int idCompany);
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
@ -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;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<IReportService, ReportService>();
|
services.AddTransient<IReportService, ReportService>();
|
||||||
services.AddTransient<IAnalyticsService, AnalyticsService>();
|
services.AddTransient<IAnalyticsService, AnalyticsService>();
|
||||||
services.AddTransient<IFileService, FileService>();
|
services.AddTransient<IFileService, FileService>();
|
||||||
|
|
||||||
|
|
||||||
services.AddTransient<ILastDataService<FluidDataDto>, LastDataService<FluidDataDto, FluidData>>();
|
services.AddTransient<ILastDataService<FluidDataDto>, LastDataService<FluidDataDto, FluidData>>();
|
||||||
services.AddTransient<ILastDataService<MudDiagramDataDto>, LastDataService<MudDiagramDataDto, MudDiagramData>>();
|
services.AddTransient<ILastDataService<MudDiagramDataDto>, LastDataService<MudDiagramDataDto, MudDiagramData>>();
|
||||||
services.AddTransient<ILastDataService<NnbDataDto>, LastDataService<NnbDataDto, NnbData>>();
|
services.AddTransient<ILastDataService<NnbDataDto>, LastDataService<NnbDataDto, NnbData>>();
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Mapster
|
namespace Mapster
|
||||||
{
|
{
|
||||||
|
@ -59,13 +59,13 @@ namespace AsbSaubReport
|
|||||||
|
|
||||||
public AnalyzeResult Analyze()
|
public AnalyzeResult Analyze()
|
||||||
{
|
{
|
||||||
var messagesQuery = from item in context.Messages
|
var messagesQuery = from item in context.Messages
|
||||||
where item.IdTelemetry == idTelemetry
|
where item.IdTelemetry == idTelemetry
|
||||||
select item;
|
select item;
|
||||||
|
|
||||||
var messagesCount = messagesQuery.Count();
|
var messagesCount = messagesQuery.Count();
|
||||||
var messagesMinDate = messagesQuery.Min(e=>e.Date);
|
var messagesMinDate = messagesQuery.Min(e => e.Date);
|
||||||
var messagesMaxDate = messagesQuery.Max(e=>e.Date);
|
var messagesMaxDate = messagesQuery.Max(e => e.Date);
|
||||||
|
|
||||||
var dataQuery = from item in context.DataSaubBases
|
var dataQuery = from item in context.DataSaubBases
|
||||||
where item.IdTelemetry == idTelemetry
|
where item.IdTelemetry == idTelemetry
|
||||||
@ -74,7 +74,8 @@ namespace AsbSaubReport
|
|||||||
var dataMinDate = dataQuery.Min(e => e.Date);
|
var dataMinDate = dataQuery.Min(e => e.Date);
|
||||||
var dataMaxDate = dataQuery.Max(e => e.Date);
|
var dataMaxDate = dataQuery.Max(e => e.Date);
|
||||||
|
|
||||||
var result = new AnalyzeResult {
|
var result = new AnalyzeResult
|
||||||
|
{
|
||||||
MaxDate = dataMinDate < messagesMinDate ? dataMinDate : messagesMinDate,
|
MaxDate = dataMinDate < messagesMinDate ? dataMinDate : messagesMinDate,
|
||||||
MinDate = dataMaxDate > messagesMaxDate ? dataMaxDate : messagesMaxDate,
|
MinDate = dataMaxDate > messagesMaxDate ? dataMaxDate : messagesMaxDate,
|
||||||
MessagesCount = messagesCount,
|
MessagesCount = messagesCount,
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Services.Cache;
|
using AsbCloudInfrastructure.Services.Cache;
|
||||||
|
using Mapster;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Mapster;
|
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
@ -84,8 +84,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return wellDepthToIntervalData;
|
return wellDepthToIntervalData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PaginationContainer<TelemetryOperationDto> GetOperationsByWell(int idWell,
|
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 telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||||
@ -94,7 +94,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
var operations = from a in db.TelemetryAnalysis.Include(t => t.Operation)
|
var operations = from a in db.TelemetryAnalysis.Include(t => t.Operation)
|
||||||
where a.IdTelemetry == telemetryId
|
where a.IdTelemetry == telemetryId
|
||||||
select a;
|
select a;
|
||||||
|
|
||||||
if ((categoryIds != default) && (categoryIds.Any()))
|
if ((categoryIds != default) && (categoryIds.Any()))
|
||||||
@ -130,7 +130,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
if (operationsList.Count == 0)
|
if (operationsList.Count == 0)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
foreach(var operation in operations)
|
foreach (var operation in operations)
|
||||||
{
|
{
|
||||||
var operationDto = new TelemetryOperationDto
|
var operationDto = new TelemetryOperationDto
|
||||||
{
|
{
|
||||||
@ -160,7 +160,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var unixEnd = (end - new DateTime(1970, 1, 1)).TotalSeconds;
|
var unixEnd = (end - new DateTime(1970, 1, 1)).TotalSeconds;
|
||||||
|
|
||||||
var operations = (from a in db.TelemetryAnalysis
|
var operations = (from a in db.TelemetryAnalysis
|
||||||
where a.IdTelemetry == telemetryId &&
|
where a.IdTelemetry == telemetryId &&
|
||||||
a.UnixDate > unixBegin && a.UnixDate < unixEnd
|
a.UnixDate > unixBegin && a.UnixDate < unixEnd
|
||||||
join o in db.Operations on a.IdOperation equals o.Id
|
join o in db.Operations on a.IdOperation equals o.Id
|
||||||
group a by new { a.IdOperation, o.Name } into g
|
group a by new { a.IdOperation, o.Name } into g
|
||||||
|
@ -24,7 +24,7 @@ namespace AsbCloudInfrastructure.Services.Cache
|
|||||||
|
|
||||||
public int Refresh()
|
public int Refresh()
|
||||||
{
|
{
|
||||||
if(cached.Any())
|
if (cached.Any())
|
||||||
cached.Clear();
|
cached.Clear();
|
||||||
var dbEntities = context.Set<TEntity>().ToList();
|
var dbEntities = context.Set<TEntity>().ToList();
|
||||||
cached.AddRange(dbEntities);
|
cached.AddRange(dbEntities);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
using System.Collections.Generic;
|
using AsbCloudApp.Services;
|
||||||
using System.Linq;
|
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudApp.Services;
|
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
public class CrudService<Tdto, TModel> : ICrudService<Tdto>
|
public class CrudService<Tdto, TModel> : ICrudService<Tdto>
|
||||||
where TModel : class, AsbCloudDb.Model.IId
|
where TModel : class, AsbCloudDb.Model.IId
|
||||||
where Tdto : AsbCloudApp.Data.IId
|
where Tdto : AsbCloudApp.Data.IId
|
||||||
{
|
{
|
||||||
|
@ -43,9 +43,9 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var datEnd = dateBegin.AddSeconds(intervalSec);
|
var datEnd = dateBegin.AddSeconds(intervalSec);
|
||||||
|
|
||||||
var query = from data in db.DataSaubBases
|
var query = from data in db.DataSaubBases
|
||||||
where data.IdTelemetry == telemetry.Id
|
where data.IdTelemetry == telemetry.Id
|
||||||
&& data.Date >= dateBegin && data.Date < datEnd
|
&& data.Date >= dateBegin && data.Date < datEnd
|
||||||
select data;
|
select data;
|
||||||
|
|
||||||
var fullDataCount = query.Count();
|
var fullDataCount = query.Count();
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
if (oldDataSaubBase.Any())
|
if (oldDataSaubBase.Any())
|
||||||
db.DataSaubBases.RemoveRange(oldDataSaubBase);
|
db.DataSaubBases.RemoveRange(oldDataSaubBase);
|
||||||
|
|
||||||
|
|
||||||
foreach (var dto in dtos)
|
foreach (var dto in dtos)
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using AsbCloudApp.Data;
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using AsbCloudApp.Data;
|
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
@ -12,22 +12,20 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
{
|
{
|
||||||
public string RootPath { get; private set; }
|
public string RootPath { get; private set; }
|
||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
private readonly ITelemetryService telemetryService;
|
|
||||||
|
|
||||||
public FileService(IAsbCloudDbContext db, ITelemetryService telemetryService)
|
public FileService(IAsbCloudDbContext db)
|
||||||
{
|
{
|
||||||
RootPath = "files";
|
RootPath = "files";
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.telemetryService = telemetryService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDictionary<string, int> SaveFilesPropertiesToDb(int idWell, 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>();
|
||||||
|
|
||||||
foreach(var fileInfo in filesInfo)
|
foreach (var fileInfo in filesInfo)
|
||||||
{
|
{
|
||||||
var file = new File()
|
var file = new File()
|
||||||
{
|
{
|
||||||
Name = fileInfo.fileName,
|
Name = fileInfo.fileName,
|
||||||
@ -46,7 +44,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PaginationContainer<FilePropertiesDto> GetFilesInfo(int idWell,
|
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 filesInfoQuery = db.Files.Include(f => f.User)
|
var filesInfoQuery = db.Files.Include(f => f.User)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System.Linq;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudApp.Services;
|
|
||||||
using Mapster;
|
using Mapster;
|
||||||
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
@ -17,7 +17,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public Tdto Get(int idWell, int idCategory)
|
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);
|
e.IdWell == idWell && e.IdCategory == idCategory);
|
||||||
|
|
||||||
if (entity is null)
|
if (entity is null)
|
||||||
@ -41,8 +41,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var newLastData = new LastData
|
var newLastData = new LastData
|
||||||
{
|
{
|
||||||
IdWell = idWell,
|
IdWell = idWell,
|
||||||
IdCategory = idCategory,
|
IdCategory = idCategory,
|
||||||
Data = model
|
Data = model
|
||||||
|
@ -26,12 +26,12 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PaginationContainer<MessageDto> GetMessages(
|
public PaginationContainer<MessageDto> GetMessages(
|
||||||
int idWell,
|
int idWell,
|
||||||
IEnumerable<int> categoryids = default,
|
IEnumerable<int> categoryids = default,
|
||||||
DateTime begin = default,
|
DateTime begin = default,
|
||||||
DateTime end = default,
|
DateTime end = default,
|
||||||
string searchString = default,
|
string searchString = default,
|
||||||
int skip = 0,
|
int skip = 0,
|
||||||
int take = 32)
|
int take = 32)
|
||||||
{
|
{
|
||||||
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||||
@ -45,7 +45,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
var messages = db.Messages.Where(m => m.IdTelemetry == telemetryId);
|
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))
|
if (!string.IsNullOrEmpty(searchString))
|
||||||
events = events.Where(e => e.MessageTemplate.Contains(searchString, StringComparison.OrdinalIgnoreCase));
|
events = events.Where(e => e.MessageTemplate.Contains(searchString, StringComparison.OrdinalIgnoreCase));
|
||||||
@ -53,7 +53,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
if (categoryids?.Any() == true)
|
if (categoryids?.Any() == true)
|
||||||
events = events.Where(e => categoryids.ToList().Contains(e.IdCategory));
|
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())
|
if (!eventIds.Any())
|
||||||
return null;
|
return null;
|
||||||
@ -70,10 +70,10 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
messages = messages.Where(m => m.Date <= end);
|
messages = messages.Where(m => m.Date <= end);
|
||||||
|
|
||||||
var result = new PaginationContainer<MessageDto>
|
var result = new PaginationContainer<MessageDto>
|
||||||
{
|
{
|
||||||
Skip = skip,
|
Skip = skip,
|
||||||
Take = take,
|
Take = take,
|
||||||
Count = messages.Count()
|
Count = messages.Count()
|
||||||
};
|
};
|
||||||
|
|
||||||
if (skip > 0)
|
if (skip > 0)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using AsbCloudDb.Model;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Data;
|
using AsbCloudDb.Model;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using AsbCloudDb.Model;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Data;
|
using AsbCloudDb.Model;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public bool IsCompanyInvolvedInWell(int idCompany, int idWell)
|
public bool IsCompanyInvolvedInWell(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)
|
public IEnumerable<WellSectionDto> GetSections(int idWell)
|
||||||
{
|
{
|
||||||
var entities = db
|
var entities = db
|
||||||
@ -52,8 +52,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var dtos = entities.Adapt<WellSection, WellSectionDto>(
|
var dtos = entities.Adapt<WellSection, WellSectionDto>(
|
||||||
(s, d) => { d.SectionType = s.WellSectionType.Caption;});
|
(s, d) => { d.SectionType = s.WellSectionType.Caption; });
|
||||||
|
|
||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,13 +18,13 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public IEnumerable<DepositDto> GetDeposits(int idCompany)
|
public IEnumerable<DepositDto> GetDeposits(int idCompany)
|
||||||
{
|
{
|
||||||
var wellEntities = (from well in db.Wells
|
var wellEntities = (from well in db.Wells
|
||||||
.Include(w => w.RelationCompaniesWells)
|
.Include(w => w.RelationCompaniesWells)
|
||||||
.Include(w => w.WellType)
|
.Include(w => w.WellType)
|
||||||
.Include(w=>w.Cluster)
|
.Include(w => w.Cluster)
|
||||||
.ThenInclude(c => c.Deposit)
|
.ThenInclude(c => c.Deposit)
|
||||||
where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany)
|
where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany)
|
||||||
select well).ToList();
|
select well).ToList();
|
||||||
|
|
||||||
var gDepositEntities = wellEntities
|
var gDepositEntities = wellEntities
|
||||||
.GroupBy(w => w.Cluster)
|
.GroupBy(w => w.Cluster)
|
||||||
@ -37,13 +37,15 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
Latitude = gDeposit.Key.Latitude,
|
Latitude = gDeposit.Key.Latitude,
|
||||||
Longitude = gDeposit.Key.Longitude,
|
Longitude = gDeposit.Key.Longitude,
|
||||||
Description = "",
|
Description = "",
|
||||||
Clusters = gDeposit.Select(gCluster=>new ClusterDto {
|
Clusters = gDeposit.Select(gCluster => new ClusterDto
|
||||||
|
{
|
||||||
Id = gCluster.Key.Id,
|
Id = gCluster.Key.Id,
|
||||||
Caption = gCluster.Key.Caption,
|
Caption = gCluster.Key.Caption,
|
||||||
Latitude = gCluster.Key.Latitude,
|
Latitude = gCluster.Key.Latitude,
|
||||||
Longitude = gCluster.Key.Longitude,
|
Longitude = gCluster.Key.Longitude,
|
||||||
Description = "",
|
Description = "",
|
||||||
Wells = gCluster.Select(well => new WellDto {
|
Wells = gCluster.Select(well => new WellDto
|
||||||
|
{
|
||||||
Id = well.Id,
|
Id = well.Id,
|
||||||
Caption = well.Caption,
|
Caption = well.Caption,
|
||||||
Latitude = well.Latitude,
|
Latitude = well.Latitude,
|
||||||
@ -117,8 +119,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
public ClusterStatDto GetStat(int idCompany, int idCluster)
|
public ClusterStatDto GetStat(int idCompany, int idCluster)
|
||||||
{
|
{
|
||||||
var wellEntities = from w in db.Wells
|
var wellEntities = from w in db.Wells
|
||||||
where w.IdCluster == idCluster && w.RelationCompaniesWells.Any(c => c.IdCompany == idCompany)
|
where w.IdCluster == idCluster && w.RelationCompaniesWells.Any(c => c.IdCompany == idCompany)
|
||||||
select w;
|
select w;
|
||||||
|
|
||||||
var wellStatDtos = wellEntities.Select(e => new WellStatDto
|
var wellStatDtos = wellEntities.Select(e => new WellStatDto
|
||||||
{
|
{
|
||||||
@ -169,7 +171,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
var clusterById = db.Clusters.FirstOrDefault(c => c.Id == idCluster);
|
var clusterById = db.Clusters.FirstOrDefault(c => c.Id == idCluster);
|
||||||
|
|
||||||
return new ClusterStatDto {
|
return new ClusterStatDto
|
||||||
|
{
|
||||||
Id = clusterById.Id,
|
Id = clusterById.Id,
|
||||||
Description = "",
|
Description = "",
|
||||||
Caption = clusterById.Caption,
|
Caption = clusterById.Caption,
|
||||||
|
@ -35,7 +35,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("{idWell}/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 idWell, 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();
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using AsbCloudApp.Data;
|
||||||
using System.Collections.Generic;
|
|
||||||
using AsbCloudApp.Data;
|
|
||||||
using AsbCloudApp.Services;
|
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
|
// 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]
|
[ApiController]
|
||||||
public abstract class CrudController<T> : ControllerBase
|
public abstract class CrudController<T> : ControllerBase
|
||||||
where T: IId
|
where T : IId
|
||||||
{
|
{
|
||||||
protected readonly ICrudService<T> service;
|
protected readonly ICrudService<T> service;
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
using System;
|
using AsbCloudApp.Data;
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using AsbCloudApp.Data;
|
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
@ -90,7 +90,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null || !wellService.IsCompanyInvolvedInWell((int)idCompany, idWell))
|
if (idCompany is null || !wellService.IsCompanyInvolvedInWell((int)idCompany, idWell))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var filesInfo = fileService.GetFilesInfo(idWell, 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())
|
||||||
@ -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, $"{idWell}", $"{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);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using AsbCloudApp.Data;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using AsbCloudApp.Data;
|
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
@ -10,7 +10,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[Authorize]
|
[Authorize]
|
||||||
public class FluidController : LastDataController<FluidDataDto>
|
public class FluidController : LastDataController<FluidDataDto>
|
||||||
{
|
{
|
||||||
public FluidController(ILastDataService<FluidDataDto> lastDataService,
|
public FluidController(ILastDataService<FluidDataDto> lastDataService,
|
||||||
IWellService wellService) : base(lastDataService, wellService)
|
IWellService wellService) : base(lastDataService, wellService)
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using AsbCloudApp.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using AsbCloudApp.Services;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using AsbCloudApp.Data;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using AsbCloudApp.Data;
|
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using AsbCloudApp.Data;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using AsbCloudApp.Data;
|
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
|
@ -75,7 +75,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (!wellService.IsCompanyInvolvedInWell((int)idCompany, idWell))
|
if (!wellService.IsCompanyInvolvedInWell((int)idCompany, idWell))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var id = reportService.CreateReport(idWell, idUser,
|
var id = reportService.CreateReport(idWell, idUser,
|
||||||
stepSeconds, format, begin, end, HandleReportProgressAsync, HandleReportNameAsync);
|
stepSeconds, format, begin, end, HandleReportProgressAsync, HandleReportNameAsync);
|
||||||
|
|
||||||
return Ok(id);
|
return Ok(id);
|
||||||
@ -102,7 +102,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (!wellService.IsCompanyInvolvedInWell((int)idCompany, idWell))
|
if (!wellService.IsCompanyInvolvedInWell((int)idCompany, idWell))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
// TODO: словарь content typoв
|
// TODO: словарь content typoв
|
||||||
var relativePath = Path.Combine(fileService.RootPath, $"{idWell}",
|
var relativePath = Path.Combine(fileService.RootPath, $"{idWell}",
|
||||||
$"{reportService.ReportCategoryId}", reportName);
|
$"{reportService.ReportCategoryId}", reportName);
|
||||||
return PhysicalFile(Path.GetFullPath(relativePath), "application/pdf", reportName);
|
return PhysicalFile(Path.GetFullPath(relativePath), "application/pdf", reportName);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
{
|
{
|
||||||
var idCompany = User.GetCompanyId();
|
var idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
if (!wellService.IsCompanyInvolvedInWell((int)idCompany, idWell))
|
if (!wellService.IsCompanyInvolvedInWell((int)idCompany, idWell))
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
@ -16,7 +11,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
public class WellSectionController : CrudController<WellSectionDto>
|
public class WellSectionController : CrudController<WellSectionDto>
|
||||||
{
|
{
|
||||||
public WellSectionController(ICrudService<WellSectionDto> service)
|
public WellSectionController(ICrudService<WellSectionDto> service)
|
||||||
:base(service)
|
: base(service)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,6 @@
|
|||||||
//using AutoMapper;
|
//using AutoMapper;
|
||||||
//using Microsoft.EntityFrameworkCore;
|
//using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using Mapster;
|
|
||||||
|
|
||||||
namespace ConsoleApp1
|
namespace ConsoleApp1
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user