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.
75 lines
3.1 KiB
C#
75 lines
3.1 KiB
C#
using System.Text.Json;
|
|
using OMS.NET.Common;
|
|
using OMS.NET.DbClass;
|
|
|
|
namespace OMS.NET.Instructs
|
|
{
|
|
public class AdjustElementOrderInstuct : Instruct
|
|
{
|
|
public AdjustElementOrderInstuct()
|
|
{
|
|
Type = "broadcast";
|
|
Class = "adjustElementOrder";
|
|
}
|
|
|
|
public override Task Handler(string wsid)
|
|
{
|
|
return Task.Run(() =>
|
|
{
|
|
if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查不通过则直接退出
|
|
if (Data?.GetType() != typeof(JsonElement)) return;//Data 非空和JsonElement类型检查
|
|
string conveyor = GlobalArea.GetLoginEmailByID(wsid);
|
|
try
|
|
{
|
|
long elementA = Data.GetProperty("elementA").GetInt64();
|
|
long elementB = Data.GetProperty("elementB").GetInt64();
|
|
string templateA = Data.GetProperty("templateA").GetString();
|
|
string templateB = Data.GetProperty("templateB").GetString();
|
|
string method = Data.GetProperty("method").GetString();
|
|
dynamic result = GlobalArea.AdjustElementOrder(elementA, elementB, templateA, templateB, method);
|
|
List<dynamic> list = new();
|
|
foreach (LayerData layerData in result.layers)
|
|
{
|
|
list.Add(new
|
|
{
|
|
id = layerData.LayerId,
|
|
members = layerData.Members,
|
|
structure = layerData.Structure,
|
|
});
|
|
}
|
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
|
{
|
|
IsBroadcast = true,
|
|
Type = "broadcast",
|
|
Class = "batchUpdateLayerData",
|
|
Conveyor = conveyor,
|
|
Time = GlobalArea.GetCurrentTime(),
|
|
Data = list
|
|
});
|
|
if (result.element != null && result.element.GetType() != typeof(MapData))
|
|
{
|
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
|
{
|
|
IsBroadcast = true,
|
|
Type = "broadcast",
|
|
Class = "updateElement",
|
|
Conveyor = conveyor,
|
|
Time = GlobalArea.GetCurrentTime(),
|
|
Data = new
|
|
{
|
|
id = result.element.ID,
|
|
type = result.element.Type,
|
|
details = result.element.Details,
|
|
custom = result.element.Custom
|
|
}
|
|
});
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
} |