From fa6bcb2e9907772480f99205f36ec2a1ce735a22 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 09 一月 2020 14:11:07 +0800 Subject: [PATCH] 合并代码 --- ZigbeeApp/Shared/Common/Device.cs | 89 +++++++++++++++++++++----------------------- 1 files changed, 42 insertions(+), 47 deletions(-) diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs index 465a7d1..4a805f6 100755 --- a/ZigbeeApp/Shared/Common/Device.cs +++ b/ZigbeeApp/Shared/Common/Device.cs @@ -223,20 +223,19 @@ #region 鈻� 娣诲姞璁惧___________________________ /// <summary> - /// 灏嗘寚瀹氱綉鍏崇殑璁惧瀛樺叆缂撳瓨涓�(浠庢柊鑾峰彇闀滃儚) + /// <para>灏嗘寚瀹氱綉鍏崇殑璁惧瀛樺叆缂撳瓨涓�(浠庢柊鑾峰彇闀滃儚)</para> + /// <para>-1:寮傚父 1:姝e父 2:璁惧淇℃伅缂烘崯</para> /// </summary> /// <param name="zbGateway">缃戝叧瀵硅薄</param> - /// <param name="deviceComingAction">鎺ユ敹鍒拌澶囨椂鐨勪簨浠�,璁惧瀵硅薄涓簄ull鏃�,浠h〃鎺ユ敹瀹屾垚</param> - /// <returns>涓�鐩磋繑鍥瀟rue</returns> - public bool SetDeviceToMemmoryByGateway(ZbGateway zbGateway, Action<CommonDevice> deviceComingAction = null) + public int SetDeviceToMemmoryByGateway(ZbGateway zbGateway) { //浠庣綉鍏宠幏鍙栧叏閮ㄧ殑璁惧 + int statu = 0; List<CommonDevice> listDevice = new List<CommonDevice>(); - List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, true, deviceComingAction); - + List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, ref statu, true); if (list == null) { - return false; + return -1; } listDevice.AddRange(list); @@ -301,14 +300,17 @@ } } - //濡傛灉鏈湴鍜岀綉鍏崇殑璁惧涓嶄竴鑷寸殑鏃跺�欙紝鏆傛椂鍒犻櫎鏈湴鐨勮澶� - //娉ㄦ剰锛氬彧鏄垹闄よ澶囨枃浠讹紝鎴块棿鍐呭浠�涔堢殑杩樺瓨鍦ㄧ潃 - foreach (var device in dicExist.Values) + //鍙湁瀹屽叏鑾峰彇鐨勬椂鍊�,鎵嶄細鍘诲鐞嗗垹闄ょ殑闂 + if (statu == 1) { - this.DeleteMemmoryDevice(device, false); + //濡傛灉鏈湴鍜岀綉鍏崇殑璁惧涓嶄竴鑷寸殑鏃跺�欙紝鍒犻櫎鏈湴鐨勮澶� + foreach (var device in dicExist.Values) + { + this.DeleteMemmoryDevice(device, true); + } } - return true; + return statu; } /// <summary> @@ -1157,13 +1159,18 @@ { //涓嶅瓨鍦ㄥ垯浣跨敤鍏遍�氬浘鐗� string[] arry = strSpecific.Split(new string[] { "_" }, StringSplitOptions.None); - if (arry.Length == 1) + //濡傛灉瀹冭嚜宸卞氨鏄叡閫氬浘鐗囩殑璇濓紝涓嶅啀澶勭悊 + if (arry.Length > 1) { - //濡傛灉瀹冭嚜宸卞氨鏄叡閫氬浘鐗囩殑璇濓紝涓嶅啀澶勭悊 - return; + imageFilePath = "Device/" + arry[0] + ".png"; + imageSelectFilePath = "Device/" + arry[0] + "Selected.png"; } - imageFilePath = "Device/" + arry[0] + ".png"; - imageSelectFilePath = "Device/" + arry[0] + "Selected.png"; + } + //濡傛灉閭f璁惧杩炲叡閫氬浘鐗囬兘娌℃湁鐨勮瘽 + if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true) + { + imageFilePath = "Device/ThirdPartyDevice.png"; + imageSelectFilePath = "Device/ThirdPartyDeviceSelected.png"; } //璁剧疆鍥剧墖 unSelectPath = imageFilePath; @@ -1817,36 +1824,23 @@ #region 鈻� 鑾峰彇璁惧鍒楄〃鐨勬帴鍙________________ /// <summary> - /// 浠庣綉鍏抽噸鏂拌幏鍙栬澶囧垪琛�(鈽呪槄鈽呪槄鈽呪槄鈽呮帴鏀跺埌璁惧鏃剁殑浜嬩欢鈽呪槄鈽呪槄鈽呪槄鈽�) + /// <para>浠庣綉鍏抽噸鏂拌幏鍙栬澶囧垪琛�(杩斿洖鐨勮澶囦负铏氭嫙鍑烘潵鐨�)</para> + /// <para>statu鐘舵�� -1:寮傚父,浼氳繑鍥瀗ull, 1锛氭病鏈夊紓甯�, 2:鏁版嵁鎺ユ敹涓嶅叏</para> /// </summary> /// <param name="zbGateway">缃戝叧瀵硅薄</param> - /// <param name="ignoreTime">鏄惁鏃犺鏃堕棿,true:姣忔璋冪敤閮藉幓缃戝叧鑾峰彇,false:3鍒嗛挓鍐呰繑鍥炵殑鏄湰鍦扮殑璁惧</param> - /// <param name="deviceComingAction">鎺ユ敹鍒拌澶囨椂鐨勪簨浠�</param> + /// <param name="statu">鐘舵��-> -1:寮傚父,浼氳繑鍥瀗ull, 1锛氭病鏈夊紓甯�, 2:鏁版嵁鎺ユ敹涓嶅叏</param> + /// <param name="ignoreTime">鏄惁鏃犺鏃堕棿(姝ゅ彉閲忔槸缁欒幏鍙栧湪绾跨姸鎬佺敤鐨�),true:姣忔璋冪敤閮藉幓缃戝叧鑾峰彇,false:3鍒嗛挓鍐呰繑鍥炵殑鏄湰鍦扮殑璁惧</param> /// <param name="mode">鏄惁鏄剧ず閿欒</param> /// <returns></returns> - public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, bool ignoreTime, Action<CommonDevice> deviceComingAction = null, ShowErrorMode mode = ShowErrorMode.YES) + public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, ref int statu, bool ignoreTime, ShowErrorMode mode = ShowErrorMode.YES) { if (ignoreTime == false) { if ((DateTime.Now - zbGateway.LastDateTime).TotalMilliseconds < 3 * 60 * 1000) { //涓嶆棤瑙嗘椂闂�,杩斿洖鏈湴璁惧鍒楄〃 - var listTemp = this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway)); - if (deviceComingAction != null) - { - for (int i = 0; i < listTemp.Count; i++) - { - try - { - //鍥炶皟鍑芥暟 - deviceComingAction.Invoke(listTemp[i]); - } - //Log鍑哄姏 - catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); } - } - } - deviceComingAction = null; - return listTemp; + statu = 1; + return this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway)); } } zbGateway.LastDateTime = DateTime.Now; @@ -1863,6 +1857,7 @@ string msg = Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg); this.ShowTipMsg(msg); } + statu = -1; return null; } @@ -1915,8 +1910,6 @@ //缃戝叧閲岄潰鏈夊彲鑳戒細鏈夐噸澶嶇殑鍥炶矾 if (listCheck.Contains(mainkeys) == false) { - //鍥炶皟鍑芥暟 - deviceComingAction?.Invoke(device); listDevice.Add(device); listCheck.Add(mainkeys); @@ -1965,6 +1958,7 @@ msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂", false); this.ShowTipMsg(msg); } + statu = -1; return null; } else @@ -1975,12 +1969,9 @@ string msg = Language.StringByID(R.MyInternationalizationString.uNetworkUnStableAndDeviceInfoIsNotFull); this.ShowTipMsg(msg); } + statu = 2; } - } - - //鍥炶皟鍑芥暟(鎺ユ敹瀹屾垚) - deviceComingAction = null; - + } return listDevice; } @@ -2186,9 +2177,9 @@ this.dicDeviceModelIdEnum["MPT2/R2-ZB.18"] = "202-200";//2鎸夐敭瑙︽懜闈㈡澘 this.dicDeviceModelIdEnum["MPT1/R1-ZB.18"] = "203-200";//12鎸夐敭瑙︽懜闈㈡澘 this.dicDeviceModelIdEnum["MPT4-ZB.18"] = "210-200";//4鎸夐敭瑙︽懜闈㈡澘(鍙甫鐢垫簮搴曞骇) - this.dicDeviceModelIdEnum["MPT4R4L/S-ZB1.8"] = "220-200";//绠�绾�4鎸夐敭闈㈡澘 - this.dicDeviceModelIdEnum["MPT3R3L/S-ZB1.8"] = "221-200";//绠�绾�3鎸夐敭闈㈡澘 - this.dicDeviceModelIdEnum["MPT2R2L/S-ZB1.8"] = "222-200";//绠�绾�2鎸夐敭闈㈡澘 + this.dicDeviceModelIdEnum["MPT4R4L/S-ZB.18"] = "220-200";//绠�绾�4鎸夐敭闈㈡澘 + this.dicDeviceModelIdEnum["MPT3R3L/S-ZB.18"] = "221-200";//绠�绾�3鎸夐敭闈㈡澘 + this.dicDeviceModelIdEnum["MPT2R2L/S-ZB.18"] = "222-200";//绠�绾�2鎸夐敭闈㈡澘 //=========鈽呪槄PIR浼犳劅鍣ㄧ被(1200-1299)鈽呪槄========= this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200";//pir浼犳劅鍣�220 @@ -2223,6 +2214,8 @@ this.dicDeviceModelIdEnum["MBUS/GW-ZB.10"] = "4200-4200";//zigbee杞琤uspro鍗忚杞崲鍣� this.dicDeviceModelIdEnum["M485/GW-ZB.10"] = "4201-4200";//zigbee杞�485鍗忚杞崲鍣� + + //鉁┾湬鉁┾湬鉁╅渶瑕佷氦鎹㈢殑妯″潡ID鉁┾湬鉁┾湬鉁� this.dicDeviceModelIdChanged = new Dictionary<string, string>(); //=========鈽呪槄瀹夐槻绫讳紶鎰熷櫒绫烩槄鈽�========= @@ -2233,6 +2226,8 @@ this.dicDeviceModelIdChanged["MULTI-WATE--EA02"] = "MSW01/M-ZB.10";//姘存蹈浼犳劅鍣� this.dicDeviceModelIdChanged["MULTI-BURO--EA06"] = "MBU01/M-ZB.10";//绱ф�ユ寜閿� + + //鉁┾湬鉁┾湬鉁╅渶瑕佸叡鏈夌殑鍥剧墖瀵硅薄鉁┾湬鉁┾湬鉁� this.dicPictrueShard = new Dictionary<string, string>(); this.dicPictrueShard["ButtonPanel_SimpleFour"] = "ButtonPanel_Four";//绠�绾�4鎸夐敭闈㈡澘 娌跨敤 4鎸夐敭鐨勫浘鏍� -- Gitblit v1.8.0