PalacePal/Pal.Client/Scheduled/QueuedUndoImport.cs

46 lines
1.5 KiB
C#
Raw Normal View History

2023-02-15 22:17:19 +00:00
using System;
using System.Collections.Generic;
using Pal.Client.Configuration;
using Pal.Client.DependencyInjection;
using Pal.Common;
2022-12-24 09:27:59 +00:00
namespace Pal.Client.Scheduled
{
2023-02-15 22:17:19 +00:00
internal sealed class QueuedUndoImport : IQueueOnFrameworkThread
2022-12-24 09:27:59 +00:00
{
public QueuedUndoImport(Guid exportId)
{
2023-02-15 22:17:19 +00:00
ExportId = exportId;
2022-12-24 09:27:59 +00:00
}
private Guid ExportId { get; }
internal sealed class Handler : IQueueOnFrameworkThread.Handler<QueuedUndoImport>
{
private readonly IPalacePalConfiguration _configuration;
private readonly FloorService _floorService;
public Handler(IPalacePalConfiguration configuration, FloorService floorService)
{
_configuration = configuration;
_floorService = floorService;
}
protected override void Run(QueuedUndoImport queued, ref bool recreateLayout, ref bool saveMarkers)
{
recreateLayout = true;
saveMarkers = true;
foreach (ETerritoryType territoryType in typeof(ETerritoryType).GetEnumValues())
{
var localState = _floorService.GetFloorMarkers((ushort)territoryType);
localState.UndoImport(new List<Guid> { queued.ExportId });
localState.Save();
}
_configuration.ImportHistory.RemoveAll(hist => hist.Id == queued.ExportId);
}
}
2022-12-24 09:27:59 +00:00
}
}