74 lines
4.2 KiB
C#
74 lines
4.2 KiB
C#
using Microsoft.EntityFrameworkCore;
|
||
using PARR.DAL.Contracts;
|
||
using PARR.DAL.Models.AIHIT;
|
||
using PARR.DAL.Models.V1;
|
||
|
||
namespace PARR.DAL.Context
|
||
{
|
||
internal class DataContext : DbContext
|
||
{
|
||
public DataContext(DbContextOptions<DataContext> options) : base(options) { }
|
||
|
||
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; }
|
||
public DbSet<V1_Host> Hosts { get; set; }
|
||
public DbSet<V1_Job> Jobs { get; set; }
|
||
public DbSet<V1_JobJournal> JobJournals { get; set; }
|
||
public DbSet<V1_Application> Applications { get; set; }
|
||
public DbSet<V1_ApplicationType> ApplicationTypes { get; set; }
|
||
public DbSet<V1_ApplicationInHost> ApplicationsInHosts { get; set; }
|
||
public DbSet<Setting> Settings { get; set; }
|
||
public DbSet<RawDataEK> RawDataEKs { get; set; }
|
||
//public DbSet<Scheduler> Schedulers { get; set; }
|
||
|
||
//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));
|
||
|
||
modelBuilder.Entity<V1_JobMode>(f =>
|
||
{
|
||
f.HasData(
|
||
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() }
|
||
);
|
||
});
|
||
|
||
modelBuilder.Entity<V1_JobStatus>(f =>
|
||
{
|
||
f.HasData(
|
||
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 = "Задание выполнено" }
|
||
);
|
||
});
|
||
|
||
|
||
modelBuilder.Entity<V1_ApplicationType>(f =>
|
||
{
|
||
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 АИХ ИТ" }
|
||
);
|
||
});
|
||
|
||
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 = "Строка подключения к базе данных АИХ ИТ" },
|
||
new() { Id = new Guid("50F66704-4D26-4587-BB1E-DCA70C8F4B89"), DateCreated = dateCreated, DateModified = null, Group = "ResponsibleArea", Name = "ZAB", Value = "94-ЗАБ", Description = "Зона ответственности" },
|
||
new() { Id = new Guid("1FD43634-4A06-4237-9727-EDFA6F3EEBE8"), DateCreated = dateCreated, DateModified = null, Group = "ResponsibleArea", Name = "DVS", Value = "96-ДВС", Description = "Зона ответственности" }
|
||
);
|
||
});
|
||
}
|
||
|
||
|
||
|
||
}
|
||
}
|