PalacePal/Pal.Client/Scheduled/QueuedUndoImport.cs

50 lines
1.6 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;
2023-02-16 18:51:54 +00:00
using Pal.Client.Windows;
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>
{
2023-02-16 18:51:54 +00:00
private readonly ImportService _importService;
private readonly FloorService _floorService;
2023-02-16 18:51:54 +00:00
private readonly ConfigWindow _configWindow;
2023-02-16 18:51:54 +00:00
public Handler(ImportService importService, FloorService floorService, ConfigWindow configWindow)
{
2023-02-16 18:51:54 +00:00
_importService = importService;
_floorService = floorService;
2023-02-16 18:51:54 +00:00
_configWindow = configWindow;
}
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();
}
2023-02-16 18:51:54 +00:00
_importService.RemoveById(queued.ExportId);
_configWindow.UpdateLastImport();
}
}
2022-12-24 09:27:59 +00:00
}
}