增加更多的指令实现
parent
670856fb58
commit
0d7cc2df5f
@ -0,0 +1,24 @@
|
||||
namespace OMS.NET.Instructs
|
||||
{
|
||||
public class GetActiveDataInstruct : Instruct
|
||||
{
|
||||
public GetActiveDataInstruct()
|
||||
{
|
||||
this.Type = "get_activeData";
|
||||
}
|
||||
|
||||
public override Task Handler(string wsid)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查,不通过则直接退出
|
||||
this.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($"处理{this.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()
|
||||
{
|
||||
this.Type = "broadcast";
|
||||
this.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($"处理{this.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($"处理{this.Class}广播指令出错:" + ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue