Compare commits
18 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
81f06d24e6 | 1 year ago |
|
|
d9e25fd97c | 1 year ago |
|
|
4222096a7d | 1 year ago |
|
|
f45f4c0032 | 1 year ago |
|
|
33546bc1ba | 1 year ago |
|
|
70a871a42e | 1 year ago |
|
|
2550084b66 | 1 year ago |
|
|
829bf729e5 | 1 year ago |
|
|
cb0103b988 | 1 year ago |
|
|
2666922c4e | 1 year ago |
|
|
13b64ed549 | 1 year ago |
|
|
7e6df3b125 | 1 year ago |
|
|
3264956cdf | 1 year ago |
|
|
9e085dbbdc | 1 year ago |
|
|
f4006f8c7d | 1 year ago |
|
|
0d7cc2df5f | 1 year ago |
|
|
670856fb58 | 1 year ago |
|
|
e2c85517cc | 1 year ago |
@ -0,0 +1,31 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
|
||||||
|
namespace OMS.NET.Common
|
||||||
|
{
|
||||||
|
public static class Extensions
|
||||||
|
{
|
||||||
|
public static int FindElementIndex(this JsonArray jsonArray, long elementToFind)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < jsonArray.Count; i++)
|
||||||
|
{
|
||||||
|
JsonNode node = jsonArray.ElementAt(i)!;
|
||||||
|
if (node.GetValueKind() == JsonValueKind.Number &&
|
||||||
|
node.GetValue<long>() == elementToFind)
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1; // 未找到目标元素,返回 -1
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RemoveAll(this JsonArray jsonArray, Func<JsonNode?, bool> predicate)
|
||||||
|
{
|
||||||
|
var itemsToRemove = jsonArray.Where(predicate).ToList();
|
||||||
|
foreach (var item in itemsToRemove)
|
||||||
|
{
|
||||||
|
jsonArray.Remove(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,131 @@
|
|||||||
|
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using OMS.NET.Common;
|
||||||
|
using OMS.NET.DbClass;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class AddElementInstruct : Instruct
|
||||||
|
{
|
||||||
|
public AddElementInstruct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task Handler(string wsid)
|
||||||
|
{
|
||||||
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查,不通过则直接退出
|
||||||
|
if (Data?.GetType() != typeof(JsonElement)) return;//Data 非空和JsonElement类型检查
|
||||||
|
try
|
||||||
|
{
|
||||||
|
char[] charsToTrim = { '"' };
|
||||||
|
long id = Data.GetProperty("id").GetInt64();
|
||||||
|
string type = Data.GetProperty("type").GetRawText().Trim(charsToTrim);
|
||||||
|
string points = Data.GetProperty("points").GetRawText();
|
||||||
|
string point = Data.GetProperty("point").GetRawText().Trim(charsToTrim);
|
||||||
|
string? color = Data.GetProperty("color").GetRawText().Trim(charsToTrim);
|
||||||
|
int? width = Data.GetProperty("width").GetInt32();
|
||||||
|
// string? childRelations = Data.GetProperty("childRelations").GetString();
|
||||||
|
// string? fatherRelation = Data.GetProperty("fatherRelation").GetString();
|
||||||
|
// string? childNodes = Data.GetProperty("childNodes").GetString();
|
||||||
|
// string? fatherNode = Data.GetProperty("fatherNode").GetString();
|
||||||
|
string? details = Data.GetProperty("details").GetRawText().Trim(charsToTrim);
|
||||||
|
string? custom = Data.GetProperty("custom").GetRawText().Trim(charsToTrim);
|
||||||
|
//validations todo
|
||||||
|
//假设所有数据均合法
|
||||||
|
MapData mapData = new()
|
||||||
|
{
|
||||||
|
Type = type,
|
||||||
|
Points = Util.JsonToBase64(points),
|
||||||
|
Point = Util.JsonToBase64(point),
|
||||||
|
Color = color,
|
||||||
|
Width = width,
|
||||||
|
// ChildRelations = childRelations,
|
||||||
|
// FatherRelation = fatherRelation,
|
||||||
|
// ChildNodes = childNodes,
|
||||||
|
// FatherNode = fatherNode,
|
||||||
|
Details = Util.JsonToBase64(details),
|
||||||
|
Custom = Util.JsonToBase64(custom)
|
||||||
|
};
|
||||||
|
//保存点到数据库
|
||||||
|
MapData.Add(mapData);
|
||||||
|
//获取图层id
|
||||||
|
if (Data.GetProperty("custom").TryGetProperty("tmpId", out JsonElement tmpIdNode))
|
||||||
|
{
|
||||||
|
string tmpId = tmpIdNode.GetString() ?? throw new Exception("tmpId不能为空");
|
||||||
|
LayerData? layer = GlobalArea.GetLayerDataByTemplateId(tmpId);
|
||||||
|
if (layer != null && mapData.Id != -1)
|
||||||
|
{
|
||||||
|
layer.AppendElement(mapData.Id, mapData.Type);//包括数据库操作
|
||||||
|
//准备回复广播
|
||||||
|
string conveyor = GlobalArea.GetLoginEmailByID(wsid);
|
||||||
|
string time = GlobalArea.GetCurrentTime();
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Type = "broadcast",
|
||||||
|
Class = Class,
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = time,
|
||||||
|
Data = mapData,
|
||||||
|
});
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Type = "broadcast",
|
||||||
|
Class = "updateLayerData",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = time,
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
id = layer.LayerId,
|
||||||
|
members = layer.Members!.ToString(),
|
||||||
|
structure = layer.Structure!.ToString(),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsResponse = true,
|
||||||
|
Type = "send_correct",
|
||||||
|
Class = "upload",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = time,
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
vid = id,
|
||||||
|
rid = mapData.Id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("未找到 tmpId");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsResponse = true,
|
||||||
|
Type = "send_error",
|
||||||
|
Class = "upload",
|
||||||
|
Conveyor = GlobalArea.GetLoginEmailByID(wsid),
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
source = Data,
|
||||||
|
message = ex.Message
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class BatchDeleteElementInstruct : Instruct
|
||||||
|
{
|
||||||
|
public BatchDeleteElementInstruct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "batchDeleteElement";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task Handler(string wsid)
|
||||||
|
{
|
||||||
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查不通过则直接退出
|
||||||
|
if (Data?.GetType() != typeof(JsonElement)) return;//Data 非空和JsonElement类型检查
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//string conveyor = GlobalArea.GetLoginEmailByID(wsid);
|
||||||
|
//string time = GlobalArea.GetCurrentTime();
|
||||||
|
throw new NotImplementedException("这个也不想搞了");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,31 +0,0 @@
|
|||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace OMS.NET.Instructs
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 广播指令的基类
|
|
||||||
/// </summary>
|
|
||||||
public class BroadcastInstuct : Instruct
|
|
||||||
{
|
|
||||||
public BroadcastInstuct()
|
|
||||||
{
|
|
||||||
this.Type = "broadcast";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SendCorrectInstuct : Instruct
|
|
||||||
{
|
|
||||||
public SendCorrectInstuct()
|
|
||||||
{
|
|
||||||
this.Type = "send_error";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SendErrorInstuct : Instruct
|
|
||||||
{
|
|
||||||
public SendErrorInstuct()
|
|
||||||
{
|
|
||||||
this.Type = "send_correct";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using OMS.NET.Common;
|
||||||
|
using OMS.NET.DbClass;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class CreateGroupLayerInstruct : Instruct
|
||||||
|
{
|
||||||
|
public CreateGroupLayerInstruct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "createGroupLayer";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task Handler(string wsid)
|
||||||
|
{
|
||||||
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查不通过则直接退出
|
||||||
|
if (Data?.GetType() != typeof(JsonElement)) return;//Data 非空和JsonElement类型检查
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string conveyor = GlobalArea.GetLoginEmailByID(wsid);
|
||||||
|
AccountData accountData = GlobalArea.GetLoginAccountData(conveyor)!;
|
||||||
|
string creator = $"{accountData.UserName}({conveyor})";
|
||||||
|
LayerData newGroupLayer = GlobalArea.CreateGroupLayer(creator);
|
||||||
|
string time = GlobalArea.GetCurrentTime();
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Type = "broadcast",
|
||||||
|
Class = "createGroupLayer",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = time,
|
||||||
|
Data = newGroupLayer
|
||||||
|
});
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Type = "broadcast",
|
||||||
|
Class = "updateLayerOrder",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = time,
|
||||||
|
Data = new{
|
||||||
|
member = GlobalArea.GetOrderLayerData().Members
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,110 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using OMS.NET.Common;
|
||||||
|
using OMS.NET.DbClass;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class DeleteElementInstruct : Instruct
|
||||||
|
{
|
||||||
|
public DeleteElementInstruct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "deleteElement";
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
//解析id和tmpId
|
||||||
|
long id = Data.GetProperty("id").GetInt64();
|
||||||
|
string tmpId = Data.GetProperty("tmpId").GetString();
|
||||||
|
//需要先实现activeData相关
|
||||||
|
MapData mapData = MapData.Get(id) ?? throw new Exception($"Element{id}不存在");
|
||||||
|
mapData.Phase = 2;
|
||||||
|
int row = MapData.Update(mapData);
|
||||||
|
if (row == -1) throw new Exception("数据库修改失败");
|
||||||
|
if (GlobalArea.IsElementExit(id))
|
||||||
|
{
|
||||||
|
GlobalArea.RemoveActiveDataElement(id);
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Type = "broadcast",
|
||||||
|
Class = "pickSelectEndElements",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
id = id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsResponse = true,
|
||||||
|
Type = "send_correct",
|
||||||
|
Class = "delete",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
rid = id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Type = "broadcast",
|
||||||
|
Class = "deleteElement",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
id = id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
LayerData layer = GlobalArea.GetLayerDataByTemplateId(tmpId)!;
|
||||||
|
layer.DeleteElement(id);
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Type = "broadcast",
|
||||||
|
Class = "updateLayerData",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
id = layer.LayerId,
|
||||||
|
members = layer.Members!.ToString(),
|
||||||
|
structure = layer.Structure!.ToString(),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
//ResponseOrBroadcastInstructs.Clear();
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsResponse = true,
|
||||||
|
Type = "send_error",
|
||||||
|
Class = "delete",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
source = Data,
|
||||||
|
message = ex.Message
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class ForceUpdateDataInstruct : Instruct
|
||||||
|
{
|
||||||
|
public ForceUpdateDataInstruct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "forceUpdate";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task Handler(string wsid)
|
||||||
|
{
|
||||||
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查不通过则直接退出
|
||||||
|
if (Data?.GetType() != typeof(JsonElement)) return;//Data 非空和JsonElement类型检查
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//string conveyor = GlobalArea.GetLoginEmailByID(wsid);
|
||||||
|
string time = GlobalArea.GetCurrentTime();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class GetActiveDataInstruct : Instruct
|
||||||
|
{
|
||||||
|
public GetActiveDataInstruct()
|
||||||
|
{
|
||||||
|
Type = "get_activeData";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task Handler(string wsid)
|
||||||
|
{
|
||||||
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查,不通过则直接退出
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsResponse = true,
|
||||||
|
Type = "send_activeData",
|
||||||
|
Data = GlobalArea.GetActiveDataList
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
using System.Text.Json;
|
||||||
|
using OMS.NET.Common;
|
||||||
|
using OMS.NET.DbClass;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class PickEndElementInstruct : Instruct
|
||||||
|
{
|
||||||
|
public PickEndElementInstruct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "pickEndElement";
|
||||||
|
}
|
||||||
|
|
||||||
|
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.GetInt64();
|
||||||
|
string conveyor = GlobalArea.GetLoginEmailByID(wsid);
|
||||||
|
if (GlobalArea.IsElementExit(id))//已存在activedata项
|
||||||
|
{
|
||||||
|
ActiveDataElement activeDataElement = GlobalArea.GetActiveDataElement(id)!;
|
||||||
|
if (activeDataElement.Pick?.Email == conveyor)
|
||||||
|
{
|
||||||
|
activeDataElement.Pick = null;
|
||||||
|
string time = GlobalArea.GetCurrentTime();
|
||||||
|
ResponseOrBroadcastInstructs.Add(new PickEndElementInstruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = time,
|
||||||
|
Data = id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using OMS.NET.Common;
|
||||||
|
using OMS.NET.DbClass;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class PickIngElementInstruct : Instruct
|
||||||
|
{
|
||||||
|
public PickIngElementInstruct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "pickIngElement";
|
||||||
|
}
|
||||||
|
|
||||||
|
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.GetInt64();
|
||||||
|
string conveyor = GlobalArea.GetLoginEmailByID(wsid);
|
||||||
|
AccountData accountData = GlobalArea.GetLoginAccountData(conveyor)!;
|
||||||
|
UserInfo userInfo = new()
|
||||||
|
{
|
||||||
|
Email = conveyor,
|
||||||
|
Color = accountData.HeadColor,
|
||||||
|
Name = accountData.UserName,
|
||||||
|
};
|
||||||
|
if (GlobalArea.IsElementExit(id))//已存在activedata项
|
||||||
|
{
|
||||||
|
ActiveDataElement activeDataElement = GlobalArea.GetActiveDataElement(id)!;
|
||||||
|
if (activeDataElement.Pick == null)
|
||||||
|
{
|
||||||
|
activeDataElement.Pick = userInfo;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"{id}已被{activeDataElement.Pick.Name}Pick");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalArea.AddActiveDataElement(new ActiveDataElement(id)
|
||||||
|
{
|
||||||
|
Pick = userInfo
|
||||||
|
});
|
||||||
|
}
|
||||||
|
string time = GlobalArea.GetCurrentTime();
|
||||||
|
ResponseOrBroadcastInstructs.Add(new PickIngElementInstruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = time,
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
id = id,
|
||||||
|
color = accountData.HeadColor
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,32 +1,22 @@
|
|||||||
namespace OMS.NET.Instructs
|
namespace OMS.NET.Instructs
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 用于测试和代码复制
|
|
||||||
/// </summary>
|
|
||||||
public class PingInstuct : Instruct
|
public class PingInstuct : Instruct
|
||||||
{
|
{
|
||||||
public PingInstuct()
|
public PingInstuct()
|
||||||
{
|
{
|
||||||
this.Type = "ping";
|
Type = "ping";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task Handler(string wsid)
|
public override Task Handler(string wsid)
|
||||||
{
|
{
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
this.ResponseOrBroadcastInstructs.Add(new PongInstuct()
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
{
|
{
|
||||||
IsResponse = true
|
IsResponse = true,
|
||||||
|
Type = "pong"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PongInstuct : Instruct
|
|
||||||
{
|
|
||||||
public PongInstuct()
|
|
||||||
{
|
|
||||||
this.Type = "pong";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using OMS.NET.Common;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class RenameLayerInstruct : Instruct
|
||||||
|
{
|
||||||
|
public RenameLayerInstruct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "renameLayer";
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
string name = Data.GetProperty("name").GetString();
|
||||||
|
if (GlobalArea.IsLayerNameRepeat(name)) throw new Exception("存在名称重复");
|
||||||
|
LayerData layerData = GlobalArea.GetLayerDataByLayerId(id) ?? throw new Exception($"未找到MapLayer {id}");
|
||||||
|
layerData.Structure!.AsArray().RemoveAt(0);
|
||||||
|
layerData.Structure!.AsArray().Insert(0, name);
|
||||||
|
layerData.UpdateToDb();
|
||||||
|
|
||||||
|
string conveyor = GlobalArea.GetLoginEmailByID(wsid);
|
||||||
|
string time = GlobalArea.GetCurrentTime();
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Type = "broadcast",
|
||||||
|
Class = "renameLayer",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = time,
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
id = id,
|
||||||
|
name = name,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using OMS.NET.Common;
|
||||||
|
using OMS.NET.DbClass;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class RestoreElementInstruct : Instruct
|
||||||
|
{
|
||||||
|
public RestoreElementInstruct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "restoreElement";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task Handler(string wsid)
|
||||||
|
{
|
||||||
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查不通过则直接退出
|
||||||
|
if (Data?.GetType() != typeof(JsonElement)) return;//Data 非空和JsonElement类型检查
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string conveyor = GlobalArea.GetLoginEmailByID(wsid);
|
||||||
|
long id = Data.GetProperty("id").GetInt64();
|
||||||
|
string tmpId = Data.GetProperty("tmpId").GetString();
|
||||||
|
MapData mapData = MapData.Get(id) ?? throw new Exception($"Element{id}不存在");
|
||||||
|
mapData.Phase = 1;
|
||||||
|
if (MapData.Update(mapData) == -1) throw new Exception("数据库修改失败");
|
||||||
|
LayerData layer = GlobalArea.GetLayerDataByTemplateId(tmpId)!;
|
||||||
|
layer.AppendElement(id, mapData.Type);
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Type = "broadcast",
|
||||||
|
Class = mapData.Type,
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = mapData
|
||||||
|
});
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Type = "broadcast",
|
||||||
|
Class = "updateLayerData",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
id = layer.LayerId,
|
||||||
|
members = layer.Members!.ToString(),
|
||||||
|
structure = layer.Structure!.ToString(),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsResponse = true,
|
||||||
|
Type = "send_correct",
|
||||||
|
Class = "upload",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
rid = id,
|
||||||
|
vid = "restore"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
using System.Text.Json;
|
||||||
|
using OMS.NET.Common;
|
||||||
|
using OMS.NET.DbClass;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class SelectEndElementInstruct : Instruct
|
||||||
|
{
|
||||||
|
public SelectEndElementInstruct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "selectEndElement";
|
||||||
|
}
|
||||||
|
|
||||||
|
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.GetInt64();
|
||||||
|
string conveyor = GlobalArea.GetLoginEmailByID(wsid);
|
||||||
|
if (GlobalArea.IsElementExit(id))//已存在activedata项
|
||||||
|
{
|
||||||
|
ActiveDataElement activeDataElement = GlobalArea.GetActiveDataElement(id)!;
|
||||||
|
if (activeDataElement.Select?.Email == conveyor)
|
||||||
|
{
|
||||||
|
activeDataElement.Select = null;
|
||||||
|
string time = GlobalArea.GetCurrentTime();
|
||||||
|
ResponseOrBroadcastInstructs.Add(new SelectEndElementInstruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = time,
|
||||||
|
Data = id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using OMS.NET.Common;
|
||||||
|
using OMS.NET.DbClass;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class SelectIngElementInstruct : Instruct
|
||||||
|
{
|
||||||
|
public SelectIngElementInstruct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "selectIngElement";
|
||||||
|
}
|
||||||
|
|
||||||
|
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.GetInt64();
|
||||||
|
string conveyor = GlobalArea.GetLoginEmailByID(wsid);
|
||||||
|
AccountData accountData = GlobalArea.GetLoginAccountData(conveyor)!;
|
||||||
|
UserInfo userInfo = new()
|
||||||
|
{
|
||||||
|
Email = conveyor,
|
||||||
|
Color = accountData.HeadColor,
|
||||||
|
Name = accountData.UserName,
|
||||||
|
};
|
||||||
|
if (GlobalArea.IsElementExit(id))//已存在activedata项
|
||||||
|
{
|
||||||
|
ActiveDataElement activeDataElement = GlobalArea.GetActiveDataElement(id)!;
|
||||||
|
if (activeDataElement.Select == null)
|
||||||
|
{
|
||||||
|
activeDataElement.Select = userInfo;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"{id}已被{activeDataElement.Select.Name}Select");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalArea.AddActiveDataElement(new ActiveDataElement(id)
|
||||||
|
{
|
||||||
|
Select = userInfo
|
||||||
|
});
|
||||||
|
}
|
||||||
|
string time = GlobalArea.GetCurrentTime();
|
||||||
|
ResponseOrBroadcastInstructs.Add(new SelectIngElementInstruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = time,
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
id = id,
|
||||||
|
color = accountData.HeadColor
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using OMS.NET.Common;
|
||||||
|
using OMS.NET.DbClass;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class UpdateElementInstuct : Instruct
|
||||||
|
{
|
||||||
|
public UpdateElementInstuct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "updateElement";
|
||||||
|
}
|
||||||
|
|
||||||
|
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 id = Data.GetProperty("id").GetInt64();
|
||||||
|
string updateId = Data.GetProperty("updateId").GetString();
|
||||||
|
if (Data.TryGetProperty("changes", out JsonElement changes))
|
||||||
|
{
|
||||||
|
MapData mapData = MapData.Get(id) ?? throw new Exception($"数据库中未能找到id为{id}的元素");
|
||||||
|
string color = changes.GetProperty("color").GetString()!;
|
||||||
|
if (changes.TryGetProperty("width", out JsonElement widthElement))
|
||||||
|
{
|
||||||
|
int width = widthElement.GetInt32();
|
||||||
|
mapData.Width = width;
|
||||||
|
}
|
||||||
|
if (changes.TryGetProperty("details", out JsonElement detailsElement))
|
||||||
|
{
|
||||||
|
string details = detailsElement.GetString()!;
|
||||||
|
mapData.Details = Util.JsonToBase64(details);
|
||||||
|
}
|
||||||
|
if (changes.TryGetProperty("custom", out JsonElement customElement))
|
||||||
|
{
|
||||||
|
string custom = customElement.GetString()!;
|
||||||
|
mapData.Custom = Util.JsonToBase64(custom);
|
||||||
|
}
|
||||||
|
if (MapData.Update(mapData) == -1) throw new Exception("数据库修改失败");
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsResponse = true,
|
||||||
|
Type = "send_correct",
|
||||||
|
Class = "updateElement",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
vid = updateId,
|
||||||
|
rid = id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Type = "broadcast",
|
||||||
|
Class = "updateElement",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = mapData
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsResponse = true,
|
||||||
|
Type = "send_error",
|
||||||
|
Class = "updateElement",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
source = Data,
|
||||||
|
message = ex.Message
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,87 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using OMS.NET.Common;
|
||||||
|
using OMS.NET.DbClass;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class UpdateElementNodeInstuct : Instruct
|
||||||
|
{
|
||||||
|
public UpdateElementNodeInstuct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "updateElementNode";
|
||||||
|
}
|
||||||
|
|
||||||
|
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 id = Data.GetProperty("id").GetInt64();
|
||||||
|
string updateId = Data.GetProperty("updateId").GetString();
|
||||||
|
string points = Data.GetProperty("points").GetRawText();//todo
|
||||||
|
MapData mapData = MapData.Get(id) ?? throw new Exception($"数据库中未能找到id为{id}的元素");
|
||||||
|
mapData.Points = Util.JsonToBase64(points);
|
||||||
|
|
||||||
|
if (Data.TryGetProperty("point", out JsonElement pointNode))
|
||||||
|
{
|
||||||
|
mapData.Point = Util.JsonToBase64(pointNode.GetRawText());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (MapData.Update(mapData) == -1) throw new Exception("数据库修改失败");
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsResponse = true,
|
||||||
|
Type = "send_correct",
|
||||||
|
Class = "updateNode",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
vid = updateId,
|
||||||
|
rid = id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Type = "broadcast",
|
||||||
|
Class = "updateElementNode",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
id = mapData.Id,
|
||||||
|
type = mapData.Type,
|
||||||
|
point = mapData.Point,
|
||||||
|
points = mapData.Points
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsResponse = true,
|
||||||
|
Type = "send_error",
|
||||||
|
Class = "updateNode",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
source = Data,
|
||||||
|
message = ex.Message
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
using OMS.NET.Common;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class UpdateLayerOrderInstruct : Instruct
|
||||||
|
{
|
||||||
|
public UpdateLayerOrderInstruct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "updateLayerOrder";
|
||||||
|
}
|
||||||
|
|
||||||
|
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 active = Data.GetProperty("active").GetInt64();
|
||||||
|
long passive = Data.GetProperty("passive").GetInt64();
|
||||||
|
string type = Data.GetProperty("type").GetString();
|
||||||
|
LayerData order = GlobalArea.GetOrderLayerData();
|
||||||
|
order.AdjustOrderLayer(active, passive, type);
|
||||||
|
ResponseOrBroadcastInstructs.Add(new Instruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Type = "broadcast",
|
||||||
|
Class = "updateLayerOrder",
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = GlobalArea.GetCurrentTime(),
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
member = order.Members
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class UpdateTemplateDataInstruct : Instruct
|
||||||
|
{
|
||||||
|
public UpdateTemplateDataInstruct()
|
||||||
|
{
|
||||||
|
Type = "broadcast";
|
||||||
|
Class = "updateTemplateData";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task Handler(string wsid)
|
||||||
|
{
|
||||||
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查不通过则直接退出
|
||||||
|
if (Data?.GetType() != typeof(JsonElement)) return;//Data 非空和JsonElement类型检查
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//string conveyor = GlobalArea.GetLoginEmailByID(wsid);
|
||||||
|
//string time = GlobalArea.GetCurrentTime();
|
||||||
|
//string template = Data.GetProperty("template").GetString();
|
||||||
|
throw new NotImplementedException("太难搞了,不干了");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{Class}广播指令出错:" + ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue