| | |
| | | this.RemoveFromParent (); |
| | | needHide = false; |
| | | }); |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | } finally { |
| | | needHide = false; |
| | | } |
| | |
| | | UserConfig.Instance.CurrentRegion = UserConfig.Instance.HomeLists [0]; |
| | | } |
| | | } |
| | | try { |
| | | if (IsNeedGoToGuideAddGatewayView) { |
| | | IsNeedGoToGuideAddGatewayView = false; |
| | | if (UserConfig.Instance.CurrentRegion.IsOthreShare) { |
| | | //提示没有分享住宅的权限 |
| | | new Alert ("", ErrorCode.InsufficientAuthority, "Close").Show (); |
| | | return; |
| | | } |
| | | |
| | | if (IsNeedGoToGuideAddGatewayView) { |
| | | IsNeedGoToGuideAddGatewayView = false; |
| | | GotoGuideAddGatewayView (UserConfig.Instance.CurrentRegion); |
| | | GotoGuideAddGatewayView (UserConfig.Instance.CurrentRegion); |
| | | |
| | | } |
| | | } |
| | | } catch { } |
| | | |
| | | } |
| | | |
| | |
| | | void AccountLogout () |
| | | { |
| | | try { |
| | | this.RemoveFromParent (); |
| | | MainPage.LoginUser.LastTime = DateTime.Now.AddDays (-30); |
| | | MainPage.LoginUser.SaveUserInfo (); |
| | | new AccountLogin ().Show (); |
| | |
| | | |
| | | var btnPoint = new Button () { |
| | | Width = Application.GetRealWidth (10), |
| | | Height = Application.GetRealHeight (10), |
| | | Height = Application.GetRealWidth (10), |
| | | X = Application.GetRealWidth (50), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "Item/Point.png", |
| | |
| | | Button FromSharingButton = new Button () { |
| | | X = Application.GetRealWidth (480), |
| | | Width = Application.GetRealWidth (30), |
| | | Height = Application.GetRealHeight (30), |
| | | Height = Application.GetRealWidth (30), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "CrabtreeAdd/FromSharing.png", |
| | | SelectedImagePath = "CrabtreeAdd/FromSharing.png", |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 启动本地模式 |
| | | /// </summary> |
| | | void EnableLocalMode () { |
| | | MainPage.AddTip ("Enable local mode."); |
| | | Utlis.ShowAppLinkStatus (AppLinkStatus.WiFiOffline); |
| | | CommonPage.IsRemote = false; |
| | | SmartHome.MqttCommon.DisConnectRemoteMqttClient ("EnableLocalMode"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 启动远程模式 |
| | | /// </summary> |
| | | void EnableRemoteMode () |
| | | { |
| | | MainPage.AddTip ("Restore remote mode."); |
| | | Utlis.ShowAppLinkStatus (AppLinkStatus.CloudUnlink); |
| | | CommonPage.IsRemote = true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 跳转网关搜索页面 |
| | | /// </summary> |
| | | /// <param name="home"></param> |
| | | void GotoGuideAddGatewayView (RegionInfoRes home) { |
| | | try { |
| | | //远程连接的时候禁止 搜索网关和添加设备 |
| | | if (CommonPage.IsRemote) { |
| | | ////当前处于远程连接模式,无法进入搜索网关页面。请先切换回本地连接模式。 |
| | | //new Alert ("", "Currently in remote connection mode, unable to enter the search gateway page. Please switch back to local connection mode first.", Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | //return; |
| | | |
| | | //2020-06-29 启动本地通信模式 |
| | | EnableLocalMode (); |
| | | } |
| | | |
| | | |
| | | var addGatewayDialog = new GuideAddGateway (); |
| | | (Parent as PageLayout).AddChidren (addGatewayDialog); |
| | | addGatewayDialog.ShowPage (home); |
| | | (Parent as PageLayout).PageIndex = (Parent as PageLayout).ChildrenCount - 1; |
| | | } catch { |
| | | |
| | | System.Console.WriteLine ("============>GotoGuideAddGatewayView 跳转失败 "); |
| | | Utlis.WriteLine ("============>GotoGuideAddGatewayView 跳转失败 "); |
| | | } |
| | | |
| | | } |
| | |
| | | void ChangeRegion (RegionInfoRes home, bool goHomePage = true, bool bNeedCheckAddRoom = false, bool goToGuideAddGatewayView = false) |
| | | { |
| | | if (home == null || string.IsNullOrEmpty (home.Id)) return; |
| | | |
| | | MainPage.Loading.Start ("Please wait..."); |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Start ("Please wait..."); |
| | | }); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | try { |
| | | //if (home.RegionID != UserConfig.Instance.CurrentRegion.RegionID) { |
| | |
| | | System.IO.FileInfo fileInfo = new System.IO.FileInfo (IO.FileUtils.RootPath + fileName); |
| | | if (fileInfo.Exists) { |
| | | fileInfo.MoveTo (oldRegionRootPath + fileName); |
| | | Console.WriteLine ("move file : " + fileName); |
| | | Utlis.WriteLine ("move file : " + fileName); |
| | | } |
| | | index++; |
| | | Application.RunOnMainThread (() => { |
| | |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.SwitchRegionSuccessfully), |
| | | Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | //this.RemoveFromParent (); |
| | | CommonPage.IsRemote = false; |
| | | EquipmentPublicClass.CheckLinkRemote (2); |
| | | //CommonPage.IsRemote = false; |
| | | EquipmentPublicClass.CheckLinkRemote (UserConfig.Instance.internetStatus); |
| | | } |
| | | if (bNeedCheckAddRoom) { |
| | | CheckIfNeedAddRoom (); |
| | |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.CheckInternet), |
| | | Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | } finally { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.PleaseEnterZoneName), Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | return; |
| | | } |
| | | if (isChangeName) { |
| | | //home.Name = button.Text = etZoneName.Text; |
| | | var requestObj2 = new EditHomeObj () { HomeId = home.Id, Name = etZoneName.Text, LoginAccessToken = MainPage.LoginUser.LoginTokenString }; |
| | | string urlHead = MainPage.RequestHttpsHost; |
| | | if (requestObj2.IsOtherAccountCtrl) { |
| | | urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl; |
| | | requestObj2.LoginAccessToken = UserConfig.Instance.MasterAccountToken; |
| | | } |
| | | |
| | | var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2); |
| | | var revertObj2 = MainPage.RequestHttps (API.EditHome, requestJson2, urlHead); |
| | | if (revertObj2.StateCode.ToUpper () != "SUCCESS") { |
| | | ShowEditHomeErrorInfo (revertObj2.StateCode); |
| | | return; |
| | | } |
| | | home.Name = button.Text = etZoneName.Text; |
| | | IO.FileUtils.ReNameFoler (UserConfig.Instance.CurrentRegion.Name, home.Name); |
| | | return; |
| | | } |
| | | |
| | | EditResidence (home, etZoneName.Text.Trim (), guide); |
| | | //if (isChangeName) { |
| | | // //home.Name = button.Text = etZoneName.Text; |
| | | // var requestObj2 = new EditHomeObj () { HomeId = home.Id, Name = etZoneName.Text, LoginAccessToken = MainPage.LoginUser.LoginTokenString }; |
| | | // string urlHead = MainPage.RequestHttpsHost; |
| | | // if (requestObj2.IsOtherAccountCtrl) { |
| | | // urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl; |
| | | // requestObj2.LoginAccessToken = UserConfig.Instance.MasterAccountToken; |
| | | // } |
| | | |
| | | // var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2); |
| | | // var revertObj2 = MainPage.RequestHttps (API.EditHome, requestJson2, urlHead); |
| | | // if (revertObj2.StateCode.ToUpper () != "SUCCESS") { |
| | | // ShowEditHomeErrorInfo (revertObj2.StateCode); |
| | | // return; |
| | | // } |
| | | // home.Name = button.Text = etZoneName.Text; |
| | | // IO.FileUtils.ReNameFoler (UserConfig.Instance.CurrentRegion.Name, home.Name); |
| | | // return; |
| | | //} |
| | | |
| | | //EditResidence (home, etZoneName.Text.Trim (), guide); |
| | | |
| | | |
| | | //2020-04-26 |
| | | MainPage.Loading.Start ("Please wait..."); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | |
| | | try { |
| | | |
| | | if (isChangeName) { |
| | | //home.Name = button.Text = etZoneName.Text; |
| | | var requestObj2 = new EditHomeObj () { HomeId = home.Id, Name = etZoneName.Text, LoginAccessToken = MainPage.LoginUser.LoginTokenString }; |
| | | string urlHead = MainPage.RequestHttpsHost; |
| | | if (requestObj2.IsOtherAccountCtrl) { |
| | | urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl; |
| | | requestObj2.LoginAccessToken = UserConfig.Instance.MasterAccountToken; |
| | | } |
| | | |
| | | var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2); |
| | | var revertObj2 = MainPage.RequestHttps (API.EditHome, requestJson2, urlHead); |
| | | if (revertObj2.StateCode.ToUpper () != "SUCCESS") { |
| | | ShowEditHomeErrorInfo (revertObj2.StateCode); |
| | | return; |
| | | } |
| | | Application.RunOnMainThread (() => { |
| | | home.Name = button.Text = etZoneName.Text; |
| | | }); |
| | | IO.FileUtils.ReNameFoler (UserConfig.Instance.CurrentRegion.Name, home.Name); |
| | | return; |
| | | } |
| | | |
| | | EditResidence (home, etZoneName.Text.Trim (), guide); |
| | | |
| | | |
| | | } catch { |
| | | //MainPage.FailureToServer (); |
| | | } finally { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | }; |
| | | |
| | |
| | | //创建住宅成功,切换到该住宅 |
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RegionInfoRes>> (revertObj21.ResponseData.ToString ()); |
| | | if (responseDataObj != null && responseDataObj.Count > 0) { |
| | | ChangeRegion (responseDataObj [0], false, true, goToGuideAddGatewayView); |
| | | ChangeRegion (responseDataObj [0], true, true, goToGuideAddGatewayView); |
| | | |
| | | } |
| | | } else { |