| | |
| | | { |
| | | public static class UserMiddle |
| | | { |
| | | //public static Button AppBtnTip = new Button () { |
| | | // Height = Application.GetRealHeight (140), |
| | | // BackgroundColor = 0xFFD7D7D7, |
| | | //}; |
| | | |
| | | |
| | | public static int userMenuItemHeight { |
| | | get { |
| | |
| | | Y = Application.GetRealHeight (1136 - 90 - 90), |
| | | Width = Application.GetRealWidth (640), |
| | | Height = Application.GetRealHeight (90), |
| | | Text = Language.StringByID (R.MyInternationalizationString.Version) + " : " + MainPage.CodeIDString, |
| | | Text = Language.StringByID (R.MyInternationalizationString.Version) + " : " + MainPage.RequestVersion, |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | BackgroundColor = SkinStyle.Current.ViewColor, |
| | | Enable = false |
| | |
| | | } |
| | | #endregion |
| | | |
| | | //public static void CleanPageView () |
| | | //{ |
| | | // FavoriteRoom.RemoveAll (); |
| | | // FavoriteBodyView.RemoveAll (); |
| | | // FavoritePageView.RemoveAll (); |
| | | // DeviceView.RemoveAll (); |
| | | // DeviceBodyView.RemoveAll (); |
| | | // DevicePageView.RemoveAll (); |
| | | // RoomBodyView.RemoveAll (); |
| | | // RoomPageView.RemoveAll (); |
| | | // SettingView.RemoveAll (); |
| | | // SettingBodyView.RemoveAll (); |
| | | // SettingPageView.RemoveAll (); |
| | | // UserPageView.RemoveAll (); |
| | | //} |
| | | static void CleanPageView (FrameLayout BodyView) |
| | | { |
| | | FavoriteRoom.RemoveAll (); |
| | |
| | | BodyView.AddChidren (UserMenuItem); |
| | | foreach (var thread in UserMiddle.updateSensorhreadList) { |
| | | thread.Abort (); |
| | | Console.WriteLine ("abortThread"); |
| | | Utlis.WriteLine ("abortThread"); |
| | | } |
| | | UserMiddle.updateSensorhreadList.Clear (); |
| | | } |
| | | |
| | | public static void Init (bool isGuide = false) |
| | | //2020-01-11 |
| | | public static void Init (bool isGuide = false, bool bFromLogin = false) |
| | | { |
| | | if (MainPage.LoginUser == null) |
| | | MainPage.LoginUser = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInfo> (System.Text.Encoding.UTF8.GetString (Shared.IO.FileUtils.ReadFile (UserInfo.GlobalRegisterFile))); |
| | |
| | | new AccountLogin ().Show (); |
| | | UserConfig.Instance.TipVersionBackup = UserConfig.Instance.VersionNumber; |
| | | } else { |
| | | if (UserConfig.Instance.GatewayList.Count == 0) { |
| | | UserHomePage.FrameLayoutMain.AddChidren (guidePageView); |
| | | var guide = new GuideAddResidence (); |
| | | guidePageView.AddChidren (guide); |
| | | guide.ShowHomeList (false); |
| | | guidePageView.PageIndex = 0; |
| | | MainPage.LoginUser.LastTime = DateTime.MinValue; |
| | | MainPage.LoginUser.SaveUserInfo (); |
| | | guidePageView.PageChange += (ddf, ffd) => { |
| | | if (ffd < guidePageView.ChildrenCount - 1) { |
| | | guidePageView.GetChildren (guidePageView.ChildrenCount - 1).RemoveFromParent (); |
| | | //if (UserConfig.Instance.GatewayList.Count == 0) { |
| | | //2020-01-11 Mac没绑定 是否来只登录界面 |
| | | if (bFromLogin) { |
| | | if (!UserConfig.Instance.CheckHomeGatewaysNotEmpty ()) { |
| | | if (guidePageView != null) { |
| | | guidePageView.RemoveAll (); |
| | | guidePageView.RemoveFromParent (); |
| | | } |
| | | }; |
| | | return; |
| | | UserHomePage.FrameLayoutMain.AddChidren (guidePageView); |
| | | var guide = new GuideAddResidence (); |
| | | guide.IsHideBack = true; |
| | | guidePageView.AddChidren (guide); |
| | | |
| | | guide.ShowHomeView (true); |
| | | guidePageView.PageIndex = 0; |
| | | MainPage.LoginUser.LastTime = DateTime.MinValue; |
| | | MainPage.LoginUser.SaveUserInfo (); |
| | | guidePageView.PageChange += (sender, e) => { |
| | | if (e < guidePageView.ChildrenCount - 1) { |
| | | guidePageView.GetChildren (guidePageView.ChildrenCount - 1).RemoveFromParent (); |
| | | } |
| | | }; |
| | | return; |
| | | } |
| | | } |
| | | InitHomePageView (); |
| | | //后台验证账号 |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | try { |
| | | var requestObj = new LoginObj () { Account = MainPage.LoginUser.AccountString, Password = MainPage.LoginUser.Password }; |
| | | var requestObj = new LoginObj () { Account = MainPage.LoginUser.AccountString, Password = MainPage.LoginUser.Password, Company = MainPage.SoftSmsType }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps ("Login", requestJson, false, false); |
| | | var revertObj = MainPage.RequestHttps (API.Login, requestJson); |
| | | if (revertObj != null) { |
| | | Application.RunOnMainThread (() => { |
| | | if (revertObj.StateCode == "SUCCESS") { |
| | | if (revertObj.StateCode.ToUpper () == "SUCCESS") { |
| | | var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes> (revertObj.ResponseData.ToString ()); |
| | | MainPage.LoginUser.AllVisionRegisterDevUserNameGuid = revertData.AllVisionRegisterDevUserNameGuid; |
| | | MainPage.LoginUser.LastTime = DateTime.Now; |
| | | MainPage.LoginUser.SaveUserInfo (); |
| | | //2020-01-14 登录成功后,刷新一次当前住宅网关 |
| | | GetNowHomeGatewayAfterLoginSuccess (); |
| | | } else if (!string.IsNullOrEmpty (revertObj.StateCode)) { |
| | | MainPage.LoginUser.LastTime = DateTime.Now.AddDays (-30); |
| | | MainPage.LoginUser.SaveUserInfo (); |
| | |
| | | //SystemRemote.LinkRemote ("", "", "",true); |
| | | if (null != UserPageView.Parent) { |
| | | if (guidePageView.Parent != null) { |
| | | guidePageView.RemoveAll (); |
| | | guidePageView.RemoveFromParent (); |
| | | } |
| | | CleanPageView (FavoriteBodyView); |
| | |
| | | #if DEBUG |
| | | //UserConfig.Instance.SkinCode = 1; |
| | | Language.CurrentLanguage = "English"; |
| | | //var lii = new LightLogic () { Type = DeviceType.LightRGB, LoopID = 1, DeviceID = 4, SubnetID = 42, Name = "RGB" }; |
| | | //IO.FileUtils.SaveEquipmentMessage (lii, lii.LoopID.ToString ()); |
| | | var lii = new LightLogic () { Type = DeviceType.LightRGB, LoopID = 1, DeviceID = 4, SubnetID = 42, Name = "RGB" }; |
| | | IO.FileUtils.SaveEquipmentMessage (lii, lii.LoopID.ToString ()); |
| | | var lii1 = new LightSwitch () { LoopID = 1, DeviceID = 2, SubnetID = 232, Name = "继电器" }; |
| | | IO.FileUtils.SaveEquipmentMessage (lii1, lii1.LoopID.ToString ()); |
| | | //var lii11 = new LightDimming () { LoopID = 1, DeviceID = 1, SubnetID = 232, Name = "调光器" }; |
| | |
| | | //IO.FileUtils.SaveEquipmentMessage (lii111, lii111.LoopID.ToString ()); |
| | | |
| | | |
| | | //var licci11 = new CurtainModel () { LoopID = 1, DeviceID = 9, SubnetID = 42, Name = "窗帘" }; |
| | | //IO.FileUtils.SaveEquipmentMessage (licci11, licci11.LoopID.ToString ()); |
| | | var mCurtainModel1 = new CurtainModel () { LoopID = 1, DeviceID = 9, SubnetID = 42, Name = "窗帘" }; |
| | | IO.FileUtils.SaveEquipmentMessage (mCurtainModel1, mCurtainModel1.LoopID.ToString ()); |
| | | //var mCurtainModel2 = new CurtainModel () { LoopID = 2, DeviceID = 9, SubnetID = 42, Name = "窗帘2" }; |
| | | //IO.FileUtils.SaveEquipmentMessage (mCurtainModel2, mCurtainModel2.LoopID.ToString ()); |
| | | //var mCurtainModel3 = new CurtainModel () { LoopID = 1, DeviceID = 2, SubnetID = 42, Name = "窗帘3" }; |
| | | //IO.FileUtils.SaveEquipmentMessage (mCurtainModel3, mCurtainModel3.LoopID.ToString ()); |
| | | |
| | | var mCurtainRoller = new CurtainRoller () { LoopID = 1, DeviceID = 88, SubnetID = 42, Name = "窗帘CurtainRoller" }; |
| | | IO.FileUtils.SaveEquipmentMessage (mCurtainRoller, mCurtainRoller.LoopID.ToString ()); |
| | | |
| | | var mCurtainTrietex = new CurtainTrietex () { LoopID = 1, DeviceID = 87, SubnetID = 42, Name = "窗帘CurtainTrietex" }; |
| | | IO.FileUtils.SaveEquipmentMessage (mCurtainTrietex, mCurtainTrietex.LoopID.ToString ()); |
| | | |
| | | |
| | | |
| | | |
| | | //var s1 = new LightEnergySocket () { LoopID = 1, DeviceID = 1, SubnetID = 44, Name = "EnergySocket" }; |
| | | //IO.FileUtils.SaveEquipmentMessage (s1, s1.LoopID.ToString ()); |
| | |
| | | |
| | | InfraredMode infraredMode = new InfraredMode () { LoopID = 1, SubnetID = 100, DeviceID = 12, InfraredType = InfraredType.TV, Name = "测试电视" }; |
| | | IO.FileUtils.SaveEquipmentMessage (infraredMode, "1"); |
| | | ACInfrared aCInfrared = new ACInfrared () { LoopID = 1, SubnetID = 100, DeviceID = 112, Name = "测试空调" }; |
| | | ACInfrared aCInfrared = new ACInfrared () { LoopID = 1, SubnetID = 100, DeviceID = 112, Name = "空调ACInfrared" }; |
| | | IO.FileUtils.SaveEquipmentMessage (aCInfrared, "1"); |
| | | |
| | | |
| | | ACPanel mACPanel = new ACPanel () { LoopID = 1, SubnetID = 100, DeviceID = 42, Name = "空调面板ACPanel" }; |
| | | IO.FileUtils.SaveEquipmentMessage (mACPanel, "1"); |
| | | |
| | | CustomAC mCustomAC = new CustomAC () { LoopID = 1, SubnetID = 99, DeviceID = 42, Name = "空调CustomAC" }; |
| | | IO.FileUtils.SaveEquipmentMessage (mCustomAC, "1"); |
| | | |
| | | HVAC mHVAC = new HVAC () { LoopID = 1, SubnetID = 98, DeviceID = 42, Name = "空调HVAC" }; |
| | | IO.FileUtils.SaveEquipmentMessage (mHVAC, "1"); |
| | | |
| | | |
| | | //var fanM = new FanModule () { Name = "Fan Module",SubnetID = 2,DeviceID = 1,LoopID = 1}; |
| | | //IO.FileUtils.SaveEquipmentMessage (fanM); |
| | | //var fanLoop1 = new FanModule () { Name = "Fan 1", SubnetID = 2, DeviceID = 1, LoopID = 1 }; |
| | |
| | | if (e < SettingPageView.ChildrenCount - 1) { |
| | | SettingPageView.GetChildren (SettingPageView.ChildrenCount - 1).RemoveFromParent (); |
| | | } |
| | | if (e == 0) { |
| | | //2020-01-15 回到主界面,重置为加密 |
| | | UserConfig.Instance.IsLocalEncrypt = true; |
| | | } |
| | | }; |
| | | RoomPageView.PageChange += (sender, e) => { |
| | | if (e < RoomPageView.ChildrenCount - 1) { |
| | |
| | | curPageView = 2; |
| | | } |
| | | |
| | | public static void ReadAllDeviceStatus () |
| | | public static void ReadAllDeviceStatus (bool isRefresh = true, bool isCheckIsReadingAll = false) |
| | | { |
| | | if (MainPage.LoginUser == null || !MainPage.LoginUser.IsLogin) { |
| | | return; |
| | | } |
| | | UserDeviceToLight.readAllStatus (true); |
| | | UserDeviceToSocket.readAllStatus (true); |
| | | UserDeviceToAC.readAllStatus (true); |
| | | UserDeviceToFH.readAllStatus (true); |
| | | UserDeviceToLight.readAllStatus (isRefresh, isCheckIsReadingAll); |
| | | UserDeviceToSocket.readAllStatus (isRefresh, isCheckIsReadingAll); |
| | | UserDeviceToAC.readAllStatus (isRefresh, isCheckIsReadingAll); |
| | | UserDeviceToFH.readAllStatus (isRefresh); |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 登录成功后,查询刷新一次当前住宅 网关列表 |
| | | /// 2020-01-11 |
| | | /// </summary> |
| | | static void GetNowHomeGatewayAfterLoginSuccess () |
| | | { |
| | | var requestObj3 = new GetSingleHomeGatewayPaggerObj (); |
| | | requestObj3.ReqDto.LoginAccessToken = MainPage.LoginUser.LoginTokenString; |
| | | requestObj3.ReqDto.HomeId = UserConfig.Instance.CurrentRegion.Id; |
| | | requestObj3.ReqDto.PageSetting.Page = 1; |
| | | requestObj3.ReqDto.PageSetting.PageSize = 10; |
| | | string urlHead = MainPage.RequestHttpsHost; |
| | | if (requestObj3.IsOtherAccountCtrl) { |
| | | urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl; |
| | | requestObj3.ReqDto.LoginAccessToken = UserConfig.Instance.MasterAccountToken; |
| | | } |
| | | |
| | | var requestJson3 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj3); |
| | | var revertObj3 = MainPage.RequestHttps (API.GetSingleHomeGatewayPagger, requestJson3, urlHead); |
| | | if (revertObj3.StateCode.ToUpper () == "SUCCESS") { |
| | | var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<GetGatewayResult> (revertObj3.ResponseData.ToString ()); |
| | | //2020-01-11 |
| | | UserConfig.Instance.SetNowHomeGateways (infoResult.PageData); |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |