2023-05-17 16:30:13 +10:00
using Microsoft.EntityFrameworkCore ;
2023-06-16 15:00:11 +10:00
using PARR.DAL.Contracts ;
2023-08-14 15:24:57 +10:00
using PARR.DAL.Models ;
2023-08-11 09:21:54 +10:00
using PARR.DAL.Models.AIHIT ;
2023-08-10 16:43:01 +10:00
using PARR.DAL.Models.V1 ;
2023-05-17 16:30:13 +10:00
namespace PARR.DAL.Context
{
2023-09-04 12:17:50 +10:00
internal class DataContext : DbContext
2023-05-17 16:30:13 +10:00
{
public DataContext ( DbContextOptions < DataContext > options ) : base ( options ) { }
2023-08-10 10:14:41 +10:00
public DbSet < V1_JobType > JobTypes { get ; set ; }
public DbSet < V1_JobCategory > JobCategories { get ; set ; }
public DbSet < V1_JobMode > JobModes { get ; set ; }
public DbSet < V1_JobStatus > JobStatuses { get ; set ; }
2023-08-14 15:24:57 +10:00
public DbSet < V1_Host > V1_Hosts { get ; set ; }
public DbSet < Host > Hosts { get ; set ; }
2023-08-10 10:14:41 +10:00
public DbSet < V1_Job > Jobs { get ; set ; }
public DbSet < V1_JobJournal > JobJournals { get ; set ; }
2023-08-14 15:24:57 +10:00
public DbSet < Application > Applications { get ; set ; }
public DbSet < ApplicationType > ApplicationTypes { get ; set ; }
public DbSet < ApplicationInHost > ApplicationsInHosts { get ; set ; }
public DbSet < V1_Application > V1_Applications { get ; set ; }
public DbSet < V1_ApplicationType > V1_ApplicationTypes { get ; set ; }
public DbSet < V1_ApplicationInHost > V1_ApplicationsInHosts { get ; set ; }
2023-08-11 09:21:54 +10:00
public DbSet < Setting > Settings { get ; set ; }
public DbSet < RawDataEK > RawDataEKs { get ; set ; }
2023-09-01 12:40:41 +10:00
public DbSet < Template > Templates { get ; set ; }
2023-06-20 12:29:58 +10:00
//public DbSet<Scheduler> Schedulers { get; set; }
2023-06-13 13:57:55 +10:00
2023-06-16 15:00:11 +10:00
//todo init application type+check migrations
protected override void OnModelCreating ( ModelBuilder modelBuilder )
{
base . OnModelCreating ( modelBuilder ) ;
var dateCreated = new DateTimeOffset ( 2023 , 05 , 01 , 0 , 0 , 0 , new TimeSpan ( 0 ) ) ;
2023-08-10 10:14:41 +10:00
modelBuilder . Entity < V1_JobMode > ( f = >
2023-06-16 15:00:11 +10:00
{
f . HasData (
2023-06-20 16:54:38 +10:00
new ( ) { Id = new Guid ( "FBA4202C-5BAD-49C4-B076-D1CA6E1FB158" ) , DateCreated = dateCreated , DateModified = null , Name = JobModeEnum . auto . ToString ( ) } ,
new ( ) { Id = new Guid ( "7516B952-510D-4AAA-971C-A14B184FC1D5" ) , DateCreated = dateCreated , DateModified = null , Name = JobModeEnum . manual . ToString ( ) }
2023-06-16 15:00:11 +10:00
) ;
} ) ;
2023-08-10 10:14:41 +10:00
modelBuilder . Entity < V1_JobStatus > ( f = >
2023-06-20 12:29:58 +10:00
{
f . HasData (
2023-06-20 16:54:38 +10:00
new ( ) { Id = new Guid ( "EDEF6DC3-ADAD-4C77-8AD1-63BB9052355A" ) , DateCreated = dateCreated , DateModified = null , Name = JobStatusEnum . started . ToString ( ) , Description = "Задание запущено" } ,
new ( ) { Id = new Guid ( "7B945EB6-D885-4570-AFF5-8866F1F75FF2" ) , DateCreated = dateCreated , DateModified = null , Name = JobStatusEnum . finished . ToString ( ) , Description = "Задание выполнено" }
2023-06-20 12:29:58 +10:00
) ;
} ) ;
2023-06-16 15:00:11 +10:00
2023-08-14 15:24:57 +10:00
modelBuilder . Entity < ApplicationType > ( f = >
2023-06-16 15:00:11 +10:00
{
f . HasData (
new ( ) { Id = new Guid ( "32c28386-6f13-4f7b-8508-be165b7fabdb" ) , DateCreated = dateCreated , DateModified = null , Name = ApplicationTypesEnum . APP . ToString ( ) , Description = "Поле СП xml АИХ ИТ" } ,
new ( ) { Id = new Guid ( "7848a96c-cdee-48c1-a786-de9cb889723a" ) , DateCreated = dateCreated , DateModified = null , Name = ApplicationTypesEnum . OS . ToString ( ) , Description = "Поле О С xml АИХ ИТ" } ,
new ( ) { Id = new Guid ( "aae2636f-b93a-42dc-873e-0764a90a0a40" ) , DateCreated = dateCreated , DateModified = null , Name = ApplicationTypesEnum . DB . ToString ( ) , Description = "Поле СУБД xml АИХ ИТ" }
) ;
} ) ;
2023-08-11 09:21:54 +10:00
modelBuilder . Entity < Models . AIHIT . Setting > ( f = >
{
f . HasData (
new ( ) { Id = new Guid ( "1AD12210-BE62-459A-AA6C-FDA7648503F7" ) , DateCreated = dateCreated , DateModified = null , Group = null , Name = "ConnectionString" , Value = @"Data Source=10.248.19.97; Initial Catalog=mao2;User ID=awhit-ipp-parr;pwd=ET3h$9y1LH#D;TrustServerCertificate=true;" , Description = "Строка подключения к базе данных АИХ ИТ" } ,
2023-08-14 11:38:59 +10:00
new ( ) { Id = new Guid ( "50F66704-4D26-4587-BB1E-DCA70C8F4B89" ) , DateCreated = dateCreated , DateModified = null , Group = AIHTITSettings . RespAreaGroupName , Name = "ZAB" , Value = "94-ЗАБ" , Description = "Зона ответственности" } ,
new ( ) { Id = new Guid ( "1FD43634-4A06-4237-9727-EDFA6F3EEBE8" ) , DateCreated = dateCreated , DateModified = null , Group = AIHTITSettings . RespAreaGroupName , Name = "DVS" , Value = "96-ДВС" , Description = "Зона ответственности" } ,
new ( ) { Id = new Guid ( "77C73C0A-8E4D-4676-B6E2-6A112F20E346" ) , DateCreated = dateCreated , DateModified = null , Group = AIHTITSettings . StatusGroupName , Name = "Exploitation" , Value = "3-В эксплуатации" , Description = "Статус актуальных ЭК" }
2023-08-11 09:21:54 +10:00
) ;
} ) ;
2023-06-16 15:00:11 +10:00
}
2023-05-17 16:30:13 +10:00
}
}