From 12a73a4e21c85bdcc834d21a8e4b33d818977e6c Mon Sep 17 00:00:00 2001 From: KharchenkoVV <vv.harchenko@autodrilling.ru> Date: Fri, 13 Aug 2021 15:35:03 +0500 Subject: [PATCH] Renamed 'TelemetryOperation' model to 'Operation' --- AsbCloudDb/Model/{TelemetryOperation.cs => Operation.cs} | 7 +++++-- AsbCloudDb/Model/TelemetryAnalysis.cs | 4 ++-- AsbCloudInfrastructure/Services/AnalyticsService.cs | 6 +++--- .../Services/TelemetryOperationDetector.cs | 2 +- .../Services/TelemetryOperationDetectorService.cs | 6 +++--- 5 files changed, 14 insertions(+), 11 deletions(-) rename AsbCloudDb/Model/{TelemetryOperation.cs => Operation.cs} (75%) diff --git a/AsbCloudDb/Model/TelemetryOperation.cs b/AsbCloudDb/Model/Operation.cs similarity index 75% rename from AsbCloudDb/Model/TelemetryOperation.cs rename to AsbCloudDb/Model/Operation.cs index b24b69bc..a41015bb 100644 --- a/AsbCloudDb/Model/TelemetryOperation.cs +++ b/AsbCloudDb/Model/Operation.cs @@ -5,8 +5,8 @@ using System.ComponentModel.DataAnnotations.Schema; namespace AsbCloudDb.Model { - [Table("t_telemetry_operation"), Comment("Справочник операций на скважине")] - public class TelemetryOperation + [Table("t_operations"), Comment("Справочник операций на скважине")] + public class Operation { [Key] [Column("id")] @@ -18,6 +18,9 @@ namespace AsbCloudDb.Model [Column("name"), Comment("Название операции")] public string Name { get; set; } + [Column("code"), Comment("Код операции")] + public int Code { get; set; } + [InverseProperty(nameof(TelemetryAnalysis.Operation))] public virtual ICollection<TelemetryAnalysis> Analysis { get; set; } } diff --git a/AsbCloudDb/Model/TelemetryAnalysis.cs b/AsbCloudDb/Model/TelemetryAnalysis.cs index 1c705d5f..2ef09d85 100644 --- a/AsbCloudDb/Model/TelemetryAnalysis.cs +++ b/AsbCloudDb/Model/TelemetryAnalysis.cs @@ -28,8 +28,8 @@ namespace AsbCloudDb.Model [JsonIgnore] [ForeignKey(nameof(IdOperation))] - [InverseProperty(nameof(Model.TelemetryOperation.Analysis))] - public virtual TelemetryOperation Operation { get; set; } + [InverseProperty(nameof(Model.Operation.Analysis))] + public virtual Operation Operation { get; set; } [Column("unix_date", TypeName = "bigint"), Comment("Unix timestamp для Linq запросов с вычислением дат")] diff --git a/AsbCloudInfrastructure/Services/AnalyticsService.cs b/AsbCloudInfrastructure/Services/AnalyticsService.cs index 5a7813a1..e1a393f0 100644 --- a/AsbCloudInfrastructure/Services/AnalyticsService.cs +++ b/AsbCloudInfrastructure/Services/AnalyticsService.cs @@ -17,9 +17,9 @@ namespace AsbCloudInfrastructure.Services private readonly IAsbCloudDbContext db; private readonly ITelemetryService telemetryService; private readonly ISaubDataCache saubDataCache; - private readonly CacheTable<TelemetryOperation> cacheOperations; + private readonly CacheTable<Operation> cacheOperations; private readonly TelemetryOperationDetectorService operationDetectorService; - private readonly IEnumerable<TelemetryOperation> operations; + private readonly IEnumerable<Operation> operations; public AnalyticsService(IAsbCloudDbContext db, ITelemetryService telemetryService, ISaubDataCache saubDataCache, CacheDb cacheDb) @@ -27,7 +27,7 @@ namespace AsbCloudInfrastructure.Services this.db = db; this.telemetryService = telemetryService; this.saubDataCache = saubDataCache; - cacheOperations = cacheDb.GetCachedTable<TelemetryOperation>((AsbCloudDbContext)db); + cacheOperations = cacheDb.GetCachedTable<Operation>((AsbCloudDbContext)db); operations = cacheOperations.Select(c => true); operationDetectorService = new TelemetryOperationDetectorService(operations); } diff --git a/AsbCloudInfrastructure/Services/TelemetryOperationDetector.cs b/AsbCloudInfrastructure/Services/TelemetryOperationDetector.cs index aecbc8ae..8ed66629 100644 --- a/AsbCloudInfrastructure/Services/TelemetryOperationDetector.cs +++ b/AsbCloudInfrastructure/Services/TelemetryOperationDetector.cs @@ -7,7 +7,7 @@ namespace AsbCloudInfrastructure.Services public class TelemetryOperationDetector { public int Order { get; set; } - public TelemetryOperation Operation { get; set; } + public Operation Operation { get; set; } public Func<TelemetryAnalysisDto, bool> Detect { get; set; } } } diff --git a/AsbCloudInfrastructure/Services/TelemetryOperationDetectorService.cs b/AsbCloudInfrastructure/Services/TelemetryOperationDetectorService.cs index 8a106ca7..5c676114 100644 --- a/AsbCloudInfrastructure/Services/TelemetryOperationDetectorService.cs +++ b/AsbCloudInfrastructure/Services/TelemetryOperationDetectorService.cs @@ -9,7 +9,7 @@ namespace AsbCloudInfrastructure.Services { private readonly IEnumerable<TelemetryOperationDetector> detectors; - public TelemetryOperationDetectorService(IEnumerable<TelemetryOperation> operations) + public TelemetryOperationDetectorService(IEnumerable<Operation> operations) { detectors = new List<TelemetryOperationDetector>() { @@ -180,8 +180,8 @@ namespace AsbCloudInfrastructure.Services }; } - public TelemetryOperation DetectOperation(TelemetryAnalysisDto data) => + public Operation DetectOperation(TelemetryAnalysisDto data) => detectors.OrderBy(d => d.Order).First(o => o.Detect(data)).Operation - ?? new TelemetryOperation { Id = 1, Name = "Невозможно определить операцию" }; + ?? new Operation { Id = 1, Name = "Невозможно определить операцию" }; } }