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.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<WellStatDto> WellsStat { get; set; }
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
public class WellSectionDto: IId
|
||||
public class WellSectionDto : IId
|
||||
{
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using AsbCloudApp.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AsbCloudApp.Data;
|
||||
|
||||
namespace AsbCloudApp.Services
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AsbCloudApp.Services
|
||||
{
|
||||
|
@ -139,7 +139,8 @@ namespace AsbCloudDb.Model
|
||||
.HasConstraintName("t_well_t_telemetry_id_fk");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<RelationCompanyWell>(entity => {
|
||||
modelBuilder.Entity<RelationCompanyWell>(entity =>
|
||||
{
|
||||
|
||||
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> {
|
||||
new RelationCompanyWell{ IdWell = 1, IdCompany = 1},
|
||||
new RelationCompanyWell{ IdWell = 2, IdCompany = 1},
|
||||
|
@ -1,6 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
#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.Schema;
|
||||
|
||||
|
@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Mapster
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ namespace AsbCloudInfrastructure.Services.Cache
|
||||
|
||||
public int Refresh()
|
||||
{
|
||||
if(cached.Any())
|
||||
if (cached.Any())
|
||||
cached.Clear();
|
||||
var dbEntities = context.Set<TEntity>().ToList();
|
||||
cached.AddRange(dbEntities);
|
||||
|
@ -1,9 +1,9 @@
|
||||
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
|
||||
{
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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,13 +12,11 @@ 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<string, int> SaveFilesPropertiesToDb(int idWell, int idCategory,
|
||||
@ -26,8 +24,8 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
var fileIdsToNames = new Dictionary<string, int>();
|
||||
|
||||
foreach(var fileInfo in filesInfo)
|
||||
{
|
||||
foreach (var fileInfo in filesInfo)
|
||||
{
|
||||
var file = new File()
|
||||
{
|
||||
Name = fileInfo.fileName,
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -1,5 +1,5 @@
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudDb.Model;
|
||||
using System;
|
||||
|
||||
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.Linq;
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
.ToList();
|
||||
|
||||
var dtos = entities.Adapt<WellSection, WellSectionDto>(
|
||||
(s, d) => { d.SectionType = s.WellSectionType.Caption;});
|
||||
(s, d) => { d.SectionType = s.WellSectionType.Caption; });
|
||||
|
||||
return dtos;
|
||||
}
|
||||
|
@ -18,13 +18,13 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
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.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,
|
||||
|
@ -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<T> : ControllerBase
|
||||
where T: IId
|
||||
where T : IId
|
||||
{
|
||||
protected readonly ICrudService<T> service;
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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<WellSectionDto>
|
||||
{
|
||||
public WellSectionController(ICrudService<WellSectionDto> service)
|
||||
:base(service)
|
||||
: base(service)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,6 @@
|
||||
//using AutoMapper;
|
||||
//using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Mapster;
|
||||
|
||||
namespace ConsoleApp1
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user