diff --git a/ReservoirServer/Enterty/AMQDataType.cs b/ReservoirServer/Enterty/AMQDataType.cs index 9fdf783..406a355 100644 --- a/ReservoirServer/Enterty/AMQDataType.cs +++ b/ReservoirServer/Enterty/AMQDataType.cs @@ -14,7 +14,8 @@ enum AMQDataType C0202_InfoResponse, C0203_ChartResponse, C0301_AlertData, - C0302_WeatherData + C0302_WeatherData, + C0401_PreReleaseData, } static class AMQDataTypeString @@ -29,6 +30,7 @@ static class AMQDataTypeString {"0203", AMQDataType.C0203_ChartResponse}, {"0301", AMQDataType.C0301_AlertData}, {"0302", AMQDataType.C0302_WeatherData}, + {"0401", AMQDataType.C0401_PreReleaseData}, }; public static AMQDataType String2Type(string s) diff --git a/ReservoirServer/Enterty/SimpleBoxData.cs b/ReservoirServer/Enterty/SimpleBoxData.cs index eeba7ec..592cfd4 100644 --- a/ReservoirServer/Enterty/SimpleBoxData.cs +++ b/ReservoirServer/Enterty/SimpleBoxData.cs @@ -17,7 +17,22 @@ class SimpleBoxData : IBoxData class BoxDataWithDate : SimpleBoxData { - public DateTime @DateTime; + public DateTime @DateTime { get; set; } + } + + class BoxAlertData : BoxDataWithDate + { + public DateTime DateEnd { get; set; } + public BoxAlertData() { } + public BoxAlertData(BoxDataWithDate data) + { + this.PlatformN = data.PlatformN; + this.DeviceN = data.DeviceN; + this.Type = data.Type; + this.Message = data.Message; + this.DateTime = data.DateTime; + + } } class BoxDataHeartBeat : IBoxData diff --git a/ReservoirServer/Enterty/SimpleSubscribeData.cs b/ReservoirServer/Enterty/SimpleSubscribeData.cs index b7b3d33..168c530 100644 --- a/ReservoirServer/Enterty/SimpleSubscribeData.cs +++ b/ReservoirServer/Enterty/SimpleSubscribeData.cs @@ -15,6 +15,11 @@ class SimpleSubscribeData : ISubscribeData public object Message { get; set; } } + class SubscribDataAlertData : SimpleSubscribeData + { + public DateTime DateEnd { get; set; } + } + public interface ISubscribeData { //public string Type { get; set; } } diff --git a/ReservoirServer/Program.cs b/ReservoirServer/Program.cs index 6a5a9ca..d2677a9 100644 --- a/ReservoirServer/Program.cs +++ b/ReservoirServer/Program.cs @@ -16,7 +16,7 @@ namespace ReservoirServer class Program { //TODO: Log file, Safety(Encryption), JSON error catch, system service - public static readonly string version = "1.08"; + public static readonly string version = "1.09"; #if DEBUG public static string VERSION => version + "a"; diff --git a/ReservoirServer/SimpleBoxAdapter.cs b/ReservoirServer/SimpleBoxAdapter.cs index fcac12a..ba0ba28 100644 --- a/ReservoirServer/SimpleBoxAdapter.cs +++ b/ReservoirServer/SimpleBoxAdapter.cs @@ -89,18 +89,9 @@ public void SimpleBoxDataReportHandler(string data) _remote.SendQueue(json); } - public void SimpleBoxDataSubscribeHandler(string json) + protected void SendDataToMultiBox(SimpleBoxData boxdata, string[] boxes) { - SimpleSubscribeData subdata = JsonConvert.DeserializeObject(json); - SimpleBoxData boxdata = new BoxDataWithDate() - { - Type = subdata.Type, - Message = subdata.Message, - PlatformN = subdata.PlatformN, - DateTime = subdata.DateTime, - }; - - foreach (string bid in subdata.DeviceN) + foreach (string bid in boxes) { Box box = _list[bid]; if (box != null) @@ -112,12 +103,41 @@ public void SimpleBoxDataSubscribeHandler(string json) var client = box.ComClient; online = (box.State == BoxState.Online); box.locker.ExitReadLock(); - if(online) + if (online) _server.SendPack(client, senddata); } } } + public void SimpleBoxDataSubscribeHandler(string json) + { + SimpleSubscribeData subdata = JsonConvert.DeserializeObject(json); + SimpleBoxData boxdata = new BoxDataWithDate() + { + Type = subdata.Type, + Message = subdata.Message, + PlatformN = subdata.PlatformN, + DateTime = subdata.DateTime, + }; + + SendDataToMultiBox(boxdata, subdata.DeviceN); + } + + public void AlertBoxDataSubscribeHandler(string json) + { + SubscribDataAlertData subdata = JsonConvert.DeserializeObject(json); + SimpleBoxData boxdata = new BoxAlertData() + { + Type = subdata.Type, + Message = subdata.Message, + PlatformN = subdata.PlatformN, + DateTime = subdata.DateTime, + DateEnd = subdata.DateEnd + }; + + SendDataToMultiBox(boxdata, subdata.DeviceN); + } + public void StartJob() { _server.Start(); @@ -146,10 +166,13 @@ private void _remote_OnSubscribeReceived(string message) case AMQDataType.C0201_RTData: case AMQDataType.C0202_InfoResponse: case AMQDataType.C0203_ChartResponse: - case AMQDataType.C0301_AlertData: case AMQDataType.C0302_WeatherData: + case AMQDataType.C0401_PreReleaseData: SimpleBoxDataSubscribeHandler(message); break; + case AMQDataType.C0301_AlertData: + AlertBoxDataSubscribeHandler(message); + break; } } catch (System.Exception ex)