Глобальное обновление #1
@@ -7,7 +7,8 @@ using Pf2eDataScrapper.Helpers;
|
||||
using Pf2eDataScrapper.Processors;
|
||||
using Pf2eDataScrapper.WPF;
|
||||
using Pf2eDataScrapper.WPF.EntityViewer;
|
||||
using Pf2eDataScrapper.WPF.Views;
|
||||
using Pf2eDataScrapper.WPF.ProgressForm;
|
||||
using Pf2eDataScrapper.WPF.StartForm;
|
||||
using Pf2eModel;
|
||||
using Slugify;
|
||||
|
||||
@@ -50,7 +51,7 @@ internal sealed class ImportApplication : Application
|
||||
|
||||
#endregion
|
||||
|
||||
#region "Формы"
|
||||
#region "Жизненный цикл"
|
||||
|
||||
private StartForm? _startFormWpf;
|
||||
|
||||
@@ -58,10 +59,6 @@ internal sealed class ImportApplication : Application
|
||||
|
||||
private EntityForm? _entityForm;
|
||||
|
||||
#endregion
|
||||
|
||||
#region "Жизненный цикл"
|
||||
|
||||
private Window? CurrentWpfForm { get; set; }
|
||||
|
||||
public delegate void ApplicationStateChangeDelegate(object sender, ApplicationStage nextStage);
|
||||
@@ -133,6 +130,9 @@ internal sealed class ImportApplication : Application
|
||||
break;
|
||||
|
||||
case ApplicationStage.ImportProcess:
|
||||
_progressFormWpf!.Hide();
|
||||
_progressFormWpf!.Close();
|
||||
_progressFormWpf = null;
|
||||
break;
|
||||
|
||||
case ApplicationStage.Viewer:
|
||||
|
||||
@@ -59,14 +59,14 @@ internal partial class StringHelper
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Извлечение информации о названии источника.
|
||||
/// Извлечение суффикса из описания источника.
|
||||
/// </summary>
|
||||
/// <param name="input">Исходная строка.</param>
|
||||
/// <returns>Название источника.</returns>
|
||||
public string ResolveSource(string input)
|
||||
/// <returns>Суффикс.</returns>
|
||||
public string ResolveSourceSuffix(string input)
|
||||
{
|
||||
Match match = SourceSuffixRegex().Match(input);
|
||||
return match.Captures.Count > 0 ? match.Captures[0].Value : "";
|
||||
return match.Captures.Count > 0 ? match.Groups[1].Value : "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+4
-1
@@ -173,7 +173,9 @@ internal abstract class AbstractEntityProcessor(
|
||||
{
|
||||
Entity = Entity,
|
||||
SourceId = Globals.SourceIds[sourceName],
|
||||
Suffix = StringHelper.ResolveSource(Input.GetRequired<string>("source_markdown")),
|
||||
Suffix = StringHelper.ResolveSourceSuffix(
|
||||
Input.GetRequired<string>("source_markdown")
|
||||
),
|
||||
IsRemaster = Input.GetOptional<JArray>("legacy_id") is not null,
|
||||
};
|
||||
|
||||
@@ -195,6 +197,7 @@ internal abstract class AbstractEntityProcessor(
|
||||
Md5 = Input.Md5(),
|
||||
};
|
||||
|
||||
Entity.Externals.Add(external);
|
||||
Context.EntityExternals.Add(external);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -33,16 +33,17 @@ internal class LegacyRemasterProcessors(ProcessorInput input) : AbstractInputPro
|
||||
{
|
||||
Context.LegacyRemasters.Add(new() { LegacyId = entityId, RemasterId = remasterId });
|
||||
}
|
||||
|
||||
/*
|
||||
foreach (int legacyId in GetEntityIds("legacy_id"))
|
||||
{
|
||||
Context.LegacyRemasters.Add(new() { LegacyId = legacyId, RemasterId = entityId });
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
protected List<int> GetEntityIds(string path)
|
||||
{
|
||||
List<string> aonprdIds = (Input.GetOptional<JArray>("path") ?? [])
|
||||
List<string> aonprdIds = (Input.GetOptional<JArray>(path) ?? [])
|
||||
.Select(token => token.ToString())
|
||||
.ToList();
|
||||
|
||||
|
||||
@@ -109,6 +109,10 @@ internal class SpellProcessor(
|
||||
{
|
||||
A(new() { Spell = Object, Type = SpellAreaType.Square });
|
||||
}
|
||||
if (areaDetails.Contains("fungi"))
|
||||
{
|
||||
areaDetails = [areaDetails[0] + " or " + areaDetails[1]];
|
||||
}
|
||||
|
||||
if (areaTypes.Count != areaDetails.Count)
|
||||
{
|
||||
|
||||
+13
-48
@@ -13,7 +13,7 @@ using Pf2eModel.Model.Enum;
|
||||
namespace Pf2eModel.Migrations
|
||||
{
|
||||
[DbContext(typeof(Pf2eDbContext))]
|
||||
[Migration("20250516162158_1")]
|
||||
[Migration("20250521102908_1")]
|
||||
partial class _1
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -288,36 +288,11 @@ namespace Pf2eModel.Migrations
|
||||
.HasColumnOrder(2)
|
||||
.HasComment("Идентификатор цели");
|
||||
|
||||
b.Property<int>("LegacyEntitiesId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("legacy_entities_id");
|
||||
|
||||
b.Property<int>("LegacyEntityId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("legacy_entity_id");
|
||||
|
||||
b.Property<int>("RemasterEntitiesId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("remaster_entities_id");
|
||||
|
||||
b.Property<int>("RemasterEntityId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("remaster_entity_id");
|
||||
|
||||
b.HasKey("LegacyId", "RemasterId")
|
||||
.HasName("pk_legacy_remasters");
|
||||
|
||||
b.HasIndex("LegacyEntitiesId")
|
||||
.HasDatabaseName("ix_legacy_remasters_legacy_entities_id");
|
||||
|
||||
b.HasIndex("LegacyEntityId")
|
||||
.HasDatabaseName("ix_legacy_remasters_legacy_entity_id");
|
||||
|
||||
b.HasIndex("RemasterEntitiesId")
|
||||
.HasDatabaseName("ix_legacy_remasters_remaster_entities_id");
|
||||
|
||||
b.HasIndex("RemasterEntityId")
|
||||
.HasDatabaseName("ix_legacy_remasters_remaster_entity_id");
|
||||
b.HasIndex("RemasterId")
|
||||
.HasDatabaseName("ix_legacy_remasters_remaster_id");
|
||||
|
||||
b.ToTable("legacy_remasters", (string)null);
|
||||
});
|
||||
@@ -1973,33 +1948,19 @@ namespace Pf2eModel.Migrations
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Base.LegacyRemaster", b =>
|
||||
{
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("LegacyEntitiesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_legacy_remasters_entities_legacy_entities_id");
|
||||
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", "LegacyEntity")
|
||||
.WithMany()
|
||||
.HasForeignKey("LegacyEntityId")
|
||||
.WithMany("LegacyTransferEntities")
|
||||
.HasForeignKey("LegacyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_legacy_remasters_entities_legacy_entity_id");
|
||||
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RemasterEntitiesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_legacy_remasters_entities_remaster_entities_id");
|
||||
.HasConstraintName("fk_legacy_remasters_entities_legacy_id");
|
||||
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", "RemasterEntity")
|
||||
.WithMany()
|
||||
.HasForeignKey("RemasterEntityId")
|
||||
.WithMany("RemasterTransferEntities")
|
||||
.HasForeignKey("RemasterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_legacy_remasters_entities_remaster_entity_id");
|
||||
.HasConstraintName("fk_legacy_remasters_entities_remaster_id");
|
||||
|
||||
b.Navigation("LegacyEntity");
|
||||
|
||||
@@ -2638,6 +2599,10 @@ namespace Pf2eModel.Migrations
|
||||
|
||||
b.Navigation("Externals");
|
||||
|
||||
b.Navigation("LegacyTransferEntities");
|
||||
|
||||
b.Navigation("RemasterTransferEntities");
|
||||
|
||||
b.Navigation("Sources");
|
||||
});
|
||||
|
||||
+7
-38
@@ -316,36 +316,20 @@ namespace Pf2eModel.Migrations
|
||||
columns: table => new
|
||||
{
|
||||
legacy_id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор сущности"),
|
||||
remaster_id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор цели"),
|
||||
legacy_entity_id = table.Column<int>(type: "integer", nullable: false),
|
||||
remaster_entity_id = table.Column<int>(type: "integer", nullable: false),
|
||||
legacy_entities_id = table.Column<int>(type: "integer", nullable: false),
|
||||
remaster_entities_id = table.Column<int>(type: "integer", nullable: false)
|
||||
remaster_id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор цели")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_legacy_remasters", x => new { x.legacy_id, x.remaster_id });
|
||||
table.ForeignKey(
|
||||
name: "fk_legacy_remasters_entities_legacy_entities_id",
|
||||
column: x => x.legacy_entities_id,
|
||||
name: "fk_legacy_remasters_entities_legacy_id",
|
||||
column: x => x.legacy_id,
|
||||
principalTable: "entities",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_legacy_remasters_entities_legacy_entity_id",
|
||||
column: x => x.legacy_entity_id,
|
||||
principalTable: "entities",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_legacy_remasters_entities_remaster_entities_id",
|
||||
column: x => x.remaster_entities_id,
|
||||
principalTable: "entities",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_legacy_remasters_entities_remaster_entity_id",
|
||||
column: x => x.remaster_entity_id,
|
||||
name: "fk_legacy_remasters_entities_remaster_id",
|
||||
column: x => x.remaster_id,
|
||||
principalTable: "entities",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
@@ -1362,24 +1346,9 @@ namespace Pf2eModel.Migrations
|
||||
column: "entity_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_legacy_remasters_legacy_entities_id",
|
||||
name: "ix_legacy_remasters_remaster_id",
|
||||
table: "legacy_remasters",
|
||||
column: "legacy_entities_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_legacy_remasters_legacy_entity_id",
|
||||
table: "legacy_remasters",
|
||||
column: "legacy_entity_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_legacy_remasters_remaster_entities_id",
|
||||
table: "legacy_remasters",
|
||||
column: "remaster_entities_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_legacy_remasters_remaster_entity_id",
|
||||
table: "legacy_remasters",
|
||||
column: "remaster_entity_id");
|
||||
column: "remaster_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_ritual_checks_ritual_id",
|
||||
@@ -285,36 +285,11 @@ namespace Pf2eModel.Migrations
|
||||
.HasColumnOrder(2)
|
||||
.HasComment("Идентификатор цели");
|
||||
|
||||
b.Property<int>("LegacyEntitiesId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("legacy_entities_id");
|
||||
|
||||
b.Property<int>("LegacyEntityId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("legacy_entity_id");
|
||||
|
||||
b.Property<int>("RemasterEntitiesId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("remaster_entities_id");
|
||||
|
||||
b.Property<int>("RemasterEntityId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("remaster_entity_id");
|
||||
|
||||
b.HasKey("LegacyId", "RemasterId")
|
||||
.HasName("pk_legacy_remasters");
|
||||
|
||||
b.HasIndex("LegacyEntitiesId")
|
||||
.HasDatabaseName("ix_legacy_remasters_legacy_entities_id");
|
||||
|
||||
b.HasIndex("LegacyEntityId")
|
||||
.HasDatabaseName("ix_legacy_remasters_legacy_entity_id");
|
||||
|
||||
b.HasIndex("RemasterEntitiesId")
|
||||
.HasDatabaseName("ix_legacy_remasters_remaster_entities_id");
|
||||
|
||||
b.HasIndex("RemasterEntityId")
|
||||
.HasDatabaseName("ix_legacy_remasters_remaster_entity_id");
|
||||
b.HasIndex("RemasterId")
|
||||
.HasDatabaseName("ix_legacy_remasters_remaster_id");
|
||||
|
||||
b.ToTable("legacy_remasters", (string)null);
|
||||
});
|
||||
@@ -1970,33 +1945,19 @@ namespace Pf2eModel.Migrations
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Base.LegacyRemaster", b =>
|
||||
{
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("LegacyEntitiesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_legacy_remasters_entities_legacy_entities_id");
|
||||
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", "LegacyEntity")
|
||||
.WithMany()
|
||||
.HasForeignKey("LegacyEntityId")
|
||||
.WithMany("LegacyTransferEntities")
|
||||
.HasForeignKey("LegacyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_legacy_remasters_entities_legacy_entity_id");
|
||||
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RemasterEntitiesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_legacy_remasters_entities_remaster_entities_id");
|
||||
.HasConstraintName("fk_legacy_remasters_entities_legacy_id");
|
||||
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", "RemasterEntity")
|
||||
.WithMany()
|
||||
.HasForeignKey("RemasterEntityId")
|
||||
.WithMany("RemasterTransferEntities")
|
||||
.HasForeignKey("RemasterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_legacy_remasters_entities_remaster_entity_id");
|
||||
.HasConstraintName("fk_legacy_remasters_entities_remaster_id");
|
||||
|
||||
b.Navigation("LegacyEntity");
|
||||
|
||||
@@ -2635,6 +2596,10 @@ namespace Pf2eModel.Migrations
|
||||
|
||||
b.Navigation("Externals");
|
||||
|
||||
b.Navigation("LegacyTransferEntities");
|
||||
|
||||
b.Navigation("RemasterTransferEntities");
|
||||
|
||||
b.Navigation("Sources");
|
||||
});
|
||||
|
||||
|
||||
@@ -110,8 +110,18 @@ public class Entity
|
||||
/// </summary>
|
||||
public ICollection<Entity> LegacyEntities { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Коллекция переходных объектов для устаревших сущностей.
|
||||
/// </summary>
|
||||
public ICollection<LegacyRemaster> LegacyTransferEntities { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Коллекция обновлённых сущностей.
|
||||
/// </summary>
|
||||
public ICollection<Entity> RemasterEntities { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Коллекция переходных объектов для обновлённых сущностей.
|
||||
/// </summary>
|
||||
public ICollection<LegacyRemaster> RemasterTransferEntities { get; set; } = [];
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Pf2eModel.Model.Base.Source;
|
||||
|
||||
@@ -50,6 +51,7 @@ public class EntitySource
|
||||
/// <summary>
|
||||
/// Сущность, к которой относится источник.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public Entity Entity { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Base.Source;
|
||||
@@ -44,5 +45,6 @@ public class Source
|
||||
/// <summary>
|
||||
/// Связанные сущности.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public ICollection<EntitySource> EntitySources { get; set; } = [];
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Pf2eModel.Model.Base.Targets;
|
||||
|
||||
@@ -45,5 +46,6 @@ public class ExternalTarget
|
||||
/// <summary>
|
||||
/// Коллекция сущностей, которые ссылаются на эту цель.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public ICollection<EntityExternal> EntityExternals { get; set; } = [];
|
||||
}
|
||||
|
||||
@@ -123,12 +123,14 @@ public partial class Pf2eDbContext
|
||||
.HasMany(e => e.LegacyEntities)
|
||||
.WithMany(e => e.RemasterEntities)
|
||||
.UsingEntity<LegacyRemaster>(
|
||||
//l =>
|
||||
// l.HasOne(lr => lr.LegacyEntity).WithMany().HasForeignKey(lr => lr.LegacyId),
|
||||
//r =>
|
||||
// r.HasOne(lr => lr.RemasterEntity)
|
||||
// .WithMany()
|
||||
// .HasForeignKey(lr => lr.RemasterId)
|
||||
l =>
|
||||
l.HasOne(lr => lr.LegacyEntity)
|
||||
.WithMany(e => e.LegacyTransferEntities)
|
||||
.HasForeignKey(lr => lr.LegacyId),
|
||||
r =>
|
||||
r.HasOne(lr => lr.RemasterEntity)
|
||||
.WithMany(e => e.RemasterTransferEntities)
|
||||
.HasForeignKey(lr => lr.RemasterId)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user