From 3aa397ab145382935492b11c1f18c9634e69910b Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 10 十二月 2020 16:45:00 +0800
Subject: [PATCH] 请合并,门锁和晾衣架第一版代码
---
ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs | 266 +++++++++++++++++++++++++++++++++++++---------------
1 files changed, 188 insertions(+), 78 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs b/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs
index ca15989..f016cbc 100755
--- a/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs
@@ -8,12 +8,13 @@
namespace Shared.Phone.Device.Logic
{
- public class SkipView
+ public class SkipView:FrameLayout
{
+
/// <summary>
/// 鍏跺畠鐣岄潰璺宠繘鏉ョ殑鍏ュ彛
/// </summary>
- public static void SkipAddLogic(int intvalue, DoorLock doorLock = null, UserCenter.MemberInfoRes accountObj = null)
+ public async static void SkipAddLogic(int intvalue, DoorLock doorLock = null, UserCenter.MemberInfoRes accountObj = null)
{
/// 0.姝e父鑷姩鍖�;1.闂ㄩ攣鑷姩鍖�;2.Sone闂ㄩ攣;
switch (intvalue)
@@ -30,7 +31,6 @@
UserView.HomePage.Instance.AddChidren(addLogicPage);
UserView.HomePage.Instance.PageIndex += 1;
addLogicPage.Show();
-
}
break;
case 1:
@@ -60,42 +60,33 @@
doorLockLogicList.Show();
}
break;
- case 2:
- {
- ///Sone闂ㄩ攣涓诲叆鍙�
- if (doorLock == null)
- {
- ///闃叉鎶涘紓甯�
- doorLock = new DoorLock();
- }
- Send.CurrentDoorLock = doorLock;
- ///杩涙潵鍒锋柊涓�娆¤澶囧垪琛紱
- Common.Logic.LogicDviceList.Clear();
- if (Common.Logic.LogicDviceList.Count == 0)
- {
- Common.Logic.LogicDviceList.AddRange(LocalDevice.Current.listAllDevice.ToArray());
- }
- var addLogicPage = new SoneLogicList();
- UserView.HomePage.Instance.AddChidren(addLogicPage);
- UserView.HomePage.Instance.PageIndex += 1;
- addLogicPage.Show();
-
- }
- break;
+
}
}
-
-
#region 鈼� 鑷姩鍖朹_________________________
+ public static bool If_once = true;//杩涙潵鍙涓�娆℃爣璇�;
/// <summary>
/// 鑷姩鍖栧姛鑳戒唬鐮佸叆鍙�
/// </summary>
public static void ShowAutotionView(FrameLayout functionSceneAutoBodyView)
{
- // functionSceneAutoBodyView.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
+ //functionSceneAutoBodyView.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
#region ---鎺ㄨ崘妯℃澘鐨勭粍浠�
//鎺ㄨ崘妯℃澘鑳屾櫙鎺т欢
+
+
+ var bjFrameLayout1 = new FrameLayout
+ {
+ Width = Application.GetRealWidth(1080 - 58),
+ Height = Application.GetRealHeight(50),
+ BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
+ X = Application.GetRealWidth(58),
+ //Radius = (uint)Application.GetRealHeight(50),
+ Y = Application.GetRealHeight(30),
+
+ };
+ functionSceneAutoBodyView.AddChidren(bjFrameLayout1);
var bjFrameLayout = new FrameLayout
{
Width = Application.GetRealWidth(1080 - 58),
@@ -104,10 +95,10 @@
X = Application.GetRealWidth(58),
//Radius = (uint)Application.GetRealHeight(50),
Y = Application.GetRealHeight(30),
-
};
functionSceneAutoBodyView.AddChidren(bjFrameLayout);
- bjFrameLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerBottomLeft);
+ bjFrameLayout1.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft);
+ bjFrameLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft|HDLUtils.RectCornerBottomLeft);
//鍥炬爣鎺т欢
var sigBtn = new Button
{
@@ -261,10 +252,14 @@
};
//涓嬫媺鍒锋柊鑷姩鍖栧垪琛ㄧ殑浜嬩欢
logicScrolView.BeginHeaderRefreshingAction += () =>
- {
- //閲嶆柊鍒锋柊logic鍒楄〃
- Common.Logic.LogicList.Clear();
- Read(logicScrolView, no);
+ {
+ if (!Config.Instance.Home.IsVirtually)
+ {//铏氭嫙鐨勪笉鑾峰彇缃戝叧閫昏緫鍒楄〃
+ //閲嶆柊鍒锋柊logic鍒楄〃
+ If_once = true;
+ Common.Logic.LogicList.Clear();
+ Read(logicScrolView, no);
+ }
//鍏抽棴鍒锋柊View锛�
logicScrolView.EndHeaderRefreshing();
};
@@ -279,37 +274,53 @@
/// <param name="logicScrolView"></param>
private static async void Read(VerticalRefreshLayout logicScrolView, bool no)
{
+ //if (Config.Instance.HomeId != UserCenter.UserCenterResourse.AccountOption.OldHomeStringId)
+ //{
+ // //鍒囨崲浣忓畢娓呴櫎涔嬪墠缂撳瓨鏁版嵁;
+ // Common.Logic.LogicList.Clear();
+ // Common.Logic.LockLogicList.Clear();
+ // Common.Logic.SoneLogicList.Clear();
+ //}
+
CommonPage.Loading.Start();
try
{
- if (Common.Logic.LogicList.Count == 0)
+ if (!Config.Instance.Home.IsVirtually)//铏氭嫙鐨勪笉鑾峰彇缃戝叧閫昏緫鍒楄〃
{
- var Idlist1 = await Send.GetLogicId(0);//
- var Idlist2 = await Send.GetLogicId(2);//闂ㄩ攣甯稿紑妯″紡
- if (Idlist1.Count != 0)
- {
- var listlogic1 = await Send.ReadList(Idlist1.Count, 0);
- for (int j = 0; j < listlogic1.Count; j++)
- {
- var logic = listlogic1[j];
- if (logic.LogicType != 0)
- {
- continue;
- }
- Common.Logic.LogicList.Add(logic);
- }
- }
- if (Idlist2.Count != 0)
- {
- var listlogic2 = await Send.ReadList(Idlist2.Count, 2);
- for (int j = 0; j < listlogic2.Count; j++)
- {
- var logic = listlogic2[j];
- if (logic.LogicType != 2)
- {
- continue;
- }
- Common.Logic.LogicList.Add(logic);
+ if (If_once)
+ {
+ if (Common.Logic.LogicList.Count == 0)
+ {
+ If_once = false;
+ var Idlist1 = await Send.GetLogicId(0);//
+ var Idlist2 = await Send.GetLogicId(2);//闂ㄩ攣甯稿紑妯″紡
+ if (Idlist1.Count != 0)
+ {
+ var listlogic1 = await Send.ReadList(Idlist1.Count, 0);
+ for (int j = 0; j < listlogic1.Count; j++)
+ {
+ var logic = listlogic1[j];
+ if (logic.LogicType != 0)
+ {
+ continue;
+ }
+ Common.Logic.LogicList.Add(logic);
+ }
+ }
+ if (Idlist2.Count != 0)
+ {
+ var listlogic2 = await Send.ReadList(Idlist2.Count, 2);
+ for (int j = 0; j < listlogic2.Count; j++)
+ {
+ var logic = listlogic2[j];
+ if (logic.LogicType != 2)
+ {
+ continue;
+ }
+ Common.Logic.LogicList.Add(logic);
+ }
+ }
+
}
}
}
@@ -323,12 +334,14 @@
CommonPage.Loading.Hide();
}
static RowLayout selectedRow = new RowLayout() { Tag = "0" };//璁板綍宸︽粦鐘舵��
+
/// <summary>
/// 鍔犺浇鑷姩鍖栧垪琛ㄧ晫闈�
/// </summary>
/// <param name="refresview">Refresview.</param>
private static async void Automationview(VerticalRefreshLayout refresview, bool no)
{
+
refresview.RemoveAll();
if (Common.Logic.LogicList.Count == 0 && no == false)
{
@@ -460,7 +473,10 @@
logic.IsEnable = 0;
StatusColor(logic, logicRowlayout, 0);
}
- Send.LogicControlSwitch(logic);
+ if (!Config.Instance.Home.IsVirtually)
+ {
+ Send.LogicControlSwitch(logic);
+ }
//Logic.Send.AddModifyLogic(logic);
};
if (logic.IsEnable == 1)
@@ -514,7 +530,7 @@
logicRowlayout.AddRightView(del);
del.MouseUpEventHandler += (sender, e) =>
{
- var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Confirm,
+ var alert = new UserCenter.ShowMsgControl(ShowMsgType.Confirm,
Language.StringByID(MyInternationalizationString.doyouwanttodelete),
Language.StringByID(MyInternationalizationString.confrim));
alert.Show();
@@ -522,7 +538,10 @@
{
Common.Logic.LogicList.Remove(logic);
Automationview(refresview, no);
- Send.DelLogic(logic.LogicId);
+ if (!Config.Instance.Home.IsVirtually)
+ {
+ Send.DelLogic(logic.LogicId);
+ }
};
};
@@ -698,12 +717,12 @@
#endregion
/// <summary>
- /// 闂ㄩ攣鍙栨秷璁剧疆鐢ㄧ殑鏂规硶(鐩稿綋涓�涓叧闂父寮�妯″紡鎸夐挳,鍒嗙被-鑷姩鍖�-涓嶉渶瑕佹樉绀鸿鑷姩鍖�)
+ /// 闂ㄩ攣澶辨晥璁剧疆鐢ㄧ殑鏂规硶(鐩稿綋涓�涓叧闂父寮�妯″紡鎸夐挳,鍒嗙被-鑷姩鍖�-涓嶉渶瑕佹樉绀鸿鑷姩鍖�)
/// </summary>
/// <param name="timeVlaue">鏃堕棿鍊�</param>
/// <param name="common">璁惧</param>
/// <returns></returns>
- public static async System.Threading.Tasks.Task<bool> LockAddModifyLogic(int timeVlaue, CommonDevice common)
+ public static async System.Threading.Tasks.Task<int> LockAddModifyLogic(int timeVlaue, CommonDevice common)
{
//璇诲彇绯荤粺褰撳墠鏃堕棿锛氭椂-鍒�
var h = DateTime.Now.ToString("HH");
@@ -716,13 +735,26 @@
timeConditionsInfo.Add("EnDelay", "0");
timeConditionsInfo.Add("DelayTime", "0");
timeConditionsInfo.Add("StartHour", h);
- timeConditionsInfo.Add("StartMin", m);
- timeConditionsInfo.Add("DoorLockOpenDelayTime", timeVlaue.ToString());
+ timeConditionsInfo.Add("StartMin", m);
+ if (UserCenter.UserCenterResourse.HideOption.DoorLockNomallyOpenTimeMode == 1)
+ {
+ //寮哄埗鍙樻洿鏃堕棿妯″紡涓哄垎閽�
+ timeConditionsInfo.Add("DoorLockOpenDelayTime", (timeVlaue * 60).ToString());
+ }
+ else
+ {
+ timeConditionsInfo.Add("DoorLockOpenDelayTime", (timeVlaue * 3600).ToString());
+ }
Dictionary<string, object> actionsInfo = new Dictionary<string, object>();
actionsInfo.Add("LinkType", 8);
actionsInfo.Add("DeviceAddr", common.DeviceAddr);
- actionsInfo.Add("Epoint", common.DeviceEpoint);
+ actionsInfo.Add("Epoint", "200");
actionsInfo.Add("PassData", "055704010113");//榛樿闂ㄩ攣甯稿叧
+
+ Dictionary<string, string> accounts = new Dictionary<string, string>();
+ accounts.Add("Type", "8");
+ accounts.Add("Option4", common.DeviceAddr.ToString());//鐢ㄤ簬鍒ゆ柇璇嗗埆鏄摢涓棬閿�;
+ accounts.Add("Option2", common.DeviceEpoint.ToString());
Common.Logic currentLogic = new Common.Logic();
currentLogic.IsEnable = 1;//榛樿涓哄紑
@@ -731,14 +763,15 @@
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)
{
//娣诲姞闂ㄩ攣澶辨晥鏃堕棿鐨勫巻鍙茶褰�
UserCenter.HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog((DoorLock)common, 9003, timeVlaue.ToString());
- return true;//琛ㄧず娣诲姞鎴愬姛;
+ return logicIfon.LogicId;//琛ㄧず娣诲姞鎴愬姛;
}
- return false;//琛ㄧず娣诲姞澶辫触;
+ return 0;//琛ㄧず娣诲姞澶辫触;
}
@@ -747,24 +780,37 @@
/// 娉ㄦ剰(鍙傛暟:2-甯稿紑鑷姩鍖�;3-澶辨晥鏃堕棿鑷姩鍖�);
/// 杩斿洖鍊硷細0涓嶅瓨鍦�;鍏跺畠鍊奸兘瀛樺湪;
/// </summary>
- public static async System.Threading.Tasks.Task<int> Exist(int valueInt)
+ public static async System.Threading.Tasks.Task<int> Exist(int valueInt, ZigBee.Device.DoorLock doorLock)
{
+
int exist = 0;
- var Idlist = await Send.GetLogicId(valueInt);
- if (Idlist.Count != 0)
+ var IdList = await Send.GetLogicId(valueInt);
+ if (IdList.Count != 0)
{
- //榛樿鍙栫涓�涓�昏緫ID
- exist = Idlist[0];
+ for (int i = 0; i < IdList.Count; i++)
+ {
+ var id = IdList[i];
+ var logic = await Send.GetLogic(id, valueInt);
+ if (logic != null)
+ {
+ if (ExistLogic(logic, doorLock))
+ {
+ exist = id;
+ ///鎵惧埌閫�鍑�
+ break;
+ }
+ }
+ }
}
return exist;
}
///<summary>
- ///鑾峰彇閫昏緫淇℃伅
+ ///鑾峰彇闂ㄩ攣鏃舵晥鎬ч�昏緫淇℃伅
/// 杩斿洖鍊硷細null涓嶅瓨鍦�;鍏跺畠鍊奸兘瀛樺湪;
/// </summary>
- public static async System.Threading.Tasks.Task<Common.Logic> GetLogicIfon()
+ public static async System.Threading.Tasks.Task<Common.Logic> GetLogicIfon(ZigBee.Device.DoorLock doorLock)
{
Common.Logic logic = null;
var Idlist = await Send.GetLogicId(3);
@@ -773,9 +819,73 @@
//榛樿鍙栫涓�涓�昏緫ID(鏃舵晥鎬у彧鏈変竴鏉¢�昏緫)
int exist = Idlist[0];
logic = await Send.GetLogic(exist, 3);
+ if (!ExistLogic(logic, doorLock))
+ {
+ logic = null;
+ }
}
return logic;
}
+
+ ///<summary>
+ ///鍒犻櫎璇ラ棬閿佹墍鏈夋椂鏁堟�ц嚜鍔ㄥ寲
+ /// 杩斿洖鍊硷細true鎴愬姛;false澶辫触;
+ /// </summary>
+ public static async System.Threading.Tasks.Task<bool> DelAllLogic(ZigBee.Device.DoorLock doorLock)
+ {
+ bool _if = false;
+ var Idlist = await Send.GetLogicId(3);
+ if (Idlist.Count != 0)
+ {
+ for (int i = 0; i < Idlist.Count; i++)
+ {
+ int id = Idlist[i];
+ var logic = await Send.GetLogic(id, 3);
+ if (logic != null)
+ {
+ if (ExistLogic(logic, doorLock))
+ {
+ //鏈潵鍙湁涓�鏉℃椂鏁堟�ц嚜鍔ㄥ寲锛�
+ //闃叉鐗规畩鎯呭喌,鎵惧埌灏卞垹闄ゆ帀;
+ //var valueInt = await Send.DelLogic(id);
+ //if (valueInt == 0)
+ //{
+ // _if = true;
+ //}
+ //(鑰冭檻鎬ц兘榛樿鍒犻櫎鎴愬姛锛岀洿鎺ヨ繑鍥炴垚鍔熺粨鏋渢rue)
+ _if = true;
+ Send.DelLogic(id);
+
+
+ }
+ }
+ }
+ }
+ return _if;
+ }
+
+ /// <summary>
+ /// 鏌ユ壘杩欎竴鏉¤嚜鍔ㄥ寲鏄惁灞炰簬璇ラ棬閿�
+ /// </summary>
+ /// <returns></returns>
+ public static bool ExistLogic(Common.Logic logic, ZigBee.Device.DoorLock doorLock)
+ {
+ for (int j = 0; j < logic.Accounts.Count; j++)
+ {
+ //Option4鏄澶噈ac锛�
+ if (logic.Accounts[j]["Option4"].ToString() == doorLock.DeviceAddr)
+ {
+ //鏌ユ壘鏄惁鏄偅涓棬閿侊紱
+ //濡傛灉涓嶆槸璇ラ棬閿佽仈鍔ㄤ簨浠朵笉鏄剧ず鍑烘潵;
+ return true;
+ }
+
+ }
+ return false;
+ }
+
+
+
}
}
--
Gitblit v1.8.0