Лабораторная_6
This commit is contained in:
parent
08b8e638f5
commit
a1f91406fa
@ -44,8 +44,10 @@ namespace RenovationWorkView
|
|||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["RepairId"].Visible = false;
|
dataGridView.Columns["RepairId"].Visible = false;
|
||||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||||
dataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
dataGridView.Columns["ClientId"].Visible = false;
|
||||||
|
dataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -68,13 +68,14 @@ namespace RenovationWorkBusinessLogic.BusinessLogics
|
|||||||
ImplementerId = implementer.Id
|
ImplementerId = implementer.Id
|
||||||
});
|
});
|
||||||
// делаем работу
|
// делаем работу
|
||||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100,
|
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100,1000) * order.Count);
|
||||||
1000) * order.Count);
|
|
||||||
_logger.LogDebug("DoWork. Worker {Id} finish order { Order}", implementer.Id, order.Id);
|
_logger.LogDebug("DoWork. Worker {Id} finish order { Order}", implementer.Id, order.Id);
|
||||||
_orderLogic.FinishOrder(new OrderBindingModel
|
_orderLogic.FinishOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
Id = order.Id
|
Id = order.Id
|
||||||
});
|
});
|
||||||
|
// отдыхаем
|
||||||
|
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
}
|
}
|
||||||
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||||
catch (InvalidOperationException ex)
|
catch (InvalidOperationException ex)
|
||||||
@ -87,8 +88,6 @@ namespace RenovationWorkBusinessLogic.BusinessLogics
|
|||||||
_logger.LogError(ex, "Error while do work");
|
_logger.LogError(ex, "Error while do work");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
// отдыхаем
|
|
||||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
257
RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.Designer.cs
generated
Normal file
257
RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.Designer.cs
generated
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using RenovationWorkDatabaseImplement;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace RenovationWorkDatabaseImplement_.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(RenovationWorkDatabase))]
|
||||||
|
[Migration("20240501150513_addingImplementors")]
|
||||||
|
partial class addingImplementors
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.17")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Component", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ComponentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Cost")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClientFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateImplement")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("RepairId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
|
|
||||||
|
b.HasIndex("RepairId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Repair", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<string>("RepairName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Repairs");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.RepairComponent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("RepairId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
|
b.HasIndex("RepairId");
|
||||||
|
|
||||||
|
b.ToTable("RepairComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("RenovationWorkDatabaseImplement.Models.Client", "Client")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("RenovationWorkDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
|
b.HasOne("RenovationWorkDatabaseImplement.Models.Repair", "Repair")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("RepairId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
|
||||||
|
b.Navigation("Repair");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.RepairComponent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("RenovationWorkDatabaseImplement.Component", "Component")
|
||||||
|
.WithMany("RepairComponents")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("RenovationWorkDatabaseImplement.Models.Repair", "Repair")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("RepairId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Repair");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Component", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("RepairComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Repair", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace RenovationWorkDatabaseImplement_.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class addingImplementors : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "ImplementerId",
|
||||||
|
table: "Orders",
|
||||||
|
type: "int",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Implementers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Qualification = table.Column<int>(type: "int", nullable: false),
|
||||||
|
WorkExperience = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_ImplementerId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ImplementerId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Orders_Implementers_ImplementerId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ImplementerId",
|
||||||
|
principalTable: "Implementers",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Orders_Implementers_ImplementerId",
|
||||||
|
table: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Implementers");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Orders_ImplementerId",
|
||||||
|
table: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ImplementerId",
|
||||||
|
table: "Orders");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -67,6 +67,33 @@ namespace RenovationWorkDatabaseImplement_.Migrations
|
|||||||
b.ToTable("Clients");
|
b.ToTable("Clients");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -87,6 +114,9 @@ namespace RenovationWorkDatabaseImplement_.Migrations
|
|||||||
b.Property<DateTime?>("DateImplement")
|
b.Property<DateTime?>("DateImplement")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("RepairId")
|
b.Property<int>("RepairId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@ -100,6 +130,8 @@ namespace RenovationWorkDatabaseImplement_.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ClientId");
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
|
|
||||||
b.HasIndex("RepairId");
|
b.HasIndex("RepairId");
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
@ -159,6 +191,10 @@ namespace RenovationWorkDatabaseImplement_.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("RenovationWorkDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
b.HasOne("RenovationWorkDatabaseImplement.Models.Repair", "Repair")
|
b.HasOne("RenovationWorkDatabaseImplement.Models.Repair", "Repair")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("RepairId")
|
.HasForeignKey("RepairId")
|
||||||
@ -167,6 +203,8 @@ namespace RenovationWorkDatabaseImplement_.Migrations
|
|||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
|
||||||
b.Navigation("Repair");
|
b.Navigation("Repair");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -199,6 +237,11 @@ namespace RenovationWorkDatabaseImplement_.Migrations
|
|||||||
b.Navigation("Orders");
|
b.Navigation("Orders");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Repair", b =>
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Repair", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Components");
|
b.Navigation("Components");
|
||||||
|
@ -103,11 +103,11 @@ namespace RenovationWorkListImplement.Implements
|
|||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
return null;
|
return null;
|
||||||
var iceCream = _source.Repairs.FirstOrDefault(x => x.Id == model.Id);
|
var repair = _source.Repairs.FirstOrDefault(x => x.Id == model.Id);
|
||||||
var client = _source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
var client = _source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
var implementer = _source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId);
|
var implementer = _source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId);
|
||||||
if (iceCream != null)
|
if (repair != null)
|
||||||
model.RepairName = iceCream.RepairName;
|
model.RepairName = repair.RepairName;
|
||||||
if (client != null)
|
if (client != null)
|
||||||
model.ClientFIO = client.ClientFIO;
|
model.ClientFIO = client.ClientFIO;
|
||||||
if (implementer != null)
|
if (implementer != null)
|
||||||
|
Loading…
Reference in New Issue
Block a user