From c6b35c3138b944830b5336bf610f918154dd47c7 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期六, 12 十月 2019 15:45:10 +0800 Subject: [PATCH] 合并门锁,完成住宅管理 --- ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs | 738 +++++--------------------------------------------------- 1 files changed, 68 insertions(+), 670 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs index 4ca338b..49cb86e 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs @@ -3302,7 +3302,7 @@ //杩樻湁绉嶆儏鍐垫槸鍚屼竴涓狪D 鏈夊涓澶囩敤杩欎釜id杩炴帴锛堜細瀵艰嚧涓柇锛� string clientId = Shared.Common.Config.Instance.ConnectZigbeeMqttClientId; - string username = Shared.Common.Config.Instance.ConnectZigbeeMqttBrokerName; + string username = Shared.Common.Config.Instance.ConnectGuid; string passwordRemote = Shared.Common.Config.Instance.ConnectZigbeeMqttBrokerPwd; //(1)杩炴帴鍒颁簯绔殑Mqtt瀹㈡埛绔繛鎺ュ弬鏁� var connectCloudMqttClientOptions = new MqttClientTcpOptions @@ -3385,15 +3385,16 @@ /// </summary> async System.Threading.Tasks.Task SendRemoteMsg(string topicName, byte[] message, MQTTnet.Core.Protocol.MqttQualityOfServiceLevel qosLevel = MQTTnet.Core.Protocol.MqttQualityOfServiceLevel.ExactlyOnce, bool retain = false) { - #region MD5鍔犲瘑 token - var result = System.Text.Encoding.UTF8.GetBytes(Shared.Common.Config.Instance.Password); - var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); - var output = md5.ComputeHash(result); - var md5Password = BitConverter.ToString(output).Replace("-", "").ToUpper(); - #endregion + //#region MD5鍔犲瘑 token + //var result = System.Text.Encoding.UTF8.GetBytes(Shared.Common.Config.Instance.Password); + //var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); + //var output = md5.ComputeHash(result); + //var md5Password = BitConverter.ToString(output).Replace("-", "").ToUpper(); + //#endregion //(1)鐢熸垚[鐢ㄦ埛鍚�:瀵嗙爜] - var userNameAndPwdStr = string.Concat(Shared.Common.Config.Instance.Account, RemoteOperatorConsts.CAP_NUMBER, md5Password); + var userNameAndPwdStr = string.Concat(Shared.Common.Config.Instance.Guid, RemoteOperatorConsts.CAP_NUMBER, Shared.Common.Config.Instance.MD5PWD); + DebugPrintLog($"userNameAndPwdStr锛歿userNameAndPwdStr} "); //(2)灏�(1)杞垚Base64瀛楃涓�,鐢熸垚鏍煎紡[Base64(鐢ㄦ埛鍚�:瀵嗙爜)] var userNameAndPwdStrBaseSexFour = Convert.ToBase64String(ZigBee.Common.CommonInfo.EncodingUTF8.GetBytes(userNameAndPwdStr)); @@ -3403,14 +3404,17 @@ ///[Zigbee.Buspro]App/id(甯愬彿Id)/Base64(DES[Base64(鐢ㄦ埛鍚�:瀵嗙爜):Timestamp ]/缃戝叧鍞竴Id/杞彂缁欑綉鍏崇殑涓婚/XX/XX //(4)鐢熸垚涓婃姤涓婚锛屼富棰樻ā寮忛渶瑕佷负 /ZigbeeApp/id(涓诲瓙璋冭瘯甯愬彿Id)/Base64(DES[Base64(鐢ㄦ埛鍚�:瀵嗙爜):Timestamp ]/缃戝叧鍞竴Id/topicName "000204022022" GateWayId 000204022022 - var reportTopic = string.Format("/{0}/{1}/{2}/{3}/{4}", RemoteOperatorConsts.ZIGBEE_APP_STARTS_WITH, Shared.Common.Config.Instance.Account, userNameAndPwdStrBaseSexFourAndTimestamp, this.getGatewayBaseInfo?.gwID, topicName); + var reportTopic = string.Format("/{0}/{1}/{2}/{3}/{4}", RemoteOperatorConsts.ZIGBEE_APP_STARTS_WITH, Shared.Common.Config.Instance.Guid, userNameAndPwdStrBaseSexFourAndTimestamp, this.getGatewayBaseInfo?.gwID, topicName); + var aa = System.Text.Encoding.UTF8.GetString(message); + DebugPrintLog($"AAAA鍙戦�佸埌浜戠涓婚鏄庢枃锛歿reportTopic}___BBBBB鍙戦�佸埌浜戠鍐呭鏄庢枃锛歿aa}"); - //(5)浣跨敤浣犵櫥褰曟垚鍔熸椂8浣峩ey锛岃繘琛孌ES鍔犲瘑浣犻渶瑕佷笂鎶ョ殑鏁版嵁 string topicEncStr = reportTopic; //鏂囦欢娴佷笉鐢ㄥ姞瀵� topicEncStr = ZigBee.Common.SecuritySet.AesEncrypt(System.Text.Encoding.UTF8.GetBytes(topicEncStr), Shared.Common.Config.Instance.MqttKey); topicEncStr = topicEncStr.Replace("/", "[[$-MQTT_TILT_SYMBOL_REPLACE-$]]").Replace("+", "[[$-MQTT_PLUS_SYMBOL_REPLACE-$]]"); message = System.Text.Encoding.UTF8.GetBytes(SecuritySet.AesEncrypt(message, Shared.Common.Config.Instance.MqttKey)); + var bb = System.Text.Encoding.UTF8.GetString(message); + DebugPrintLog($"CCCC鍙戦�佸埌浜戠涓婚绉樻枃锛歿topicEncStr}___DDDD鍙戦�佸埌浜戠鍐呭绉樻枃锛歿bb}"); //(6)鏋勫缓Mqtt闇�瑕佸彂甯冪殑鏁版嵁鍖�,鍙戝竷缁欎簯绔殑MqttBroker await RemoteMqttClient.PublishAsync(new MQTTnet.Core.MqttApplicationMessage(topicEncStr, message, qosLevel, retain)); @@ -3697,14 +3701,6 @@ if (gwa.GwResDataAction != null) { gwa.GwResDataAction(topic, message); - if (topic == $"{gatewayID}/DoorLock/DoorLockOperatingEventNotificationCommand") - { - Console.WriteLine($"111_DoorLockOperatingEventNotificationCommand:{message}"); - } - if (topic == $"{gatewayID}/DoorLock/DoorLockProgrammingEventNotificationCommand") - { - Console.WriteLine($"111_DoorLockProgrammingEventNotificationCommand:{message}"); - } } gwa.CurrentGateWayId = gatewayID; @@ -3829,380 +3825,43 @@ if (topic == gatewayID + "/" + "DeviceInComingRespon") { //鏂拌澶囦笂鎶ワ紝閲嶆柊鍙戣幏鍙栨墍鏈夌殑璁惧 - var deviceID = jobject.Value<int>("Device_ID"); - switch ((DeviceType)(deviceID)) - { - case DeviceType.DimmableLight: - var dimmableLight = new DimmableLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - dimmableLight.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.NewDeviceInfoData>(jobject["Data"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("DeviceInComingRespon宸茬粡閫氱煡"); - gwa.ReportAction("DeviceInComingRespon", dimmableLight.getNewDeviceInfo); - } - UpdateDeviceInfo(dimmableLight, "DeviceInComingRespon"); - UpdateDeviceStatus(gwa); - break; - case DeviceType.OnOffOutput: - var toggleLight = new ToggleLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - toggleLight.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.NewDeviceInfoData>(jobject["Data"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("DeviceInComingRespon宸茬粡閫氱煡"); - gwa.ReportAction("DeviceInComingRespon", toggleLight.getNewDeviceInfo); - } - UpdateDeviceInfo(toggleLight, "DeviceInComingRespon"); - UpdateDeviceStatus(gwa); - break; - case DeviceType.AirSwitch: - var airSwitch = new AirSwitch() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - airSwitch.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.NewDeviceInfoData>(jobject["Data"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("DeviceInComingRespon宸茬粡閫氱煡"); - gwa.ReportAction("DeviceInComingRespon", airSwitch.getNewDeviceInfo); - } - UpdateDeviceInfo(airSwitch, "DeviceInComingRespon"); - UpdateDeviceStatus(gwa); - break; - case DeviceType.OnOffSwitch: - var panel = new Panel() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - panel.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.NewDeviceInfoData>(jobject["Data"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("DeviceInComingRespon宸茬粡閫氱煡"); - gwa.ReportAction("DeviceInComingRespon", panel.getNewDeviceInfo); - } - UpdateDeviceInfo(panel, "DeviceInComingRespon"); - UpdateDeviceStatus(gwa); - break; - case DeviceType.WindowCoveringDevice: - var curtain = new Rollershade() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - curtain.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.NewDeviceInfoData>(jobject["Data"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("DeviceInComingRespon宸茬粡閫氱煡"); - gwa.ReportAction("DeviceInComingRespon", curtain.getNewDeviceInfo); - } - UpdateDeviceInfo(curtain, "DeviceInComingRespon"); - UpdateDeviceStatus(gwa); - break; - case DeviceType.IASZone: - var ias = new IASZone() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - ias.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.NewDeviceInfoData>(jobject["Data"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("DeviceInComingRespon宸茬粡閫氱煡"); - gwa.ReportAction("DeviceInComingRespon", ias.getNewDeviceInfo); - } - UpdateDeviceInfo(ias, "DeviceInComingRespon"); - UpdateDeviceStatus(gwa); - break; - case DeviceType.Repeater: - var repeater = new Repeater() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - repeater.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Repeater.NewDeviceInfoData>(jobject["Data"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("DeviceInComingRespon宸茬粡閫氱煡"); - gwa.ReportAction("DeviceInComingRespon", repeater.getNewDeviceInfo); - } - UpdateDeviceInfo(repeater, "DeviceInComingRespon"); - UpdateDeviceStatus(gwa); - break; - case DeviceType.Thermostat: - var ac = new AC() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - ac.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.NewDeviceInfoData>(jobject["Data"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("DeviceInComingRespon宸茬粡閫氱煡"); - gwa.ReportAction("DeviceInComingRespon", ac.getNewDeviceInfo); - } - UpdateDeviceInfo(ac, "DeviceInComingRespon"); - UpdateDeviceStatus(gwa); - break; - case DeviceType.Transverter: - var transverter = new Transverter() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - transverter.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.NewDeviceInfoData>(jobject["Data"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("DeviceInComingRespon宸茬粡閫氱煡"); - gwa.ReportAction("DeviceInComingRespon", transverter.getNewDeviceInfo); - } - UpdateDeviceInfo(transverter, "DeviceInComingRespon"); - UpdateDeviceStatus(gwa); - break; - case DeviceType.DoorLock: - var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - doorLock.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.NewDeviceInfoData>(jobject["Data"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("DeviceInComingRespon宸茬粡閫氱煡"); - gwa.ReportAction("DeviceInComingRespon", doorLock.getNewDeviceInfo); - } - UpdateDeviceInfo(doorLock, "DeviceInComingRespon"); - UpdateDeviceStatus(gwa); - break; - } + var tempDevice = new CommonDevice() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; + tempDevice.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.NewDeviceInfoData>(jobject["Data"].ToString()); + if (gwa.ReportAction != null) + { + DebugPrintLog("DeviceInComingRespon宸茬粡閫氱煡"); + gwa.ReportAction("DeviceInComingRespon", tempDevice.getNewDeviceInfo); + } + UpdateDeviceInfo(tempDevice, "DeviceInComingRespon"); + UpdateDeviceStatus(gwa); } #endregion #region 璁惧鍦ㄧ嚎鐘舵�佹洿鏂板弽棣� else if (topic == gatewayID + "/" + "OnlineStatusChange_Respon") { - var deviceID = jobject.Value<int>("Device_ID"); - switch ((DeviceType)(deviceID)) - { - case DeviceType.DimmableLight: - var dimmableLight = new DimmableLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - dimmableLight.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString()); - - if (gwa.ReportAction != null) - { - DebugPrintLog("OnlineStatusChange宸茬粡閫氱煡"); - gwa.ReportAction("OnlineStatusChange", dimmableLight); - } - var lightDimmer = gwa.DeviceList.Find(obj => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr); - if (lightDimmer == null) - { - gwa.DeviceList.Add(dimmableLight); - UpdateDeviceStatus(dimmableLight); - UpdateDeviceInfo(dimmableLight, "OnlineStatusChange"); - } - else - { - if (dimmableLight.DeviceInfo != null) - { - dimmableLight.DeviceInfo.IsOnline = dimmableLight.IsOnline; - } - UpdateDeviceInfo(dimmableLight, "OnlineStatusChange"); - UpdateDeviceStatus(dimmableLight); - } - - break; - case DeviceType.OnOffOutput: - var toggleLight = new ToggleLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - toggleLight.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("OnlineStatusChange宸茬粡閫氱煡"); - gwa.ReportAction("OnlineStatusChange", toggleLight); - } - var toggleInfo = gwa.DeviceList.Find(obj => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr); - if (toggleInfo == null) - { - gwa.DeviceList.Add(toggleLight); - UpdateDeviceInfo(toggleLight, "OnlineStatusChange"); - UpdateDeviceStatus(toggleLight); - } - else - { - if (toggleLight.DeviceInfo != null) - { - toggleLight.DeviceInfo.IsOnline = toggleLight.IsOnline; - } - UpdateDeviceInfo(toggleLight, "OnlineStatusChange"); - UpdateDeviceStatus(toggleLight); - } - break; - case DeviceType.AirSwitch: - var airSwitch = new AirSwitch() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - airSwitch.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("OnlineStatusChange宸茬粡閫氱煡"); - gwa.ReportAction("OnlineStatusChange", airSwitch); - } - var airSwitchInfo = gwa.DeviceList.Find(obj => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr); - if (airSwitchInfo == null) - { - gwa.DeviceList.Add(airSwitch); - UpdateDeviceInfo(airSwitch, "OnlineStatusChange"); - UpdateDeviceStatus(gwa); - } - else - { - if (airSwitchInfo.DeviceInfo != null) - { - airSwitchInfo.DeviceInfo.IsOnline = airSwitchInfo.IsOnline; - } - UpdateDeviceInfo(airSwitchInfo, "OnlineStatusChange"); - UpdateDeviceStatus(airSwitchInfo); - } - break; - case DeviceType.OnOffSwitch: - var panel = new Panel() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - panel.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("OnlineStatusChange宸茬粡閫氱煡"); - gwa.ReportAction("OnlineStatusChange", panel); - } - var panelInfo = gwa.DeviceList.Find(obj => obj.DeviceID == panel.DeviceID && obj.DeviceAddr == panel.DeviceAddr); - if (panelInfo == null) - { - gwa.DeviceList.Add(panel); - UpdateDeviceInfo(panel, "OnlineStatusChange"); - UpdateDeviceStatus(panel); - } - else - { - if (panelInfo.DeviceInfo != null) - { - panelInfo.DeviceInfo.IsOnline = panelInfo.IsOnline; - } - UpdateDeviceInfo(panelInfo, "OnlineStatusChange"); - UpdateDeviceStatus(panelInfo); - } - break; - case DeviceType.WindowCoveringDevice: - var curtain = new Rollershade() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - curtain.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("OnlineStatusChange宸茬粡閫氱煡"); - gwa.ReportAction("OnlineStatusChange", curtain); - } - var curtainInfo = gwa.DeviceList.Find(obj => obj.DeviceID == curtain.DeviceID && obj.DeviceAddr == curtain.DeviceAddr); - if (curtainInfo == null) - { - gwa.DeviceList.Add(curtain); - UpdateDeviceInfo(curtain, "OnlineStatusChange"); - UpdateDeviceStatus(gwa); - } - else - { - if (curtain.DeviceInfo != null) - { - curtain.DeviceInfo.IsOnline = curtain.IsOnline; - } - UpdateDeviceStatus(curtain); - UpdateDeviceInfo(curtain, "OnlineStatusChange"); - } - break; - case DeviceType.IASZone: - var ias = new IASZone() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - ias.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("OnlineStatusChange宸茬粡閫氱煡"); - gwa.ReportAction("OnlineStatusChange", ias); - } - var iasInfo = gwa.DeviceList.Find(obj => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr); - if (iasInfo == null) - { - gwa.DeviceList.Add(iasInfo); - UpdateDeviceInfo(iasInfo, "OnlineStatusChange"); - UpdateDeviceStatus(gwa); - } - else - { - if (iasInfo.DeviceInfo != null) - { - iasInfo.DeviceInfo.IsOnline = iasInfo.IsOnline; - } - UpdateDeviceInfo(iasInfo, "OnlineStatusChange"); - UpdateDeviceStatus(iasInfo); - } - break; - case DeviceType.Repeater: - var repeater = new Repeater() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - repeater.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("OnlineStatusChange宸茬粡閫氱煡"); - gwa.ReportAction("OnlineStatusChange", repeater); - } - var repeaterInfo = gwa.DeviceList.Find(obj => obj.DeviceID == repeater.DeviceID && obj.DeviceAddr == repeater.DeviceAddr); - if (repeaterInfo == null) - { - gwa.DeviceList.Add(repeaterInfo); - UpdateDeviceInfo(repeaterInfo, "OnlineStatusChange"); - UpdateDeviceStatus(gwa); - } - else - { - if (repeaterInfo.DeviceInfo != null) - { - repeaterInfo.DeviceInfo.IsOnline = repeaterInfo.IsOnline; - } - UpdateDeviceInfo(repeaterInfo, "OnlineStatusChange"); - UpdateDeviceStatus(repeaterInfo); - } - break; - case DeviceType.Thermostat: - var ac = new AC() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - ac.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("OnlineStatusChange宸茬粡閫氱煡"); - gwa.ReportAction("OnlineStatusChange", ac); - } - var acInfo = gwa.DeviceList.Find(obj => obj.DeviceID == ac.DeviceID && obj.DeviceAddr == ac.DeviceAddr); - if (acInfo == null) - { - gwa.DeviceList.Add(acInfo); - UpdateDeviceInfo(acInfo, "OnlineStatusChange"); - UpdateDeviceStatus(gwa); - } - else - { - if (acInfo.DeviceInfo != null) - { - acInfo.DeviceInfo.IsOnline = acInfo.IsOnline; - } - UpdateDeviceInfo(acInfo, "OnlineStatusChange"); - UpdateDeviceStatus(acInfo); - } - break; - case DeviceType.Transverter: - var transverter = new Transverter() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - transverter.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("OnlineStatusChange宸茬粡閫氱煡"); - gwa.ReportAction("OnlineStatusChange", transverter); - } - var transverterInfo = gwa.DeviceList.Find(obj => obj.DeviceID == transverter.DeviceID && obj.DeviceAddr == transverter.DeviceAddr); - if (transverterInfo == null) - { - gwa.DeviceList.Add(transverterInfo); - UpdateDeviceInfo(transverterInfo, "OnlineStatusChange"); - UpdateDeviceStatus(gwa); - } - else - { - if (transverterInfo.DeviceInfo != null) - { - transverterInfo.DeviceInfo.IsOnline = transverterInfo.IsOnline; - } - UpdateDeviceInfo(transverterInfo, "OnlineStatusChange"); - UpdateDeviceStatus(transverterInfo); - } - break; - case DeviceType.DoorLock: - var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - doorLock.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString()); - if (gwa.ReportAction != null) - { - DebugPrintLog("OnlineStatusChange宸茬粡閫氱煡"); - gwa.ReportAction("OnlineStatusChange", doorLock); - } - var doorLockInfo = gwa.DeviceList.Find(obj => obj.DeviceID == doorLock.DeviceID && obj.DeviceAddr == doorLock.DeviceAddr); - if (doorLockInfo == null) - { - gwa.DeviceList.Add(doorLockInfo); - UpdateDeviceInfo(doorLockInfo, "OnlineStatusChange"); - UpdateDeviceStatus(gwa); - } - else - { - if (doorLockInfo.DeviceInfo != null) - { - doorLockInfo.DeviceInfo.IsOnline = doorLockInfo.IsOnline; - } - UpdateDeviceInfo(doorLockInfo, "OnlineStatusChange"); - UpdateDeviceStatus(doorLockInfo); - } - break; + var tempDevice = new CommonDevice() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; + tempDevice.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString()); + + if (gwa.ReportAction != null) + { + DebugPrintLog("OnlineStatusChange宸茬粡閫氱煡"); + gwa.ReportAction("OnlineStatusChange", tempDevice); + } + var infoTempDevice = gwa.DeviceList.Find(obj => obj.DeviceID == tempDevice.DeviceID && obj.DeviceAddr == tempDevice.DeviceAddr); + if (infoTempDevice == null) + { + gwa.DeviceList.Add(tempDevice); + UpdateDeviceStatus(tempDevice); + UpdateDeviceInfo(tempDevice, "OnlineStatusChange"); + } + else + { + if (infoTempDevice.DeviceInfo != null) + { + infoTempDevice.DeviceInfo.IsOnline = infoTempDevice.IsOnline; + } + UpdateDeviceInfo(infoTempDevice, "OnlineStatusChange"); + UpdateDeviceStatus(infoTempDevice); } } #endregion @@ -4220,219 +3879,24 @@ { foreach (var delD in gatewayTemp.removeDeviceResponseData.DeviceList) { - var deviceID = delD.Device_ID; - switch ((DeviceType)(deviceID)) - { - case DeviceType.OnOffOutput: - var toggleLight = new ToggleLight() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - toggleLight.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (toggleLight.removeDeviceResponseData == null) - { - return; - } - else - { - UpdateDeviceStatus(toggleLight); - UpdateDeviceInfo(toggleLight, "RemoveDeviceRespon"); - if (toggleLight.removeDeviceResponseData.Result == 0) - { - var infoToggleLight = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint); - if (infoToggleLight != null) - { - gwa.DeviceList.Remove(infoToggleLight); - } - } - } - break; - case DeviceType.AirSwitch: - var airSwitch = new AirSwitch() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - airSwitch.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (airSwitch.removeDeviceResponseData == null) - { - return; - } - else - { - UpdateDeviceStatus(airSwitch); - UpdateDeviceInfo(airSwitch, "RemoveDeviceRespon"); - if (airSwitch.removeDeviceResponseData.Result == 0) - { - var infoAirSwitch = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr && obj.DeviceEpoint == airSwitch.DeviceEpoint); - if (infoAirSwitch != null) - { - gwa.DeviceList.Remove(infoAirSwitch); - } - } - } - break; - case DeviceType.OnOffSwitch: - var panelObj = new Panel() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - panelObj.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (panelObj.removeDeviceResponseData == null) - { - return; - } - else - { - UpdateDeviceStatus(panelObj); - UpdateDeviceInfo(panelObj, "RemoveDeviceRespon"); - if (panelObj.removeDeviceResponseData.Result == 0) - { - var infoPanel = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == panelObj.DeviceID && obj.DeviceAddr == panelObj.DeviceAddr && obj.DeviceEpoint == panelObj.DeviceEpoint); - if (infoPanel != null) - { - gwa.DeviceList.Remove(infoPanel); - } - } - } - break; - case DeviceType.WindowCoveringDevice: - var rollershade = new Rollershade() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - rollershade.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (rollershade.removeDeviceResponseData == null) - { - return; - } - else - { - UpdateDeviceStatus(rollershade); - UpdateDeviceInfo(rollershade, "RemoveDeviceRespon"); - if (rollershade.removeDeviceResponseData.Result == 0) - { - var infoRoller = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == rollershade.DeviceID && obj.DeviceAddr == rollershade.DeviceAddr && obj.DeviceEpoint == rollershade.DeviceEpoint); - if (infoRoller != null) - { - gwa.DeviceList.Remove(infoRoller); - } - } - } - break; - case DeviceType.IASZone: - var ias = new IASZone() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - ias.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (ias.removeDeviceResponseData == null) - { - return; - } - else - { - UpdateDeviceStatus(ias); - UpdateDeviceInfo(ias, "RemoveDeviceRespon"); - if (ias.removeDeviceResponseData.Result == 0) - { - var info = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint); - if (info != null) - { - gwa.DeviceList.Remove(info); - } - } - } - break; - case DeviceType.DimmableLight: - var dimmableLight = new DimmableLight() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - dimmableLight.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (dimmableLight.removeDeviceResponseData == null) - { - return; - } - else - { - UpdateDeviceStatus(dimmableLight); - UpdateDeviceInfo(dimmableLight, "RemoveDeviceRespon"); - if (dimmableLight.removeDeviceResponseData.Result == 0) - { - var info = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint); - if (info != null) - { - gwa.DeviceList.Remove(info); - } - } - } - break; - case DeviceType.Repeater: - var repeater = new Repeater() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - repeater.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (repeater.removeDeviceResponseData == null) - { - return; - } - else - { - UpdateDeviceStatus(repeater); - UpdateDeviceInfo(repeater, "RemoveDeviceRespon"); - if (repeater.removeDeviceResponseData.Result == 0) - { - var info = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == repeater.DeviceID && obj.DeviceAddr == repeater.DeviceAddr && obj.DeviceEpoint == repeater.DeviceEpoint); - if (info != null) - { - gwa.DeviceList.Remove(info); - } - } - } - break; - case DeviceType.Thermostat: - var ac = new AC() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - ac.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (ac.removeDeviceResponseData == null) - { - return; - } - else - { - UpdateDeviceStatus(ac); - UpdateDeviceInfo(ac, "RemoveDeviceRespon"); - if (ac.removeDeviceResponseData.Result == 0) - { - var info = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ac.DeviceID && obj.DeviceAddr == ac.DeviceAddr && obj.DeviceEpoint == ac.DeviceEpoint); - if (info != null) - { - gwa.DeviceList.Remove(info); - } - } - } - break; - case DeviceType.Transverter: - var transverter = new Transverter() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - transverter.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (transverter.removeDeviceResponseData == null) - { - return; - } - else - { - UpdateDeviceStatus(transverter); - UpdateDeviceInfo(transverter, "RemoveDeviceRespon"); - if (transverter.removeDeviceResponseData.Result == 0) - { - var info = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == transverter.DeviceID && obj.DeviceAddr == transverter.DeviceAddr && obj.DeviceEpoint == transverter.DeviceEpoint); - if (info != null) - { - gwa.DeviceList.Remove(info); - } - } - } - break; - case DeviceType.DoorLock: - var doorLock = new DoorLock() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; - doorLock.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (doorLock.removeDeviceResponseData == null) - { - return; - } - else - { - UpdateDeviceStatus(doorLock); - UpdateDeviceInfo(doorLock, "RemoveDeviceRespon"); - if (doorLock.removeDeviceResponseData.Result == 0) - { - var info = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == doorLock.DeviceID && obj.DeviceAddr == doorLock.DeviceAddr && obj.DeviceEpoint == doorLock.DeviceEpoint); - if (info != null) - { - gwa.DeviceList.Remove(info); - } - } - } - break; + var tempDevice = new CommonDevice() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; + tempDevice.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.RemoveDeviceResponseData>(jobject["Data"].ToString()); + if (tempDevice.removeDeviceResponseData == null) + { + return; + } + else + { + UpdateDeviceStatus(tempDevice); + UpdateDeviceInfo(tempDevice, "RemoveDeviceRespon"); + if (tempDevice.removeDeviceResponseData.Result == 0) + { + var infoTempDevice = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == tempDevice.DeviceID && obj.DeviceAddr == tempDevice.DeviceAddr && obj.DeviceEpoint == tempDevice.DeviceEpoint); + if (infoTempDevice != null) + { + gwa.DeviceList.Remove(infoTempDevice); + } + } } } } @@ -4449,76 +3913,10 @@ var tempEpoint = jobject.Value<int>("Epoint"); var dataId = jobject.Value<int>("Data_ID"); - switch ((DeviceType)(deviceID)) - { - case DeviceType.DimmableLight: - var light = new DimmableLight { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId }; - light.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.DeviceStatusReportData>(jobject["Data"].ToString()); - UpdateDeviceStatus(light); - UpdateDeviceInfo(light, "DeviceStatusReport"); - break; - case DeviceType.OnOffSwitch: - var lightSwitch = new Panel { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId }; - lightSwitch.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(jobject["Data"].ToString()); - UpdateDeviceStatus(lightSwitch); - UpdateDeviceInfo(lightSwitch, "DeviceStatusReport"); - break; - case DeviceType.OnOffOutput: - var lighttoggle = new ToggleLight { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId }; - lighttoggle.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.DeviceStatusReportData>(jobject["Data"].ToString()); - UpdateDeviceStatus(lighttoggle); - UpdateDeviceInfo(lighttoggle, "DeviceStatusReport"); - break; - case DeviceType.AirSwitch: - var airSwitch = new AirSwitch { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId }; - airSwitch.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.DeviceStatusReportData>(jobject["Data"].ToString()); - UpdateDeviceStatus(airSwitch); - UpdateDeviceInfo(airSwitch, "DeviceStatusReport"); - break; - case DeviceType.WindowCoveringDevice: - var curtain = new Rollershade { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId }; - curtain.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.DeviceStatusReportData>(jobject["Data"].ToString()); - UpdateDeviceStatus(curtain); - UpdateDeviceInfo(curtain, "DeviceStatusReport"); - break; - case DeviceType.OtaDevice: - case DeviceType.OtaPanelDevice: - var ota = new OTADevice { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId }; - ota.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<OTADevice.DeviceStatusReportData>(jobject["Data"].ToString()); - UpdateDeviceStatus(ota); - UpdateDeviceInfo(ota, "DeviceStatusReport"); - break; - case DeviceType.IASZone: - var ias = new IASZone { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId }; - ias.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.DeviceStatusReportData>(jobject["Data"].ToString()); - UpdateDeviceStatus(ias); - UpdateDeviceInfo(ias, "DeviceStatusReport"); - break; - case DeviceType.Repeater: - var repeater = new Repeater { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId }; - repeater.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Repeater.DeviceStatusReportData>(jobject["Data"].ToString()); - UpdateDeviceStatus(repeater); - UpdateDeviceInfo(repeater, "DeviceStatusReport"); - break; - case DeviceType.Thermostat: - var ac = new AC { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId }; - ac.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.DeviceStatusReportData>(jobject["Data"].ToString()); - UpdateDeviceStatus(ac); - UpdateDeviceInfo(ac, "DeviceStatusReport"); - break; - case DeviceType.Transverter: - var transverter = new Transverter { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId }; - transverter.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.DeviceStatusReportData>(jobject["Data"].ToString()); - UpdateDeviceStatus(transverter); - UpdateDeviceInfo(transverter, "DeviceStatusReport"); - break; - case DeviceType.DoorLock: - var doorLock = new DoorLock { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId }; - doorLock.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.DeviceStatusReportData>(jobject["Data"].ToString()); - UpdateDeviceStatus(doorLock); - UpdateDeviceInfo(doorLock, "DeviceStatusReport"); - break; - } + var tempDevice = new CommonDevice { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId }; + tempDevice.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceStatusReportData>(jobject["Data"].ToString()); + UpdateDeviceStatus(tempDevice); + UpdateDeviceInfo(tempDevice, "DeviceStatusReport"); } #endregion #region IAS瀹夐槻淇℃伅涓婃姤 -- Gitblit v1.8.0