Move entity schema
Move classes for work with DB in root dir. Fix problems with num cycles, after change to Enum
This commit is contained in:
		@@ -1,23 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.ComponentModel.DataAnnotations.Schema;
 | 
			
		||||
using System.ComponentModel.DataAnnotations;
 | 
			
		||||
 | 
			
		||||
namespace GenCycleVDP.Db
 | 
			
		||||
{
 | 
			
		||||
    [Table("Cycles")]
 | 
			
		||||
    internal class DbCycle
 | 
			
		||||
    {
 | 
			
		||||
        [Column("idCycle"), Required, Key]
 | 
			
		||||
        public int IdCycle { get; set; }
 | 
			
		||||
        [Column("numVdp")]
 | 
			
		||||
        public int NumVdp { get; set; }
 | 
			
		||||
        [Column("numCycle")]
 | 
			
		||||
        public int NumCycle { get; set; }
 | 
			
		||||
        [Column("factStart")]
 | 
			
		||||
        public DateTime FactStart { get; set; }
 | 
			
		||||
        [Column("thinkEnd")]
 | 
			
		||||
        public DateTime ThinkEnd { get; set; }
 | 
			
		||||
        [Column("factEnd")]
 | 
			
		||||
        public DateTime FactEnd { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,23 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
using Microsoft.EntityFrameworkCore;
 | 
			
		||||
 | 
			
		||||
namespace GenCycleVDP.Db
 | 
			
		||||
{
 | 
			
		||||
    internal class DbFurnace : DbContext
 | 
			
		||||
    {
 | 
			
		||||
        public DbSet<DbCycle> Cycles { get; set; }
 | 
			
		||||
        public DbFurnace()
 | 
			
		||||
        {
 | 
			
		||||
            Database.EnsureCreated();
 | 
			
		||||
        }
 | 
			
		||||
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 | 
			
		||||
        {
 | 
			
		||||
            optionsBuilder.UseMySql("server=127.0.0.1;user=diplom;password=diplom;database=VDPCycles;", new MySqlServerVersion(new Version(8, 0)));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        protected override void OnModelCreating(ModelBuilder modelBuilder)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -2,6 +2,7 @@
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using GenCycleVDP.Resources;
 | 
			
		||||
using DbCycleVDP;
 | 
			
		||||
 | 
			
		||||
namespace GenCycleVDP
 | 
			
		||||
{
 | 
			
		||||
@@ -78,7 +79,7 @@ namespace GenCycleVDP
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                using var db = new Db.DbFurnace();
 | 
			
		||||
                using var db = new DbFurnace();
 | 
			
		||||
                var tmp = (from u in db.Cycles
 | 
			
		||||
                           where
 | 
			
		||||
                              u.NumVdp == vdp
 | 
			
		||||
@@ -122,19 +123,17 @@ namespace GenCycleVDP
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                using (var db = new Db.DbFurnace())
 | 
			
		||||
                using var db = new DbFurnace();
 | 
			
		||||
                var tmp = new TableCycle()
 | 
			
		||||
                {
 | 
			
		||||
                    var tmp = new Db.DbCycle()
 | 
			
		||||
                    {
 | 
			
		||||
                        NumVdp = vdp,
 | 
			
		||||
                        NumCycle = (int)currCycle,
 | 
			
		||||
                        FactStart = factStart,
 | 
			
		||||
                        FactEnd = factEnd,
 | 
			
		||||
                        ThinkEnd = thinkEnd
 | 
			
		||||
                    };
 | 
			
		||||
                    db.Cycles.Add(tmp);
 | 
			
		||||
                    db.SaveChanges();
 | 
			
		||||
                }
 | 
			
		||||
                    NumVdp = vdp,
 | 
			
		||||
                    NumCycle = (int)currCycle,
 | 
			
		||||
                    FactStart = factStart,
 | 
			
		||||
                    FactEnd = factEnd,
 | 
			
		||||
                    ThinkEnd = thinkEnd
 | 
			
		||||
                };
 | 
			
		||||
                db.Cycles.Add(tmp);
 | 
			
		||||
                db.SaveChanges();
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,11 @@
 | 
			
		||||
    <Nullable>enable</Nullable>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Compile Include="..\DbCycleVDP\DbFurnace.cs" Link="Db/DbFurnace.cs" />
 | 
			
		||||
	  <Compile Include="..\DbCycleVDP\TableCycle.cs" Link="Db/TableCycle.cs" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,6 @@ namespace GenCycleVDP
 | 
			
		||||
                a.Start();
 | 
			
		||||
                tasks.Add(a);
 | 
			
		||||
            }
 | 
			
		||||
            Task.Delay(1000 * 5).Wait();
 | 
			
		||||
 | 
			
		||||
            int count = 0;
 | 
			
		||||
            while (!isExiting)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
namespace GenCycleVDP.Resources
 | 
			
		||||
{
 | 
			
		||||
    public enum CycleStatus : ushort
 | 
			
		||||
    public enum CycleStatus : int
 | 
			
		||||
    {
 | 
			
		||||
        EndTechCycle = 0,
 | 
			
		||||
        LoadUnload = 1,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user