forked from ddrilling/AsbCloudServer
add db model and edit db context
This commit is contained in:
parent
dc8aa67344
commit
4014dd03f6
@ -1,4 +1,5 @@
|
||||
using AsbCloudDb.Model.Subsystems;
|
||||
using AsbCloudDb.Model.GTR;
|
||||
using AsbCloudDb.Model.Subsystems;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -55,6 +56,11 @@ namespace AsbCloudDb.Model
|
||||
|
||||
public virtual DbSet<TelemetryWirelineRunOut> TelemetryWirelineRunOut => Set<TelemetryWirelineRunOut>();
|
||||
|
||||
// GTR WITS
|
||||
public DbSet<WitsFloat> WitsFloat => Set<WitsFloat>();
|
||||
public DbSet<WitsInt> WitsInt => Set<WitsInt>();
|
||||
public DbSet<WitsStr> WitsStr => Set<WitsStr>();
|
||||
|
||||
// WITS
|
||||
public DbSet<WITS.Record1> Record1 => Set<WITS.Record1>();
|
||||
public DbSet<WITS.Record7> Record7 => Set<WITS.Record7>();
|
||||
@ -334,6 +340,14 @@ namespace AsbCloudDb.Model
|
||||
.HasJsonConversion();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<WitsBase>(entity =>
|
||||
{
|
||||
entity.HasKey(
|
||||
nameof(ITelemetryData.IdTelemetry),
|
||||
nameof(WitsBase.IdRecord),
|
||||
nameof(WitsBase.IdItem));
|
||||
});
|
||||
|
||||
|
||||
modelBuilder.Entity<UserSetting>(entity =>
|
||||
{
|
||||
|
25
AsbCloudDb/Model/GTR/WitsBase.cs
Normal file
25
AsbCloudDb/Model/GTR/WitsBase.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AsbCloudDb.Model.GTR
|
||||
{
|
||||
[Table("t_wits_base"), Comment("таблица данных ГТИ")]
|
||||
public abstract class WitsBase : ITelemetryData
|
||||
{
|
||||
[Column("id_telemetry")]
|
||||
public int IdTelemetry { get; set; }
|
||||
|
||||
[Column("id_record")]
|
||||
public int IdRecord { get; set; }
|
||||
|
||||
[Column("id_item")]
|
||||
public int IdItem { get; set; }
|
||||
|
||||
[Column("date", TypeName = "timestamp with time zone")]
|
||||
public DateTimeOffset DateTime { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdTelemetry))]
|
||||
public virtual Telemetry? Telemetry { get; set; }
|
||||
}
|
||||
}
|
12
AsbCloudDb/Model/GTR/WitsFloat.cs
Normal file
12
AsbCloudDb/Model/GTR/WitsFloat.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AsbCloudDb.Model.GTR
|
||||
{
|
||||
[Table("t_wits_int"), Comment("таблица данных ГТИ с типом значения float")]
|
||||
public class WitsFloat : WitsBase
|
||||
{
|
||||
[Column("value")]
|
||||
public float? Value { get; set; }
|
||||
}
|
||||
}
|
17
AsbCloudDb/Model/GTR/WitsInt.cs
Normal file
17
AsbCloudDb/Model/GTR/WitsInt.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AsbCloudDb.Model.GTR
|
||||
{
|
||||
[Table("t_wits_int"), Comment("таблица данных ГТИ с типом значения int16 int32")]
|
||||
public class WitsInt : WitsBase
|
||||
{
|
||||
[Column("Value", TypeName = "bigint")]
|
||||
public int? Value { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
14
AsbCloudDb/Model/GTR/WitsStr.cs
Normal file
14
AsbCloudDb/Model/GTR/WitsStr.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AsbCloudDb.Model.GTR
|
||||
{
|
||||
[Table("t_wits_string"), Comment("таблица данных ГТИ с типом значения string")]
|
||||
public class WitsStr: WitsBase
|
||||
{
|
||||
[Column("value")]
|
||||
[StringLength(64)]
|
||||
public string? Value { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using AsbCloudDb.Model.Subsystems;
|
||||
using AsbCloudDb.Model.GTR;
|
||||
using AsbCloudDb.Model.Subsystems;
|
||||
using AsbCloudDb.Model.WITS;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
@ -47,6 +48,9 @@ namespace AsbCloudDb.Model
|
||||
DbSet<WellOperationCategory> WellOperationCategories { get; }
|
||||
DbSet<WellSectionType> WellSectionTypes { get; }
|
||||
DbSet<WellType> WellTypes { get; }
|
||||
DbSet<WitsFloat> WitsFloat { get; }
|
||||
DbSet<WitsInt> WitsInt { get; }
|
||||
DbSet<WitsStr> WitsStr { get; }
|
||||
DbSet<Driller> Drillers { get; }
|
||||
DbSet<Schedule> Schedule { get; }
|
||||
DbSet<OperationValue> OperationValues { get; }
|
||||
|
Loading…
Reference in New Issue
Block a user