From 6fa9d69da922c8049f5acfcbb9ce9fd26811024c Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 16 四月 2020 17:10:57 +0800
Subject: [PATCH] 请合并代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs |  172 ++++++++++++++++++++++++++-------------------------------
 1 files changed, 78 insertions(+), 94 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
index f0cae0b..6ca7502 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
@@ -92,7 +92,7 @@
             }
             //缁忕含搴�
             var btnLocation = rowHome.frameTable.AddMostRightView(string.Empty, 500);
-            btnLocation.Text = this.GetLatitudeAndLongitudeText(Common.Config.Instance.Home.Longitude, Common.Config.Instance.Home.Latitude);
+            btnLocation.Text = Common.Config.Instance.Home.ResidenceAddressName;
 
             //涓讳汉鎴栬�呯鐞嗗憳鎵嶄細鍑虹幇杩欎釜鑿滃崟
             if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
@@ -109,9 +109,12 @@
                         HdlThreadLogic.Current.RunThread(() =>
                         {
                             //淇濆瓨浣忓畢鍦板潃
-                            this.SaveResidenceAdrress(btnLocation, mLatitude, mLongitude);
+                            this.SaveResidenceAdrress(btnLocation, mLatitude, mLongitude, name);
                         });
-                    }, Language.StringByID(R.MyInternationalizationString.uSelectAdrress), true, latitude, longitude, 100);
+                    }, 
+                    Language.StringByID(R.MyInternationalizationString.uSelectAdrress),
+                    Language.StringByID(R.MyInternationalizationString.uSave),
+                    true, latitude, longitude, 100);
                 };
             }
 
@@ -194,7 +197,7 @@
                     frame.AddRowMenu(Language.StringByID(R.MyInternationalizationString.uCreatFloor), "Item/CreatFloor.png", "Item/CreatFloorSelected.png", () =>
                     {
                         //鍒涘缓妤煎眰
-                        this.CreatOrEditorFloor(null, string.Empty, string.Empty);
+                        this.CreatOrEditorFloor(null, null, string.Empty, string.Empty);
                     });
                     //鍒涘缓鎴块棿
                     frame.AddRowMenu(Language.StringByID(R.MyInternationalizationString.uCreatRoom), "Item/RoomIcon.png", "Item/RoomIconSelected.png", () =>
@@ -212,7 +215,7 @@
                 else if (AppResidenceMode == 1)
                 {
                     //鍒涘缓妤煎眰
-                    this.CreatOrEditorFloor(null, string.Empty, string.Empty);
+                    this.CreatOrEditorFloor(null, null, string.Empty, string.Empty);
                 }
                 //鏃犳ゼ灞傛ā寮�
                 else if (AppResidenceMode == 2)
@@ -266,7 +269,7 @@
         private void InitFloorRow()
         {
             //鑾峰彇妤煎眰
-            var dicFloor = Common.Room.CurrentRoom.GetFloorSortList();
+            var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
             this.listFloorSort.Clear();
             foreach (string keys in dicFloor.Keys)
             {
@@ -325,17 +328,12 @@
             if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
             {
                 //鏇存敼
-                var btnChanged = new NormalViewControl(Application.GetRealWidth(184), frameRow.Height, false);
-                btnChanged.BackgroundColor = 0xff4a4a4a;
-                btnChanged.TextSize = 12;
-                btnChanged.TextColor = UserCenterColor.Current.White;
-                btnChanged.TextAlignment = TextAlignment.Center;
+                var btnChanged = frameRow.AddEditorControl();
                 btnChanged.TextID = R.MyInternationalizationString.uChanged1;
-                frameRow.AddRightView(btnChanged);
                 btnChanged.ButtonClickEvent += (sender, e) =>
                 {
                     //鍒涘缓鎴栬�呯紪杈戞ゼ灞�
-                    this.CreatOrEditorFloor(btnFloor, keys, floorName);
+                    this.CreatOrEditorFloor(frameRow, btnFloor, keys, floorName);
                 };
 
                 //鍒犻櫎
@@ -363,34 +361,32 @@
                                 Common.Config.Instance.Home.CurrentFloorId = floorId;
                                 break;
                             }
+                            //鍒犻櫎褰撳墠妤煎眰鐨勮瘽,闇�瑕佸幓鍒锋柊涓婚〉宸﹁竟鐨勬埧闂村垪琛�
+                            HdlRoomLogic.Current.RefreshRoomListView();
                         }
-                        
-                        if (Common.Room.CurrentRoom == null)
+                        var listDeleteId = new List<string>();
+                        var listAllRoom = HdlRoomLogic.Current.GetAllListRooms();
+                        for (int i = 0; i < listAllRoom.Count; i++)
                         {
-                            Common.Room.CurrentRoom = Common.Room.Lists[0];
-                        }
-                        var listDeleteFile = new List<string>();
-                        for (int i = 0; i < Common.Room.Lists.Count; i++)
-                        {
-                            if (Common.Room.Lists[i].FloorId == keys)
+                            if (listAllRoom[i].FloorId == keys)
                             {
-                                listDeleteFile.Add(Common.Room.Lists[i].FileName);
+                                listDeleteId.Add(listAllRoom[i].Id);
                             }
                         }
                         //濡傛灉褰撳墠閫夋嫨鐨勬埧闂存槸鍒犻櫎瀵硅薄鐨勮瘽
-                        if (Common.Room.CurrentRoom.FloorId == keys)
+                        if (HdlRoomLogic.Current.CurrentRoom.FloorId == keys)
                         {
-                            Common.Room.CurrentRoom = Common.Room.Lists[0];
+                            HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom();
                         }
                         //鍒犻櫎鎴块棿
-                        foreach (string fileName in listDeleteFile)
+                        foreach (string roomId in listDeleteId)
                         {
-                            Common.Room.CurrentRoom.Remove(fileName);
+                            HdlRoomLogic.Current.RemoveRoom(roomId);
                         }
                         Common.Config.Instance.Home.Save();
                         //淇濆瓨椤哄簭
                         listFloorSort.Remove(keys);
-                        Common.Room.CurrentRoom.SaveFloorSort(listFloorSort);
+                        HdlRoomLogic.Current.SaveFloorSort(listFloorSort);
 
                         if (Common.Config.Instance.Home.FloorDics.Count == 0)
                         {
@@ -413,7 +409,7 @@
         /// <param name="btnFloor"></param>
         /// <param name="keys"></param>
         /// <param name="floorName"></param>
-        private void CreatOrEditorFloor(NormalViewControl btnFloor, string keys, string floorName)
+        private void CreatOrEditorFloor(RowLayoutControl frameRow, NormalViewControl btnFloor, string keys, string floorName)
         {
             //鐢熸垚涓�涓脊绐楃敾闈�
             var dialogForm = new DialogInputControl();
@@ -438,6 +434,9 @@
             //鎸変笅纭鎸夐挳
             dialogForm.ComfirmClickEvent += ((textValue) =>
             {
+                //杩樺師宸﹀彸鑿滃崟
+                frameRow?.HideMenu();
+
                 if (this.CheckFloorName(keys, textValue) == false)
                 {
                     //妤煎眰鍚嶇О妫�娴�
@@ -454,6 +453,12 @@
                     }
                     Common.Config.Instance.Home.FloorDics[keys] = textValue;
                     Common.Config.Instance.Home.Save();
+                    if (Common.Config.Instance.Home.CurrentFloorId == string.Empty)
+                    {
+                        Common.Config.Instance.Home.CurrentFloorId = keys;
+                        //鍒涘缓绗竴涓柊鐨勬ゼ灞傜殑璇�,闇�瑕佸幓鍒锋柊涓婚〉宸﹁竟鐨勬埧闂村垪琛�
+                        HdlRoomLogic.Current.RefreshRoomListView();
+                    }
                     if (btnFloor != null)
                     {
                         btnFloor.Text = textValue;
@@ -506,7 +511,7 @@
         private void InitRoomListRow()
         {
             //鑾峰彇妤煎眰鐨勬埧闂�
-            var listRoom = Common.Room.CurrentRoom.GetFloorSortRoom(string.Empty);
+            var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(string.Empty);
             this.listRoomSort.Clear();
             for (int i = 0; i < listRoom.Count; i++)
             {
@@ -579,17 +584,18 @@
                 //纭鍒犻櫎鎴块棿?
                 this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteRoomMsg), () =>
                 {
-                    if (Common.Room.CurrentRoom.Id == room.Id)
+                    if (HdlRoomLogic.Current.CurrentRoom.Id == room.Id)
                     {
                         //濡傛灉鍒犻櫎鐨勬槸褰撳墠鎴块棿鐨勮瘽
-                        Common.Room.CurrentRoom = Common.Room.Lists[0];
+                        HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom();
                     }
-                    Common.Room.CurrentRoom.Remove(room.FileName);
+                    HdlRoomLogic.Current.RemoveRoom(room.Id);
                     //淇濆瓨椤哄簭
                     this.listRoomSort.Remove(room.Id);
-                    Common.Room.CurrentRoom.SaveRoomSort(string.Empty, this.listRoomSort);
+                    HdlRoomLogic.Current.SaveRoomSort(string.Empty, this.listRoomSort);
 
-                    if (Common.Room.Lists.Count <= 1)
+                    var listAllRoom = HdlRoomLogic.Current.GetAllListRooms();
+                    if (listAllRoom.Count <= 1)
                     {
                         //鏍规嵁鎸囧畾妯″紡,鍒濆鍖栨甯冩帶浠�
                         this.InitFrameTableByMode();
@@ -615,16 +621,36 @@
             //寮�鍚繘搴︽潯
             this.ShowProgressBar();
 
-            var Pra = new DeleteResidencePra();
-            Pra.HomeId = Common.Config.Instance.Home.Id;
-            Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
-
-            bool result = await UserCenterLogic.GetResultStatuByRequestHttps("App/DelHome", true, Pra);
-            if (result == false)
+            if (Common.Config.Instance.Home.IsOthreShare == false)
             {
-                //鍏抽棴杩涘害鏉�
-                this.CloseProgressBar();
-                return;
+                //鍒犻櫎涓讳汉鑷繁鐨勪綇瀹�
+                var Pra = new DeleteResidencePra();
+                Pra.HomeId = Common.Config.Instance.Home.Id;
+                Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
+
+                bool result = await UserCenterLogic.GetResultStatuByRequestHttps("App/DelHome", true, Pra);
+                if (result == false)
+                {
+                    //鍏抽棴杩涘害鏉�
+                    this.CloseProgressBar();
+                    return;
+                }
+            }
+            else
+            {
+                //鍒犻櫎鍒嗕韩鐨勪綇瀹�
+                var Pra2 = new
+                {
+                    HomeId = Common.Config.Instance.Home.Id,
+                    PrimaryUserId = Common.Config.Instance.Home.MainUserDistributedMark
+                };
+                bool result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/SubAccountDelShareHome", false, Pra2);
+                if (result == false)
+                {
+                    //鍏抽棴杩涘害鏉�
+                    this.CloseProgressBar();
+                    return;
+                }
             }
 
             //鍥犱负鍒犻櫎鐨勬槸褰撳墠鐨勪綇瀹�,鎵�浠ラ渶瑕佸厛鍒囨崲鍒板埆鐨勪綇瀹�
@@ -658,7 +684,7 @@
 
             //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
             await UserCenterLogic.InitUserCenterMenmoryAndThread(false);
-            Common.Room.InitAllRoom();
+            HdlRoomLogic.Current.InitAllRoom();
 
             //鍒犻櫎浣忓畢
             Common.House.DeleteHouseByHouseId(deleteId);
@@ -680,7 +706,8 @@
         /// <param name="btnLocation">鏄剧ず鎺т欢</param>
         /// <param name="latitude">绾害</param>
         /// <param name="longitude">缁忓害</param>
-        private async void SaveResidenceAdrress(NormalViewControl btnLocation, double latitude, double longitude)
+        /// <param name="addresName">浣嶇疆鍚嶇О</param>
+        private async void SaveResidenceAdrress(NormalViewControl btnLocation, double latitude, double longitude, string addresName)
         {
             //寮�鍚繘搴︽潯
             this.ShowProgressBar();
@@ -710,7 +737,7 @@
                     //閿欒:缃戝叧瀵硅薄涓㈠け
                     continue;
                 }
-                var result = HdlGatewayLogic.Current.SetGatewaySite(gateway, longitude, latitude);
+                var result = HdlGatewayLogic.Current.SetGatewaySite(gateway, longitude, latitude, ShowErrorMode.YES);
                 if (result == false)
                 {
                     //鍏抽棴杩涘害鏉�
@@ -724,10 +751,11 @@
             //淇濆瓨缂撳瓨
             Common.Config.Instance.Home.Longitude = longitude;
             Common.Config.Instance.Home.Latitude = latitude;
+            Common.Config.Instance.Home.ResidenceAddressName = addresName;
             Common.Config.Instance.Home.Save();
             HdlThreadLogic.Current.RunMain(() =>
             {
-                btnLocation.Text = this.GetLatitudeAndLongitudeText(longitude, latitude);
+                btnLocation.Text = addresName;
             });
         }
 
@@ -746,7 +774,7 @@
                 //鎷ユ湁妤煎眰
                 return 1;
             }
-            if (Common.Room.Lists.Count > 1)
+            if (HdlRoomLogic.Current.GetAllListRooms().Count > 1)
             {
                 //鏃犳ゼ灞傛ā寮�
                 return 2;
@@ -768,7 +796,7 @@
             {
                 //璇疯緭鍏ヤ綇瀹呭悕绉�
                 string msg = Language.StringByID(R.MyInternationalizationString.uPleaseInputFloorName);
-                this.ShowMassage(ShowMsgType.Error, msg);
+                this.ShowMassage(ShowMsgType.Tip, msg);
                 return false;
             }
             foreach (string floorKeys in Common.Config.Instance.Home.FloorDics.Keys)
@@ -777,55 +805,11 @@
                 {
                     //妤煎眰鍚嶇О宸茬粡瀛樺湪
                     string msg = Language.StringByID(R.MyInternationalizationString.uFloorNameIsExist);
-                    this.ShowMassage(ShowMsgType.Error, msg);
+                    this.ShowMassage(ShowMsgType.Tip, msg);
                     return false;
                 }
             }
             return true;
-        }
-
-        /// <summary>
-        /// 鑾峰彇缁忕含搴︾殑缈昏瘧鍚嶅瓧
-        /// </summary>
-        /// <param name="Longitude">缁忓害</param>
-        /// <param name="Latitude">绾害</param>
-        /// <returns></returns>
-        private string GetLatitudeAndLongitudeText(double Longitude, double Latitude)
-        {
-            string value1 = string.Empty;
-            string value2 = string.Empty;
-            if (Longitude == 0)
-            {
-                //榛樿涓滅粡
-                value1 = "0掳00'E";
-            }
-            else if (Longitude > 0)
-            {
-                //涓滅粡
-                value1 = Math.Round(Longitude, 2).ToString().Replace(".", "掳") + "'E";
-            }
-            else if (Longitude < 0)
-            {
-                //瑗跨粡
-                value1 = Math.Round(-Longitude, 2).ToString().Replace(".", "掳") + "'W";
-            }
-
-            if (Latitude == 0)
-            {
-                //榛樿鍖楃含
-                value2 = "0掳00'N";
-            }
-            else if (Latitude > 0)
-            {
-                //鍖楃含
-                value2 = Math.Round(Latitude, 2).ToString().Replace(".", "掳") + "'N";
-            }
-            else if (Latitude < 0)
-            {
-                //鍗楃含
-                value2 = Math.Round(-Latitude, 2).ToString().Replace(".", "掳") + "'S";
-            }
-            return value1 + " " + value2;
         }
 
         #endregion

--
Gitblit v1.8.0