From 61205fa7c191323769eb83791dd47bce098d28b4 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Wed, 21 Jul 2021 17:59:18 +0500 Subject: [PATCH] =?UTF-8?q?=D0=92=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B5?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B0=20?= =?UTF-8?q?=D0=B0=D0=B2=D1=82=D0=BE=D0=B7=D0=B0=D0=BF=D0=BE=D0=BB=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=80=D0=B0=D0=B7=D0=B1=D0=B8=D1=82?= =?UTF-8?q?=D0=BE=20=D0=BD=D0=B0=20FillData()=20=D0=B8=20FillDemoData?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudDb/Model/AsbCloudDbContext.cs | 293 +++++++++++++++++++------- 1 file changed, 221 insertions(+), 72 deletions(-) diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index 2055d509..e8c5e104 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -113,29 +113,6 @@ namespace AsbCloudDb.Model .HasConstraintName("t_event_t_telemetry_id_fk"); }); - modelBuilder.Entity(entity => - { - entity.HasData(new List{ - new UserRole{ Id = 1, Caption = "Администратор", }, - }); - }); - - modelBuilder.Entity(entity => - { - entity.HasData(new List{ - new CompanyType{ Id = 1, Caption = "Недрапользователь", }, - new CompanyType{ Id = 2, Caption = "Буровой подрядчик", }, - new CompanyType{ Id = 3, Caption = "Сервис автоматизации бурения", }, - }); - }); - - modelBuilder.Entity(entity => - { - entity.HasData(new List{ - new Company{ Id = 1, Caption = "\"ООО\" АСБ", IdCompanyType = 3}, - }); - }); - modelBuilder.Entity(entity => { entity.HasOne(d => d.Company) @@ -145,18 +122,6 @@ namespace AsbCloudDb.Model entity.HasIndex(d => d.Login) .IsUnique(); - - entity.HasData(new List{ - new User{ - Id = 1, - IdCompany = 1, - IdRole = 1, - Level = int.MaxValue, - Login = "dev", - PasswordHash = "Vlcj|4fa529103dde7ff72cfe76185f344d4aa87931f8e1b2044e8a7739947c3d18923464eaad93843e4f809c5e126d013072", // dev - Name = "Разработчик", - }, - }); }); modelBuilder.Entity(entity => @@ -170,8 +135,6 @@ namespace AsbCloudDb.Model .WithOne(p => p.Well) .HasForeignKey(d => d.IdTelemetry) .HasConstraintName("t_well_t_telemetry_id_fk"); - - }); modelBuilder.Entity(entity => { @@ -190,54 +153,37 @@ namespace AsbCloudDb.Model }); FillData(modelBuilder); + FillDemoData(modelBuilder); } private static void FillData(ModelBuilder modelBuilder) { - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { - entity.HasData(new List { - new Deposit{Id = 1, Caption = "м/р 1", Latitude = 60.8705722222222, Longitude = 70.3811888888889 }, + entity.HasData(new List{ + new UserRole{ Id = 1, Caption = "Администратор", }, }); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { - entity.HasData(new List { - new Cluster{Id = 1, Caption = "к221", IdDeposit = 1, Latitude = 60.8705722222222, Longitude = 70.3811888888889}, - new Cluster{Id = 2, Caption = "к151", IdDeposit = 1, Latitude = 60.8205750000000, Longitude = 70.1343833333334}, - new Cluster{Id = 3, Caption = "к611", IdDeposit = 1, Latitude = 60.8100666666667, Longitude = 69.7778388888889}, - new Cluster{Id = 4, Caption = "к203", IdDeposit = 1, Latitude = 60.8928805555556, Longitude = 70.3272055555556}, - new Cluster{Id = 5, Caption = "к39.1", IdDeposit = 1, Latitude = 60.6672055555556, Longitude = 69.6603861111111}, + entity.HasData(new List{ + new User{ + Id = 1, + IdCompany = 1, + IdRole = 1, + Level = int.MaxValue, + Login = "dev", + PasswordHash = "Vlcj|4fa529103dde7ff72cfe76185f344d4aa87931f8e1b2044e8a7739947c3d18923464eaad93843e4f809c5e126d013072", // dev + Name = "Разработчик", + }, }); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { - entity.HasData(new List { - new Well{Id = 1, IdCluster = 1, Caption = "скв 42669", Latitude = 60.8705722222222, Longitude = 70.3811888888889}, - new Well{Id = 2, IdCluster = 1, Caption = "скв 16311", Latitude = 60.8705722222222, Longitude = 70.3811888888889}, - new Well{Id = 3, IdCluster = 2, Caption = "скв 16315", Latitude = 60.8205750000000, Longitude = 70.1343833333334}, - new Well{Id = 4, IdCluster = 2, Caption = "скв 16318", Latitude = 60.8205750000000, Longitude = 70.1343833333334}, - new Well{Id = 5, IdCluster = 3, Caption = "скв 16310", Latitude = 60.8100666666667, Longitude = 69.7778388888889}, - new Well{Id = 6, IdCluster = 4, Caption = "скв 16316", Latitude = 60.8928805555556, Longitude = 70.3272055555556}, - new Well{Id = 7, IdCluster = 5, Caption = "скв 16312", Latitude = 60.6672055555556, Longitude = 69.6603861111111}, - new Well{Id = 8, IdCluster = 5, Caption = "скв 16313", Latitude = 60.6672055555556, Longitude = 69.6603861111111}, - new Well{Id = 9, IdCluster = 5, Caption = "скв 16314", Latitude = 60.6672055555556, Longitude = 69.6603861111111}, - }); - }); - - modelBuilder.Entity(entity => { - entity.HasData(new List { - new RelationCompanyWell{ IdWell = 1, IdCompany = 1}, - new RelationCompanyWell{ IdWell = 2, IdCompany = 1}, - new RelationCompanyWell{ IdWell = 3, IdCompany = 1}, - new RelationCompanyWell{ IdWell = 4, IdCompany = 1}, - new RelationCompanyWell{ IdWell = 5, IdCompany = 1}, - new RelationCompanyWell{ IdWell = 6, IdCompany = 1}, - new RelationCompanyWell{ IdWell = 7, IdCompany = 1}, - new RelationCompanyWell{ IdWell = 8, IdCompany = 1}, - new RelationCompanyWell{ IdWell = 9, IdCompany = 1}, + entity.HasData(new List{ + new Company{ Id = 1, Caption = "\"ООО\" АСБ", IdCompanyType = 3}, }); }); @@ -265,6 +211,209 @@ namespace AsbCloudDb.Model }); } + private static void FillDemoData(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.HasData(new List{ + new CompanyType{ Id = 1, Caption = "Недрапользователь", }, + new CompanyType{ Id = 2, Caption = "Буровой подрядчик", }, + new CompanyType{ Id = 3, Caption = "Сервис автоматизации бурения", }, + }); + }); + + modelBuilder.Entity(entity => + { + entity.HasData(new List { + new Deposit{Id = 1, Caption = "м/р 1", Latitude = 60.8705722222222, Longitude = 70.3811888888889 }, + }); + }); + + modelBuilder.Entity(entity => + { + entity.HasData(new List { + new Cluster{Id = 1, Caption = "к39.1", IdDeposit = 1, Latitude = 60.8705722222222, Longitude = 70.3811888888889}, + new Cluster{Id = 2, Caption = "к151", IdDeposit = 1, Latitude = 60.8205750000000, Longitude = 70.1343833333334}, + new Cluster{Id = 3, Caption = "к611", IdDeposit = 1, Latitude = 60.8100666666667, Longitude = 69.7778388888889}, + new Cluster{Id = 4, Caption = "к203", IdDeposit = 1, Latitude = 60.8928805555556, Longitude = 70.3272055555556}, + new Cluster{Id = 5, Caption = "к221", IdDeposit = 1, Latitude = 60.6672055555556, Longitude = 69.6603861111111}, + }); + }); + + modelBuilder.Entity(entity => + { + entity.HasData(new List { + new Well{Id = 1, IdCluster = 1, Caption = "скв 16314", Latitude = 60.8705722222222, Longitude = 70.3811888888889}, + new Well{Id = 2, IdCluster = 1, Caption = "скв 16311", Latitude = 60.8705722222222, Longitude = 70.3811888888889}, + new Well{Id = 3, IdCluster = 2, Caption = "скв 16315", Latitude = 60.8205750000000, Longitude = 70.1343833333334}, + new Well{Id = 4, IdCluster = 2, Caption = "скв 16318", Latitude = 60.8205750000000, Longitude = 70.1343833333334}, + new Well{Id = 5, IdCluster = 3, Caption = "скв 16310", Latitude = 60.8100666666667, Longitude = 69.7778388888889}, + new Well{Id = 6, IdCluster = 4, Caption = "скв 16316", Latitude = 60.8928805555556, Longitude = 70.3272055555556}, + new Well{Id = 7, IdCluster = 5, Caption = "скв 16312", Latitude = 60.6672055555556, Longitude = 69.6603861111111}, + new Well{Id = 8, IdCluster = 5, Caption = "скв 16313", Latitude = 60.6672055555556, Longitude = 69.6603861111111}, + new Well{Id = 9, IdCluster = 5, Caption = "скв 42669", Latitude = 60.6672055555556, Longitude = 69.6603861111111}, + }); + }); + + modelBuilder.Entity(entity => + { + entity.HasData(new List{ + new Telemetry{ + Id = 1, + RemoteUid = "123", + Info = new TelemetryInfo + { + Well = "1", + Cluster = "1", + Comment = "", + Deposit = "1", + Customer = "1", + HmiVersion = "1", + PlcVersion = "1", + TimeZoneId = "1", + DrillingStartDate = DateTime.Parse("2021-06-29T12:01:19.000000"), + TimeZoneOffsetTotalHours = 5.0 + }, + } + }); + }); + + modelBuilder.Entity(entity => { + entity.HasData(new List { + new RelationCompanyWell{ IdWell = 1, IdCompany = 1}, + new RelationCompanyWell{ IdWell = 2, IdCompany = 1}, + new RelationCompanyWell{ IdWell = 3, IdCompany = 1}, + new RelationCompanyWell{ IdWell = 4, IdCompany = 1}, + new RelationCompanyWell{ IdWell = 5, IdCompany = 1}, + new RelationCompanyWell{ IdWell = 6, IdCompany = 1}, + new RelationCompanyWell{ IdWell = 7, IdCompany = 1}, + new RelationCompanyWell{ IdWell = 8, IdCompany = 1}, + new RelationCompanyWell{ IdWell = 9, IdCompany = 1}, + }); + }); + + modelBuilder.Entity(entity => + { + entity.HasData(new List{ + new TelemetryAnalysis + { + Id = 1, + IdTelemetry = 1, + IdOperation = 17, + UnixDate = 1626870355, + DurationSec = 10, + OperationStartDepth = null, + OperationEndDepth = 206, + IsWellDepthIncreasing = false, + IsWellDepthDecreasing = false, + IsBitPositionIncreasing = false, + IsBitPositionDecreasing = false, + IsBitPositionLt20 = true, + IsBlockPositionIncreasing = false, + IsBlockPositionDecreasing = false, + IsRotorSpeedLt3 = true, + IsRotorSpeedGt3 = false, + IsPressureLt20 = true, + IsPressureGt20 = false, + IsHookWeightNotChanges = true, + IsHookWeightLt3 = true + }, + new TelemetryAnalysis + { + Id = 2, + IdTelemetry = 1, + IdOperation = 8, + UnixDate = 1626870364, + DurationSec = 6, + OperationStartDepth = 206, + OperationEndDepth = 206, + IsWellDepthIncreasing = false, + IsWellDepthDecreasing = false, + IsBitPositionIncreasing = true, + IsBitPositionDecreasing = false, + IsBitPositionLt20 = true, + IsBlockPositionIncreasing = true, + IsBlockPositionDecreasing = false, + IsRotorSpeedLt3 = true, + IsRotorSpeedGt3 = false, + IsPressureLt20 = true, + IsPressureGt20 = false, + IsHookWeightNotChanges = true, + IsHookWeightLt3 = true + }, + new TelemetryAnalysis + { + Id = 3, + IdTelemetry = 1, + IdOperation = 10, + UnixDate = 1626870370, + DurationSec = 2, + OperationStartDepth = null, + OperationEndDepth = 206, + IsWellDepthIncreasing = false, + IsWellDepthDecreasing = false, + IsBitPositionIncreasing = false, + IsBitPositionDecreasing = true, + IsBitPositionLt20 = true, + IsBlockPositionIncreasing = false, + IsBlockPositionDecreasing = true, + IsRotorSpeedLt3 = true, + IsRotorSpeedGt3 = false, + IsPressureLt20 = true, + IsPressureGt20 = false, + IsHookWeightNotChanges = true, + IsHookWeightLt3 = true + }, + new TelemetryAnalysis + { + Id = 4, + IdTelemetry = 1, + IdOperation = 17, + UnixDate = 1626870372, + DurationSec = 7, + OperationStartDepth = 206, + OperationEndDepth = 206, + IsWellDepthIncreasing = false, + IsWellDepthDecreasing = false, + IsBitPositionIncreasing = false, + IsBitPositionDecreasing = false, + IsBitPositionLt20 = true, + IsBlockPositionIncreasing = false, + IsBlockPositionDecreasing = false, + IsRotorSpeedLt3 = true, + IsRotorSpeedGt3 = false, + IsPressureLt20 = true, + IsPressureGt20 = false, + IsHookWeightNotChanges = true, + IsHookWeightLt3 = true + }, + new TelemetryAnalysis + { + Id = 5, + IdTelemetry = 1, + IdOperation = 8, + UnixDate = 1626870379, + DurationSec = 7, + OperationStartDepth = 206, + OperationEndDepth = 206, + IsWellDepthIncreasing = false, + IsWellDepthDecreasing = false, + IsBitPositionIncreasing = true, + IsBitPositionDecreasing = false, + IsBitPositionLt20 = true, + IsBlockPositionIncreasing = true, + IsBlockPositionDecreasing = false, + IsRotorSpeedLt3 = true, + IsRotorSpeedGt3 = false, + IsPressureLt20 = true, + IsPressureGt20 = false, + IsHookWeightNotChanges = true, + IsHookWeightLt3 = true + } + }); + }); + } + public IQueryable GetWellsForCompany(int idCompany) { return from well in Wells