From e406f66352fa72ef830ec237ca18d9e8816cb470 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期三, 13 五月 2020 16:02:29 +0800 Subject: [PATCH] 2020-05-13-1 --- ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs | 74 ++++++++++++++++++++++++++++++++---- 1 files changed, 65 insertions(+), 9 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs b/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs index b90af36..431837d 100644 --- a/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs @@ -724,6 +724,10 @@ actionsInfo.Add("Epoint", common.DeviceEpoint); actionsInfo.Add("PassData", "055704010113");//榛樿闂ㄩ攣甯稿叧 + Dictionary<string, string> accounts = new Dictionary<string, string>(); + accounts.Add("DeviceAddr", common.DeviceAddr.ToString());//鐢ㄤ簬鍒ゆ柇璇嗗埆鏄摢涓棬閿�; + accounts.Add("Epoint", common.DeviceEpoint.ToString()); + Common.Logic currentLogic = new Common.Logic(); currentLogic.IsEnable = 1;//榛樿涓哄紑 currentLogic.TimeAttribute.Repeat = 0;//鎵ц涓�娆� @@ -731,6 +735,7 @@ currentLogic.LogicName = Language.StringByID(R.MyInternationalizationString.openmode); currentLogic.Conditions.Add(timeConditionsInfo); currentLogic.Actions.Add(actionsInfo); + currentLogic.Accounts.Add(accounts); var logicIfon = await Send.AddModifyLogic(currentLogic); if (logicIfon != null && logicIfon.LogicId != 0) { @@ -754,14 +759,32 @@ if (Idlist.Count != 0) { //榛樿鍙栫涓�涓�昏緫ID - exist = Idlist[0]; - + var id = Idlist[0]; + if (valueInt != 3) + { + exist = id; + } + else + { + var logic = await Send.GetLogic(id, 3); + if (logic != null) + { + if (ExistLogic(logic)) + { + exist = id; + } + else + { + exist = 0; + } + } + } } return exist; } - + ///<summary> - ///鑾峰彇閫昏緫淇℃伅 + ///鑾峰彇闂ㄩ攣閫昏緫淇℃伅 /// 杩斿洖鍊硷細null涓嶅瓨鍦�;鍏跺畠鍊奸兘瀛樺湪; /// </summary> public static async System.Threading.Tasks.Task<Common.Logic> GetLogicIfon() @@ -773,12 +796,16 @@ //榛樿鍙栫涓�涓�昏緫ID(鏃舵晥鎬у彧鏈変竴鏉¢�昏緫) int exist = Idlist[0]; logic = await Send.GetLogic(exist, 3); + if (!ExistLogic(logic)) + { + logic = null; + } } return logic; } ///<summary> - ///鍒犻櫎鎵�鏈夋椂鏁堟�ц嚜鍔ㄥ寲 + ///鍒犻櫎璇ラ棬閿佹墍鏈夋椂鏁堟�ц嚜鍔ㄥ寲 /// 杩斿洖鍊硷細true鎴愬姛;false澶辫触; /// </summary> public static async System.Threading.Tasks.Task<bool> GetLogicAll() @@ -792,15 +819,44 @@ for (int i = 0; i < Idlist.Count; i++) { int id = Idlist[i]; - //鏈潵鍙湁涓�鏉℃椂鏁堟�ц嚜鍔ㄥ寲锛� - //闃叉鐗规畩鎯呭喌,鎵惧埌灏卞垹闄ゆ帀; - Send.DelLogic(id); + var logic = await Send.GetLogic(id, 3); + if (logic != null) + { + if (ExistLogic(logic)) + { + //鏈潵鍙湁涓�鏉℃椂鏁堟�ц嚜鍔ㄥ寲锛� + //闃叉鐗规畩鎯呭喌,鎵惧埌灏卞垹闄ゆ帀; + Send.DelLogic(id); + } + } } } return _if; } - + /// <summary> + /// 鏌ユ壘杩欎竴鏉¤嚜鍔ㄥ寲鏄惁灞炰簬璇ラ棬閿� + /// </summary> + /// <returns></returns> + public static bool ExistLogic(Common.Logic logic) + { + bool yes = false; + for (int j = 0; j < logic.Accounts.Count; j++) + { + //Option4鏄澶噈ac锛汷ption2鏄澶囩鍙o紱 + if (logic.Accounts[j]["Option4"].ToString() != Send.CurrentDoorLock.DeviceAddr && logic.Accounts[j]["Option2"].ToString() != Send.CurrentDoorLock.DeviceEpoint.ToString()) + { + //鏌ユ壘鏄惁鏄偅涓棬閿侊紱 + //濡傛灉涓嶆槸璇ラ棬閿佽仈鍔ㄤ簨浠朵笉鏄剧ず鍑烘潵; + yes = false; + } + else + { + yes = true; + } + } + return yes; + } } } -- Gitblit v1.8.0