From 0d9f64668fd7350d6a21fd157e32009a96d98134 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期三, 16 十二月 2020 13:09:08 +0800 Subject: [PATCH] 新云端代码Ver1.2 --- ZigbeeApp/Shared/Phone/Common/Logic/HdlGatewayReceiveLogic.cs | 213 ++++++++++++++--------------------------------------- 1 files changed, 57 insertions(+), 156 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs b/ZigbeeApp/Shared/Phone/Common/Logic/HdlGatewayReceiveLogic.cs similarity index 83% rename from ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs rename to ZigbeeApp/Shared/Phone/Common/Logic/HdlGatewayReceiveLogic.cs index f263cf4..eab944a 100644 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs +++ b/ZigbeeApp/Shared/Phone/Common/Logic/HdlGatewayReceiveLogic.cs @@ -4,7 +4,7 @@ using Newtonsoft.Json.Linq; using ZigBee.Device; -namespace Shared.Phone.UserCenter +namespace Shared.Phone { /// <summary> /// 鍏ㄥ眬鎺ユ敹缃戝叧鎺ㄩ�佺殑鐨勯�昏緫(涓轰簡鎵ц閫熷害,灏藉彲鑳界殑鍒姞鑰楁椂鐨勬搷浣�) @@ -73,10 +73,9 @@ { //鐧诲綍瀵嗗寵宸茬粡杩囨湡,璇烽噸鏂扮櫥褰� string msg = Language.StringByID(R.MyInternationalizationString.uTokenIsOldAndLoginAgain); - var contr = new ShowMsgControl(ShowMsgType.Tip, msg); - contr.Show(); + HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, msg); - UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false); + HdlAccountLogic.Current.ReLoginAgain(HdlUserCenterResourse.UserInfo.Account, false); }); return; } @@ -86,10 +85,9 @@ { //姝ゅ笎鍙峰凡鍦ㄥ埆澶勭櫥褰�,鎮ㄨ杩笅绾� string msg = Language.StringByID(R.MyInternationalizationString.uHadBeenLoginAndOffLine); - var contr = new ShowMsgControl(ShowMsgType.Tip, msg); - contr.Show(); + HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, msg); - UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false); + HdlAccountLogic.Current.ReLoginAgain(HdlUserCenterResourse.UserInfo.Account, false); }); return; } @@ -99,10 +97,9 @@ { //鎮ㄥ綋鍓嶇殑IP鍙婄鍙e湪浜戠涓嶅瓨鍦�,璇烽噸鏂扮櫥褰�! string msg = Language.StringByID(R.MyInternationalizationString.uYouIpAndPortNoRecord); - var contr = new ShowMsgControl(ShowMsgType.Tip, msg); - contr.Show(); + HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, msg); - UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false); + HdlAccountLogic.Current.ReLoginAgain(HdlUserCenterResourse.UserInfo.Account, false); }); return; } @@ -112,10 +109,9 @@ { //鍒嗕韩浣忓畢宸叉洿鏀癸紝璇疯仈绯荤鐞嗗憳锛� string msg = Language.StringByID(R.MyInternationalizationString.uShardResidenceHadDeletePleaseTakeToAdmin); - var contr = new ShowMsgControl(ShowMsgType.Tip, msg); - contr.Show(); + HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, msg); - UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false); + HdlAccountLogic.Current.ReLoginAgain(HdlUserCenterResourse.UserInfo.Account, false); }); return; } @@ -125,14 +121,13 @@ { //鎮ㄧ殑鏉冮檺宸茬粡鍙樻洿,璇烽噸鏂扮櫥闄� string msg = Language.StringByID(R.MyInternationalizationString.uYouAccessHadChangedPleaseTakeToAdmin); - var contr = new ShowMsgControl(ShowMsgType.Tip, msg); - contr.Show(); + HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, msg); - UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false); + HdlAccountLogic.Current.ReLoginAgain(HdlUserCenterResourse.UserInfo.Account, false); }); return; } - else if (UserCenterResourse.UserInfo.AuthorityNo == 3) + else if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 3) { if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/Deleted" || topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/DeletedShareData") @@ -141,10 +136,9 @@ { //鍒嗕韩鏁版嵁宸茬粡鍙樻洿,璇烽噸鏂扮櫥闄� string msg = Language.StringByID(R.MyInternationalizationString.uShardDataIsChangedPleaseLoginAgain); - var contr = new ShowMsgControl(ShowMsgType.Tip, msg); - contr.Show(); + HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, msg); - UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false); + HdlAccountLogic.Current.ReLoginAgain(HdlUserCenterResourse.UserInfo.Account, false); }); return; } @@ -251,15 +245,8 @@ return; } - var tempList = Common.LocalDevice.Current.GetDevicesByMac(report.DeviceAddr, false); - var res = Common.LocalDevice.Current.GetMyDeviceEnumInfo(tempList); - if (res.ConcreteType == Common.DeviceConcreteType.Airer) - { - //鏅捐。鏋剁壒娈婂鐞嗭紝鏈湴鍙瓨浜嗙鐐�1锛屽叾浣�2锝�5绔偣閮戒笉瀛� - deviceEpoint = 1; - } //澶勭悊缃戝叧涓婃姤鐨勬暟鎹�,鐒跺悗鍙樻洿鏈湴缂撳瓨 - var locadevice = Common.LocalDevice.Current.GetDevice(deviceAddr, deviceEpoint); + var locadevice = HdlDeviceCommonLogic.Current.GetDevice(deviceAddr, deviceEpoint); if (locadevice != null) { //鏈夊弽棣�,杩欎釜璁惧鑲畾鏄湪绾跨殑 @@ -267,98 +254,15 @@ locadevice.LastDateTime = DateTime.Now; #region 鈻� 寮�鍏冲姛鑳� - //鏅捐。鏋跺洖璺�2锛�3锛�4锛�5閮芥槸CluterID鏄�6 ,浣嗘槸鍔熻兘涓嶆槸寮�鍏� - if (locadevice.Type == DeviceType.Airer) + //寮�鍏冲姛鑳� + if (report.DeviceStatusReport.CluterID == 6) { - if (report.DeviceStatusReport.CluterID == 6) + if (locadevice is LightBase) { - foreach (var attData in report.DeviceStatusReport.AttriBute) - { - locadevice.DeviceStatusReport = report.DeviceStatusReport; - if (attData.AttributeId == 0) - { - //娉ㄦ剰鏅捐。鏋跺洖璺笂鎶ラ兘绔偣閮芥槸琚浛鎹负鍥炶矾1锛屾墍浠ヨ繖閲岀敤涓婃姤閮藉洖璺� - switch (report.DeviceEpoint) - { - //鐓ф槑 - case 2: - ((Airer)locadevice).OnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData; - break; - //椋庡共 - case 3: - ((Airer)locadevice).WindOnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData; - break; - //鐑樺共 - case 4: - ((Airer)locadevice).DryOnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData; - break; - //娑堟瘨 - case 5: - ((Airer)locadevice).DisinfectOnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData; - break; - } - } - - //鏅捐。鏋讹紙椋庡共/鐑樺共/娑堟瘨锛夎缃殑榛樿鏃堕棿 - // 娉ㄦ剰锛岀涓�闃舵鏃堕棿璁惧涓嶆敮鎸佽�屾殏鍋滐紝娌℃湁澶勭悊鍓╀綑澶氬皯鏃堕棿瑙﹀彂锛岀洿鎺ヤ笂鎶ュ洖澶嶄竴涓睘鎬D鐨勬儏鍐� - //if (attData.AttributeId == 16385) - //{ - // //娉ㄦ剰鏅捐。鏋跺洖璺笂鎶ラ兘绔偣閮芥槸琚浛鎹负鍥炶矾1锛屾墍浠ヨ繖閲岀敤涓婃姤閮藉洖璺� - // switch (report.DeviceEpoint) - // { - // //椋庡共 - // case 3: - // ((Airer)locadevice).WindTime = report.DeviceStatusReport.AttriBute[0].AttriButeData; - // break; - // //鐑樺共 - // case 4: - // ((Airer)locadevice).DryTime = report.DeviceStatusReport.AttriBute[0].AttriButeData; - // break; - // //娑堟瘨 - // case 5: - // ((Airer)locadevice).DisinfectTime = report.DeviceStatusReport.AttriBute[0].AttriButeData; - // break; - // } - //} - //鏅捐。鏋讹紙椋庡共/鐑樺共/娑堟瘨锛夎缃殑鍓╀綑澶氬皯鏃堕棿瑙﹀彂 - // 娉ㄦ剰锛岀涓�闃舵鏃堕棿璁惧涓嶆敮鎸佽�屾殏鍋滐紝娌℃湁澶勭悊鍓╀綑澶氬皯鏃堕棿瑙﹀彂锛岀洿鎺ヤ笂鎶ュ洖澶嶄竴涓睘鎬D鐨勬儏鍐� - //if (attData.AttributeId == 16386) - //{ - // //娉ㄦ剰鏅捐。鏋跺洖璺笂鎶ラ兘绔偣閮芥槸琚浛鎹负鍥炶矾1锛屾墍浠ヨ繖閲岀敤涓婃姤閮藉洖璺� - // switch (report.DeviceEpoint) - // { - // //椋庡共 - // case 3: - // ((Airer)locadevice).WindRemainTime = report.DeviceStatusReport.AttriBute[0].AttriButeData; - // break; - // //鐑樺共 - // case 4: - // ((Airer)locadevice).DryRemainTime = report.DeviceStatusReport.AttriBute[0].AttriButeData; - // break; - // //娑堟瘨 - // case 5: - // ((Airer)locadevice).DisinfectRemainTime = report.DeviceStatusReport.AttriBute[0].AttriButeData; - // break; - // } - //} - - //宸茬粡鎺ユ敹鍒扮姸鎬� - locadevice.HadReadDeviceStatu = true; - } - } - } - else - { - //寮�鍏冲姛鑳� - if (report.DeviceStatusReport.CluterID == 6) - { - if (locadevice is LightBase) - { - locadevice.DeviceStatusReport = report.DeviceStatusReport; - ((LightBase)locadevice).OnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData; - //宸茬粡鎺ユ敹鍒扮姸鎬� - locadevice.HadReadDeviceStatu = true; - } + locadevice.DeviceStatusReport = report.DeviceStatusReport; + ((LightBase)locadevice).OnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData; + //宸茬粡鎺ユ敹鍒扮姸鎬� + locadevice.HadReadDeviceStatu = true; } } #endregion @@ -394,7 +298,7 @@ else if (report.DeviceStatusReport.CluterID == 1282) { //mini澶滅伅 - if (Common.LocalDevice.Current.IsMiniLight(locadevice) == true) + if (HdlDeviceCommonLogic.Current.IsMiniLight(locadevice) == true) { foreach (var attData in report.DeviceStatusReport.AttriBute) { @@ -501,7 +405,7 @@ foreach (var attData in report.DeviceStatusReport.AttriBute) { //鍖哄垎鏄┖璋冭繕鏄柊椋� - var device = Shared.Common.LocalDevice.Current.GetDevice(report.DeviceAddr, report.DeviceEpoint); + var device = HdlDeviceCommonLogic.Current.GetDevice(report.DeviceAddr, report.DeviceEpoint); if (device.Type == DeviceType.FreshAir) { @@ -752,7 +656,7 @@ else if (report.DeviceStatusReport.CluterID == 0) { - var listLocalDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceAddr, false); + var listLocalDevice = HdlDeviceCommonLogic.Current.GetDevicesByMac(deviceAddr, false); //灞炴�ч兘鏄竴鏍风殑 foreach (var myDevice in listLocalDevice) { @@ -765,7 +669,7 @@ { if (data.AttriButeDataHex.Length > 2) { - var value = UserCenterLogic.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2)); + var value = HdlCommonLogic.Current.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2)); if (myDevice.ManufacturerName != value) { //灞炴�у彉鏇翠簡 @@ -779,7 +683,7 @@ { if (data.AttriButeDataHex.Length > 2) { - var value = UserCenterLogic.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2)); + var value = HdlCommonLogic.Current.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2)); if (myDevice.ModelIdentifier != value) { //灞炴�у彉鏇翠簡 @@ -793,7 +697,7 @@ { if (data.AttriButeDataHex.Length > 2) { - var value = UserCenterLogic.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2)); + var value = HdlCommonLogic.Current.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2)); if (myDevice.ProductionDate != value) { //灞炴�у彉鏇翠簡 @@ -813,7 +717,7 @@ if (data.AttriButeDataHex.Length > 2) { string value; - if (Common.LocalDevice.Current.IsHdlDevice(myDevice) == false) + if (HdlDeviceCommonLogic.Current.IsHdlDevice(myDevice) == false) { //绗笁鏂硅澶� value = data.AttriButeDataHex.Substring(2); @@ -821,7 +725,7 @@ else { //娌充笢璁惧 - value = UserCenterLogic.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2)); + value = HdlCommonLogic.Current.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2)); } if (myDevice.SerialNumber != value) { @@ -846,7 +750,7 @@ } else if (deviceEpoint == 200) { - var localOta = Common.LocalDevice.Current.GetOTADevice(deviceAddr); + var localOta = HdlDeviceCommonLogic.Current.GetOTADevice(deviceAddr); if (localOta != null) { #region 鈻� 鍥轰欢鐗堟湰 @@ -900,7 +804,7 @@ } //澶勭悊缃戝叧涓婃姤鐨勬暟鎹�,鐒跺悗鍙樻洿鏈湴缂撳瓨 - var locadevice = Common.LocalDevice.Current.GetDevice(ias.DeviceAddr, ias.DeviceEpoint); + var locadevice = HdlDeviceCommonLogic.Current.GetDevice(ias.DeviceAddr, ias.DeviceEpoint); if (locadevice != null) { ((IASZone)locadevice).iASInfo = ias.iASInfo; @@ -926,9 +830,9 @@ /// <param name="receiveData"></param> private void DoorLockDeviceReportPush(JObject receiveData) { - if (UserCenterResourse.UserInfo.AuthorityNo == 1) + if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1) { - var device = Common.LocalDevice.Current.GetDevice(receiveData.Value<string>("DeviceAddr"), receiveData.Value<int>("Epoint")); + var device = HdlDeviceCommonLogic.Current.GetDevice(receiveData.Value<string>("DeviceAddr"), receiveData.Value<int>("Epoint")); if (device.Type != DeviceType.DoorLock) { //瀹冧笉鏄棬閿� @@ -974,7 +878,7 @@ tempDevice.IsOnline = Convert.ToInt32(receiveData["Data"]["IsOnline"].ToString()); //澶勭悊缃戝叧涓婃姤鐨勬暟鎹�,鐒跺悗鍙樻洿鏈湴缂撳瓨 - var locadevice = Common.LocalDevice.Current.GetDevicesByMac(tempDevice.DeviceAddr); + var locadevice = HdlDeviceCommonLogic.Current.GetDevicesByMac(tempDevice.DeviceAddr); for (int i = 0; i < locadevice.Count; i++) { bool onlineChanged = locadevice[i].IsOnline != tempDevice.IsOnline; @@ -1033,12 +937,11 @@ //淇濆瓨鎶ヨ淇℃伅鐒跺悗鎺ㄩ�佸埌鐣岄潰涓� HdlAlarmsLogic.Current.SaveSafeguardAlarmInfo(garrison); - if (UserCenterResourse.DicActionForm.ContainsKey("SafetyManagementMainForm") == true) - { - //鎺ㄩ�� - var form = (Safety.SafetyManagementMainForm)UserCenterResourse.DicActionForm["SafetyManagementMainForm"]; - form?.GarrisonModePush(garrison); - } + + //鎺ㄩ�� + var form = HdlFormLogic.Current.GetFormByName("SafetyManagementMainForm") as UserCenter.Safety.SafetyManagementMainForm; + form?.GarrisonModePush(garrison); + //鏄剧ず鏈夋柊娑堟伅鐨勭壒鏁� this.ShowHadNewMessageAppeal(); } @@ -1059,12 +962,11 @@ { //淇濆瓨鎶ヨ淇℃伅鐒跺悗鎺ㄩ�佸埌鐣岄潰涓� HdlAlarmsLogic.Current.SaveSafeguardAlarmInfo(GarrisonMode.RemoveGarrison); - if (UserCenterResourse.DicActionForm.ContainsKey("SafetyManagementMainForm") == true) - { - //鎺ㄩ�� - var form = (Safety.SafetyManagementMainForm)UserCenterResourse.DicActionForm["SafetyManagementMainForm"]; - form?.GarrisonModePush(GarrisonMode.RemoveGarrison); - } + + //鎺ㄩ�� + var form = HdlFormLogic.Current.GetFormByName("SafetyManagementMainForm") as UserCenter.Safety.SafetyManagementMainForm; + form?.GarrisonModePush(GarrisonMode.RemoveGarrison); + //鏄剧ず鏈夋柊娑堟伅鐨勭壒鏁� this.ShowHadNewMessageAppeal(); } @@ -1106,12 +1008,11 @@ //淇濆瓨鎶ヨ淇℃伅鐒跺悗鎺ㄩ�佸埌鐣岄潰涓� HdlAlarmsLogic.Current.SaveSafeguardAlarmInfo(garrison, appendText); - if (UserCenterResourse.DicActionForm.ContainsKey("SafetyManagementMainForm") == true) - { - //鎺ㄩ�� - var form = (Safety.SafetyManagementMainForm)UserCenterResourse.DicActionForm["SafetyManagementMainForm"]; - form?.GarrisonModePush(garrison); - } + + //鎺ㄩ�� + var form = HdlFormLogic.Current.GetFormByName("SafetyManagementMainForm") as UserCenter.Safety.SafetyManagementMainForm; + form?.GarrisonModePush(garrison); + //鏄剧ず鏈夋柊娑堟伅鐨勭壒鏁� this.ShowHadNewMessageAppeal(); } @@ -1149,7 +1050,7 @@ this.ShowHadNewMessageAppeal(); // 閫昏緫鎵ц甯稿紑妯″紡澶辨晥鐨勬儏鍐� - if (UserCenterResourse.UserInfo.AuthorityNo == 1) + if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1) { //鑷姩鍖栨墽琛� 甯稿紑鍏抽棴 var data = Newtonsoft.Json.JsonConvert.DeserializeObject<LogicPushResult>(receiveData["Data"].ToString()); @@ -1158,7 +1059,7 @@ if (data.ActionData.Actiontype == 8 && data.ActionData.PassDataString == "055704010113") { var deviceAddr = data.ActionData.MacStr; - var device = Common.LocalDevice.Current.GetDevicesByMac(deviceAddr, false); + var device = HdlDeviceCommonLogic.Current.GetDevicesByMac(deviceAddr, false); if (device.Count > 0 && device[0].Type != DeviceType.DoorLock) { return; @@ -1334,7 +1235,7 @@ catch (Exception ex) { //Log鍑哄姏 - string msg = "鎺ㄩ�侀敊璇�! 褰撳墠婵�娲荤殑鐣岄潰[" + UserCenterResourse.NowActionFormID + "]"; + string msg = "鎺ㄩ�侀敊璇�! 褰撳墠婵�娲荤殑鐣岄潰[" + HdlFormLogic.Current.NowActionFormID + "]"; HdlLogLogic.Current.WriteLog(ex, msg); } } @@ -1357,16 +1258,16 @@ private void ShowHadNewMessageAppeal() { //鏈夋柊娑堟伅(鐗规晥杩樺湪鏃�,涓嶉渶瑕佸啀澶勭悊) - if (ControlCommonResourse.HadNewMessage == false) + if (HdlControlResourse.HadNewMessage == false) { HdlThreadLogic.Current.RunMain(() => { - for (int i = 0; i < ControlCommonResourse.listMessageManaContr.Count; i++) + for (int i = 0; i < HdlControlResourse.listMessageManaContr.Count; i++) { //鏄剧ず瑙掓爣鐗规晥 - ControlCommonResourse.listMessageManaContr[i].IsSelected = true; + HdlControlResourse.listMessageManaContr[i].IsSelected = true; } - ControlCommonResourse.HadNewMessage = true; + HdlControlResourse.HadNewMessage = true; }); } } -- Gitblit v1.8.0