From b68cdc7e103a00d5df73e4b75603be8da1815b4a Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期三, 29 四月 2020 13:59:52 +0800
Subject: [PATCH] 上传版本

---
 ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs |  434 ++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 293 insertions(+), 141 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs
index 50ddc77..6b5ed4f 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs
@@ -47,7 +47,7 @@
         /// </summary>
         bool canVolume = false;
         /// <summary>
-        /// 淇濈暀涓婁竴娆¢煶閲�
+        /// 鏄惁鏀寔甯稿紑
         /// </summary>
         bool canOpenNormallyMode = false;
         /// <summary>
@@ -90,6 +90,7 @@
         /// 璁剧疆FrameLayout
         /// </summary>
         FrameLayout btnFuncSetFrameLayout;
+        FrameLayout progressFrameLayoutMatch;
         /// <summary>
         /// 鐐瑰嚮寮�甯冨眬
         /// </summary>
@@ -207,8 +208,8 @@
             btnFuncSet = new Button
             {
                 X = Application.GetRealWidth(103),
-                Height = Application.GetRealHeight(69),
-                Width = Application.GetRealWidth(69),
+                Height = Application.GetMinReal(69),
+                Width = Application.GetMinReal(69),
                 UnSelectedImagePath = "DoorLock/SettingIcon.png",
             };
             btnFuncSetFrameLayout.AddChidren(btnFuncSet);
@@ -269,8 +270,8 @@
             midTopFrameLayout.AddChidren(btnRecordFrameLayout);
             btnRecord = new Button()
             {
-                Width = Application.GetRealWidth(69),
-                Height = Application.GetRealHeight(69),
+                Width = Application.GetMinReal(69),
+                Height = Application.GetMinReal(69),
                 X = Application.GetRealWidth(46),
                 Y = Application.GetRealHeight(46),
                 UnSelectedImagePath = "DoorLock/RecordIcon.png",
@@ -287,8 +288,8 @@
             midTopFrameLayout.AddChidren(btnCollectFrameLayout);
             btnCollect = new Button()
             {
-                Width = Application.GetRealWidth(69),
-                Height = Application.GetRealHeight(69),
+                Width = Application.GetMinReal(69),
+                Height = Application.GetMinReal(69),
                 X = Application.GetRealWidth(15),
                 Y = Application.GetRealHeight(46),
                 UnSelectedImagePath = "Item/Collection.png",
@@ -329,8 +330,8 @@
             //闂ㄩ攣寮�/鍏冲浘鐗�
             btnDoorLockPic = new Button()
             {
-                Width = Application.GetRealWidth(383),
-                Height = Application.GetRealHeight(343),
+                Width = Application.GetMinReal(383),
+                Height = Application.GetMinReal(343),
                 X = Application.GetRealWidth(161),
                 Y = Application.GetRealHeight(415),
                 UnSelectedImagePath = "DoorLock/DoorLockPicClose.png",
@@ -366,30 +367,37 @@
             };
             btnFrameLayout.AddChidren(closeFrameLayout);
 
+            progressFrameLayoutMatch = new FrameLayout()
+            {
+                Width = Application.GetRealHeight(84),//639-35
+                Height = Application.GetRealHeight(446),
+                X = Application.GetMinReal(51),
+                BackgroundColor = ZigbeeColor.Current.XMWhite,
+            };
+            btnFrameLayout.AddChidren(progressFrameLayoutMatch);
+
             var progressFrameLayout = new FrameLayout()
             {
-                Width = Application.GetRealWidth(9),//639-35
-                Height = Application.GetRealHeight(446),
-                X = Application.GetRealWidth(95),
-                Y = Application.GetRealHeight(0),
+                Width = Application.GetRealHeight(17),//639-35
+                Gravity = Gravity.CenterHorizontal,
                 BackgroundColor = ZigbeeColor.Current.XMVerticalSeekBar,
             };
-            btnFrameLayout.AddChidren(progressFrameLayout);
+            progressFrameLayoutMatch.AddChidren(progressFrameLayout);
 
             progressButton = new Button()
             {
-                Width = Application.GetRealWidth(84),//639-35
-                Height = Application.GetRealHeight(93),
-                X = Application.GetRealWidth(58),
+                Width = Application.GetMinReal(84),//639-35
+                Height = Application.GetMinReal(93),
+                Gravity = Gravity.CenterHorizontal,
                 Y = Application.GetRealHeight(347),
                 UnSelectedImagePath = "DoorLock/UnLockButton.png",
             };
-            btnFrameLayout.AddChidren(progressButton);
+            progressFrameLayoutMatch.AddChidren(progressButton);
 
             btnDoorOpenPic = new Button()
             {
-                Width = Application.GetRealWidth(81),
-                Height = Application.GetRealHeight(81),
+                Width = Application.GetMinReal(81),
+                Height = Application.GetMinReal(81),
                 X = Application.GetRealWidth(164),
                 Y = Application.GetRealHeight(6),
                 UnSelectedImagePath = "DoorLock/DoorLockOpen.png",
@@ -398,8 +406,8 @@
 
             btnDoorClosePic = new Button()
             {
-                Width = Application.GetRealWidth(81),
-                Height = Application.GetRealHeight(81),
+                Width = Application.GetMinReal(81),
+                Height = Application.GetMinReal(81),
                 X = Application.GetRealWidth(164),
                 Y = Application.GetRealHeight(117),
                 UnSelectedImagePath = "DoorLock/DoorLockClose.png",
@@ -410,8 +418,8 @@
             //鐢甸噺
             btnPower = new Button()
             {
-                Width = Application.GetRealWidth(81),
-                Height = Application.GetRealHeight(81),
+                Width = Application.GetMinReal(81),
+                Height = Application.GetMinReal(81),
                 X = Application.GetRealWidth(253),
                 Y = Application.GetRealHeight(994),
                 UnSelectedImagePath = "DoorLock/PowerOffline.png",
@@ -429,8 +437,8 @@
             midTopFrameLayout.AddChidren(btnVolumeFrameLayout);
             btnVolume = new Button()
             {
-                Width = Application.GetRealWidth(81),
-                Height = Application.GetRealHeight(81),
+                Width = Application.GetMinReal(81),
+                Height = Application.GetMinReal(81),
                 X = Application.GetRealWidth(40),
                 Y = Application.GetRealHeight(40),
                 UnSelectedImagePath = "DoorLock/VolumeIcon.png",
@@ -449,8 +457,8 @@
             midTopFrameLayout.AddChidren(btnNormallyOpenFrameLayout);
             btnNormallyOpen = new Button()
             {
-                Width = Application.GetRealWidth(81),
-                Height = Application.GetRealHeight(81),
+                Width = Application.GetMinReal(81),
+                Height = Application.GetMinReal(81),
                 X = Application.GetRealWidth(40),
                 Y = Application.GetRealHeight(40),
                 UnSelectedImagePath = "DoorLock/NormallyOpen.png",
@@ -482,8 +490,8 @@
             #region 褰撳墠鎴块棿
             var btnCurrentRoomPic = new Button()
             {
-                Width = Application.GetRealWidth(81),
-                Height = Application.GetRealHeight(81),
+                Width = Application.GetMinReal(81),
+                Height = Application.GetMinReal(81),
                 X = Application.GetRealWidth(58),
                 Y = Application.GetRealHeight(29),
                 UnSelectedImagePath = "DoorLock/RoomPic.png",
@@ -536,14 +544,14 @@
             };
             flMain.AddChidren(progressBackground);
 
-            var progressValue = (currentVolume * (Convert.ToInt32(((float)100 / 15) * 100))) / 100;
+            //var progressValue = (currentVolume * (Convert.ToInt32(((float)100 / 15) * 100))) / 100;
             progressText = new Button()
             {
                 Height = Application.GetRealHeight(58),
                 Y = Application.GetRealHeight(89),
                 TextColor = ZigbeeColor.Current.XMGray2,
                 TextAlignment = TextAlignment.Center,
-                Text = progressValue.ToString() + "%",
+                Text = currentVolume.ToString() + "%",
             };
 
             diyImageVerticalSeekBar = new DiyImageVerticalSeekBar()
@@ -559,27 +567,14 @@
                 ProgressTextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                 ProgressTextSize = 12,//鏄剧ず鐧惧垎姣斿瓧浣撳ぇ灏� 
                 SeekBarViewHeight = Application.GetRealHeight(17),//杩涘害鏉$殑瀹藉害
-                Progress = progressValue,
+                Progress = currentVolume,
             };
             progressBackground.AddChidren(progressText);
             progressBackground.AddChidren(diyImageVerticalSeekBar);
             diyImageVerticalSeekBar.OnProgressChangedEvent += (sender, e) =>
             {
                 int curVolume = -1;
-                if (e == 0)
-                {
-                    curVolume = 0;
-                }
-                else if (e == 100)
-                {
-                    curVolume = 14;
-                }
-                else
-                {
-                    int comandValue = e;
-                    int comandValueTemp = (comandValue * 100) / (Convert.ToInt32(((float)100 / 15) * 100));
-                    curVolume = comandValueTemp;
-                }
+                curVolume = e;
                 currentVolume = curVolume;
                 progressText.Text = e.ToString() + "%";
             };
@@ -690,12 +685,18 @@
                             {
                                 tempRes = false;
                             }
-
-                            NormallyOpenModeValue(tempRes);
-                            HaveLogicNormallyOpenMode = await Shared.Phone.Device.Logic.SkipView.Exist();
-                            Application.RunOnMainThread(() =>
+                            DoorLockCommonInfo.NormallyOpenModeValue(doorLock, tempRes);
+                            Application.RunOnMainThread(async () =>
                             {
-                                UpdateNomallyOpenStatus();
+                                var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(2);
+                                if (resTemp == 1)
+                                {
+                                    HaveLogicNormallyOpenMode = true;
+                                }
+                                else if (resTemp == 0)
+                                {
+                                    HaveLogicNormallyOpenMode = false;
+                                }
                             });
                         }
                     }
@@ -758,6 +759,7 @@
                 {
                     Application.RunOnMainThread(() =>
                     {
+                        UpdateNomallyOpenStatus();
                         CommonPage.Loading.Hide();
                     });
                 }
@@ -786,10 +788,14 @@
             //璁剧疆
             EventHandler<MouseEventArgs> btnFuncSetHander = (sender, e) =>
             {
-                var functionSetting = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(doorLock);
+                //鎵撳紑鍏朵粬鐣岄潰鏃跺墠绉婚櫎銆愭殏鏃朵笉绉婚櫎銆�
+                //RemoveFromParent();
+
+                var functionSetting = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(currentRoom, doorLock);
                 Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSetting);
                 Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                 functionSetting.Show();
+
                 functionSetting.devicNameAction += (deviceRename) =>
                 {
                     if (!string.IsNullOrEmpty(deviceRename))
@@ -870,6 +876,10 @@
             };
             openFrameLayout.MouseUpEventHandler += hander1;
             btnDoorOpenPic.MouseUpEventHandler += hander1;
+            if (progressButton.Y == Application.GetRealHeight(10))
+            {
+                progressFrameLayoutMatch.MouseUpEventHandler += hander1;
+            }
 
             //鍏抽攣浜嬩欢
             EventHandler<MouseEventArgs> hander2 = (sender, e) =>
@@ -910,7 +920,6 @@
             EventHandler<MouseEventArgs> handerNormallyOpen = (sender, e) =>
             {
                 NomallyOpenDialog();
-
             };
             btnNormallyOpenFrameLayout.MouseUpEventHandler += handerNormallyOpen;
             btnNormallyOpen.MouseUpEventHandler += handerNormallyOpen;
@@ -932,15 +941,15 @@
             {
                 btnPower.UnSelectedImagePath = "DoorLock/Power40.png";
             }
-            else if (currentPower <= 60 && currentPower > 40 || currentPower == 60)
+            else if (currentPower <= 60 && currentPower > 40)
             {
                 btnPower.UnSelectedImagePath = "DoorLock/Power60.png";
             }
-            else if (currentPower <= 80 && currentPower >= 60)
+            else if (currentPower <= 80 && currentPower > 60)
             {
                 btnPower.UnSelectedImagePath = "DoorLock/Power80.png";
             }
-            else if (currentPower <= 100 && currentPower >= 80)
+            else if (currentPower <= 100 && currentPower > 80)
             {
                 btnPower.UnSelectedImagePath = "DoorLock/Power100.png";
             }
@@ -1026,33 +1035,46 @@
         }
         #endregion
 
-        #region 甯稿紑妯″紡 
-        /// <summary>
-        /// 闂ㄩ攣甯稿紑妯″紡鍊�
-        /// </summary>
-        public void NormallyOpenModeValue(bool value)
-        {
-            string key = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
-            if (doorLock.IsDoorLockNormallyMode.ContainsKey(key))
-            {
-                doorLock.IsDoorLockNormallyMode[key] = value;
-            }
-            else
-            {
-                doorLock.IsDoorLockNormallyMode.Add(key, value);
-            }
-        }
-
+        #region 甯稿紑妯″紡  
         /// <summary>
         /// 甯稿紑妯″紡澶勭悊
         /// </summary>
         private async void NomallyOpenDialog()
         {
+            #region 鍚庣画鐗堟湰
+            //if (UserCenterResourse.UserInfo.AuthorityNo != 1)
+            //{
+            //    this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.OnlyMasterOperate));
+            //    return;
+            //}
+
+            //if (!UserCenterResourse.AccountOption.DoorUnLockByRemote)
+            //{
+            //    SystemSecondAuthentication();
+            //    return;
+            //}
+
+            //action = () =>
+            //{
+            //    //绯荤粺瀵嗙爜鏀寔鎿嶄綔闂ㄩ攣鍚庯紝璋冪敤娓╁眳鍩庣殑鐣岄潰銆愬父寮�鑷姩鍖栥��
+            //    var functionSetting = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(currentRoom, doorLock);
+            //    Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSetting);
+            //    Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
+            //    functionSetting.Show();
+            //    functionSetting.aaaAction = () =>
+            //   {
+            //       UpdateNomallyOpenStatus();
+            //   };
+            //};
+            //HdlCheckLogic.Current.CheckSecondarySecurity(action);
+            #endregion 
+
+            #region 鏆傛椂鐗堟湰 (鏈�缁堝幓鎺夛級
             if (!btnNormallyOpen.IsSelected)
             {
                 if (UserCenterResourse.UserInfo.AuthorityNo != 1)
                 {
-                    this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.NoAccess));
+                    this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.OnlyMasterOperate));
                     return;
                 }
 
@@ -1064,6 +1086,12 @@
 
                 action = () =>
                 {
+                    //绯荤粺瀵嗙爜鏀寔鎿嶄綔闂ㄩ攣鍚庯紝璋冪敤闂俯灞呭煄鐨勭晫闈€�愬父寮�鑷姩鍖栥��
+                    //Action nomallyOpenModeStartAction = () =>
+                    //{
+                    //    UpdateNomallyOpenStatus();
+                    //};
+
                     string msg = Language.StringByID(R.MyInternationalizationString.SetDoorLockNomallyOpen).Replace("{0}", "\r\n");
                     var confirm = Language.StringByID(R.MyInternationalizationString.Confrim);
                     var alert = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.Confirm, msg, confirm);
@@ -1087,31 +1115,23 @@
                         }
                         else
                         {
+                            //娣诲姞App寮�鍚父寮�妯″紡鐨勫巻鍙茶褰�
+                            HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog(this.doorLock, 9001, string.Empty);
+
                             //姣忔閲嶆柊璁剧疆甯稿紑锛岄粯璁ゆ椂闂撮兘鏄�12灏忔椂
                             DoorLockCommonInfo.NormallyOpenModeInvalidTime = 12;
-                            NormallyOpenModeValue(true);
-                            UpdateNomallyOpenStatus();
-                            CommonPage.Loading.Hide();
+                            DoorLockCommonInfo.NormallyOpenModeValue(doorLock, true);
+                            Application.RunOnMainThread(() =>
+                            {
+                                UpdateNomallyOpenStatus();
+                                CommonPage.Loading.Hide();
+                            });
 
                             //甯稿紑妯″紡寮�鍚彁绀�
-                            string msgNomallyModeIsTurnOn = Language.StringByID(R.MyInternationalizationString.NomallyModeIsTurnOn);
-                            var doorLockInValidSetting = Language.StringByID(R.MyInternationalizationString.DoorLockInValidSetting);
-                            var alertNomallyModeIsTurnOn = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.DoorLockLogic, msgNomallyModeIsTurnOn, doorLockInValidSetting);
-                            alertNomallyModeIsTurnOn.Show();
-
-                            //鐐瑰嚮鑷姩鍖�
-                            alertNomallyModeIsTurnOn.LogicClickEvent += () =>
-                            {
-                                //閫昏緫璋冪敤鍓嶈寰楃Щ闄�
-                                ZbGateway.StatusList.Remove(this);
-                                Shared.Phone.Device.Logic.SkipView.SkipAddLogic(2, doorLock);
-                            };
-                            alertNomallyModeIsTurnOn.InvalidClickEvent += async () =>
-                            {
-                                NomallyOpenModeInvalidTimeDialog();
-                            };
+                            AlreadyOpenNormallyMode();
                         }
                     };
+
                 };
                 HdlCheckLogic.Current.CheckSecondarySecurity(action);
             }
@@ -1119,6 +1139,8 @@
             {
                 NomallyOpenModeInvalidDialog();
             }
+
+            #endregion
         }
 
         /// <summary>
@@ -1128,6 +1150,7 @@
         {
             if (UserCenterResourse.UserInfo.AuthorityNo != 1)
             {
+                this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.OnlyMasterOperate));
                 return;
             }
             string msg = Language.StringByID(R.MyInternationalizationString.NomallyModeIsCanceled).Replace("{0}", "\r\n");
@@ -1139,67 +1162,136 @@
                 alert = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.CancelNomallyOpenModeWithLogic, msg, confirm);
             }
             alert.Show();
+
             alert.MsgControlClickEvent += async () =>
             {
                 if (IsFromReport)
                 {
-                    //鍙栨秷甯稿紑
-                    NormallyOpenModeValue(false);
-                    UpdateNomallyOpenStatus();
+                    //涓婃姤鈥滃父寮�妯″紡鈥濆凡琚彇娑堬紝app榛樿浜嗏�滃父寮�妯″紡鈥濊鍙栨秷 
+                    DoorLockCommonInfo.NormallyOpenModeValue(doorLock, false);
+                    Application.RunOnMainThread(() =>
+                    {
+                        UpdateNomallyOpenStatus();
+                    });
+                    //鍒犻櫎宸茬粡澶辨晥鐨勨�滃父寮�妯″紡鈥濈殑閫昏緫
+                    if (HaveLogicNormallyOpenMode)
+                    {
+                        var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3);
+                        //if (resTemp == 3)
+                        //{
+                        //    string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed);
+                        //    this.ShowTipMsg(msg0);
+                        //}
+                    }
                 }
                 else
                 {
-                    //淇濇寔甯稿紑
-                    NormallyOpenModeValue(true);
-                    UpdateNomallyOpenStatus();
+                    //app榛樿鈥滃父寮�妯″紡鈥濊繕鏄紑鍚� 
+                    DoorLockCommonInfo.NormallyOpenModeValue(doorLock, true);
+                    Application.RunOnMainThread(() =>
+                    {
+                        UpdateNomallyOpenStatus();
+                    });
                 }
             };
+
             alert.CancelClickEvent += async () =>
             {
-                //淇濇寔甯稿紑
                 if (IsFromReport)
                 {
+                    //涓婃姤鈥滃父寮�妯″紡鈥濆凡琚彇娑�
                     Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); });
+                    //鍏堝垹闄ゅ凡澶辨晥鐨勨�滃父寮�妯″紡鈥濈殑閫昏緫
+                    if (HaveLogicNormallyOpenMode)
+                    {
+                        var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3);
+                        //if (resTemp == 3)
+                        //{
+                        //    string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed2);
+                        //    this.ShowTipMsg(msg0);
+                        //    return;
+                        //}
+                    }
+                    //app閲嶆柊寮�鍚�滃父寮�妯″紡鈥�
                     var result = await doorLock.SetNormallyOpenModeFuncAsync(true);
                     if (result == null || result.defaultControlResponseData == null)
                     {
-                        string msg0 = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime);
-                        this.ShowTipMsg(msg0);
-                        NormallyOpenModeValue(false);
-                        UpdateNomallyOpenStatus();
+                        Application.RunOnMainThread(() =>
+                        {
+                            string msg0 = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime);
+                            this.ShowTipMsg(msg0);
+                            DoorLockCommonInfo.NormallyOpenModeValue(doorLock, false);
+                            UpdateNomallyOpenStatus();
+                        });
                         return;
                     }
                     if (result.defaultControlResponseData.status != 0)
                     {
                         string msg1 = Language.StringByID(R.MyInternationalizationString.OpenNormallyOpenModeFailed);
                         this.ShowTipMsg(msg1);
-                        NormallyOpenModeValue(false);
-                        UpdateNomallyOpenStatus();
+                        DoorLockCommonInfo.NormallyOpenModeValue(doorLock, false);
+                        Application.RunOnMainThread(() =>
+                        {
+                            UpdateNomallyOpenStatus();
+                        });
                         return;
                     }
                     else
                     {
-                        NormallyOpenModeValue(true);
-                        UpdateNomallyOpenStatus();
+                        //淇濇寔鈥滃父寮�鎴愬姛鈥� 
+                        DoorLockCommonInfo.NormallyOpenModeValue(doorLock, true);
+                        Application.RunOnMainThread(() =>
+                        {
+                            UpdateNomallyOpenStatus();
+                        });
+
+                        //鍒涘缓甯稿紑妯″紡鐨勭壒娈婇�昏緫 
+                        var resu = await Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock);
+                        //if (!resu)
+                        //{
+                        //    string msg0 = Language.StringByID(R.MyInternationalizationString.AddLogicNormallyModeFailed);
+                        //    this.ShowTipMsg(msg0);
+                        //}
+
                         CommonPage.Loading.Hide();
                     }
                 }
                 else
                 {
-                    NormallyOpenModeValue(true);
-                    UpdateNomallyOpenStatus();
+                    //app鎿嶄綔涓嶅彇娑堚�滃父寮�妯″紡鈥� 
+                    DoorLockCommonInfo.NormallyOpenModeValue(doorLock, true);
+                    Application.RunOnMainThread(() =>
+                    {
+                        UpdateNomallyOpenStatus();
+                    });
                 }
             };
+
             alert.ConfirmClickEvent += async () =>
             {
-                //纭鍙栨秷甯稿紑
                 if (IsFromReport)
                 {
-                    NormallyOpenModeValue(false);
-                    UpdateNomallyOpenStatus();
+                    //涓婃姤闂ㄩ攣鈥滃父寮�妯″紡鈥濆凡缁忓彇娑堬紝鐜板湪app纭鈥滃父寮�妯″紡鈥濆彇娑� 
+                    DoorLockCommonInfo.NormallyOpenModeValue(doorLock, false);
+                    Application.RunOnMainThread(() =>
+                    {
+                        UpdateNomallyOpenStatus();
+                    });
+
+                    //鍒犻櫎宸茬粡澶辨晥鐨勨�滃父寮�妯″紡鈥濈殑閫昏緫
+                    if (HaveLogicNormallyOpenMode)
+                    {
+                        var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3);
+                        //if (resTemp == 3)
+                        //{
+                        //    string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed);
+                        //    this.ShowTipMsg(msg0);
+                        //}
+                    }
                 }
                 else
                 {
+                    //app鎿嶄綔鍙栨秷鈥滃父寮�妯″紡鈥�
                     Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); });
                     var result = await doorLock.SetNormallyOpenModeFuncAsync(false);
                     if (result == null || result.defaultControlResponseData == null)
@@ -1215,18 +1307,75 @@
                         return;
                     }
                     else
-                    {
-                        NormallyOpenModeValue(false);
-                        UpdateNomallyOpenStatus();
+                    {
+                        //娣诲姞App寮�鍚父寮�妯″紡鐨勫巻鍙茶褰�
+                        HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog(this.doorLock, 9002, string.Empty);
+
+                        //app纭鍙栨秷鈥滃父寮�妯″紡鈥濇垚鍔� 
+                        DoorLockCommonInfo.NormallyOpenModeValue(doorLock, false);
+                        Application.RunOnMainThread(() =>
+                        {
+                            UpdateNomallyOpenStatus();
+                        });
+                        //鍒犻櫎璁剧疆甯稿紑妯″紡鍒涘缓鐨勯�昏緫
+                        if (HaveLogicNormallyOpenMode)
+                        {
+                            var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3);
+                            //鍥犱负鐩墠鏈哄埗闂锛岄�昏緫缁忓父澶辫触锛屾墍浠ヤ笉鎻愮ず锛屽悗鏈熸満鍒惰鏀癸紝閲嶆柊鍋氫竴涓繖涓晫闈�
+                            //if (resTemp == 3)
+                            //{
+                            //    string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed);
+                            //    this.ShowTipMsg(msg0);
+                            //}
+                            //else if (resTemp == 2)
+                            //{
+                            //    string msg2 = Language.StringByID(R.MyInternationalizationString.CloseNormallyOpenModeSuccess);
+                            //    this.ShowTipMsg(msg2);
+                            //}
+                        }
                         string msg2 = Language.StringByID(R.MyInternationalizationString.CloseNormallyOpenModeSuccess);
                         this.ShowTipMsg(msg2);
-                        Shared.Phone.Device.Logic.SkipView.LockCloseLogic(doorLock);
                     }
                 }
             };
         }
 
-        ///// <summary>
+        /// <summary>
+        /// 宸茬粡寮�鍚父寮�妯″紡鎻愮ず
+        /// </summary>
+        public void AlreadyOpenNormallyMode()
+        {
+            //甯稿紑妯″紡寮�鍚彁绀�
+            string msgNomallyModeIsTurnOn = Language.StringByID(R.MyInternationalizationString.NomallyModeIsTurnOn);
+            var doorLockInValidSetting = Language.StringByID(R.MyInternationalizationString.DoorLockInValidSetting);
+            var alertNomallyModeIsTurnOn = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.DoorLockLogic, msgNomallyModeIsTurnOn, doorLockInValidSetting);
+            alertNomallyModeIsTurnOn.Show();
+            alertNomallyModeIsTurnOn.MsgControlClickEvent += async () =>
+            {
+                //榛樿鍒涘缓甯稿紑妯″紡鐨勭壒娈婇�昏緫 
+                var res = await Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock);
+                //if (!res)
+                //{
+                //string msg0 = Language.StringByID(R.MyInternationalizationString.AddLogicNormallyModeFailed);
+                // this.ShowTipMsg(msg0);
+                //return;
+                //}
+            };
+            //鐐瑰嚮鑷姩鍖�
+            alertNomallyModeIsTurnOn.LogicClickEvent += () =>
+            {
+                //閫昏緫璋冪敤鍓嶈寰楃Щ闄�
+                ZbGateway.StatusList.Remove(this);
+                //璋冪敤閫昏緫鐣岄潰
+                Shared.Phone.Device.Logic.SkipView.SkipAddLogic(2, doorLock);
+            };
+            alertNomallyModeIsTurnOn.InvalidClickEvent += async () =>
+            {
+                NomallyOpenModeInvalidTimeDialog();
+            };
+        }
+
+        /// <summary>
         /// 甯稿紑妯″紡澶辨晥鏃堕棿澶勭悊
         /// </summary>
         private void NomallyOpenModeInvalidTimeDialog()
@@ -1237,26 +1386,25 @@
             var alertTimeInValidSetting = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.InValid, msgTimeInValidSetting, timeConfrim);
             alertTimeInValidSetting.Show();
 
-            alertTimeInValidSetting.InvalidTimeAction += (obj) =>
-            {
-                Regex rg = new Regex("^[0-9]+$");
-                if (!rg.IsMatch(obj))
-                {
-                    //蹇呴』鏄暟瀛�
-                    string msg0 = Language.StringByID(R.MyInternationalizationString.NormallyOpenModeInvalidTimeTip);
-                    this.ShowTipMsg(msg0);
-
-                    string msgTimeInValidSetting2 = Language.StringByID(R.MyInternationalizationString.DoorLockOpenAllTheTime);
-                    var timeConfrim2 = Language.StringByID(R.MyInternationalizationString.Confrim);
-                    var alertTimeInValidSetting2 = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.InValid, msgTimeInValidSetting2, timeConfrim2);
-                    alertTimeInValidSetting2.Show();
-                    return;
-                }
-                var temp = int.Parse(obj);
-                DoorLockCommonInfo.NormallyOpenModeInvalidTime = temp;
-                Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock);
-            };
+            alertTimeInValidSetting.InvalidTimeAction += async (obj) =>
+             {
+                 //甯稿紑妯″紡澶辨晥鏃堕棿璁剧疆鎴愬姛
+                 var temp = int.Parse(obj);
+                 DoorLockCommonInfo.NormallyOpenModeInvalidTime = temp;
+                 //榛樿鍒涘缓甯稿紑妯″紡鐨勭壒娈婇�昏緫 
+                 var res = await Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock);
+                 if (!res)
+                 {
+                     //榛樿鍒涘缓甯稿紑妯″紡澶辫触
+                     string msg0 = Language.StringByID(R.MyInternationalizationString.AddLogicNormallyModeFailed);
+                     var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal, msg0, Language.StringByID(R.MyInternationalizationString.confrim));
+                     alert.Show();
+                     //浜屾鍔犺浇寮圭獥 甯稿紑妯″紡寮�鍚彁绀�
+                     NomallyOpenModeInvalidTimeDialog();
+                 }
+             };
         }
+
         /// <summary>
         /// 甯稿紑妯″紡鐘舵�佹洿鏂�
         /// </summary>
@@ -1267,7 +1415,11 @@
                 btnNormallyOpenFrameLayout.Width = Application.GetRealWidth(0);
                 return;
             }
-            string key = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
+            string key = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
+            if (!doorLock.IsDoorLockNormallyMode.ContainsKey(key))
+            {
+                return;
+            }
             if (doorLock.IsDoorLockNormallyMode[key] == true)
             {
                 btnNormallyOpen.IsSelected = true;
@@ -1305,7 +1457,7 @@
                     var result1 = await DoorLockCommonInfo.GetDoorLockUnlockAccess(doorLock, Shared.Common.Config.Instance.Guid);
                     if (result1 == true)
                     {
-                        RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
+                        RemoteUnlockRequest(currentRoom, deviceUI, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
                         devicNameSecAction += (deviceRename) =>
                         {
                             if (!string.IsNullOrEmpty(deviceRename))
@@ -1335,7 +1487,7 @@
             }
             else
             {
-                RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
+                RemoteUnlockRequest(currentRoom, deviceUI, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
                 devicNameSecAction += (deviceRename) =>
                 {
                     if (!string.IsNullOrEmpty(deviceRename))

--
Gitblit v1.8.0