| | |
| | | this.RemoveFromParent (); |
| | | needHide = false; |
| | | }); |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | } finally { |
| | | needHide = false; |
| | | } |
| | |
| | | } |
| | | |
| | | /// <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; |
| | | //CommonPage.IsRemote = false; |
| | | EquipmentPublicClass.CheckLinkRemote (UserConfig.Instance.internetStatus); |
| | | } |
| | | if (bNeedCheckAddRoom) { |
| | |
| | | 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 (); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | }; |
| | | |