From 2e7e5f9af5b32cfe1fc3c6ba40bf7eb984bbd0a4 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 11 五月 2020 17:52:06 +0800
Subject: [PATCH] ???????

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 58 insertions(+), 1 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs
index 1477384..0ae952d 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs
@@ -20,6 +20,10 @@
         /// </summary>
         private VerticalListControl listview = null;
         /// <summary>
+        /// 璁惧澶囨敞鎺т欢
+        /// </summary>
+        private FrameCaptionInputControl btnNote = null;
+        /// <summary>
         /// 淇濆瓨榛樿鍚嶅瓧(涓昏閽堝娌℃湁淇敼鍚嶅瓧鐨勬椂鍊欙紝蹇呴』瑕佺粰涓�涓粯璁ゅ悕瀛楃粰缃戝叧)
         /// </summary>
         private string saveDefultName = string.Empty;
@@ -41,6 +45,9 @@
                 listNewDevice.Add(Common.LocalDevice.Current.GetOTADevice(deviceMac));
             }
 
+            //娣诲姞鏂拌澶囩殑璇�,涓婚〉闇�瑕侀噸鏂板埛鏂�
+            UserView.UserPage.Instance.RefreshForm = true;
+
             //璁剧疆鏍囬淇℃伅
             base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice));
 
@@ -49,6 +56,10 @@
 
             //璁剧疆鍏ㄩ儴鍥炶矾鐨勯粯璁ゅ悕瀛�
             this.SetAllEpointName();
+            // 璁剧疆缃戝叧鎵�鍦ㄧ殑鏃跺尯鐨勬椂闂寸粰闂ㄩ攣鏃堕棿
+            this.SetDoorTime();
+            //鏂板叆缃戠殑璁惧,娓呯┖鎺夊畠鐨勬埧闂�
+            this.ClearDeviceFromRoom();
         }
 
         /// <summary>
@@ -95,7 +106,7 @@
             //璁惧澶囨敞
             string caption = Language.StringByID(R.MyInternationalizationString.uDeviceNote);
             string deviceName = Common.LocalDevice.Current.GetDeviceMacName(listNewDevice[0]);
-            var btnNote = new FrameCaptionInputControl(caption, deviceName, listview.rowSpace / 2);
+            this.btnNote = new FrameCaptionInputControl(caption, deviceName, listview.rowSpace / 2);
             listview.AddChidren(btnNote);
             btnNote.InitControl();
             //鍒掔嚎
@@ -173,6 +184,13 @@
             btnHelp.Text = Language.StringByID(R.MyInternationalizationString.uMoreSettion);
             btnHelp.ButtonClickEvent += (sender, e) =>
             {
+                //鏇存敼杩囦竴娆′箣鍚庯紝鍒欑晫闈㈠叧闂悗涓嶅啀鏇存敼
+                this.saveDefultName = string.Empty;
+                //鏀瑰悕瀛�
+                btnNote.txtInput.FinishInputEvent();
+
+                this.CloseForm();
+
                 var form = new DeviceMacInfoEditorForm();
                 form.AddForm(this.listNewDevice[0].DeviceAddr);
             };
@@ -226,6 +244,10 @@
             detailBackFrame.AddChidren(btnFinish);
             btnFinish.MouseUpEventHandler += (sender, e) =>
             {
+                //鏇存敼杩囦竴娆′箣鍚庯紝鍒欑晫闈㈠叧闂悗涓嶅啀鏇存敼
+                this.saveDefultName = string.Empty;
+                //鏀瑰悕瀛�
+                btnNote.txtInput.FinishInputEvent();
                 //鍏抽棴鑷韩
                 this.CloseForm();
             };
@@ -271,6 +293,41 @@
             }
         }
 
+        /// <summary>
+        /// 璁剧疆缃戝叧鎵�鍦ㄧ殑鏃跺尯鐨勬椂闂寸粰闂ㄩ攣鏃堕棿
+        /// </summary>
+        private async void SetDoorTime()
+        {
+            //濡傛灉鏄棬閿�
+            if (this.listNewDevice[0].Type == DeviceType.DoorLock)
+            {
+                var doorLock = this.listNewDevice[0] as ZigBee.Device.DoorLock;
+                //1銆佸叆缃戝悗鍏堣幏鍙栭棬閿佸湪缃戝叧涓殑鏃跺尯鏃堕棿
+                var curDateTime = DoorLock.DoorLockCommonInfo.GetDoorLockZoneTime();
+                //2銆佸皢鏃堕棿璁剧疆鍒扮綉鍏充腑
+                var dateTime = new DateTime(curDateTime.Year, curDateTime.Month, curDateTime.Day, curDateTime.Hour, curDateTime.Minute, curDateTime.Second);
+                var setTimestamp = DoorLock.DoorLockCommonInfo.GetUnixTimeStamp(dateTime);
+                await doorLock.RectifyDoorLockTimeAsync(int.Parse(setTimestamp));
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 涓�鑸柟娉昣__________________________
+
+        /// <summary>
+        /// 鏂板叆缃戠殑璁惧,娓呯┖鎺夊畠鐨勬埧闂�
+        /// </summary>
+        private void ClearDeviceFromRoom()
+        {
+            foreach (var device in this.listNewDevice)
+            {
+                HdlRoomLogic.Current.DeleteDevice(device);
+                HdlRoomLogic.Current.DeleteLoveDevice(device);
+            }
+            Common.LocalDevice.Current.DeleteRealDeviceFromRoom(this.listNewDevice[0]);
+        }
+
         #endregion
 
         #region 鈻� 鐢婚潰鍏抽棴___________________________

--
Gitblit v1.8.0