protected override void Save(object sender, EventArgs e) { DetailsViewModel dvm = Model as DetailsViewModel; AuthenticationObject authObj = dvm.DetailsObject as AuthenticationObject; try { dvm.Save(sender, e); if (dvm.Errors != null && dvm.Errors.HasErrors()) { return; } PersonInfo userInfo = dvm.ServiceProvider.GetService <IPersonService>().Read(authObj.EmailProperty.Value).Result; ClaimsIdentity ci = SecurityManager.CreateIdentity(AuthenticationTypes.Password, userInfo); Thread.CurrentPrincipal = new ClaimsPrincipal(ci); MainView.Start(); Close(); } catch (Exception ex) { ErrorParser ep = dvm.ServiceProvider.GetService <ErrorParser>(); ErrorList errors = ep.FromException(ex); ErrorPresenter.Show(errors); } }
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { if (System.Diagnostics.Debugger.IsAttached) { return; } e.Handled = true; ErrorPresenter.Show(e.ExceptionObject); }
public override void Execute(object parameter) { RavenJObject metadata; try { metadata = RavenJObject.Parse(editableDocumentModel.JsonMetadata); editableDocumentModel.JsonData = RavenJObject.Parse(editableDocumentModel.JsonData).ToString(Formatting.Indented); editableDocumentModel.JsonMetadata = metadata.ToString(Formatting.Indented); } catch (JsonReaderException ex) { ErrorPresenter.Show(ex.Message, string.Empty); return; } editableDocumentModel.UpdateMetadata(metadata); }
private void SaveDocument() { RavenJObject doc; RavenJObject metadata; try { doc = RavenJObject.Parse(document.JsonData); metadata = RavenJObject.Parse(document.JsonMetadata); if (document.Key != null && Seperator != null && metadata.Value <string>(Constants.RavenEntityName) == null) { var entityName = document.Key.Split(new[] { Seperator }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); if (entityName != null && entityName.Length > 1) { metadata[Constants.RavenEntityName] = char.ToUpper(entityName[0]) + entityName.Substring(1); } else { metadata[Constants.RavenEntityName] = entityName; } } } catch (JsonReaderException ex) { ErrorPresenter.Show(ex.Message); return; } document.UpdateMetadata(metadata); ApplicationModel.Current.AddNotification(new Notification("Saving document " + document.Key + " ...")); var url = new UrlParser(UrlUtil.Url); var docId = url.GetQueryParam("id"); Guid?etag = string.Equals(docId, document.Key, StringComparison.InvariantCultureIgnoreCase) ? document.Etag : Guid.Empty; DatabaseCommands.PutAsync(document.Key, etag, doc, metadata) .ContinueOnSuccess(result => { ApplicationModel.Current.AddNotification(new Notification("Document " + result.Key + " saved")); document.Etag = result.ETag; document.SetCurrentDocumentKey(result.Key, dontOpenNewTag: true); }) .ContinueOnSuccess(() => new RefreshDocumentCommand(document).Execute(null)) .Catch(exception => ApplicationModel.Current.AddNotification(new Notification(exception.Message))); }
private void SaveDocument() { RavenJObject doc; RavenJObject metadata; try { doc = RavenJObject.Parse(document.JsonData); metadata = RavenJObject.Parse(document.JsonMetadata); if (document.Key != null && document.Key.Contains("/") && metadata.Value <string>(Constants.RavenEntityName) == null) { var entityName = document.Key.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); if (entityName != null && entityName.Length > 1) { metadata[Constants.RavenEntityName] = char.ToUpper(entityName[0]) + entityName.Substring(1); } else { metadata[Constants.RavenEntityName] = entityName; } } } catch (JsonReaderException ex) { ErrorPresenter.Show(ex.Message, string.Empty); return; } document.UpdateMetadata(metadata); ApplicationModel.Current.AddNotification(new Notification("Saving document " + document.Key + " ...")); DatabaseCommands.PutAsync(document.Key, document.Etag, doc, metadata) .ContinueOnSuccess(result => { ApplicationModel.Current.AddNotification(new Notification("Document " + result.Key + " saved")); document.Etag = result.ETag; document.SetCurrentDocumentKey(result.Key); }) .ContinueOnSuccess(() => new RefreshDocumentCommand(document).Execute(null)) .Catch(exception => ApplicationModel.Current.AddNotification(new Notification(exception.Message))); }
protected override void Save(object sender, EventArgs e) { DetailsViewModel dvm = Model as DetailsViewModel; AuthenticationObject authObj = dvm.DetailsObject as AuthenticationObject; try { authObj.Validate(true); authObj.GetValidationErrors().AbortIfHasErrors(); WcfServices.Authenticate(authObj.EmailProperty.Value, authObj.PasswordProperty.Value); authObj.TrackModifications = false; // to prevent confirmation on closing of the login view MainView.Start(); Close(); } catch (Exception ex) { ErrorParser ep = dvm.ServiceProvider.GetService <ErrorParser>(); ErrorList errors = ep.FromException(ex); ErrorPresenter.Show(errors); } }
protected override async void Save(object sender, EventArgs e) { try { SaveButton.IsEnabled = false; var user = await Authenticate(); principalProvider.CurrentPrincipal = user; MainMenu.M_Sales_Visible = user.IsEmployee() || user.IsStoreContact() || user.IsIndividualCustomer(); MainView.Start(); Close(); } catch (Exception ex) { ErrorList errors = Model.ErrorParser.FromException(ex); ErrorPresenter.Show(errors); } finally { SaveButton.IsEnabled = true; } }
// If an error occurs during navigation, show an error window private void ContentFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) { e.Handled = true; ErrorPresenter.Show(e.Exception); }
// If an error occurs during navigation, show an error window private void ContentFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) { e.Handled = true; ErrorPresenter.Show(e.Exception, null, string.Format("Could not load page: {0}", e.Uri)); }