From c6ff92e84b6cb2815cb98065ecb0ecf95d0689c3 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期三, 15 一月 2020 09:42:29 +0800
Subject: [PATCH] 2020-01-15-1
---
ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/AddCondition.cs | 395 +++++++++++++++++++++++++++-----------------------------
1 files changed, 192 insertions(+), 203 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/AddCondition.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/AddCondition.cs
index b80464b..96425fe 100644
--- 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
@@ -27,14 +28,15 @@
var titleName = new Button
{
- TextSize = 16,
+ TextSize = 17,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
TextAlignment = TextAlignment.CenterLeft,
X = Application.GetRealWidth(176),
- Width = Application.GetRealWidth(400),
+ Width = Application.GetRealWidth(600),
Height = Application.GetRealHeight(69),
Y = Application.GetRealHeight(92),
TextID = MyInternationalizationString.userlist,
+ IsBold = true,
//Text = "閫夋嫨鐢ㄦ埛",
};
topRowLayout.AddChidren(titleName);
@@ -68,93 +70,85 @@
#endregion
- var middle = new VerticalScrolViewLayout
+ middle = new VerticalRefreshLayout
{
Y = topRowLayout.Bottom,
Height = Application.GetRealHeight(1920 - 184),
BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
};
this.AddChidren(middle);
-
- var userlist = new List<Send.MembershipIfon>();
- ///鍒ゆ柇APP鐧诲綍杩涙潵鐢ㄦ埛韬唤(涓讳汉锛岀鐞嗗憳锛屾垚鍛�)
- var doorlockifonlist = await Send.UserListIfon(LockIfon.DoorLock.DeviceAddr);
- if (UserCenter.UserCenterResourse.UserInfo.AuthorityNo == 3)
+ middle.BeginHeaderRefreshingAction += () =>
{
- Send.MembershipIfon membershipIfon = new Send.MembershipIfon();
- foreach (var o in doorlockifonlist)
+ //閲嶆柊鍒锋柊logic鍒楄〃
+ string macport = Send.CurrentDoorLock.DeviceAddr + "_" + Send.CurrentDoorLock.DeviceEpoint.ToString();
+ for (int i = 0; i < Send.LockList.Count; i++)
{
-
- if (o.CloudAccountId == LockIfon.UserMemberInfoRes.SubAccountDistributedMark)
+ if (Send.LockList[i].DoorLockMacPort == macport)
{
- Send.LockMode lockMode = new Send.LockMode();
- lockMode.OpenMode = o.OpenLockMode;
- lockMode.UserId = o.DoorLockLocalUserId;
- membershipIfon.UserIdMode.Add(lockMode);
- membershipIfon.MembershipId = LockIfon.UserMemberInfoRes.SubAccountDistributedMark;
- if (string.IsNullOrEmpty(LockIfon.UserMemberInfoRes.UserName))
- {
- membershipIfon.MembershipName = LockIfon.UserMemberInfoRes.Account;
- }
- else
- {
- membershipIfon.MembershipName = LockIfon.UserMemberInfoRes.UserName;
- }
+ ///浠庡垪琛ㄧЩ闄ゅ綋鍓嶉棬閿佸叏閮ㄧ殑鏃ф暟鎹紱
+ Send.LockList.Remove(Send.LockList[i]);
+ i--;
}
-
}
- userlist.Add(membershipIfon);
+ Read();
+ //鍏抽棴鍒锋柊View锛�
+ middle.EndHeaderRefreshing();
+ };
+ Read();
- }
- else
+ }
+ /// <summary>
+ /// 璇诲彇褰撳墠闂ㄩ攣鐨勪簯绔暟鎹紱
+ /// </summary>
+ public void Read()
+ {
+ bool d = false;
+ string macport = Send.CurrentDoorLock.DeviceAddr + "_" + Send.CurrentDoorLock.DeviceEpoint.ToString();
+ for (int i = 0; i < Send.LockList.Count; i++)
{
- var pra = new UserCenter.MemberListInfoPra();
- string result = await UserCenter.UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra);
- var listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UserCenter.MemberInfoRes>>(result);
- for (int i = 0; i < listInfo.Count; i++)
+ if (Send.LockList[i].DoorLockMacPort == macport)
{
- var membership = new Send.MembershipIfon();
- var membershipifon = listInfo[i];
- for (int j = 0; j < doorlockifonlist.Count; j++)
- {
- ///鏌ユ壘鎴愬憳浠ュ強鎴愬憳闂ㄩ攣瑙﹀彂婧�(1鎸夐敭/3鍗�/15鎸囩汗)
- if (doorlockifonlist[j].CloudAccountId == membershipifon.SubAccountDistributedMark)
- {
- Send.LockMode lockMode = new Send.LockMode();
- lockMode.OpenMode = doorlockifonlist[j].OpenLockMode;
- lockMode.UserId = doorlockifonlist[j].DoorLockLocalUserId;
- membership.UserIdMode.Add(lockMode);
- membership.MembershipId = membershipifon.SubAccountDistributedMark;
- if (string.IsNullOrEmpty(membershipifon.UserName))
- {
- membership.MembershipName = membershipifon.Account;
- }
- else
- {
- membership.MembershipName = membershipifon.UserName;
-
- }
-
- }
-
- }
- if (membership.UserIdMode.Count != 0)
- {
- ///杩囨护鎺夐噸澶嶆暟鎹紱
- var str = userlist.Find((c) => { return c.MembershipId == membershipifon.SubAccountDistributedMark; });
- if (str == null)
- {
- userlist.Add(membership);
- }
- }
-
+ ///宸茬粡瀛樺湪璇ラ棬閿佷俊鎭�
+ d = true;
+ break;
}
-
}
-
- for (int i = 0; i < userlist.Count; i++)
+ CommonPage.Loading.Start();
+ middle.RemoveAll();
+ System.Threading.Tasks.Task.Run(async () =>
{
- var user = userlist[i];
+ try
+ {
+ if (!d)
+ {
+ var allMemberslist = await Send.AllMembers(macport);
+ Send.LockList.AddRange(allMemberslist);
+ }
+ }
+ catch { }
+ finally
+ {
+ Application.RunOnMainThread(() =>
+ {
+ CommonPage.Loading.Hide();
+ UserAllView(macport);
+ });
+ }
+ });
+ }
+ /// <summary>
+ /// 鏄剧ず鎵�鏈夌敤鎴�
+ /// </summary>
+ public void UserAllView(string macport)
+ {
+ middle.RemoveAll();
+ for (int i = 0; i < Send.LockList.Count; i++)
+ {
+ var user = Send.LockList[i];
+ if (user.DoorLockMacPort != macport)
+ {
+ continue;
+ }
var userFramelayout = new FrameLayout
{
Height = Application.GetRealHeight(160),
@@ -174,12 +168,13 @@
var usernameBtn = new Button
{
- Text = user.MembershipName,
+ Text = user.UserName,
TextAlignment = TextAlignment.CenterLeft,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
Width = Application.GetRealWidth(600),
Height = Application.GetRealHeight(130),
- Tag = userlist[i],
+ Tag = Send.LockList[i],
+ TextSize = 14,
};
userRow.AddChidren(usernameBtn);
@@ -196,7 +191,7 @@
EventHandler<MouseEventArgs> userclick = (sender, e) =>
{
- SelectedUserID(user.UserIdMode, usernameBtn.Text);
+ SelectedUserID(user);
};
usernameBtn.MouseUpEventHandler += userclick;
btntimeback.MouseUpEventHandler += userclick;
@@ -206,15 +201,14 @@
}
}
-
/// <summary>
/// 閫夋嫨鏌愪釜鐢ㄦ埛
/// </summary>
/// <param name="membershipIfon">瑙﹀彂婧愬垪琛�</param>
- /// <param name="userName">鐢ㄦ埛鍚嶅瓧</param>
- void SelectedUserID(List<Send.LockMode> 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) =>
@@ -222,14 +216,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
{
@@ -241,12 +228,14 @@
Radius = (uint)Application.GetRealHeight(60),
};
flMain.AddChidren(lockcolorfra1);
+ lockcolorfra1.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
#region -------鍙栨秷 瀹屾垚
var lockRow = new RowLayout
{
Height = Application.GetRealHeight(140),
LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
+
};
lockcolorfra1.AddChidren(lockRow);
var Btncancel = new Button
@@ -257,6 +246,7 @@
Width = Application.GetRealWidth(200),
X = Application.GetRealWidth(80),
TextAlignment = TextAlignment.CenterLeft,
+ TextSize = 14,
};
lockRow.AddChidren(Btncancel);
Btncancel.MouseUpEventHandler += (sender16, e16) =>
@@ -274,7 +264,7 @@
TextAlignment = TextAlignment.Center,
X = Btncancel.Right + Application.GetRealWidth(100),
TextSize = 16,
- Text =userName,
+ Text = membershipIfon.UserName,
};
lockRow.AddChidren(Btntitle);
var Btncomplete = new Button
@@ -285,19 +275,30 @@
Width = Application.GetRealWidth(200),
TextAlignment = TextAlignment.CenterRight,
X = Btntitle.Right + Application.GetRealWidth(100),
+ TextSize = 14,
};
lockRow.AddChidren(Btncomplete);
#endregion
- string SelectedLockStatus = "";
- lockcolorfra1.Y = Application.GetRealHeight(1920 - 140 - (160 * membershipIfon.Count) - 20 - 50);
- lockcolorfra1.Height = Application.GetRealHeight(140 + (160 * membershipIfon.Count) + 20 + 50);
- ///瀹氫箟涓や釜鍙橀噺璁板綍閫変腑鐘舵�侊紱
- string attriButeId ="", attriButeData2 ="";
- for (int j = 0; j < membershipIfon.Count; j++)
+
+ lockcolorfra1.Y = Application.GetRealHeight(1920 - 140 - (160 * membershipIfon.UserIdMode.Count) - 20 - 50);
+ lockcolorfra1.Height = Application.GetRealHeight(140 + (160 * membershipIfon.UserIdMode.Count) + 20 + 50);
+ if (membershipIfon.UserIdMode.Count > 9)
{
- var userIdmode = membershipIfon[j];
+ ///鍏冪礌瓒呭嚭10涓紝鏆傛椂榛樿鏄剧ず10;
+ lockcolorfra1.Y = Application.GetRealHeight(1920 - 140 - (160 * 9) - 20 - 50);
+ lockcolorfra1.Height = Application.GetRealHeight(140 + (160 * 9) + 20 + 50);
+ }
+ string SelectedLockStatus = "";
+ ///瀹氫箟涓や釜鍙橀噺璁板綍閫変腑鐘舵�侊紱
+ string attriButeId = "";
+ string attriButeData2 = "";
+ string modeName = "";
+
+ for (int j = 0; j < membershipIfon.UserIdMode.Count; j++)
+ {
+ var userIdmode = membershipIfon.UserIdMode[j];
var doorlockfra = new FrameLayout
{
Height = Application.GetRealHeight(160),
@@ -320,29 +321,33 @@
Width = Application.GetRealWidth(600),
TextAlignment = TextAlignment.CenterLeft,
TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
+ Text = userIdmode.ModeName,
+ TextSize = 14,
};
doorlockRow.AddChidren(doorlockBtn);
- //(0鎸夐敭/3鍗�/15鎸囩汗)
- switch (userIdmode.OpenMode.ToString())
+ if (string.IsNullOrEmpty(doorlockBtn.Text))
{
- 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;
-
+ string strname = "";
+ switch (userIdmode.OpenMode)
+ {
+ case 0:
+ {
+ strname = Language.StringByID(MyInternationalizationString.lockpassword);
+ }
+ break;
+ case 3:
+ {
+ strname = Language.StringByID(MyInternationalizationString.ic);
+ }
+ break;
+ case 15:
+ {
+ strname = Language.StringByID(MyInternationalizationString.fingerprint);
+ }
+ break;
+ }
+ doorlockBtn.Text = strname + "ID" + userIdmode.UserId;
}
-
var doorlockSelected = new Button
{
@@ -355,7 +360,7 @@
};
doorlockRow.AddChidren(doorlockSelected);
- if ((membershipIfon.Count - 1) == j)
+ if ((membershipIfon.UserIdMode.Count - 1) == j)
{
doorlockRow.LineColor = ZigbeeColor.Current.LogicBackgroundColor;
}
@@ -365,9 +370,10 @@
selectedIcon.Visible = false;
selectedIcon = doorlockSelected;
doorlockSelected.Visible = true;
- //doorlockBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
- attriButeId = userIdmode.OpenMode.ToString();
+ //doorlockBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
+ attriButeId = userIdmode.OpenMode.ToString();
attriButeData2 = userIdmode.UserId;
+ modeName = doorlockBtn.Text;
};
doorlockRow.MouseUpEventHandler += doorlockclick;
doorlockBtn.MouseUpEventHandler += doorlockclick;
@@ -383,31 +389,90 @@
selectedIcon = doorlockSelected;
doorlockSelected.Visible = true;
}
+
+
}
}
-
+
+
Btncomplete.MouseUpEventHandler += (sender, e) =>
{
var lockConditionsInfo = new Dictionary<string, string>();
lockConditionsInfo.Add("Type", "1");
lockConditionsInfo.Add("IsValid", "1");
- lockConditionsInfo.Add("MacAddr", LockIfon.DoorLock.DeviceAddr);
- lockConditionsInfo.Add("Epoint", LockIfon.DoorLock.DeviceEpoint.ToString());
+ lockConditionsInfo.Add("MacAddr", Send.CurrentDoorLock.DeviceAddr);
+ lockConditionsInfo.Add("Epoint", Send.CurrentDoorLock.DeviceEpoint.ToString());
lockConditionsInfo.Add("Cluster_ID", "64529");
lockConditionsInfo.Add("AttriButeId", attriButeId);
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", Config.Instance.Guid);
+ accounts.Add("AccountName", membershipIfon.UserName + modeName);//鐢ㄦ潵鏄剧ず鍚嶇О
+ accounts.Add("UserId", attriButeData2);
if (SelectedLockStatus != "")
{
if (conditionsIndex == -1)
{
- Common.Logic.CurrentLogic.Conditions.Add(lockConditionsInfo);
+ 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")
+ {
+ if ((Common.Logic.CurrentLogic.Conditions[i]["MacAddr"] == Send.CurrentDoorLock.DeviceAddr) && (Common.Logic.CurrentLogic.Conditions[i]["Epoint"] == Send.CurrentDoorLock.DeviceEpoint.ToString()))
+ {
+ if (Common.Logic.CurrentLogic.Conditions[i]["AttriButeId"] == lockConditionsInfo["AttriButeId"] && Common.Logic.CurrentLogic.Conditions[i]["AttriButeData2"] == lockConditionsInfo["AttriButeData2"])
+ {
+ addCondition = true;
+ break;
+ }
+ }
+ }
+ }
+ 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;
+ }
+ }
+ }
+
}
}
@@ -415,9 +480,9 @@
{
if (conditionsIndex == -1)
{
- var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
- Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
- Language.StringByID(MyInternationalizationString.complete));
+ var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
+ Language.StringByID(MyInternationalizationString.usertip),
+ Language.StringByID(MyInternationalizationString.confrim));
alert.Show();
return;
}
@@ -428,82 +493,6 @@
lockLogicCommunalPage.Show(() => { });
};
}
- /*
- public async List<Send.MembershipIfon> readuserlist(){
- var userlist = new List<Send.MembershipIfon>();
- ///鍒ゆ柇APP鐧诲綍杩涙潵鐢ㄦ埛韬唤(涓讳汉锛岀鐞嗗憳锛屾垚鍛�)
- var doorlockifonlist = await Send.UserListIfon(LockIfon.DoorLock.DeviceAddr);
- if (UserCenter.UserCenterResourse.UserInfo.AuthorityNo == 3)
- {
- Send.MembershipIfon membershipIfon = new Send.MembershipIfon();
- //var list = LockIfon.GetUserIfon(LockIfon.UserMemberInfoRes.SubAccountDistributedMark);
- foreach (var o in doorlockifonlist)
- {
-
- if (o.CloudAccountId == LockIfon.UserMemberInfoRes.SubAccountDistributedMark)
- {
- membershipIfon.MembershipId = LockIfon.UserMemberInfoRes.SubAccountDistributedMark;
- membershipIfon.UserIdMode.Add(o.OpenLockMode.ToString());
- if (string.IsNullOrEmpty(LockIfon.UserMemberInfoRes.UserName))
- {
- membershipIfon.MembershipName = LockIfon.UserMemberInfoRes.Account;
-
- }
- else
- {
- membershipIfon.MembershipName = LockIfon.UserMemberInfoRes.UserName;
-
- }
- }
-
- }
- userlist.Add(membershipIfon);
-
- }
- else
- {
- var pra = new UserCenter.MemberListInfoPra();
- string result = await UserCenter.UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra);
- var listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UserCenter.MemberInfoRes>>(result);
- for (int i = 0; i < listInfo.Count; i++)
- {
- var membership = new Send.MembershipIfon();
- var membershipifon = listInfo[i];
- for (int j = 0; j < doorlockifonlist.Count; j++)
- {
- ///鏌ユ壘鎴愬憳浠ュ強鎴愬憳闂ㄩ攣瑙﹀彂婧�(1鎸夐敭/3鍗�/15鎸囩汗)
- if (doorlockifonlist[j].CloudAccountId == membershipifon.SubAccountDistributedMark)
- {
- membership.UserIdMode.Add(doorlockifonlist[j].UserIdMode);
- membership.MembershipId = membershipifon.SubAccountDistributedMark;
- if (string.IsNullOrEmpty(membershipifon.UserName))
- {
- membership.MembershipName = membershipifon.Account;
- }
- else
- {
- membership.MembershipName = membershipifon.UserName;
-
- }
-
- }
-
- }
- if (membership.UserIdMode.Count != 0)
- {
- ///杩囨护鎺夐噸澶嶆暟鎹紱
- var str = userlist.Find((c) => { return c.MembershipId == membership.MembershipId; });
- if (str == null)
- {
- userlist.Add(membership);
- }
- }
-
- }
-
- }
- return userlist;
- }
- */
+
}
}
--
Gitblit v1.8.0