public ActionResult Index(GenerateErrorPostModel postModel) { var model = new GenerateErrorViewModel { Applications = Core.GetApplications().Items.ToSelectList(a => a.Token, a => a.Name, a => a.FriendlyId == postModel.Token), Errors = GenerateErrorViewModel.GetErrors(postModel.ErrorId), }; model.Token = model.Applications.First().Value; model.ErrorId = model.Errors.First().Value; model.Json = JsonConvert.SerializeObject(GetClientError(model.ErrorId, model.Token), Formatting.Indented); return(View(model)); }
public ActionResult GenerateError(GenerateErrorPostModel model) { var clientError = JsonConvert.DeserializeObject <ClientError>(model.Json); var response = _getApplicationByTokenQuery.Invoke(new GetApplicationByTokenRequest { Token = clientError.Token, CurrentUser = Errordite.Core.Domain.Organisation.User.System() }); if (response.Status != ApplicationStatus.Ok) { ErrorNotification("Failed to locate application from token, please check the token and try again"); return(RedirectToAction("index")); } var error = clientError.GetError(response.Application); var success = false; ReceiveErrorResponse receiveErrorResponse = null; //try and generate the error 3 times, to catch any concurrency errors if lots of users are generating test errors at the same time for (int i = 0; i < 3; i++) { try { receiveErrorResponse = Generate(error, response.Application); success = true; break; } catch {} } if (success) { ConfirmationNotification(new MvcHtmlString("Test error generated - attached to issue <a href='{0}'>{1}</a>".FormatWith( Url.Issue(IdHelper.GetFriendlyId(receiveErrorResponse.IssueId)), IdHelper.GetFriendlyId(receiveErrorResponse.IssueId)))); } else { ErrorNotification("Failed to generate error, please try again."); } return(RedirectToAction("index")); }