public async Task <IActionResult> List() { try { var Token = HttpContext.Request.Headers["Token"]; List <StoryAggregate> Stories = await this.StoryServiceInstance.List(Token); return(View("Index", Stories)); } catch (Exception ex) { if (ex is CustomHttpResponseException) { var cex = ex as CustomHttpResponseException; Console.WriteLine(JsonConvert.SerializeObject(cex.CustomData)); } else { Console.WriteLine(JsonConvert.SerializeObject(ex)); } ErrorView Error = new ErrorView(); Error.HasError = true; Error.Message = "Đã có lỗi xảy ra. Vui lòng thử lại sau"; ViewBag.Error = Error; return(View("Index")); } }
public async Task <IActionResult> ChangeEmail(string password, string email) { email = email.Trim(); if (!EmailValidator.IsValid(email)) { return(BadRequest(ErrorView.SoftError("EmailInvalid", "Email not valid"))); } var user = await GetUserAsync(); if (!await userManager.CheckPasswordAsync(user, password)) { return(BadRequest(ErrorView.SoftError("PasswordInvalid", "Password not valid"))); } if (await userManager.CheckEmailInDbAsync(email, user.Id)) { return(BadRequest(ErrorView.SoftError("EmailAlreadyTaken", "Email already registered"))); } await accountManager.SendChangeEmailConfirmationMessageByEmailAsync(user, email); return(Ok()); }
public async Task <IActionResult> Create([FromQuery(Name = "cate")] int Cate) { try { var Token = HttpContext.Request.Headers["Token"]; StoryAggregate Story = new StoryAggregate(); Story.StoryInfo.CategoryId = Cate; List <Tag> Tags = await this.TagServiceInstance.List(new List <int>(), Token); ViewBag.Tags = Tags; return(View(Story)); } catch (Exception ex) { if (ex is CustomHttpResponseException) { var cex = ex as CustomHttpResponseException; Console.WriteLine(JsonConvert.SerializeObject(cex.CustomData)); } else { Console.WriteLine(JsonConvert.SerializeObject(ex)); } ErrorView Error = new ErrorView(); Error.HasError = true; Error.Message = "Đã có lỗi xảy ra. Vui lòng thử lại sau"; ViewBag.Error = Error; return(View()); } }
private void OnError(string err) { infoView.AddStatus(" · An error has occurred"); errorView = Instantiate(errorViewPrefab); errorView.SetMessage(err); errorView.AddOnBackListener(Back); }
public TeamCreateVM(ErrorView err) { Err = err; Array _schedule = System.Enum.GetValues(typeof(Schedule)); Schedules = _schedule.OfType <Schedule>().ToList(); }
public async Task <IActionResult> ChangeCachePolicy(CachePolicy selectedPolicy, int?invalidateCacheTime = null) { if (selectedPolicy != CachePolicy.NeverPolicy && invalidateCacheTime == null) { return(BadRequest(ErrorView.ValidationError())); } try { await cacheSettingsManager.UpdateCachePolicy(new CacheSettings() { CachePolicy = selectedPolicy, InvalidateCacheTime = invalidateCacheTime }); return(Ok()); } catch (ArgumentOutOfRangeException) { return(BadRequest(ErrorView.ValidationError())); } catch (NotFoundDataException) { return(BadRequest(ErrorView.ServerError())); } }
protected async Task SetNameAsync(Material material, string name) { if (User.IsInRole(RoleNames.Admin)) { if (string.IsNullOrWhiteSpace(name)) { material.Name = null; } else { if (!materialsManager.IsNameValid(name)) { throw new SunViewException(new ErrorView("MaterialNameNotValid", "Invalid material name", ErrorType.System)); } if (name != material.Name && await materialsManager.IsNameInDbAsync(name)) { throw new SunViewException(ErrorView.SoftError("MaterialNameAlreadyUsed", "This material name is already used")); } material.Name = name; } } }
private void adjustHeight() { double height; if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) { height = nonScrollableContentHeight + ScrollViewContent.Bounds.Height; if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { height += UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Bottom; } } else { var errorHeight = ErrorView.Hidden ? 0 : ErrorView.SizeThatFits(UIView.UILayoutFittingCompressedSize).Height; var titleHeight = DescriptionView.SizeThatFits(UIView.UILayoutFittingCompressedSize).Height; var isBillableHeight = BillableView.Hidden ? 0 : 56; var timeFieldsHeight = ViewModel.IsEditingGroup ? 0 : 167; height = preferredIpadHeight + errorHeight + titleHeight + timeFieldsHeight + isBillableHeight; } var newSize = new CGSize(0, height); if (newSize != PreferredContentSize) { PreferredContentSize = newSize; PresentationController.ContainerViewWillLayoutSubviews(); } ScrollView.ScrollEnabled = ScrollViewContent.Bounds.Height > ScrollView.Bounds.Height; }
public override async Task ExecuteAsync(object parameter) { _loginViewModel.ErrorMessage = string.Empty; try { User user = await _authenticator.Login(_loginViewModel.Username, _loginViewModel.Password); string userJson = JsonConvert.SerializeObject(new User() { Login = user.Login, Passwd = user.Passwd, Id = user.Id }); await File.WriteAllTextAsync("user.json", userJson); var a = new UpdateCurrentViewModelCommand(_navigator, user, _authenticator.GetUserContext()); a.Execute(ViewType.Home); } catch (Exception ex) { ErrorView errorView = new ErrorView(); errorView.DataContext = new ErrorViewModel(ex.Message); errorView.ShowDialog(); } }
public void CreateView(DeviceViewArgs args, IUnityContainer container) { this.container = container; ProgressView progress = new ProgressView("Loading .."); if (this.content.Content is IDisposable) { var dis = this.content.Content as IDisposable; dis.Dispose(); } this.content.Content = progress; loadingDisp.Add(Load(args.nvtSession, args.odmSession, args.capabilities) .ObserveOnCurrentDispatcher() .Subscribe(analyticsArgs => { SectionAnalytics analyticsView = new SectionAnalytics(container); disposables.Add(analyticsView); analyticsView.Init(analyticsArgs); this.content.Content = analyticsView; }, err => { ErrorView errorView = new ErrorView(err); disposables.Add(errorView); this.content.Content = errorView; } )); }
private void ShowErrorMessage(string errorMsg) { ErrorView ev = new ErrorView(); ev.ErrorMessage = errorMsg; ev.Show(); }
public void Init(DeviceDescriptionHolder devHolder, NvtSessionFactory sessionFactory, IUnityContainer container) { this.container = container; //Add device section (all devices must have this section) parent.Title = devHolder.Name; //Display progress bar devicePanel.Content = new ProgressView("Loading ..."); //Begin load device section disposables.Add(SectionDevice.Load(devHolder, sessionFactory) .ObserveOnCurrentDispatcher() .Subscribe( args => { invtSession = args.nvtSession; SectionDevice devView = container.Resolve <SectionDevice>(); disposables.Add(devView); devView.Init(args); devicePanel.Content = devView; //Load sections LoadSections(args); }, err => { ErrorView errorView = new ErrorView(err); disposables.Add(errorView); devicePanel.Content = errorView; } )); }
public virtual void ShowLoadErrorPage() { if (!IsErrorPage) { IsErrorPage = true; Device.BeginInvokeOnMainThread(() => { try { var errorView = new ErrorView(); var content = Content; Content = errorView; errorView.TryAgain += (sender, e) => { this.IsErrorPage = false; Content = content; ReloadPage(); }; } catch (Exception e) { ExceptionHandler.Catch(e); } }); } }
public void LogInAction(string user, string pwd) { if (model.Login(user, pwd)) { //((Window)LoginView).Hide(); viewHandler.Hide(LoginView); if (MainView == null) { MainView = container.GetMainView(); } //((Window)MainView).Show(); viewHandler.Show(MainView); Error = ""; } else { if (!viewHandler.IsReady(ErrorView)) //ErrorView == null || !((Window)ErrorView).IsVisible) { ErrorView = container.GetLoginErrorView(); } Error = "Invalid login"; ErrorView.UpdateView(); //((Window)ErrorView).ShowDialog(); viewHandler.ShowModal(ErrorView); } }
public TeamEditVM() { Array _schedule = System.Enum.GetValues(typeof(Schedule)); Schedules = _schedule.OfType <Schedule>().ToList(); Err = new ErrorView(); }
protected async Task <ServiceResult> SetNameAsync(Material material, string name) { if (User.IsInRole(RoleNames.Admin)) { if (string.IsNullOrWhiteSpace(name)) { material.Name = null; } else { if (!materialsManager.IsNameValid(name)) { return(ServiceResult.BadResult(new ErrorView("MaterialNameNotValid", "Invalid material name"))); } if (name != material.Name && await materialsManager.IsNameInDb(name)) { return(ServiceResult.BadResult(ErrorView.SoftError("MaterialNameAlreadyUsed", "This material name is already used"))); } material.Name = name; } } return(ServiceResult.OkResult()); }
public ErrorView ChampionshipTeamCreate(int id_player, Championship c) { ErrorView err = new ErrorView(); if (_championshipDAL.ChampionshipIsFull(c.Id, c.NumberOfGames)) { Team t = _teamBLL.TeamSelectByPlayerCap(id_player); bool aux = t.SubCaptain.Id == 0 ? false : true; if (_teamBLL.TeamCompleted(t.Id, aux)) { if (!_championshipDAL.ChampionshipTeamSelectTeamVerify(t.Id, c.Id)) { if (c.Type == ChampionshipType.Grátis) { if (_championshipDAL.ChampionshipTeamCreate(c, t)) { err.HasError = true; err.MsgError = "Seu time foi cadastrado com sucesso neste campeonato!"; } else { err.HasError = true; err.MsgError = "Erro!"; } } else { if (_championshipDAL.ChampionshipTeamCreateTemporary(c, t)) { err.HasError = true; err.MsgError = "Aguardando comprovação de pagamento."; } else { err.HasError = true; err.MsgError = "Erro!"; } } } else { err.HasError = true; err.MsgError = "Seu time já está cadastrado neste campeonato!"; } } else { err.HasError = true; err.MsgError = "Seu time está incompleto!"; } } else { err.HasError = true; err.MsgError = "Infelimente não existe mais vagas para este campeonato, fique de olho que temos campeonatos todo fim de semana!"; } return(err); }
public ErrorView ChampionshipPlayerCreate(Player player, Championship c) { ErrorView err = new ErrorView(); if (_championshipDAL.ChampionshipIsFull(c.Id, c.NumberOfGames)) { if (!_championshipDAL.ChampionshipPlayerSelectPlayerVerify(player, c.Id)) { if (_championshipDAL.ChampionshipPlayerCreate(c, player)) { err.HasError = true; err.MsgError = "Você foi cadastrado com sucesso neste campeonato!"; } else { err.HasError = true; err.MsgError = "Erro!"; } } else { err.HasError = true; err.MsgError = "Você já está cadastrado neste campeonato!"; } } else { err.HasError = true; err.MsgError = "Infelimente não existe mais vagas para este campeonato, fique de olho que temos diversos campeonatos!"; } return(err); }
public async Task LeavePendingGame() { if (PendingGameService.PendingGames.Count == 0) { await ReplyAsync(ErrorView.NotFound()); } else { PendingGame game = PendingGameService.PendingGames.FirstOrDefault(); IUser user = game.Users.FirstOrDefault(u => u.Id == Context.User.Id); if (game.Active) { _game.RemoveUserFromPlay(user); await _game.NotifyPlayerLeft(Context.User); } else { game.Users.Remove(user); await ReplyAsync(InfoView.LeftLobby()); if (game.Users.Count == 0) { PendingGameService.PendingGames.Clear(); await ReplyAsync(InfoView.DeletedLobby()); } } } }
public ErrorView GetError(Error error) { ErrorView errorView = new ErrorView(); errorView.Code = (int)error; errorView.Description = error.ToString(); return(errorView); }
/// <summary> /// Shows a window which contains detailed error information (such as stack trace). /// </summary> /// <param name="sender">Sender object. Must be an <see cref="ApsimNG.Classes.CustomButton"/></param> /// <param name="e">Event Arguments.</param> private void ShowDetailedErrorMessage(object sender, EventArgs e) { if (sender is ApsimNG.Classes.CustomButton) { ErrorView err = new ErrorView(LastError[(sender as ApsimNG.Classes.CustomButton).ID], view as ViewBase); err.Show(); } }
public static UserServiceResult BadResult(ErrorView error = null) { return(new UserServiceResult { Succeeded = false, Error = error }); }
public TeamEditVM(Player currentPlayer, Team team) { Err = new ErrorView(); CurrentPlayer = currentPlayer; Team = team; Array _schedule = System.Enum.GetValues(typeof(Schedule)); Schedules = _schedule.OfType <Schedule>().ToList(); }
void ReleaseDesignerOutlets() { if (CloseButton != null) { CloseButton.Dispose(); CloseButton = null; } if (ErrorView != null) { ErrorView.Dispose(); ErrorView = null; } if (FeedbackPlaceholderTextView != null) { FeedbackPlaceholderTextView.Dispose(); FeedbackPlaceholderTextView = null; } if (FeedbackTextView != null) { FeedbackTextView.Dispose(); FeedbackTextView = null; } if (IndicatorView != null) { IndicatorView.Dispose(); IndicatorView = null; } if (SendButton != null) { SendButton.Dispose(); SendButton = null; } if (TitleLabel != null) { TitleLabel.Dispose(); TitleLabel = null; } if (ErrorTitleLabel != null) { ErrorTitleLabel.Dispose(); ErrorTitleLabel = null; } if (ErrorMessageLabel != null) { ErrorMessageLabel.Dispose(); ErrorMessageLabel = null; } }
protected override void SetValueImpl(object target, object value) { try { if (!(target is EmptyDataSet emptyDataSet) || value == null) { return; } States state = (States)Enum.Parse(typeof(States), value.ToString()); UIView stateView = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }; foreach (UIView view in emptyDataSet.ContentView.Subviews) { view.RemoveFromSuperview(); } emptyDataSet.ContentView.Alpha = 1f; var _frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height); switch (state) { case States.Normal: emptyDataSet.ContentView.Alpha = 0f; break; case States.Loading: stateView = new LoadingView(_frame); break; case States.NoData: stateView = new NoDataView(_frame); break; case States.NoInternet: stateView = new NoInternetView(_frame, emptyDataSet.RefreshCommand); break; case States.Error: stateView = new ErrorView(_frame); break; } emptyDataSet.ContentView.AddSubview(stateView); stateView.SetCenterContraintTo(emptyDataSet.ContentView); stateView.SetLeftContraintTo(emptyDataSet.ContentView, 0); stateView.SetRightContraintTo(emptyDataSet.ContentView, 0); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
public static void Show(string title, string message) { ErrorViewModel errorViewModel = new ErrorViewModel(title, message); ErrorView errorView = new ErrorView { DataContext = errorViewModel }; errorView.ShowDialog(); }
public async Task <IActionResult> Auth( [FromForm] AuthBinding binding, [FromServices] AuthenticationService authenticationService, CancellationToken cancellationToken) { switch (binding.GrantType) { case GrantType.password: if (IsNullOrEmpty(binding.UserName)) { BadRequest(ErrorView.Build(O2AuthErrorCode.InvalidRequest, $"Field 'username' is required for '{GrantType.password}' grant type")); } if (IsNullOrEmpty(binding.Password)) { BadRequest(ErrorView.Build(O2AuthErrorCode.InvalidRequest, $"Field 'password' is required for '{GrantType.password}' grant type")); } try { var(accessToken, expiresIn, refreshToken) = await authenticationService.AuthenticationByPassword(binding.UserName, binding.Password, HttpContext.GetIp(), cancellationToken); return(Ok(new TokenView(accessToken, "Bearer", (Int64)expiresIn.TotalSeconds, refreshToken))); } catch (UnauthorizedException) { return(BadRequest(ErrorView.Build(O2AuthErrorCode.UnauthorizedClient, "Email or password is incorrect"))); } case GrantType.refresh_token: if (IsNullOrEmpty(binding.RefreshToken)) { BadRequest(ErrorView.Build(O2AuthErrorCode.InvalidRequest, $"Field 'refresh_token' is required for '{GrantType.refresh_token}' grant type")); } try { var(accessToken, expiresIn, refreshToken) = await authenticationService.AuthenticationByRefreshToken(binding.RefreshToken, HttpContext.GetIp(), cancellationToken); return(Ok(new TokenView(accessToken, "Bearer", (Int64)expiresIn.TotalSeconds, refreshToken))); } catch (UnauthorizedException) { return(BadRequest(ErrorView.Build(O2AuthErrorCode.UnauthorizedClient, "Refresh token is incorrect"))); } default: return(BadRequest(ErrorView.Build(O2AuthErrorCode.UnsupportedGrantType, $"Unsupported grant type: {binding.GrantType}."))); } }
// // GET: /Player/Login public ActionResult Login() { //Temp //if (_sessionHelper.Temp) //{ ErrorView err = new ErrorView(); return(View("Login", "_Master3", err)); //} //else // return RedirectToAction("Temp", "Home"); }
private static void CurrentDispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { Logger.Current.Error("CurrentDispatcher_UnhandledException", e.Exception); using (var form = new ErrorView(e.Exception, false)) { if (form.ShowDialog() == DialogResult.OK) { Application.Exit(); } } }
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { Logger.Current.Error("Application_ThreadException", e.Exception); using (var form = new ErrorView(e.Exception, false)) { if (form.ShowDialog() == DialogResult.OK) { Application.Exit(); } } }
// Description: Initializes Unity dependent variables // PRE: N/A // POST: Creates errorview to enable displaying errors, ArrayList disconnectedNodes is initialized void Awake() { _errorView = gameObject.AddComponent<ErrorView>(); _disconnectedNodes = new List<Node>(); }
private void Load(string page, bool push = true, bool forceInvalidation = false) { this.DoWork(() => { if (_errorView != null) { InvokeOnMainThread(delegate { _errorView.RemoveFromSuperview(); _errorView = null; }); } var url = RequestAndSave(page, forceInvalidation); var escapedUrl = Uri.EscapeUriString("file://" + url); var request = NSUrlRequest.FromUrl(new NSUrl(escapedUrl)); NSUrlCache.SharedCache.RemoveCachedResponse(request); InvokeOnMainThread(() => Web.LoadRequest(request)); }, ex => { if (_isVisible) Utilities.ShowAlert("Unable to Find Wiki Page", ex.Message); }); }