| | |
| | | using Shared; |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.DAL.Server; |
| | | using System.Security.Cryptography; |
| | | using System.Text; |
| | | |
| | | namespace HDL_ON.UI.UI1Login |
| | | { |
| | |
| | | try |
| | | { |
| | | var mGlobalRegionListObj = Newtonsoft.Json.JsonConvert.DeserializeObject<GlobalRegionListRes>(result.Data.ToString()); |
| | | if (UserInfo.Current.RequestHttpsHost != mGlobalRegionListObj.regionUrl) |
| | | if (OnAppConfig.Instance.RequestHttpsHost != mGlobalRegionListObj.regionUrl) |
| | | { |
| | | UserInfo.Current.RequestHttpsHost = mGlobalRegionListObj.regionUrl; |
| | | UserInfo.Current.GlobalRegion = mGlobalRegionListObj; |
| | | UserInfo.Current.SaveUserInfo(); |
| | | OnAppConfig.Instance.RequestHttpsHost = mGlobalRegionListObj.regionUrl; |
| | | OnAppConfig.Instance.GlobalRegion = mGlobalRegionListObj; |
| | | OnAppConfig.Instance.SaveConfig(); |
| | | } |
| | | } |
| | | catch { } |
| | |
| | | if (verAccount == etPassword.Text.Trim()) |
| | | { |
| | | //跳转页面---- |
| | | MainPage.GoUserPage(); |
| | | MainPage.GoUserPage(true); |
| | | return; |
| | | } |
| | | }); |
| | |
| | | * 查看本地是否存在数据 |
| | | * 存在则导出 |
| | | */ |
| | | var isExis = FileUtils.IsExisFolder(DB_ResidenceData.residenceData.CurReginID); |
| | | if (isExis) |
| | | { |
| | | FileUtils.DeleteAllFile(); |
| | | string regionRootPath = FileUtils.CreateRegionBackup(DB_ResidenceData.residenceData.CurReginID); |
| | | FileUtils.RestoreRegionFiles(regionRootPath); |
| | | DB_ResidenceData.residenceData.EixtAccount(); |
| | | OnAppConfig.Instance.RefreshUserConfig(); |
| | | SpatialInfo.CurrentSpatial.InitRoomFunction(); |
| | | } |
| | | //var isExis = FileUtils.IsExisFolder(DB_ResidenceData.residenceData.CurReginID); |
| | | //if (isExis) |
| | | //{ |
| | | // FileUtils.DeleteAllFile(); |
| | | // string regionRootPath = FileUtils.CreateRegionBackup(DB_ResidenceData.residenceData.CurReginID); |
| | | // FileUtils.RestoreRegionFiles(regionRootPath); |
| | | // DB_ResidenceData.residenceData.EixtAccount(); |
| | | // OnAppConfig.Instance.RefreshUserConfig(); |
| | | // SpatialInfo.CurrentSpatial.InitRoomFunction(); |
| | | //} |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //20201223-登录成功之后,将下载数据完成标记标记为false,防止主页提前加载 |
| | | Common.ApiUtlis.Ins.DownloadDataComplete = false; |
| | | //跳转页面---- |
| | | MainPage.GoUserPage(); |
| | | MainPage.GoUserPage(true); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | BindingResidencePage page = new BindingResidencePage(); |
| | | MainPage.BaseView.AddChidren(page); |
| | | page.LoadView(); |
| | | |
| | | |
| | | |
| | | //2020-11-13 待确认 |
| | | //获取住宅失败,重新标记为未登录状态 |
| | | UserInfo.Current.LastTime = DateTime.MinValue; |
| | |
| | | // refreshToken = revertData.refreshToken, |
| | | // userName = revertData.name |
| | | //}; |
| | | if (OnAppConfig.Instance.LastLoginUserId != revertData.userId) |
| | | { |
| | | OnAppConfig.Instance.LastLoginUserId = revertData.userId; |
| | | OnAppConfig.Instance.SaveConfig(); |
| | | } |
| | | UserInfo.Current.ClearUserInfo(); |
| | | UserInfo.Current.userType = revertData.userType; |
| | | UserInfo.Current.AccountString = account; |
| | | //UserInfo.Current.password = password; |
| | |
| | | UserInfo.Current.LoginTokenString = revertData.headerPrefix + revertData.accessToken; |
| | | UserInfo.Current.RefreshToken = revertData.refreshToken; |
| | | UserInfo.Current.userName = revertData.name; |
| | | UserInfo.Current.userMobileInfo = "";//重置用户手机 |
| | | UserInfo.Current.userEmailInfo = "";//重置用户邮箱 |
| | | UserInfo.Current.headImagePagePath = "LoginIcon/2.png";//重置用户头像 |
| | | //UserInfo.Current.userMobileInfo = "";//重置用户手机 |
| | | //UserInfo.Current.userEmailInfo = "";//重置用户邮箱 |
| | | //UserInfo.Current.headImagePagePath = "LoginIcon/2.png";// |
| | | //UserInfo.Current.CurrentRegion.RegionID = ""; |
| | | UserInfo.Current.SaveUserInfo(); |
| | | MainPage.Log("登录成功。"); |
| | | result = true; |
| | | //获取用户信息 |
| | | new Thread(() => |
| | | { |
| | | pm.GetUserHeadImage(revertData.userId); |
| | | pm.GetUserInfo(false); |
| | | pm.GetUserInfo(); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | |
| | | //账号或者密码错误 |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | waitPage.Hide(); |
| | | |
| | | if (loginResult.Code == "10008") |
| | | { |
| | | //用户名或密码错误 |
| | |
| | | btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | btnPasswordViewBottomLine.Height = Application.GetRealHeight(2); |
| | | } |
| | | waitPage.Hide(); |
| | | else if (loginResult.Code == StateCode.AccountLoginLock) |
| | | { |
| | | ShowAccountLoginLockTip(loginResult); |
| | | //var tipStr = Language.StringByID(StringId.AccountLoginLock) + "\r\n" + Language.StringByID(StringId.PleaseTryToForgetPassword); |
| | | //Utlis.ShowTip(tipStr); |
| | | return; |
| | | } |
| | | IMessageCommon.Current.ShowErrorInfoAlter(loginResult.Code); |
| | | }); |
| | | |
| | | IMessageCommon.Current.ShowErrorInfoAlter(loginResult.Code); |
| | | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 解析提示用户解锁时间 |
| | | /// 密码错误次数过多,账号被锁定!请通过忘记密码找回密码或{0}分钟后重试. |
| | | /// </summary> |
| | | /// <param name="loginResult"></param> |
| | | void ShowAccountLoginLockTip(ResponsePackNew loginResult) |
| | | { |
| | | //密码错误次数过多,账号被锁定! |
| | | var tipStr = Language.StringByID(StringId.AccountLoginLock); |
| | | try |
| | | { |
| | | if (loginResult.extra != null) |
| | | { |
| | | //请通过忘记密码找回密码或{0}分钟后重试. |
| | | var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountLoginLockExtraRes>(loginResult.extra.ToString()); |
| | | string msg = Language.StringByID(StringId.PleaseTryToForgetPassword); |
| | | //var unlockTime = Utlis.UnixToDateTimeWithFormatMS(revertData.unlockTime, "HH:mm"); |
| | | //msg = msg.Replace("{0}", unlockTime); |
| | | |
| | | var unlockDatetime = Utlis.UnixToDateTimeMS(revertData.unlockTime); |
| | | var unlockTimeInt = unlockDatetime.Minute - DateTime.Now.Minute; |
| | | if(unlockTimeInt <= 0) |
| | | { |
| | | unlockTimeInt = 1; |
| | | } |
| | | msg = msg.Replace("{0}", unlockTimeInt.ToString()); |
| | | tipStr = tipStr + "\r\n" + msg; |
| | | } |
| | | } |
| | | catch { } |
| | | |
| | | Utlis.ShowTip(tipStr); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | btnRegister.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | //2020-12-22 增加点击隐藏键盘事件 |
| | | Application.HideSoftInput(); |
| | | |
| | | |
| | | #if DEBUG |
| | | TestEZSDK(); |
| | | return; |
| | | #endif |
| | | |
| | | //判断是否同意了隐私政策 |
| | | if (CheckPrivacyPolicy() == false) return; |
| | | |
| | |
| | | MainPage.Log($"login callBackAction : {ex.Message}"); |
| | | } |
| | | }; |
| | | |
| | | |
| | | var registerPage = new RegisterPage(autoLoginAction); |
| | | registerPage.Show(); |
| | | registerPage.ShowDialog(); |
| | | }; |
| | | } |
| | | |
| | | |
| | | void TestESVideo() |
| | | { |
| | | var mESVideoInfo = new ESVideoInfo() |
| | | { |
| | | DeviceName = "室外机88", |
| | | ESVideoUUID = "JJY000019VPLLF", |
| | | ESRoomID = 801, |
| | | RoomName = "801" |
| | | |
| | | }; |
| | | |
| | | #if __Android__ |
| | | |
| | | Android.Content.Intent intent = new Android.Content.Intent(Application.Activity, typeof(HDL_ON_Android.VideoActivity)); |
| | | intent.PutExtra("DeviceName", mESVideoInfo.DeviceName);//室外机的名称,例,室外机 |
| | | intent.PutExtra("ESRoomID", mESVideoInfo.ESRoomID);//当前用户的房间 ID |
| | | intent.PutExtra("ESVideoUUID", mESVideoInfo.ESVideoUUID);//室外机UUID,例:JJY000007FSEYX |
| | | intent.PutExtra("IsCollect", mESVideoInfo.IsCollect);//是否收藏 |
| | | intent.PutExtra("RoomName", mESVideoInfo.RoomName);//房间命名,例 8栋1单元0801 |
| | | intent.AddFlags(Android.Content.ActivityFlags.NewTask); |
| | | intent.PutExtra("Type", 0);//类型,0 监控,1反呼 |
| | | Application.Activity.StartActivity(intent); |
| | | #else |
| | | //EZSDK.IOS.EZSDK.Go2EZvizMonitor(); |
| | | Shared.ESVideoInfo eSVideoInfo = new Shared.ESVideoInfo(); |
| | | eSVideoInfo.DeviceName = "室外机88"; |
| | | eSVideoInfo.ESVideoUUID = "JJY000019VPLLF"; |
| | | eSVideoInfo.ESRoomID = 801; |
| | | eSVideoInfo.RoomName = "0801"; |
| | | Shared.ESVideo.ShowESVideoMonitor(eSVideoInfo); |
| | | return; |
| | | #endif |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="signstr"></param> |
| | | /// <returns></returns> |
| | | static string SignMD5Encrypt(string s) |
| | | { |
| | | byte[] sign = MD5.Create().ComputeHash(UTF8Encoding.UTF8.GetBytes(s)); |
| | | string signstr = string.Empty; |
| | | foreach (byte item in sign) |
| | | { |
| | | signstr += item.ToString("X2"); |
| | | } |
| | | return signstr.ToLower(); |
| | | } |
| | | |
| | | void TestEZSDK() |
| | | { |
| | | |
| | | #if __Android__ |
| | | #else |
| | | //设置子账号AccessToken方案 |
| | | EZSDK.IOS.EZSDK.SetEZAccessToken("ra.cekz6j9y1zg7mqgj3rmb099p49fuf6w3-9keosamseq-00wktld-brmhuciz1"); |
| | | |
| | | EZSDK.IOS.EZSDK.Go2EZvizMonitor(); |
| | | |
| | | |
| | | //var psw = SignMD5Encrypt("1aa98a90489b4838b966b57018b4b04b#123456"); |
| | | |
| | | //Utlis.WriteLine("MD5 psw: " + psw); |
| | | return; |
| | | #endif |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | btnForgetPassword.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | //2020-12-22 增加点击隐藏键盘事件 |
| | | Application.HideSoftInput(); |
| | | |
| | | #if DEBUG |
| | | TestESVideo(); |
| | | return; |
| | | #endif |
| | | |
| | | //判断是否同意了隐私政策 |
| | | if (CheckPrivacyPolicy() == false) return; |
| | | |
| | |
| | | MainPage.Log($"login callBackAction : {ex.Message}"); |
| | | } |
| | | }; |
| | | |
| | | var forgetPasswordDialog = new ForgetPasswordPage(autoLoginAction); |
| | | forgetPasswordDialog.Show(); |
| | | forgetPasswordDialog.ShowDialog(); |
| | |
| | | new PublicAssmebly().LoadPage_WaitPage(loginThread, bodyView, waitPage); |
| | | } |
| | | } |
| | | |
| | | public class ESVideoInfo |
| | | { |
| | | /// <summary> |
| | | /// 室外机的UUID |
| | | /// 例:JJY000007FSEYX |
| | | /// </summary> |
| | | public string ESVideoUUID = string.Empty; |
| | | /// <summary> |
| | | /// 当前用户的房间ID |
| | | /// 例:0801 |
| | | /// </summary> |
| | | public int ESRoomID; |
| | | /// <summary> |
| | | /// 室外机的名称 |
| | | /// 例:室外机 |
| | | /// </summary> |
| | | public string DeviceName = string.Empty; |
| | | /// <summary> |
| | | /// 房间命名 |
| | | /// 例:8栋1单元0801 |
| | | /// </summary> |
| | | public string RoomName = string.Empty; |
| | | /// <summary> |
| | | /// 是否收藏 |
| | | /// </summary> |
| | | public bool IsCollect; |
| | | |
| | | } |
| | | } |