using System; using System.Collections.Generic; using service.hdlcontrol.com_push; namespace Shared.SimpleControl.Phone { public class AccountView :FrameLayout { public AccountView () { } public void ShouwAccountView () { #region 标题 var topView = new FrameLayout () { Y = Application.GetRealHeight (36), Height = Application.GetRealHeight (90), BackgroundColor = SkinStyle.Current.MainColor, }; AddChidren (topView); Button NameButton = new Button () { Width = Application.GetRealWidth (400), TextID = R.MyInternationalizationString.Account, TextColor = SkinStyle.Current.TextColor1, Gravity = Gravity.CenterHorizontal, TextAlignment = TextAlignment.Center, TextSize = 20, }; topView.AddChidren (NameButton); var logo = new Button () { Width = Application.GetRealWidth (154), Height = Application.GetRealHeight (90), X = Application.GetRealWidth (486), UnSelectedImagePath = MainPage.LogoString, }; topView.AddChidren (logo); var back = new Button () { Height = Application.GetRealHeight (90), Width = Application.GetRealWidth (85), UnSelectedImagePath = "Item/Back.png", SelectedImagePath = "Item/BackSelected.png", }; topView.AddChidren (back); back.MouseUpEventHandler += (sender, e) => { (Parent as PageLayout).PageIndex -= 1; }; #endregion FrameLayout topUserMsgView = new FrameLayout () { Y = Application.GetRealHeight (126), Height = Application.GetRealHeight (175), BackgroundColor = SkinStyle.Current.ViewColor }; AddChidren (topUserMsgView); Button btnUserIcon = new Button () { X = Application.GetRealWidth (27), Width = Application.GetRealWidth (96), Height = Application.GetRealHeight (96), Gravity = Gravity.CenterVertical, Radius = 5, BorderColor = SkinStyle.Current.Transparent, BorderWidth = 0, UnSelectedImagePath = "AccountSettings/UserIcon.png", }; topUserMsgView.AddChidren (btnUserIcon); btnUserIcon.MouseLongEventHandler += (sender, e) => { Alert alert = new Alert ("", Language.StringByID (R.MyInternationalizationString.TipDeleteAllFiles), Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim)); alert.ResultEventHandler += ( sender2, e2) => { if (e2) { MainPage.LoginUser.LastTime = DateTime.MinValue; MainPage.LoginUser.SaveUserInfo (); Room.Lists.Clear (); new AccountLogin (MainPage.LoginUser.AccountString, "").Show (); System.Threading.Tasks.Task.Run (() => { WebServicePush webPush = new WebServicePush (); webPush.DeleteToken_Push (UserConfig.Instance.tokenID); if (string.IsNullOrEmpty (UserConfig.Instance.RemoteModeFile)) return; }); CommonPage.IsRemote = false; } }; alert.Show (); }; Button btnUserName = new Button () { X = btnUserIcon.Right + Application.GetRealWidth (20), Y = Application.GetRealHeight (40), Width = Application.GetRealWidth (400), Height = Application.GetRealHeight (50), TextAlignment = TextAlignment.CenterLeft, TextColor = SkinStyle.Current.TextColor1, Text = MainPage.LoginUser.Name == "" ? Language.StringByID (R.MyInternationalizationString.Account) : MainPage.LoginUser.Name, }; topUserMsgView.AddChidren (btnUserName); Button btnUserAccount = new Button () { X = btnUserName.X, Y = btnUserName.Bottom, Width = btnUserName.Width, Height = btnUserName.Height, TextAlignment = TextAlignment.CenterLeft, Text = "", TextColor = SkinStyle.Current.TextColor1 }; topUserMsgView.AddChidren (btnUserAccount); if (MainPage.LoginUser != null) { btnUserAccount.Text += MainPage.LoginUser.AccountString; } Button btTopNull = new Button () { Y = topUserMsgView.Bottom, BackgroundColor = SkinStyle.Current.MainColor, Height = Application.GetRealHeight (50), }; AddChidren (btTopNull); var contentView = new VerticalScrolViewLayout () { Y = btTopNull.Bottom, Height = Application.GetRealHeight (1136 - 90) - btTopNull.Bottom, BackgroundColor = SkinStyle.Current.ViewColor, //ScrollEnabled = false, }; AddChidren (contentView); #region PasswordView var ModifyPasswordView = new FrameLayout () { Height = Application.GetRealHeight (100), }; contentView.AddChidren (ModifyPasswordView); Button btnModifyPasswordTitle = new Button () { X = Application.GetRealWidth (40), TextID = R.MyInternationalizationString.ModifyPasswrod, TextAlignment = TextAlignment.CenterLeft, TextColor = SkinStyle.Current.TextColor1, }; ModifyPasswordView.AddChidren (btnModifyPasswordTitle); Button btnModifyPasswordRight = new Button () { X = Application.GetRealWidth (580), Width = Application.GetRealWidth (28), Height = Application.GetRealHeight (40), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "Item/Right.png", SelectedImagePath = "Item/RightSelected.png", }; ModifyPasswordView.AddChidren (btnModifyPasswordRight); EventHandler modifyPasswordHandler = (sender, e) => { AccountModifyPassword am = new AccountModifyPassword (); UserMiddle.SettingPageView.AddChidren (am); am.ShowAccountModifyPassword (); UserMiddle.SettingPageView.PageIndex = UserMiddle.SettingPageView.ChildrenCount - 1; }; ModifyPasswordView.MouseUpEventHandler += modifyPasswordHandler; btnModifyPasswordTitle.MouseUpEventHandler += modifyPasswordHandler; btnModifyPasswordRight.MouseUpEventHandler += modifyPasswordHandler; Button btnModifyNullLine = new Button () { Height = Application.GetRealHeight (5), BackgroundColor = SkinStyle.Current.MainColor, }; contentView.AddChidren (btnModifyNullLine); #endregion #region 平台迁移 var moveToNewCloudView = new FrameLayout () { Height = Application.GetRealHeight (100), }; contentView.AddChidren (moveToNewCloudView); Button btnTitle = new Button () { X = Application.GetRealWidth (40), TextID = R.MyInternationalizationString.ModifyPasswrod, TextAlignment = TextAlignment.CenterLeft, TextColor = SkinStyle.Current.TextColor1, }; moveToNewCloudView.AddChidren (btnTitle); Button btnRight = new Button () { X = Application.GetRealWidth (580), Width = Application.GetRealWidth (28), Height = Application.GetRealHeight (40), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "Item/Right.png", SelectedImagePath = "Item/RightSelected.png", }; moveToNewCloudView.AddChidren (btnRight); EventHandler eHandler = (sender, e) => { //1.检测一端口固件 var localFileList = IO.FileUtils.ReadFiles (); var gateWayList = localFileList.FindAll ((obj) => { return (obj.StartsWith ("Equipment_")) && ( obj.Split ('_') [1].ToString () == DeviceType.OnePortBus.ToString () || obj.Split ('_') [1].ToString () == DeviceType.RCU.ToString () || obj.Split ('_') [1].ToString () == DeviceType.OnePortWirelessFR.ToString ()); }); List linkList = new List (); GatewayBase common = null; string gateWayString = ""; if (gateWayList.Count > 0) { foreach (var gatewayFileName in gateWayList) { var tempStrings = gatewayFileName.Split ('_'); if (tempStrings [1].ToString () == DeviceType.OnePortBus.ToString () || tempStrings [1].ToString () == DeviceType.RCU.ToString () || tempStrings [1].ToString () == DeviceType.OnePortWirelessFR.ToString ()) { gateWayString = CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (gatewayFileName)); common = Newtonsoft.Json.JsonConvert.DeserializeObject (gateWayString); for (int i = 0; i < 7; i++) { Control.ControlBytesSend (Command.enjoyUpgrade, common.SubnetID, common.DeviceID, new byte [] { }); } break;//只升级一个 } } } else { //没有网关 return; } Control.ControlBytesSend (Command.enjoyUpgrade2, common.SubnetID, common.DeviceID, new byte [] { }); //2.进入网关升级模式 //3.接收升级文件获取请求 //迁移账号 #region 弹窗输入密码确认迁移 Dialog dialog = new Dialog (); FrameLayout dialogBodyView = new FrameLayout () { Gravity = Gravity.Center, Width = Application.GetRealWidth (500), Height = Application.GetRealHeight (500), BackgroundColor = SkinStyle.Current.DialogColor, Radius = 5, BorderColor = SkinStyle.Current.Transparent, BorderWidth = 0, }; dialog.AddChidren (dialogBodyView); Button btnTitle = new Button () { Height = Application.GetRealHeight (80), BackgroundColor = SkinStyle.Current.DialogTitle, TextAlignment = TextAlignment.Center, TextID = R.MyInternationalizationString.Tip, TextColor = SkinStyle.Current.DialogTextColor }; dialogBodyView.AddChidren (btnTitle); Button btnackupRemark = new Button () { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight (100), Width = Application.GetRealWidth (400), Height = Application.GetRealHeight (80), Text = "请输入密码,确认迁移", TextAlignment = TextAlignment.CenterLeft, TextColor = SkinStyle.Current.TextColor, }; dialogBodyView.AddChidren (btnackupRemark); EditText etBackupRemark = new EditText () { Gravity = Gravity.CenterHorizontal, Y = btnackupRemark.Bottom, Width = Application.GetRealWidth (400), Height = Application.GetRealHeight (80), TextAlignment = TextAlignment.Center, Radius = 5, BorderColor = SkinStyle.Current.BorderColor, BorderWidth = 1, TextColor = SkinStyle.Current.TextColor, SecureTextEntry = true }; dialogBodyView.AddChidren (etBackupRemark); etBackupRemark.EditorEnterAction += (obj) => { Application.HideSoftInput (); }; var btnTipMsg = new Button () { Gravity = Gravity.CenterHorizontal, Y = etBackupRemark.Bottom , Width = Application.GetRealWidth (400), Height = Application.GetRealHeight (80), TextAlignment = TextAlignment.CenterLeft, TextColor = SkinStyle.Current.DelColor, }; dialogBodyView.AddChidren (btnTipMsg); FrameLayout bottomView = new FrameLayout () { Y = Application.GetRealHeight (420), Height = Application.GetRealHeight (85), BackgroundColor = SkinStyle.Current.DialogTitle }; dialogBodyView.AddChidren (bottomView); Button btnClose = new Button () { Width = Application.GetRealWidth (249), TextID = R.MyInternationalizationString.Close, TextAlignment = TextAlignment.Center }; bottomView.AddChidren (btnClose); btnClose.MouseUpEventHandler += (send2er, e2) => { dialog.Close (); }; Button btnBottomLine = new Button () { X = btnClose.Right, Width = 1, BackgroundColor = SkinStyle.Current.Black50Transparent, }; bottomView.AddChidren (btnBottomLine); Button btnSave = new Button () { X = btnBottomLine.Right, Width = Application.GetRealWidth (249), TextID = R.MyInternationalizationString.Confrim, TextAlignment = TextAlignment.Center }; bottomView.AddChidren (btnSave); btnSave.MouseUpEventHandler += (sender2, e2) => { var requestObj = new LoginObj () { Account = MainPage.LoginUser.AccountString, Password = etBackupRemark.Text.Trim(), Company = MainPage.SoftSmsType }; var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); var revertObj = MainPage.RequestHttps ("Login", requestJson, false); if (revertObj.StateCode == "SUCCESS") { //var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject (revertObj.ResponseData.ToString ()); //var revertData = responseDataObj; //MainPage.LoginUser = new UserInfo { // ID = revertData.UserId, MasterID = revertData.MainUserId, AccountType = revertData.UserType, AccountString = account, Password = password, LastTime = DateTime.Now, // AllVisionRegisterDevUserNameGuid = revertData.AllVisionRegisterDevUserNameGuid, Name = revertData.Contact //}; Dictionary dicAccount = new Dictionary (); dicAccount.Add ("email", MainPage.LoginUser.AccountString); dicAccount.Add ("language", "ENGLISH"); dicAccount.Add ("appCode", "HDL-HOME-IND-APP"); dicAccount.Add ("pwd", etBackupRemark.Text.Trim()); dicAccount.Add ("tenantId", "202106"); var revertObj = MainPage.RequestHttps ("/home-wisdom/data/move/home/save", requestJson, false,false, $"https://test-gz.hdlcontrol.com"); } else { } }; dialog.Show (); #endregion Dictionary dic = new Dictionary (); dic.Add ("homeName", UserConfig.Instance.CurrentRegion.RegionName); dic.Add ("userId", MainPage.LoginUser.ID); dic.Add ("homeType", "BUSPRO"); dic.Add ("tenantId", "202106"); requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (dic); revertObj = MainPage.RequestHttps ("/home-wisdom/data/move/home/save", requestJson, false,false, $"https://test-gz.hdlcontrol.com"); }; Button btnLine = new Button () { Height = Application.GetRealHeight (5), BackgroundColor = SkinStyle.Current.MainColor, }; contentView.AddChidren (btnLine); #endregion Button btnLogout = new Button () { Y = contentView.Bottom, Height = Application.GetRealHeight (93), TextColor = SkinStyle.Current.TextColor1, BackgroundColor = SkinStyle.Current.MainColor, TextID = R.MyInternationalizationString.LogoutAccount, TextAlignment = TextAlignment.Center }; AddChidren (btnLogout); btnLogout.MouseUpEventHandler += (sender1, e1) => { btnLogout.IsSelected = false; if (MainPage.LoginUser == null) { new AccountLogin ().Show (); } else { var alertDialog = new Dialog (); var alertBodyView = new FrameLayout (); alertDialog.AddChidren (alertBodyView); alertBodyView.MouseUpEventHandler += (d, f) => { alertDialog.Close (); }; var tipView = new FrameLayout () { Gravity = Gravity.Center, Width = Application.GetRealWidth(500), Height = Application.GetRealHeight(250), BackgroundColor = 0xFF333333, Radius = 5, BorderColor = SkinStyle.Current.Transparent, BorderWidth = 1, }; alertBodyView.AddChidren (tipView); var btnTipMsg = new TextView () { X = Application.GetRealWidth (20), Height = Application.GetRealHeight (130), Width = Application.GetRealWidth (460), IsMoreLines = true, TextColor = SkinStyle.Current.TextColor2, TextID = R.MyInternationalizationString.CloseYourAccount, TextSize = 16 }; tipView.AddChidren (btnTipMsg); var bottomView = new FrameLayout () { Y = btnTipMsg.Bottom, Height = Application.GetRealHeight (120), BackgroundColor = SkinStyle.Current.MainColor, }; tipView.AddChidren (bottomView); var btnYes = new Button () { X= Application.GetRealWidth(40), Y = Application.GetRealHeight(20), Height =Application.GetRealHeight(70), Width = Application.GetRealWidth(200), BackgroundColor = SkinStyle.Current.ViewColor, TextColor = SkinStyle.Current.TextColor1, TextID = R.MyInternationalizationString.Yes, TextAlignment = TextAlignment.Center, Radius = 5, BorderColor = SkinStyle.Current.Transparent, BorderWidth = 1, }; bottomView.AddChidren (btnYes); var btnNo = new Button () { X = btnYes.Right + Application.GetRealWidth (30), Y = Application.GetRealHeight (20), Height = Application.GetRealHeight (70), Width = Application.GetRealWidth (200), BackgroundColor = SkinStyle.Current.ViewColor, TextColor = SkinStyle.Current.TextColor1, TextID = R.MyInternationalizationString.No, TextAlignment = TextAlignment.Center, Radius = 5, BorderColor = SkinStyle.Current.Transparent, BorderWidth = 1, }; bottomView.AddChidren (btnNo); btnYes.MouseUpEventHandler += (sdd, ff) => { alertDialog.Close (); IO.FileUtils.DeleteAllFile (); foreach (var tempHome in UserConfig.Instance.HomeLists) { IO.FileUtils.DeleteRegionFiles (IO.FileUtils.CreateRegionBackup (tempHome.RegionName)); } MainPage.LoginUser.LastTime = DateTime.MinValue; MainPage.LoginUser.SaveUserInfo (); Room.Lists.Clear (); new AccountLogin (MainPage.LoginUser.AccountString, "").Show (); this.RemoveFromParent (); SharedMethod.SharedMethod.CurPageLayout = null; System.Threading.Tasks.Task.Run (() => { var webPush = new WebServicePush (); webPush.DeleteToken_Push (UserConfig.Instance.tokenID); }); CommonPage.IsRemote = false; }; btnNo.MouseUpEventHandler += (sdd, ff) => { alertDialog.Close (); MainPage.LoginUser.LastTime = DateTime.MinValue; MainPage.LoginUser.SaveUserInfo (); Room.Lists.Clear (); new AccountLogin (MainPage.LoginUser.AccountString, "").Show (); this.RemoveFromParent (); System.Threading.Tasks.Task.Run (() => { var webPush = new WebServicePush (); webPush.DeleteToken_Push (UserConfig.Instance.tokenID); }); CommonPage.IsRemote = false; }; alertDialog.Show (); //Alert alert = new Alert ("", Language.StringByID (R.MyInternationalizationString.CloseYourAccount), Language.StringByID (R.MyInternationalizationString.No), Language.StringByID (R.MyInternationalizationString.Yes)); //alert.Show (); //alert.ResultEventHandler += (sender2, e2) => { // if (e2) { // IO.FileUtils.DeleteAllFile (); // foreach (var tempHome in UserConfig.Instance.HomeLists) { // IO.FileUtils.DeleteRegionFiles (IO.FileUtils.CreateRegionBackup (tempHome.RegionName)); // } // } // MainPage.LoginUser.LastTime = DateTime.MinValue; // MainPage.LoginUser.SaveUserInfo (); // Room.Lists.Clear (); // new AccountLogin (MainPage.LoginUser.AccountString, "").Show (); // this.RemoveFromParent (); // System.Threading.Tasks.Task.Run (() => { // var webPush = new WebServicePush (); // webPush.DeleteToken_Push (UserConfig.Instance.tokenID); // }); // CommonPage.IsRemote = false; //}; } }; } void SubaccountListView () { FrameLayout subAccView = new FrameLayout (); UserMiddle.SettingPageView.AddChidren (subAccView); UserMiddle.SettingPageView.PageIndex = UserMiddle.SettingPageView.ChildrenCount - 1; } } }