From 9d61367c1fd278f58f721d4c0e69999f89e4485d Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 12 十二月 2019 14:14:30 +0800
Subject: [PATCH] 添加最新绑定机制
---
ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/AddCondition.cs | 145 ++++++++++++++++++++++++++++++------------------
1 files changed, 90 insertions(+), 55 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/AddCondition.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/AddCondition.cs
old mode 100755
new mode 100644
index dae8177..fa4eb0b
--- a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/AddCondition.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/AddCondition.cs
@@ -12,9 +12,10 @@
Tag = "LockLogic";
}
Button selectedIcon = new Button();
-
+ VerticalRefreshLayout middle;
public int conditionsIndex = -1;
- public async void Show()
+
+ public void Show()
{
#region 鏈�涓婇潰鐨勫竷灞�浠g爜
var topRowLayout = new RowLayout
@@ -68,14 +69,37 @@
#endregion
- var middle = new VerticalScrolViewLayout
+ middle = new VerticalRefreshLayout
{
Y = topRowLayout.Bottom,
Height = Application.GetRealHeight(1920 - 184),
BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
};
this.AddChidren(middle);
+ middle.BeginHeaderRefreshingAction += () =>
+ {
+ //閲嶆柊鍒锋柊logic鍒楄〃
+ string macport = Send.CurrentDoorLock.DeviceAddr + "_" + Send.CurrentDoorLock.DeviceEpoint.ToString();
+ for (int i = 0; i < Send.LockList.Count; i++)
+ {
+ if (Send.LockList[i].DoorLockMacPort == macport)
+ {
+ ///浠庡垪琛ㄧЩ闄ゅ綋鍓嶉棬閿佸叏閮ㄧ殑鏃ф暟鎹紱
+ Send.LockList.Remove(Send.LockList[i]);
+ }
+ }
+ Read();
+ //鍏抽棴鍒锋柊View锛�
+ middle.EndHeaderRefreshing();
+ };
+ Read();
+ }
+ /// <summary>
+ /// 璇诲彇褰撳墠闂ㄩ攣鐨勪簯绔暟鎹紱
+ /// </summary>
+ public async void Read()
+ {
bool d = false;
string macport = Send.CurrentDoorLock.DeviceAddr + "_" + Send.CurrentDoorLock.DeviceEpoint.ToString();
for (int i = 0; i < Send.LockList.Count; i++)
@@ -86,23 +110,20 @@
d = true;
break;
}
-
}
-
+ CommonPage.Loading.Start();
if (!d)
{
-
var allMemberslist = await Send.AllMembers(Send.CurrentDoorLock.DeviceAddr);
Send.LockList.AddRange(allMemberslist);
}
- UserAllView(middle, macport);
-
+ UserAllView(macport);
+ CommonPage.Loading.Hide();
}
/// <summary>
/// 鏄剧ず鎵�鏈夌敤鎴�
/// </summary>
- /// <param name="middle"></param>
- void UserAllView(VerticalScrolViewLayout middle,string macport)
+ public void UserAllView(string macport)
{
for (int i = 0; i < Send.LockList.Count; i++)
@@ -154,7 +175,7 @@
EventHandler<MouseEventArgs> userclick = (sender, e) =>
{
- SelectedUserID(user.UserIdMode, usernameBtn.Text);
+ SelectedUserID(user);
};
usernameBtn.MouseUpEventHandler += userclick;
btntimeback.MouseUpEventHandler += userclick;
@@ -168,10 +189,10 @@
/// 閫夋嫨鏌愪釜鐢ㄦ埛
/// </summary>
/// <param name="membershipIfon">瑙﹀彂婧愬垪琛�</param>
- /// <param name="userName">鐢ㄦ埛鍚嶅瓧</param>
- void SelectedUserID(List<Send.UnlockingMode> membershipIfon, string userName) {
+ public void SelectedUserID(Send.MembershipIfon membershipIfon)
+ {
- var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
+ var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
this.AddChidren(flMain);
flMain.MouseUpEventHandler += (sender1, e1) =>
@@ -179,14 +200,7 @@
flMain.RemoveFromParent();
};
- var lockcolorfra = new FrameLayout
- {
- Width = Application.GetRealWidth(1080),
- Height = Application.GetRealHeight(100),
- Y = Application.GetRealHeight(1920 - 100),
- BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
- };
- flMain.AddChidren(lockcolorfra);
+
var lockcolorfra1 = new FrameLayout
{
@@ -198,6 +212,7 @@
Radius = (uint)Application.GetRealHeight(60),
};
flMain.AddChidren(lockcolorfra1);
+ lockcolorfra1.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
#region -------鍙栨秷 瀹屾垚
var lockRow = new RowLayout
@@ -233,7 +248,7 @@
TextAlignment = TextAlignment.Center,
X = Btncancel.Right + Application.GetRealWidth(100),
TextSize = 16,
- Text =userName,
+ Text = membershipIfon.UserName,
};
lockRow.AddChidren(Btntitle);
var Btncomplete = new Button
@@ -251,13 +266,15 @@
#endregion
string SelectedLockStatus = "";
- lockcolorfra1.Y = Application.GetRealHeight(1920 - 140 - (160 * membershipIfon.Count) - 20 - 50);
- lockcolorfra1.Height = Application.GetRealHeight(140 + (160 * membershipIfon.Count) + 20 + 50);
+ lockcolorfra1.Y = Application.GetRealHeight(1920 - 140 - (160 * membershipIfon.UserIdMode.Count) - 20 - 50);
+ lockcolorfra1.Height = Application.GetRealHeight(140 + (160 * membershipIfon.UserIdMode.Count) + 20 + 50);
///瀹氫箟涓や釜鍙橀噺璁板綍閫変腑鐘舵�侊紱
- string attriButeId ="", attriButeData2 ="";
- for (int j = 0; j < membershipIfon.Count; j++)
+ string attriButeId = "";
+ string attriButeData2 = "";
+ string modeName = "";
+ for (int j = 0; j < membershipIfon.UserIdMode.Count; j++)
{
- var userIdmode = membershipIfon[j];
+ var userIdmode = membershipIfon.UserIdMode[j];
var doorlockfra = new FrameLayout
{
Height = Application.GetRealHeight(160),
@@ -284,26 +301,6 @@
TextSize = 14,
};
doorlockRow.AddChidren(doorlockBtn);
- //(0鎸夐敭/3鍗�/15鎸囩汗)
- //switch (userIdmode.OpenMode.ToString())
- //{
- // case "0":
- // {
- // doorlockBtn.Text = Language.StringByID(MyInternationalizationString.lockpassword);
- // }
- // break;
- // case "3":
- // {
- // doorlockBtn.Text = Language.StringByID(MyInternationalizationString.ic);
- // }
- // break;
- // case "15":
- // {
- // doorlockBtn.Text = Language.StringByID(MyInternationalizationString.fingerprint);
- // }
- // break;
- //}
-
var doorlockSelected = new Button
{
@@ -316,7 +313,7 @@
};
doorlockRow.AddChidren(doorlockSelected);
- if ((membershipIfon.Count - 1) == j)
+ if ((membershipIfon.UserIdMode.Count - 1) == j)
{
doorlockRow.LineColor = ZigbeeColor.Current.LogicBackgroundColor;
}
@@ -329,6 +326,7 @@
//doorlockBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
attriButeId = userIdmode.OpenMode.ToString();
attriButeData2 = userIdmode.UserId;
+ modeName = userIdmode.ModeName;
};
doorlockRow.MouseUpEventHandler += doorlockclick;
doorlockBtn.MouseUpEventHandler += doorlockclick;
@@ -344,9 +342,11 @@
selectedIcon = doorlockSelected;
doorlockSelected.Visible = true;
}
+
+
}
}
-
+
Btncomplete.MouseUpEventHandler += (sender, e) =>
{
var lockConditionsInfo = new Dictionary<string, string>();
@@ -359,11 +359,16 @@
lockConditionsInfo.Add("AttriButeData2", attriButeData2);
lockConditionsInfo.Add("AttriButeData1", "2");
lockConditionsInfo.Add("Range", "0");
+ var accounts = new Dictionary<string, string>();
+ accounts.Add("Type", "1");
+ accounts.Add("Account", membershipIfon.UserName + modeName);
+ accounts.Add("UserId", attriButeData2);
if (SelectedLockStatus != "")
{
if (conditionsIndex == -1)
{
- bool add = false;
+ bool addCondition = false;
+ bool addAccount = false;
for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++)
{
if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == "1")
@@ -372,23 +377,53 @@
{
if (Common.Logic.CurrentLogic.Conditions[i]["AttriButeId"] == lockConditionsInfo["AttriButeId"] && Common.Logic.CurrentLogic.Conditions[i]["AttriButeData2"] == lockConditionsInfo["AttriButeData2"])
{
- add = true;
+ addCondition = true;
break;
}
}
}
}
-
- if (!add)
+ if (!addCondition)
{
Common.Logic.CurrentLogic.Conditions.Add(lockConditionsInfo);
}
+ for (int i = 0; i < Common.Logic.CurrentLogic.Accounts.Count; i++)
+ {
+ if (Common.Logic.CurrentLogic.Accounts[i]["Type"] == "1")
+ {
+ if (Common.Logic.CurrentLogic.Accounts[i]["UserId"] == attriButeData2)
+ {
+ addAccount = true;
+ break;
+ }
+ }
+ }
+ if (!addAccount)
+ {
+ Common.Logic.CurrentLogic.Accounts.Add(accounts);
+ }
}
else
{
+ ///鎵惧嚭涔嬪墠鐨勬棫鏁版嵁绉婚櫎鎺夛紝鍐嶉噸鏂版坊鍔犳柊鏁版嵁锛�
+ string accountuserId = Common.Logic.CurrentLogic.Conditions[conditionsIndex]["AttriButeData2"];
Common.Logic.CurrentLogic.Conditions.RemoveAt(conditionsIndex);
Common.Logic.CurrentLogic.Conditions.Insert(conditionsIndex, lockConditionsInfo);
+ for (int i = 0; i < Common.Logic.CurrentLogic.Accounts.Count; i++)
+ {
+ if (Common.Logic.CurrentLogic.Accounts[i]["Type"] == "1")
+ {
+ ///鎵惧嚭涔嬪墠鐨勬棫鏁版嵁绉婚櫎鎺夛紝鍐嶉噸鏂版坊鍔犳柊鏁版嵁锛�
+ if (Common.Logic.CurrentLogic.Accounts[i]["UserId"] == accountuserId)
+ {
+ Common.Logic.CurrentLogic.Accounts.RemoveAt(i);
+ Common.Logic.CurrentLogic.Accounts.Insert(i, accounts);
+ break;
+ }
+ }
+ }
+
}
}
@@ -409,6 +444,6 @@
lockLogicCommunalPage.Show(() => { });
};
}
-
+
}
}
--
Gitblit v1.8.0