Vocabolario:

- Fix creazione tab + stored
- modifica metodo upsert
This commit is contained in:
Samuele Locatelli
2023-04-03 16:20:03 +02:00
parent 0dfc561125
commit f31b3187e8
6 changed files with 951 additions and 49 deletions
@@ -3,8 +3,11 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using NLog;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Data;
using WebDoorCreator.Data.DbModels;
using WebDoorCreator.Data.DTO;
using static WebDoorCreator.Core.Enum;
namespace WebDoorCreator.Data.Controllers
{
@@ -676,8 +679,8 @@ namespace WebDoorCreator.Data.Controllers
try
{
dbCtx
.Database
.ExecuteSqlRaw("EXEC man.[stp_TruncTables]");
.Database
.ExecuteSqlRaw("EXEC man.[stp_TruncTables]");
dbResult = true;
}
@@ -836,55 +839,34 @@ namespace WebDoorCreator.Data.Controllers
/// <summary>
/// Aggiunta di un nuovo set di lemmi
/// </summary>
/// <param name="newVocLemma"></param>
/// <param name="listNewTerms"></param>
/// <returns></returns>
public async Task<bool> VocLemmaInsert(List<VocabularyModel> newVocLemma)
public async Task<bool> VocLemmaInsert(List<VocabularyTempModel> listNewTerms)
{
bool fatto = false;
List<VocabularyModel> list2Ins = new List<VocabularyModel>();
List<VocabularyModel> list2Upd = new List<VocabularyModel>();
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
{
try
{
var lisKey = localDbCtx
.DbSetVocabulary
.ToList();
foreach (var item in newVocLemma)
{
var trovato = lisKey.Where(x => x.Lingua == item.Lingua && x.Lemma == item.Lemma).FirstOrDefault();
if (trovato == null)
{
list2Ins.Add(item);
}
else
{
if (trovato.Traduzione != item.Traduzione)
{
list2Upd.Add(item);
}
}
}
//aggiungo i mancanti
// stored di reset vocabolario
var storedRes = localDbCtx
.Database
.ExecuteSqlRaw("exec dbo.stp_Voc_Prepare");
// import massivo dati in tab temp
localDbCtx
.DbSetVocabulary
.AddRange(list2Ins);
.DbSetVocabularyTemp
.AddRange(listNewTerms);
localDbCtx.SaveChanges();
// stored di merge dati in vocabolario
storedRes = localDbCtx
.Database
.ExecuteSqlRaw("exec dbo.stp_Voc_Import");
foreach (var item in list2Upd)
{
var trovato = newVocLemma.Where(x => x.Lingua == item.Lingua && x.Lemma == item.Lemma).FirstOrDefault();
if (trovato != null)
{
trovato.Traduzione = item.Traduzione;
localDbCtx.Entry<VocabularyModel>(trovato).State = EntityState.Modified;
}
}
await localDbCtx.SaveChangesAsync();
fatto = true;
}
catch (Exception exc)
@@ -0,0 +1,763 @@
// <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 WebDoorCreator.Data;
#nullable disable
namespace WebDoorCreator.Data.Migrations.WDCData
{
[DbContext(typeof(WDCDataContext))]
[Migration("20230403140917_VocabularySetup")]
partial class VocabularySetup
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.UseCollation("Latin1_General_CI_AS")
.HasAnnotation("ProductVersion", "6.0.14")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("nvarchar(450)");
b.Property<string>("ConcurrencyStamp")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("NormalizedName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations());
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("RoleId")
.HasColumnType("nvarchar(450)");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations());
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("nvarchar(450)");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("bit");
b.Property<bool>("LockoutEnabled")
.HasColumnType("bit");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset");
b.Property<string>("NormalizedEmail")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("NormalizedUserName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit");
b.Property<string>("SecurityStamp")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations());
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b =>
{
b.Property<int>("CompanyId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("CompanyId"), 1L, 1);
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("nvarchar(250)");
b.Property<string>("City")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("CompanyExtCode")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("nvarchar(250)");
b.Property<string>("CompanyName")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<string>("CompanyToken")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<string>("PrivateNote")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<string>("State")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("VAT")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<int>("ZipCode")
.HasColumnType("int");
b.HasKey("CompanyId");
b.ToTable("Company");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b =>
{
b.Property<int>("DoorId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("DoorId"), 1L, 1);
b.Property<DateTime>("DateIns")
.HasColumnType("datetime2");
b.Property<DateTime>("DateLockExpiry")
.HasColumnType("datetime2");
b.Property<DateTime>("DateMod")
.HasColumnType("datetime2");
b.Property<string>("DoorDescript")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("DoorExtCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("MeasureUnit")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("OrderId")
.HasColumnType("int");
b.Property<int>("Quantity")
.HasColumnType("int");
b.Property<int>("TypeId")
.HasColumnType("int");
b.Property<decimal>("UnitCost")
.HasColumnType("decimal(18,2)");
b.Property<string>("UserIdIns")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserIdLock")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserIdMod")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("DoorId");
b.HasIndex("OrderId");
b.HasIndex("TypeId");
b.ToTable("Door");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b =>
{
b.Property<int>("DoorOpId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("DoorOpId"), 1L, 1);
b.Property<DateTime>("DateIns")
.HasColumnType("datetime2");
b.Property<DateTime>("DateMod")
.HasColumnType("datetime2");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("DoorId")
.HasColumnType("int");
b.Property<int>("DoorOpTypId")
.HasColumnType("int");
b.Property<string>("JsoncConfigVal")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserIdIns")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserIdMod")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("DoorOpId");
b.HasIndex("DoorId");
b.HasIndex("DoorOpTypId");
b.ToTable("DoorOp");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b =>
{
b.Property<int>("DoorOpTypId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("DoorOpTypId"), 1L, 1);
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("DisplayUrl")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<HierarchyId>("DoorOpIdPathFromPatriarch")
.HasColumnType("hierarchyid");
b.Property<string>("ExtDescript")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ExtOpCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FPath")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("HasHw")
.HasColumnType("bit");
b.Property<string>("HwCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("HwDescription")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsConcrete")
.HasColumnType("bit");
b.Property<bool>("IsDefault")
.HasColumnType("bit");
b.Property<string>("JsoncConfig")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("MaxAllowed")
.HasColumnType("int");
b.Property<string>("OpCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("ParentDoorOpId")
.HasColumnType("int");
b.Property<string>("Rev")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("ValidFrom")
.HasColumnType("datetime2");
b.Property<DateTime>("ValidUntil")
.HasColumnType("datetime2");
b.HasKey("DoorOpTypId");
b.ToTable("DoorOpType");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b =>
{
b.Property<int>("TypeId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TypeId"), 1L, 1);
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("TypeCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("TypeId");
b.ToTable("DoorType");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b =>
{
b.Property<int>("GraphicParamId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("GraphicParamId"), 1L, 1);
b.Property<int>("compoId")
.HasColumnType("int");
b.Property<string>("graphicParamAlias")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("graphicParamDefaultVal")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("graphicParamKey")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("graphicParamName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("graphicParamType")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("graphicParamsN")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("GraphicParamId");
b.ToTable("GraphicParams");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b =>
{
b.Property<int>("HardwareId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("HardwareId"), 1L, 1);
b.Property<string>("compoAlias")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("compoLayerName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("compoName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("compoTemplateIsActive")
.HasColumnType("bit");
b.HasKey("HardwareId");
b.ToTable("Hardware");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b =>
{
b.Property<string>("TableName")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("FieldName")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("value")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("label")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<int>("ordinal")
.HasColumnType("int");
b.HasKey("TableName", "FieldName", "value");
b.ToTable("ListValues");
b.HasData(
new
{
TableName = "Opening",
FieldName = "Swing",
value = "LH",
label = "Left Handed",
ordinal = 1
},
new
{
TableName = "Opening",
FieldName = "Swing",
value = "RH",
label = "Right Handed",
ordinal = 2
},
new
{
TableName = "Opening",
FieldName = "Swing",
value = "LHR",
label = "Left Handed Reverse",
ordinal = 3
},
new
{
TableName = "Opening",
FieldName = "Swing",
value = "RHR",
label = "Right Handed Reverse",
ordinal = 4
},
new
{
TableName = "Edges",
FieldName = "EdgeType",
value = "BV",
label = "Bevel",
ordinal = 1
},
new
{
TableName = "Edges",
FieldName = "EdgeType",
value = "SQ",
label = "Squared",
ordinal = 2
},
new
{
TableName = "Edges",
FieldName = "EdgeType",
value = "1B",
label = "Bull Nose 1",
ordinal = 3
});
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b =>
{
b.Property<int>("OrderId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("OrderId"), 1L, 1);
b.Property<int>("CompanyId")
.HasColumnType("int");
b.Property<DateTime>("DateIns")
.HasColumnType("datetime2");
b.Property<DateTime>("DateMod")
.HasColumnType("datetime2");
b.Property<string>("OrderDescript")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("OrderExtCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<string>("UserIdIns")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserIdMod")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("OrderId");
b.HasIndex("CompanyId");
b.ToTable("Order");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b =>
{
b.Property<int>("OrderId")
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("OrderId"), 1L, 1);
b.Property<int>("CompanyId")
.HasColumnType("int");
b.Property<DateTime>("DateIns")
.HasColumnType("datetime2");
b.Property<int>("NumDoors")
.HasColumnType("int");
b.Property<int>("NumType")
.HasColumnType("int");
b.Property<string>("OrderDescript")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("OrderExtCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("OrderStatus")
.HasColumnType("int");
b.Property<decimal>("TotCost")
.HasColumnType("decimal(18,2)");
b.Property<string>("UserIdIns")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserIdMod")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("OrderId");
b.ToView("OrderStatusViewModel");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("RoleId")
.HasColumnType("nvarchar(450)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("RoleName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("UserId", "RoleId");
b.ToView("UsersViewModel");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b =>
{
b.Property<string>("Lingua")
.HasMaxLength(5)
.HasColumnType("nvarchar(5)");
b.Property<string>("Lemma")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Traduzione")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("nvarchar(250)");
b.HasKey("Lingua", "Lemma");
b.ToTable("Vocabulary");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b =>
{
b.Property<string>("Lingua")
.HasMaxLength(5)
.HasColumnType("nvarchar(5)");
b.Property<string>("Lemma")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Traduzione")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("nvarchar(250)");
b.HasKey("Lingua", "Lemma");
b.ToTable("VocabularyTemp");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b =>
{
b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("RolesNav");
b.Navigation("UsersNav");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b =>
{
b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav")
.WithMany()
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav")
.WithMany()
.HasForeignKey("TypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("OrderNav");
b.Navigation("TypeNav");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b =>
{
b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav")
.WithMany()
.HasForeignKey("DoorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav")
.WithMany()
.HasForeignKey("DoorOpTypId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DoorNav");
b.Navigation("DoorOpTypeNav");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b =>
{
b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav")
.WithMany()
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyNav");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,66 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WebDoorCreator.Data.Migrations.WDCData
{
public partial class VocabularySetup : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Vocabulary",
columns: table => new
{
Lingua = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
Lemma = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Traduzione = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Vocabulary", x => new { x.Lingua, x.Lemma });
});
migrationBuilder.CreateTable(
name: "VocabularyTemp",
columns: table => new
{
Lingua = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
Lemma = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Traduzione = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_VocabularyTemp", x => new { x.Lingua, x.Lemma });
});
addStored(migrationBuilder, "stp_Voc_Prepare");
addStored(migrationBuilder, "stp_Voc_Import");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Vocabulary");
migrationBuilder.DropTable(
name: "VocabularyTemp");
remStored(migrationBuilder, "stp_Voc_Prepare");
remStored(migrationBuilder, "stp_Voc_Import");
}
private void addStored(MigrationBuilder migrationBuilder, string viewName)
{
string path = Path.Combine("SqlScripts", "Stored", $"{viewName}.sql");
string viewBody = File.ReadAllText(path);
migrationBuilder.Sql(viewBody);
}
private void remStored(MigrationBuilder migrationBuilder, string viewName)
{
migrationBuilder.Sql($"exec('DROP PROCEDURE dbo.{viewName}');");
}
}
}
@@ -174,7 +174,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData
b.HasKey("CompanyId");
b.ToTable("Company", (string)null);
b.ToTable("Company");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b =>
@@ -236,7 +236,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData
b.HasIndex("TypeId");
b.ToTable("Door", (string)null);
b.ToTable("Door");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b =>
@@ -281,7 +281,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData
b.HasIndex("DoorOpTypId");
b.ToTable("DoorOp", (string)null);
b.ToTable("DoorOp");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b =>
@@ -358,7 +358,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData
b.HasKey("DoorOpTypId");
b.ToTable("DoorOpType", (string)null);
b.ToTable("DoorOpType");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b =>
@@ -379,7 +379,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData
b.HasKey("TypeId");
b.ToTable("DoorType", (string)null);
b.ToTable("DoorType");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b =>
@@ -419,7 +419,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData
b.HasKey("GraphicParamId");
b.ToTable("GraphicParams", (string)null);
b.ToTable("GraphicParams");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b =>
@@ -447,7 +447,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData
b.HasKey("HardwareId");
b.ToTable("Hardware", (string)null);
b.ToTable("Hardware");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b =>
@@ -473,7 +473,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData
b.HasKey("TableName", "FieldName", "value");
b.ToTable("ListValues", (string)null);
b.ToTable("ListValues");
b.HasData(
new
@@ -574,7 +574,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData
b.HasIndex("CompanyId");
b.ToTable("Order", (string)null);
b.ToTable("Order");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b =>
@@ -648,6 +648,46 @@ namespace WebDoorCreator.Data.Migrations.WDCData
b.ToView("UsersViewModel");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b =>
{
b.Property<string>("Lingua")
.HasMaxLength(5)
.HasColumnType("nvarchar(5)");
b.Property<string>("Lemma")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Traduzione")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("nvarchar(250)");
b.HasKey("Lingua", "Lemma");
b.ToTable("Vocabulary");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b =>
{
b.Property<string>("Lingua")
.HasMaxLength(5)
.HasColumnType("nvarchar(5)");
b.Property<string>("Lemma")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Traduzione")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("nvarchar(250)");
b.HasKey("Lingua", "Lemma");
b.ToTable("VocabularyTemp");
});
modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b =>
{
b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav")
@@ -0,0 +1,22 @@
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: S.E.L.
-- Create date: 2023.04.03
-- Description: Esecuzione preparazione tab temp x import vocabolario
-- =============================================
ALTER PROCEDURE [dbo].[stp_Voc_Prepare]
AS
BEGIN
SET NOCOUNT ON;
BEGIN tran
-- effettua preparazione tab appoggio
TRUNCATE TABLE VocabularyTemp
COMMIT tran
END
@@ -0,0 +1,29 @@
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: S.E.L.
-- Create date: 2023.04.03
-- Description: Esecuzione upsert vocabolario
-- =============================================
ALTER PROCEDURE [dbo].[stp_Voc_Import]
AS
BEGIN
SET NOCOUNT ON;
BEGIN tran
-- effettua merge dati vocabolario
MERGE Vocabulary as tgt
USING (SELECT Lingua, Lemma, Traduzione FROM VocabularyTemp) as src
ON tgt.Lemma = src.Lemma AND tgt.Lingua = src.Lingua
WHEN MATCHED THEN
UPDATE SET Traduzione = Traduzione
WHEN NOT MATCHED THEN
INSERT (Lingua, Lemma, Traduzione)
VALUES (Lingua, Lemma, Traduzione);
COMMIT tran
END