fix(dal,aihitMainSyncer): FieldValues поле Value теперь уникально. В aihitMainSyncer поднят уровень журналированияя

This commit is contained in:
Mikhail Kuznetsov
2025-05-21 16:50:00 +10:00
parent cd40adaa91
commit 6daf54fc56
7 changed files with 3539 additions and 10 deletions

View File

@@ -71,7 +71,7 @@ namespace PARR.AIHITMainSyncer.Services
if (isChanged && !await unitService.CommitAsync()) if (isChanged && !await unitService.CommitAsync())
logger.LogError($"Не удалось изменить Unit {objFromQuery.Name}"); logger.LogError($"Не удалось изменить Unit {objFromQuery.Name}");
else else
logger.LogInformation($"----- Набор данных в Unit изменён: {objFromQuery.Name} -----"); logger.LogDebug($"----- Набор данных в Unit изменён: {objFromQuery.Name} -----");
} }
@@ -132,7 +132,7 @@ namespace PARR.AIHITMainSyncer.Services
if (!await unitService.CreateAsync(unit) || !await unitService.CommitAsync()) if (!await unitService.CreateAsync(unit) || !await unitService.CommitAsync())
logger.LogError($"Не удалось создать Unit {unit.Name}"); logger.LogError($"Не удалось создать Unit {unit.Name}");
else else
logger.LogInformation($"----- Создан Unit: {unit.Name} -----"); logger.LogDebug($"----- Создан Unit: {unit.Name} -----");
return (await unitService.GetUnitByName(unit.Name))!; return (await unitService.GetUnitByName(unit.Name))!;
} }
@@ -155,7 +155,7 @@ namespace PARR.AIHITMainSyncer.Services
if (!await unitFieldService.CreateAsync(field) || !await unitFieldService.CommitAsync()) if (!await unitFieldService.CreateAsync(field) || !await unitFieldService.CommitAsync())
logger.LogError($"Не удалось создать запись в таблице Fields: {name}, {field.ToJson()}"); logger.LogError($"Не удалось создать запись в таблице Fields: {name}, {field.ToJson()}");
else else
logger.LogInformation($"Создана запись а таблице Fields: {name}, {field.ToJson()}"); logger.LogDebug($"Создана запись а таблице Fields: {name}, {field.ToJson()}");
return (await unitFieldService.GetAsync(field.Id))!; return (await unitFieldService.GetAsync(field.Id))!;
} }
@@ -183,7 +183,7 @@ namespace PARR.AIHITMainSyncer.Services
if (!await unitFieldValueService.CommitAsync()) if (!await unitFieldValueService.CommitAsync())
logger.LogError($"Не удалось создать связь таблицы FieldValues и Fields: {unitFieldValueService.ToJson()}"); logger.LogError($"Не удалось создать связь таблицы FieldValues и Fields: {unitFieldValueService.ToJson()}");
else else
logger.LogInformation($"Создана связь таблицы FieldValues и Fields: {unitFieldValueService.ToJson()}"); logger.LogDebug($"Создана связь таблицы FieldValues и Fields: {unitFieldValueService.ToJson()}");
} }
return existUnitFieldValue; return existUnitFieldValue;
@@ -209,7 +209,7 @@ namespace PARR.AIHITMainSyncer.Services
if (!await unitFieldValueService.CreateAsync(newValue) || !await unitFieldValueService.CommitAsync()) if (!await unitFieldValueService.CreateAsync(newValue) || !await unitFieldValueService.CommitAsync())
logger.LogError($"Не удалось создать запись в таблице Values: {newValue.Value}, {newValue.ToJson()}"); logger.LogError($"Не удалось создать запись в таблице Values: {newValue.Value}, {newValue.ToJson()}");
else else
logger.LogInformation($"Создана запись а таблице Values: {newValue.Value}, {newValue.ToJson()}"); logger.LogDebug($"Создана запись а таблице Values: {newValue.Value}, {newValue.ToJson()}");
return (await unitFieldValueService.GetAsync(newValue.Id))!; return (await unitFieldValueService.GetAsync(newValue.Id))!;
} }

View File

@@ -10,10 +10,10 @@
}, },
"Serilog": { "Serilog": {
"MinimumLevel": { "MinimumLevel": {
"Default": "Debug", "Default": "Information",
"Override": { "Override": {
"Microsoft": "Warning", "Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Debug" "Microsoft.Hosting.Lifetime": "Information"
} }
}, },
"WriteTo": [ "WriteTo": [

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,41 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblFieldValuesValueIsUniqueClmn : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_FieldValues_Value",
schema: "unit",
table: "FieldValues");
migrationBuilder.CreateIndex(
name: "IX_FieldValues_Value",
schema: "unit",
table: "FieldValues",
column: "Value",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_FieldValues_Value",
schema: "unit",
table: "FieldValues");
migrationBuilder.CreateIndex(
name: "IX_FieldValues_Value",
schema: "unit",
table: "FieldValues",
column: "Value");
}
}
}

View File

@@ -2621,7 +2621,8 @@ namespace PARR.DAL.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("Value"); b.HasIndex("Value")
.IsUnique();
b.ToTable("FieldValues", "unit", t => b.ToTable("FieldValues", "unit", t =>
{ {

View File

@@ -8,7 +8,7 @@ namespace PARR.DAL.Models.Unit
{ {
[Table("FieldValues", Schema = DataContextSettings.Unit)] [Table("FieldValues", Schema = DataContextSettings.Unit)]
[Comment("Значения полей ЭК")] [Comment("Значения полей ЭК")]
[Index(nameof(Value))] [Index(nameof(Value), IsUnique = true)]
public class UnitFieldValue : IBase public class UnitFieldValue : IBase
{ {
[Key] [Key]

View File

@@ -22,7 +22,7 @@ namespace PARR.DAL.Services.Implementations.Unit
public async Task<UnitField?> GetByAihitNameAsync(string name) public async Task<UnitField?> GetByAihitNameAsync(string name)
{ {
return await EntitySet.FirstOrDefaultAsync(uf => uf.AihitName.ToLower() == name.ToLower()); return await EntitySet.FirstOrDefaultAsync(uf => uf.AihitName.ToLower().Trim() == name.ToLower().Trim());
} }
} }
} }