From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 17 十二月 2020 09:07:13 +0800 Subject: [PATCH] 新云端Ver1.3 --- ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs | 225 +++++++++++++++++++++++++++++++------------------------ 1 files changed, 126 insertions(+), 99 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs index cfa71e7..86e3760 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs @@ -42,10 +42,14 @@ base.SetTitleText(Common.Config.Instance.Home.Name); //涓讳汉鎴栬�呯鐞嗗憳鎵嶄細鍑虹幇杩欎釜鑿滃崟 - if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2) + if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1 || HdlUserCenterResourse.ResidenceOption.AuthorityNo == 2) { - //鍒濆鍖栧彸涓婅鑿滃崟 - this.InitTopRightMenu(); + //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈� + if (Common.Config.Instance.Home.IsShowTemplate == false) + { + //鍒濆鍖栧彸涓婅鑿滃崟 + this.InitTopRightMenu(); + } } //鍒濆鍖栦腑閮ㄤ俊鎭� this.InitMiddleFrame(i_CanDeleteResidence); @@ -87,7 +91,7 @@ btnNowView.TextColor = UserCenterColor.Current.TextGrayColor1; rowHome.frameTable.AddChidren(btnNowView, ChidrenBindMode.BindEvent); //涓讳汉鎴栬�呯鐞嗗憳鎵嶄細鍑虹幇杩欎釜鑿滃崟 - if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2) + if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1 || HdlUserCenterResourse.ResidenceOption.AuthorityNo == 2) { //鍙崇澶� rowHome.frameTable.AddRightArrow(); @@ -99,30 +103,22 @@ btnLocation.Text = Common.Config.Instance.Home.ResidenceAddressName; //涓讳汉鎴栬�呯鐞嗗憳鎵嶄細鍑虹幇杩欎釜鑿滃崟 - if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2) + if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1 || HdlUserCenterResourse.ResidenceOption.AuthorityNo == 2) { rowHome.frameTable.UseClickStatu = true; + //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈� + if (Common.Config.Instance.Home.IsShowTemplate == true) + { + rowHome.frameTable.CanClick = false; + } rowHome.frameTable.ButtonClickEvent += (sender, e) => { - //榛樿鍊� 23.134421,113.267189 - double latitude = Common.Config.Instance.Home.Latitude; - double longitude = Common.Config.Instance.Home.Longitude; - //鍦板浘 - GDMapKit.Show((mLatitude, mLongitude, mRadius, name) => - { - HdlThreadLogic.Current.RunThread(() => - { - //淇濆瓨浣忓畢鍦板潃 - this.SaveResidenceAdrress(btnLocation, mLatitude, mLongitude, name); - }); - }, - Language.StringByID(R.MyInternationalizationString.uSelectAdrress), - Language.StringByID(R.MyInternationalizationString.uSave), - true, latitude, longitude, 100); + //妫�娴嬫潈闄�,鐒跺悗鏄剧ず鍦板浘 + this.CheckAuthorityAndShowMap(btnLocation); }; } - if (i_CanDeleteResidence == true) + if (i_CanDeleteResidence == true && Common.Config.Instance.Home.IsShowTemplate == false) { //鍒犻櫎 var btnDelete = new NormalViewControl(Application.GetRealWidth(184), rowHome.Height, false); @@ -324,8 +320,13 @@ form.AddForm(keys); }; - if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2) + if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1 || HdlUserCenterResourse.ResidenceOption.AuthorityNo == 2) { + //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈� + if (Common.Config.Instance.Home.IsShowTemplate == true) + { + return; + } //鏇存敼 var btnChanged = frameRow.AddEditorControl(); btnChanged.TextID = R.MyInternationalizationString.uChanged1; @@ -363,6 +364,7 @@ //鍒犻櫎褰撳墠妤煎眰鐨勮瘽,闇�瑕佸幓鍒锋柊涓婚〉宸﹁竟鐨勬埧闂村垪琛� HdlRoomLogic.Current.RefreshRoomListView(); } + var uploadRoom = false; var listDeleteId = new List<string>(); var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); for (int i = 0; i < listAllRoom.Count; i++) @@ -370,6 +372,11 @@ if (listAllRoom[i].FloorId == keys) { listDeleteId.Add(listAllRoom[i].Id); + } + if (listAllRoom[i].ListDevice.Count > 0) + { + //闇�瑕佷笂浼犵┖闂村尯鍩� + uploadRoom = true; } } //鍒犻櫎鎴块棿 @@ -404,6 +411,11 @@ frameRow.RemoveFromParent(); //璋冩暣妗屽竷楂樺害 this.AdjustContrlTableHeight(); + } + if (uploadRoom == true) + { + //涓婁紶绌洪棿鍖哄煙淇℃伅 + HdlRoomLogic.Current.SetRoomInfoToGateway(); } //鍒犻櫎妤煎眰鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� UserView.UserPage.Instance.RefreshAllForm = true; @@ -460,13 +472,15 @@ { keys = Guid.NewGuid().ToString(); } + bool hadFloor = Common.Config.Instance.Home.CurrentFloorId != string.Empty; Common.Config.Instance.Home.FloorDics[keys] = textValue; Common.Config.Instance.Home.Save(); - if (Common.Config.Instance.Home.CurrentFloorId == string.Empty) + if (hadFloor == false) { //鍒涘缓绗竴涓柊鐨勬ゼ灞傜殑璇�,闇�瑕佸幓鍒锋柊涓婚〉宸﹁竟鐨勬埧闂村垪琛� HdlRoomLogic.Current.RefreshRoomListView(); } + if (btnFloor != null) { btnFloor.Text = textValue; @@ -580,7 +594,12 @@ btnName.Text = roomName; }; }; - + //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈� + if (Common.Config.Instance.Home.IsShowTemplate == true) + { + btnEditor.Text = Language.StringByID(R.MyInternationalizationString.uSearch1); + return; + } //鍒犻櫎 var btnDelete = frameRow.AddDeleteControl(); btnDelete.ButtonClickEvent += (sender, e) => @@ -617,6 +636,11 @@ //璋冩暣妗屽竷楂樺害 this.AdjustContrlTableHeight(); } + if (room.ListDevice.Count > 0) + { + //涓婁紶绌洪棿鍖哄煙淇℃伅 + HdlRoomLogic.Current.SetRoomInfoToGateway(); + } //鍒犻櫎鎴块棿鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� UserView.UserPage.Instance.RefreshAllForm = true; }); @@ -635,14 +659,10 @@ //寮�鍚繘搴︽潯 this.ShowProgressBar(); - if (Common.Config.Instance.Home.IsOthreShare == false) + if (Common.Config.Instance.Home.IsOtherShare == false) { //鍒犻櫎涓讳汉鑷繁鐨勪綇瀹� - var Pra = new DeleteResidencePra(); - Pra.HomeId = Common.Config.Instance.Home.Id; - Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); - - bool result = UserCenterLogic.GetResultStatuByRequestHttps("App/DelHome", true, Pra); + var result = HdlResidenceLogic.Current.DeleteCloundHouse(Common.Config.Instance.Home.Id); if (result == false) { //鍏抽棴杩涘害鏉� @@ -652,13 +672,8 @@ } else { - //鍒犻櫎鍒嗕韩鐨勪綇瀹� - var Pra2 = new - { - HomeId = Common.Config.Instance.Home.Id, - PrimaryUserId = Common.Config.Instance.Home.MainUserDistributedMark - }; - bool result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/SubAccountDelShareHome", false, Pra2); + //鍒犻櫎鍒嗕韩鐨勪綇瀹�,浣跨敤涓讳汉鐨凾oken,鎶婅嚜宸卞垹浜� + var result = HdlMemberLogic.Current.DeleteMember(Common.Config.Instance.Guid); if (result == false) { //鍏抽棴杩涘害鏉� @@ -668,51 +683,95 @@ } //鍥犱负鍒犻櫎鐨勬槸褰撳墠鐨勪綇瀹�,鎵�浠ラ渶瑕佸厛鍒囨崲鍒板埆鐨勪綇瀹� - string deleteId = Common.Config.Instance.Home.Id; - string deleteFile = Common.Config.Instance.Home.FileName; - int index = 0; - for (; index < Common.Config.Instance.HomeFilePathList.Count; index++) + var listLocalHouse = HdlResidenceLogic.Current.GetAllLocalResidenceListByDirectory(); + //鍙栦竴涓綇瀹卛d + string houseId = string.Empty; + foreach (var myHouse in listLocalHouse) { - if (Common.Config.Instance.HomeFilePathList[index] == deleteFile) + houseId = myHouse.Id; + if (houseId != Common.Config.Instance.Home.Id) { - //褰撳墠浣忓畢鎵�澶勭殑浣嶇疆(浣忓畢鏁拌偗瀹氬ぇ浜�1,涓嶇劧涓嶄細鍑虹幇鍒犻櫎鎸夐挳) - if (index == 0) - { - //鍙栦笅涓�浣� - index++; - } - else - { - //鍙栧墠涓�浣� - index--; - } + //闅忎究鍙栦竴涓拰褰撳墠浣忓畢涓嶇浉绛夌殑ID break; } } - - var myHouse = HdlResidenceLogic.Current.GetHouseByFilePath(Common.Config.Instance.HomeFilePathList[index]); + //褰撳墠浣忓畢ID + string nowHouseId = Common.Config.Instance.Home.Id; //鍒囨崲浣忓畢 - Common.Config.Instance.HomeId = myHouse.Id; - Common.Config.Instance.Home = HdlResidenceLogic.Current.GetHouseByHouseId(myHouse.Id); - Common.Global.CreateHomeDirectory(myHouse.Id); - Common.Config.Instance.Save(); - - //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼ - bool result2 = UserCenterLogic.InitUserCenterMenmoryAndThread(false); + bool result2 = HdlResidenceLogic.Current.SwitchResidence(houseId); + //鍒犳帀杩欎釜鏂囦欢澶� + HdlResidenceLogic.Current.DeleteHouseMemmory(nowHouseId); if (result2 == false) { //寮�鍚簡璋冭瘯鍔熻兘 return; } - //鍒犻櫎浣忓畢 - HdlResidenceLogic.Current.DeleteHouseMemmory(deleteId); - HdlThreadLogic.Current.RunMain(() => { //鍏抽棴鐣岄潰 this.CloseForm(); }); + } + + #endregion + + #region 鈻� 鏄剧ず鍦板浘___________________________ + + /// <summary> + /// 妫�娴嬫潈闄�,鐒跺悗鏄剧ず鍦板浘 + /// </summary> + /// <param name="btnLocation">鍦板潃鏄剧ず鎺т欢</param> + private void CheckAuthorityAndShowMap(NormalViewControl btnLocation) + { +#if Android + //鐢宠瀹氫綅鏉冮檺 + ((BaseActivity)Application.Activity).SetGPSLocationPermission((result1) => + { + if (result1 == false) { return; } + + //鐢宠鍏佽绋嬪簭鍐欏叆澶栭儴瀛樺偍锛屽SD鍗′笂鍐欐枃浠� + ((BaseActivity)Application.Activity).SetPermission((result2) => + { + if (result2 == false) { return; } + //璇诲彇鐢佃瘽鐘舵�佹潈闄� + ((BaseActivity)Application.Activity).SetPermission((result3) => + { + if (result3 == false) { return; } + //鏄剧ず鍦板浘 + this.ShowMap(btnLocation); + }, "android.permission.READ_PHONE_STATE"); + + }, "android.permission.WRITE_EXTERNAL_STORAGE"); + }); +#endif +#if iOS + //鏄剧ず鍦板浘 + this.ShowMap(btnLocation); +#endif + } + + /// <summary> + /// 鏄剧ず鍦板浘 + /// </summary> + /// <param name="btnLocation">鍦板潃鏄剧ず鎺т欢</param> + private void ShowMap(NormalViewControl btnLocation) + { + //榛樿鍊� 23.134421,113.267189 + double latitude = Common.Config.Instance.Home.Latitude; + double longitude = Common.Config.Instance.Home.Longitude; + //鍦板浘 + GDMapKit.Show((mLatitude, mLongitude, mRadius, name) => + { + HdlThreadLogic.Current.RunThread(() => + { + //淇濆瓨浣忓畢鍦板潃 + this.SaveResidenceAdrress(btnLocation, mLatitude, mLongitude, name); + }); + }, + Language.StringByID(R.MyInternationalizationString.uSelectAdrress), + Language.StringByID(R.MyInternationalizationString.uSave), + true, latitude, longitude, 100); } #endregion @@ -734,48 +793,16 @@ //寮�鍚繘搴︽潯 this.ShowProgressBar(); - var Pra = new EditorResidencePra(); - Pra.HomeId = Common.Config.Instance.Home.Id; - Pra.Name = Common.Config.Instance.Home.Name; - Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); - Pra.Latitude = latitude; - Pra.Longitude = longitude; - - //缂栬緫浣忓畢 - bool flage = UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", true, Pra); - if (flage == false) + var result = HdlResidenceLogic.Current.EditorResidenceLongitudeAndLatitude(latitude, longitude, addresName); + if (result == false) { //鍏抽棴杩涘害鏉� this.CloseProgressBar(); return; } - //璁剧疆鍏ㄩ儴缃戝叧鐨勪綇瀹呭湴鍧� - var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway(); - foreach (var gateway in listGateway) - { - ZigBee.Device.ZbGateway realWay = null; - if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, gateway) == false) - { - //閿欒:缃戝叧瀵硅薄涓㈠け - continue; - } - var result = HdlGatewayLogic.Current.SetGatewaySite(gateway, longitude, latitude, ShowErrorMode.YES); - if (result == false) - { - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(); - return; - } - } //鍏抽棴杩涘害鏉� this.CloseProgressBar(); } - - //淇濆瓨缂撳瓨 - 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 = addresName; -- Gitblit v1.8.0