diff --git a/Instructs/AddElementBroadcastInstruct.cs b/Instructs/AddElementBroadcastInstruct.cs deleted file mode 100644 index 3dd109e..0000000 --- a/Instructs/AddElementBroadcastInstruct.cs +++ /dev/null @@ -1,134 +0,0 @@ - -using System.Text; -using System.Text.Json; -using OMS.NET.Common; -using OMS.NET.DbClass; - -namespace OMS.NET.Instructs -{ - public class AddElementBroadcastInstruct : BroadcastInstuct - { - public AddElementBroadcastInstruct() - { - Type = "broadcast"; - } - - public override Task Handler(string wsid) - { - return Task.Run(() => - { - if (GlobalArea.LoginCheckByID(wsid)) - { - //从Data中解析数据,收到的是json文本类型 - if (Data?.GetType() == typeof(JsonElement)) - { - try - { - long id = Data.GetProperty("id").GetInt64(); - string type = Data.GetProperty("type").GetString(); - string points = Data.GetProperty("points").GetString(); - string point = Data.GetProperty("point").GetString(); - string? color = Data.GetProperty("color").GetString(); - int? width = Data.GetProperty("width").GetInt32(); - string? childRelations = Data.GetProperty("childRelations").GetString(); - string? fatherRelations = Data.GetProperty("fatherRelations").GetString(); - string? childNodes = Data.GetProperty("childNodes").GetString(); - string? fatherNode = Data.GetProperty("fatherNode").GetString(); - string? details = Data.GetProperty("details").GetString(); - string? custom = Data.GetProperty("custom").GetString(); - //validations todo - //假设所有数据均合法 - MapData mapData = new() - { - Type = type, - Points = Util.JsonToBase64(points), - Point = Util.JsonToBase64(point), - Color = color, - Width = width, - ChildRelations = childRelations, - FatherRelations = fatherRelations, - 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 BroadcastInstuct() - { - IsBroadcast = true, - Class = this.Class, - Conveyor = conveyor, - Time = time, - Data = mapData, - }); - ResponseOrBroadcastInstructs.Add(new BroadcastInstuct() - { - IsBroadcast = true, - Class = "updateLayerData", - Conveyor = conveyor, - Time = time, - Data = new - { - id = layer.LayerId, - members = layer.Members!.ToString(), - structure = layer.Structure!.ToString(), - } - }); - ResponseOrBroadcastInstructs.Add(new SendErrorInstuct() - { - IsResponse = true, - Class = "upload", - Conveyor = conveyor, - Time = time, - Data = new Dictionary() - { - {"vid",id}, - {"rid",mapData.Id} - }, - - }); - - } - - } - else - { - throw new Exception("未找到 tmpId"); - } - - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - ResponseOrBroadcastInstructs.Add(new SendErrorInstuct() - { - IsResponse = true, - Class = "upload", - Conveyor = GlobalArea.GetLoginEmailByID(wsid), - Time = GlobalArea.GetCurrentTime(), - Data = new - { - source = Data, - message = ex.Message, - }, - - }); - } - } - } - }); - } - } -} \ No newline at end of file diff --git a/Instructs/AddElementInstruct.cs b/Instructs/AddElementInstruct.cs new file mode 100644 index 0000000..7601f93 --- /dev/null +++ b/Instructs/AddElementInstruct.cs @@ -0,0 +1,132 @@ + +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 + { + long id = Data.GetProperty("id").GetInt64(); + string type = Data.GetProperty("type").GetString(); + string points = Data.GetProperty("points").GetString(); + string point = Data.GetProperty("point").GetString(); + string? color = Data.GetProperty("color").GetString(); + int? width = Data.GetProperty("width").GetInt32(); + string? childRelations = Data.GetProperty("childRelations").GetString(); + string? fatherRelations = Data.GetProperty("fatherRelations").GetString(); + string? childNodes = Data.GetProperty("childNodes").GetString(); + string? fatherNode = Data.GetProperty("fatherNode").GetString(); + string? details = Data.GetProperty("details").GetString(); + string? custom = Data.GetProperty("custom").GetString(); + //validations todo + //假设所有数据均合法 + MapData mapData = new() + { + Type = type, + Points = Util.JsonToBase64(points), + Point = Util.JsonToBase64(point), + Color = color, + Width = width, + ChildRelations = childRelations, + FatherRelations = fatherRelations, + 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 = this.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 Dictionary() + { + {"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 + } + }); + } + }); + } + } +} \ No newline at end of file diff --git a/Instructs/BroadcastInstuct.cs b/Instructs/BroadcastInstuct.cs deleted file mode 100644 index 0ab7c0a..0000000 --- a/Instructs/BroadcastInstuct.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Text.Json; - -namespace OMS.NET.Instructs -{ - /// - /// 广播指令的基类 - /// - 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"; - } - } -} \ No newline at end of file diff --git a/Instructs/DeleteElementBroadcastInstuct.cs b/Instructs/DeleteElementInstuct.cs similarity index 86% rename from Instructs/DeleteElementBroadcastInstuct.cs rename to Instructs/DeleteElementInstuct.cs index bfc2270..9c62936 100644 --- a/Instructs/DeleteElementBroadcastInstuct.cs +++ b/Instructs/DeleteElementInstuct.cs @@ -2,9 +2,9 @@ using System.Text.Json; namespace OMS.NET.Instructs { - public class DeleteElementBroadcastInstruct : BroadcastInstuct + public class DeleteElementInstruct : Instruct { - public DeleteElementBroadcastInstruct() + public DeleteElementInstruct() { this.Class = "deleteElement"; } @@ -14,7 +14,7 @@ namespace OMS.NET.Instructs return Task.Run(() => { if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查不通过则直接退出 - if (Data?.GetType() != typeof(JsonElement)) return; + if (Data?.GetType() != typeof(JsonElement)) return;//Data 非空和JsonElement类型检查 try { string conveyor = GlobalArea.GetLoginEmailByID(wsid); diff --git a/Instructs/GetMapDataInstruct.cs b/Instructs/GetMapDataInstruct.cs index bb4041a..f81fd0e 100644 --- a/Instructs/GetMapDataInstruct.cs +++ b/Instructs/GetMapDataInstruct.cs @@ -13,24 +13,15 @@ namespace OMS.NET.Instructs { return Task.Run(() => { - if (GlobalArea.LoginCheckByID(wsid)) + if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查,不通过则直接退出 + List mapDatas = MapData.GetMapDataList().Where(m => m.Phase != 2).ToList(); + this.ResponseOrBroadcastInstructs.Add(new Instruct() { - List mapDatas = MapData.GetMapDataList().Where(m => m.Phase != 2).ToList(); - this.ResponseOrBroadcastInstructs.Add(new SendMapDataInstruct() - { - IsResponse = true, - Data = mapDatas - }); - } + IsResponse = true, + Type = "send_mapData", + Data = mapDatas + }); }); } } - - public class SendMapDataInstruct : Instruct - { - public SendMapDataInstruct() - { - this.Type = "send_mapData"; - } - } } \ No newline at end of file diff --git a/Instructs/GetMapLayerInstruct.cs b/Instructs/GetMapLayerInstruct.cs index b91d681..67ccddb 100644 --- a/Instructs/GetMapLayerInstruct.cs +++ b/Instructs/GetMapLayerInstruct.cs @@ -13,24 +13,15 @@ namespace OMS.NET.Instructs { return Task.Run(() => { - if (GlobalArea.LoginCheckByID(wsid)) + if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查,不通过则直接退出 + List mapLayers = MapLayer.GetMapLayerList().Where(m => m.Phase != 2).ToList(); + this.ResponseOrBroadcastInstructs.Add(new Instruct() { - List mapLayers = MapLayer.GetMapLayerList().Where(m => m.Phase != 2).ToList(); - this.ResponseOrBroadcastInstructs.Add(new SendMapLayerInstruct() - { - IsResponse = true, - Data = mapLayers - }); - } + IsResponse = true, + Type = "send_mapLayer", + Data = mapLayers + }); }); } } - - public class SendMapLayerInstruct : Instruct - { - public SendMapLayerInstruct() - { - this.Type = "send_mapLayer"; - } - } } \ No newline at end of file diff --git a/Instructs/GetPresenceInstruct.cs b/Instructs/GetPresenceInstruct.cs index 9c5c588..6786216 100644 --- a/Instructs/GetPresenceInstruct.cs +++ b/Instructs/GetPresenceInstruct.cs @@ -13,40 +13,30 @@ namespace OMS.NET.Instructs { return Task.Run(() => { - if (GlobalArea.LoginCheckByID(wsid)) + if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查,不通过则直接退出 + //获取所有在线用户,移除重复 + List emails = GlobalArea.UserConnects.Where(u => u.UserEmail != null) + .Select(u => u.UserEmail).Distinct().ToList(); + List allLoginUsers = new(); + emails.ForEach(email => { - //获取所有在线用户,移除重复 - List emails = GlobalArea.UserConnects.Where(u => u.UserEmail != null) - .Select(u => u.UserEmail).Distinct().ToList(); - List allLoginUsers = new(); - emails.ForEach(email => + AccountData accountData = GlobalArea.GetLoginAccountData(email)!; + //由于是已登录用户,默认都能查询到值 + allLoginUsers.Add(new { - AccountData accountData = GlobalArea.GetLoginAccountData(email)!; - //由于是已登录用户,默认都能查询到值 - allLoginUsers.Add(new - { - userEmail = accountData.UserEmail, - userQq = accountData.UserQQ, - userName = accountData.UserName, - headColor = accountData.HeadColor, - }); + userEmail = accountData.UserEmail, + userQq = accountData.UserQQ, + userName = accountData.UserName, + headColor = accountData.HeadColor, }); - this.ResponseOrBroadcastInstructs.Add(new SendPresenceInstruct() - { - IsResponse = true, - Data = allLoginUsers, - }); - - } + }); + this.ResponseOrBroadcastInstructs.Add(new Instruct() + { + IsResponse = true, + Type = "send_presence", + Data = allLoginUsers, + }); }); } } - - public class SendPresenceInstruct : Instruct - { - public SendPresenceInstruct() - { - this.Type = "send_presence"; - } - } } \ No newline at end of file diff --git a/Instructs/GetPublickeyInstruct.cs b/Instructs/GetPublickeyInstruct.cs index 9e6d02a..c04899c 100644 --- a/Instructs/GetPublickeyInstruct.cs +++ b/Instructs/GetPublickeyInstruct.cs @@ -11,22 +11,14 @@ namespace OMS.NET.Instructs { return Task.Run(() => { - this.ResponseOrBroadcastInstructs.Add(new PublickeyInstruct() + this.ResponseOrBroadcastInstructs.Add(new Instruct() { - Data = GlobalArea.GetRsaPublickKey(), - IsResponse = true + IsResponse = true, + Type = "publickey", + Data = GlobalArea.GetRsaPublickKey() }); //Thread.Sleep(9000);//模拟耗时操作 }); } } - - public class PublickeyInstruct : Instruct - { - public PublickeyInstruct() - { - this.Type = "publickey"; - } - - } } \ No newline at end of file diff --git a/Instructs/GetServerConfigInstruct.cs b/Instructs/GetServerConfigInstruct.cs index 365b5f2..dfdcc7b 100644 --- a/Instructs/GetServerConfigInstruct.cs +++ b/Instructs/GetServerConfigInstruct.cs @@ -11,9 +11,10 @@ namespace OMS.NET.Instructs { return Task.Run(() => { - this.ResponseOrBroadcastInstructs.Add(new SendServerConfigInstruct + this.ResponseOrBroadcastInstructs.Add(new Instruct() { IsResponse = true, + Type = "send_serverConfig", Data = new { anonymous_login = bool.TryParse(GlobalArea.ServerConfig.AnonymousLogin, out bool booleanValue) && booleanValue, @@ -36,12 +37,4 @@ namespace OMS.NET.Instructs }); } } - - public class SendServerConfigInstruct : Instruct - { - public SendServerConfigInstruct() - { - this.Type = "send_serverConfig"; - } - } } \ No newline at end of file diff --git a/Instructs/GetServerImgInstruct.cs b/Instructs/GetServerImgInstruct.cs index c0ba598..0f9f3d5 100644 --- a/Instructs/GetServerImgInstruct.cs +++ b/Instructs/GetServerImgInstruct.cs @@ -24,9 +24,10 @@ namespace OMS.NET.Instructs if (File.Exists(serverImgPath)) { DateTime serverImgLastModified = File.GetLastWriteTime(serverImgPath); - Instruct res = new SendServerConfigInstruct + Instruct res = new() { - IsResponse = true + IsResponse = true, + Type = "send_serverImg" }; if (serverImgLastModified > clientDateTime) { @@ -73,12 +74,4 @@ namespace OMS.NET.Instructs return "unknown"; } } - - public class SendServerImgInstruct : Instruct - { - public SendServerImgInstruct() - { - this.Type = "send_serverImg"; - } - } } \ No newline at end of file diff --git a/Instructs/GetUserDataInstruct.cs b/Instructs/GetUserDataInstruct.cs index 6131274..a40a266 100644 --- a/Instructs/GetUserDataInstruct.cs +++ b/Instructs/GetUserDataInstruct.cs @@ -13,36 +13,27 @@ namespace OMS.NET.Instructs { return Task.Run(() => { - if (GlobalArea.LoginCheckByID(wsid)) + if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查,不通过则直接退出 + string userEmail = GlobalArea.UserConnects.First(u => u.ID == wsid).UserEmail!; + AccountData accountData = GlobalArea.GetLoginAccountData(userEmail)!; + this.ResponseOrBroadcastInstructs.Add(new Instruct() { - string userEmail = GlobalArea.UserConnects.First(u => u.ID == wsid).UserEmail!; - AccountData accountData = GlobalArea.GetLoginAccountData(userEmail)!; - this.ResponseOrBroadcastInstructs.Add(new SendUserDataInstruct() + IsResponse = true, + Type = "send_userData", + Data = new { - IsResponse = true, - Data = new - { - user_email = accountData.UserEmail, - user_name = accountData.UserName, - map_layer = accountData.MapLayer, - default_a1 = accountData.DefaultA1, - save_point = accountData.SavePoint, - head_color = accountData.HeadColor, - mode = accountData.Mode, - phase = accountData.Phase, - custom = accountData.Custom, - } - }); - } + user_email = accountData.UserEmail, + user_name = accountData.UserName, + map_layer = accountData.MapLayer, + default_a1 = accountData.DefaultA1, + save_point = accountData.SavePoint, + head_color = accountData.HeadColor, + mode = accountData.Mode, + phase = accountData.Phase, + custom = accountData.Custom, + } + }); }); } } - - public class SendUserDataInstruct : Instruct - { - public SendUserDataInstruct() - { - this.Type = "send_userData"; - } - } } \ No newline at end of file diff --git a/Instructs/Instruct.cs b/Instructs/Instruct.cs index 5173568..65ae634 100644 --- a/Instructs/Instruct.cs +++ b/Instructs/Instruct.cs @@ -58,12 +58,12 @@ namespace OMS.NET.Instructs "broadcast" => classValue switch { //广播指令继承结构 - "point" => JsonSerializer.Deserialize(root.GetRawText(), options), - "line" => JsonSerializer.Deserialize(root.GetRawText(), options), - "area" => JsonSerializer.Deserialize(root.GetRawText(), options), - "curve" => JsonSerializer.Deserialize(root.GetRawText(), options), - "deleteElement" => JsonSerializer.Deserialize(root.GetRawText(), options), - "textMessage" => JsonSerializer.Deserialize(root.GetRawText(), options), + "point" => JsonSerializer.Deserialize(root.GetRawText(), options), + "line" => JsonSerializer.Deserialize(root.GetRawText(), options), + "area" => JsonSerializer.Deserialize(root.GetRawText(), options), + "curve" => JsonSerializer.Deserialize(root.GetRawText(), options), + "deleteElement" => JsonSerializer.Deserialize(root.GetRawText(), options), + "textMessage" => JsonSerializer.Deserialize(root.GetRawText(), options), _ => JsonSerializer.Deserialize(root.GetRawText(), options) }, _ => null diff --git a/Instructs/LoginInstruct.cs b/Instructs/LoginInstruct.cs index e8a78f2..c344d74 100644 --- a/Instructs/LoginInstruct.cs +++ b/Instructs/LoginInstruct.cs @@ -11,70 +11,61 @@ namespace OMS.NET.Instructs { public LoginInstruct() { - this.Type = "login"; + Type = "login"; } public override Task Handler(string wsid) { return Task.Run(() => { - if (this.Data?.GetType() == typeof(JsonElement)) + if (Data?.GetType() != typeof(JsonElement)) return;//Data 非空和JsonElement类型检查 + string email = Data.GetProperty("email").GetString(); + string password = Data.GetProperty("password").GetString(); + if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { - string email = this.Data.GetProperty("email").GetString(); - string password = this.Data.GetProperty("password").GetString(); - if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) - { - GlobalArea.Log.Warn("登录信息不能为空!"); - return; - } - //能够获取到则说明客户端有发送数据过来 - Instruct res1 = new LoginStatusInstuct - { - Data = false, - IsResponse = true - };//默认为false - //Console.WriteLine($"已获取到{email}:{password},解密测试{GlobalArea.DecryptFromBase64String(password)}"); - AccountData? accountData = AccountData.Get(email); - GlobalArea.AddLoginAccountData(accountData); - if (accountData != null) + GlobalArea.Log.Warn("登录信息不能为空!"); + return; + } + //能够获取到则说明客户端有发送数据过来 + Instruct res1 = new() + { + IsResponse = true, + Type = "loginStatus", + Data = false + };//默认为false + //Console.WriteLine($"已获取到{email}:{password},解密测试{GlobalArea.DecryptFromBase64String(password)}"); + AccountData? accountData = AccountData.Get(email); + GlobalArea.AddLoginAccountData(accountData); + if (accountData != null) + { + //只能原文比较,密文每次都不一样,涉及随机性填充 + if (accountData.Password == GlobalArea.DecryptFromBase64String(password)) { - //只能原文比较,密文每次都不一样,涉及随机性填充 - if (accountData.Password == GlobalArea.DecryptFromBase64String(password)) + res1.Data = true;//登录成功则修改为true + ResponseOrBroadcastInstructs.Add(res1); + GlobalArea.Log.Info($"{accountData.UserEmail}:登录成功"); + GlobalArea.Login(wsid, accountData.UserEmail); + GlobalArea.Log.Info($"当前登录用户数量: {GlobalArea.LoginUserCount}"); + ResponseOrBroadcastInstructs.Add(new Instruct { - res1.Data = true;//登录成功则修改为true - this.ResponseOrBroadcastInstructs.Add(res1); - GlobalArea.Log.Info($"{accountData.UserEmail}:登录成功"); - GlobalArea.Login(wsid, accountData.UserEmail); - GlobalArea.Log.Info($"当前登录用户数量: {GlobalArea.LoginUserCount}"); - this.ResponseOrBroadcastInstructs.Add(new Instruct + Type = "broadcast", + Class = "logIn", + Data = new { - Type = "broadcast", - Class = "logIn", - Data = new - { - userEmail = accountData.UserEmail, - userName = accountData.UserName, - headColor = accountData.HeadColor, - userQq = accountData.UserQQ, - }, - IsBroadcast = true - }); - } - else - { - this.ResponseOrBroadcastInstructs.Add(res1); - } + userEmail = accountData.UserEmail, + userName = accountData.UserName, + headColor = accountData.HeadColor, + userQq = accountData.UserQQ, + }, + IsBroadcast = true + }); + } + else + { + ResponseOrBroadcastInstructs.Add(res1); } } }); } } - - public class LoginStatusInstuct : Instruct - { - public LoginStatusInstuct() - { - this.Type = "loginStatus"; - } - } } \ No newline at end of file diff --git a/Instructs/PingInstuct.cs b/Instructs/PingInstuct.cs index 47551ef..c8796e7 100644 --- a/Instructs/PingInstuct.cs +++ b/Instructs/PingInstuct.cs @@ -1,8 +1,5 @@ namespace OMS.NET.Instructs { - /// - /// 用于测试和代码复制 - /// public class PingInstuct : Instruct { public PingInstuct() @@ -14,19 +11,12 @@ namespace OMS.NET.Instructs { return Task.Run(() => { - this.ResponseOrBroadcastInstructs.Add(new PongInstuct() + this.ResponseOrBroadcastInstructs.Add(new Instruct() { - IsResponse = true + IsResponse = true, + Type = "pong" }); }); } } - - public class PongInstuct : Instruct - { - public PongInstuct() - { - this.Type = "pong"; - } - } } \ No newline at end of file diff --git a/Instructs/SelectIngElementBroadcastInstruct.cs b/Instructs/SelectIngElementInstruct.cs similarity index 91% rename from Instructs/SelectIngElementBroadcastInstruct.cs rename to Instructs/SelectIngElementInstruct.cs index 17f5bf4..92eb855 100644 --- a/Instructs/SelectIngElementBroadcastInstruct.cs +++ b/Instructs/SelectIngElementInstruct.cs @@ -4,10 +4,11 @@ using OMS.NET.DbClass; namespace OMS.NET.Instructs { - public class SelectIngElementBroadcastInstruct : BroadcastInstuct + public class SelectIngElementInstruct : Instruct { - public SelectIngElementBroadcastInstruct() + public SelectIngElementInstruct() { + this.Type = "broadcast"; this.Class = "selectIngElement"; } @@ -15,8 +16,8 @@ namespace OMS.NET.Instructs { return Task.Run(() => { - if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查不通过则直接退出 - if (Data?.GetType() != typeof(JsonElement)) return; + if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查,不通过则直接退出 + if (Data?.GetType() != typeof(JsonElement)) return;//Data 非空和JsonElement类型检查 try { long id = Data.GetInt64(); @@ -48,7 +49,7 @@ namespace OMS.NET.Instructs }); } string time = GlobalArea.GetCurrentTime(); - ResponseOrBroadcastInstructs.Add(new SelectIngElementBroadcastInstruct() + ResponseOrBroadcastInstructs.Add(new SelectIngElementInstruct() { IsBroadcast = true, Conveyor = conveyor, diff --git a/Instructs/TextMessageBroadcastInstruct.cs b/Instructs/TextMessageInstruct.cs similarity index 86% rename from Instructs/TextMessageBroadcastInstruct.cs rename to Instructs/TextMessageInstruct.cs index b7b1d0b..dd3a8ca 100644 --- a/Instructs/TextMessageBroadcastInstruct.cs +++ b/Instructs/TextMessageInstruct.cs @@ -2,10 +2,11 @@ using System.Text.Json; namespace OMS.NET.Instructs { - public class TextMessageBroadcastInstruct : BroadcastInstuct + public class TextMessageInstruct : Instruct { - public TextMessageBroadcastInstruct() + public TextMessageInstruct() { + this.Type = "broadcast"; this.Class = "textMessage"; } @@ -14,14 +15,14 @@ namespace OMS.NET.Instructs return Task.Run(() => { if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查不通过则直接退出 - if (Data?.GetType() != typeof(JsonElement)) return; + if (Data?.GetType() != typeof(JsonElement)) return;//Data 非空和JsonElement类型检查 try { string message = Data.GetProperty("message").GetString(); string conveyor = GlobalArea.GetLoginEmailByID(wsid); string time = GlobalArea.GetCurrentTime(); GlobalArea.Log.Info($"[{time}] {conveyor}:{message}"); - ResponseOrBroadcastInstructs.Add(new TextMessageBroadcastInstruct() + ResponseOrBroadcastInstructs.Add(new TextMessageInstruct() { IsBroadcast = true, Conveyor = conveyor,