You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OMS.NET/Instructs/DeleteLayerAndMembersInstuc...

68 lines
2.6 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System.Text.Json;
using System.Text.Json.Nodes;
using OMS.NET.Common;
using OMS.NET.DbClass;
namespace OMS.NET.Instructs
{
public class DeleteLayerAndMembersInstuct : Instruct
{
public DeleteLayerAndMembersInstuct()
{
Type = "broadcast";
Class = "deleteLayerAndMembers";
}
public override Task Handler(string wsid)
{
return Task.Run(() =>
{
if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查不通过则直接退出
if (Data?.GetType() != typeof(JsonElement)) return;//Data 非空和JsonElement类型检查
try
{
long id = Data.GetProperty("id").GetInt64();
LayerData layer = GlobalArea.GetLayerDataByLayerId(id)!;
if (layer.Type == "order") throw new Exception("Order Layer不能删");
layer.Phase = 2;
layer.Reset();//本身移除member和structure内的elementId引用然后更新到数据库
layer.HasChange = true;
LayerData order = GlobalArea.GetOrderLayerData();
order.OrderDeleteGroupLayer(id);
GlobalArea.RemoveDeletedLayerData();//更新图层模板映射
string conveyor = GlobalArea.GetLoginEmailByID(wsid);
string time = GlobalArea.GetCurrentTime();
ResponseOrBroadcastInstructs.Add(new Instruct()
{
IsBroadcast = true,
Type = "broadcast",
Class = "updateLayerOrder",
Conveyor = conveyor,
Time = time,
Data = new
{
member = order.Members
}
});
ResponseOrBroadcastInstructs.Add(new Instruct()
{
IsBroadcast = true,
Type = "broadcast",
Class = "deleteLayerAndMembers",
Conveyor = conveyor,
Time = time,
Data = new
{
id = id,
member = layer.Members
}
});
}
catch (Exception ex)
{
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
}
});
}
}
}