private async Task <bool> RegisterAsync() { try { //注册 IsLoading = true; var loader = new ResourceLoader(); var check = await CloudService.CheckEmailExistAsync(TempEmail); if (check) { throw new MyerListException() { ErrorCode = "202" }; } string salt = await CloudService.RegisterAsync(TempEmail, InputPassword); if (!string.IsNullOrEmpty(salt)) { LocalSettingHelper.AddValue("email", TempEmail); LocalSettingHelper.AddValue("password", InputPassword); return(true); } else { throw new MyerListException() { ErrorCode = "" }; } } catch (MyerListException e) { ToastService.SendToast(ErrorUtils.GetUserMsgFromErrorCode(int.Parse(e.ErrorCode))); IsLoading = false; return(false); } catch (TaskCanceledException) { ToastService.SendToast(ResourcesHelper.GetResString("RequestError")); IsLoading = false; return(false); } catch (COMException) { ToastService.SendToast(ResourcesHelper.GetResString("RequestError")); IsLoading = false; return(false); } }
private async Task <bool> LoginAsync() { try { IsLoading = true; var check = await CloudService.CheckEmailExistAsync(TempEmail); string salt = await CloudService.GetSaltAsync(TempEmail); //尝试登录 var login = await CloudService.LoginAsync(TempEmail, InputPassword, salt); App.IsInOfflineMode = false; LocalSettingHelper.AddValue("OfflineMode", "false"); return(true); } catch (MyerListException e) { ToastService.SendToast(ErrorUtils.GetUserMsgFromErrorCode(int.Parse(e.ErrorCode))); return(false); } catch (TaskCanceledException) { ToastService.SendToast(ResourcesHelper.GetResString("RequestError")); return(false); } catch (COMException) { ToastService.SendToast(ResourcesHelper.GetResString("RequestError")); return(false); } catch (Exception) { ToastService.SendToast(ResourcesHelper.GetResString("RequestError")); return(false); } finally { IsLoading = false; } }