实现更多的指令
parent
0082549e0b
commit
e2c85517cc
@ -0,0 +1,33 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class DeleteElementBroadcastInstruct : BroadcastInstuct
|
||||||
|
{
|
||||||
|
public DeleteElementBroadcastInstruct()
|
||||||
|
{
|
||||||
|
this.Class = "deleteElement";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task Handler(string wsid)
|
||||||
|
{
|
||||||
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查不通过则直接退出
|
||||||
|
if (Data?.GetType() != typeof(JsonElement)) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string conveyor = GlobalArea.GetLoginEmailByID(wsid);
|
||||||
|
//解析id和tmpId
|
||||||
|
long id = Data.GetProperty("id").GetInt64();
|
||||||
|
string tmpId = Data.GetProperty("tmpId").GetString();
|
||||||
|
//需要先实现activeData相关
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using OMS.NET.Common;
|
||||||
|
using OMS.NET.DbClass;
|
||||||
|
|
||||||
|
namespace OMS.NET.Instructs
|
||||||
|
{
|
||||||
|
public class SelectIngElementBroadcastInstruct : BroadcastInstuct
|
||||||
|
{
|
||||||
|
public SelectIngElementBroadcastInstruct()
|
||||||
|
{
|
||||||
|
this.Class = "selectIngElement";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task Handler(string wsid)
|
||||||
|
{
|
||||||
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查不通过则直接退出
|
||||||
|
if (Data?.GetType() != typeof(JsonElement)) return;
|
||||||
|
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}选中");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalArea.AddActiveDataElement(new ActiveDataElement(id)
|
||||||
|
{
|
||||||
|
Select = userInfo
|
||||||
|
});
|
||||||
|
}
|
||||||
|
string time = GlobalArea.GetCurrentTime();
|
||||||
|
ResponseOrBroadcastInstructs.Add(new SelectIngElementBroadcastInstruct()
|
||||||
|
{
|
||||||
|
IsBroadcast = true,
|
||||||
|
Conveyor = conveyor,
|
||||||
|
Time = time,
|
||||||
|
Data = new
|
||||||
|
{
|
||||||
|
id = id,
|
||||||
|
color = accountData.HeadColor
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalArea.Log.Warn($"处理{this.Class}广播指令出错:" + ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue