private static void OnPositionEstimatesSaved(IAsyncResult result) { bool errorOccured = false; radiomapEntities context = result.AsyncState as radiomapEntities; try { // Complete the save changes operation and display the response. DataServiceResponse response = context.EndSaveChanges(result); foreach (ChangeOperationResponse changeResponse in response) { if (changeResponse.Error != null) { errorOccured = true; } } if (!errorOccured) { //Maybe raise success event? } } catch (Exception ex) { Exception exCopy = ex; } }
private void OnChangesSaved(IAsyncResult result) { bool errorOccured = false; // Use the Dispatcher to ensure that the // asynchronous call returns in the correct thread. Dispatcher.BeginInvoke(() => { isUploading = false; uploadProgressIndicator.IsVisible = isUploading; mContext = result.AsyncState as radiomapEntities; try { // Complete the save changes operation and display the response. DataServiceResponse response = mContext.EndSaveChanges(result); foreach (ChangeOperationResponse changeResponse in response) { if (changeResponse.Error != null) errorOccured = true; } if (!errorOccured) { Globals.ShowDialog(this, Globals.CHANGES_SAVED, Globals.DURATION_SHORT); //Finalize edge, i.e., add it to the endpoint's edges and to the building /* Building b = LocationService.CurrentBuilding; b.Edges.Add(mCurrentEdge); foreach (Vertex v in mCurrentEdge.Vertices) { if (!v.Edges.Contains(mCurrentEdge)) v.Edges.Add(mCurrentEdge); } */ NavigationService.GoBack(); //Tell everyone the good news! if (OnEdgeAdded != null) { OnEdgeAdded(this, EventArgs.Empty); } } else { MessageBox.Show("An error occured. One or more changes could not be saved."); } } catch (Exception ex) { // Display the error from the response. string errorMsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; MessageBox.Show(string.Format("The following error occured: {0}", errorMsg)); } } ); }
private void OnChangesSaved(IAsyncResult result) { bool errorOccured = false; // Use the Dispatcher to ensure that the // asynchronous call returns in the correct thread. Dispatcher.BeginInvoke(() => { isUploading = false; uploadProgressIndicator.IsVisible = isUploading; mContext = result.AsyncState as radiomapEntities; try { // Complete the save changes operation and display the response. DataServiceResponse response = mContext.EndSaveChanges(result); foreach (ChangeOperationResponse changeResponse in response) { if (changeResponse.Error != null) { errorOccured = true; } } if (!errorOccured) { Globals.ShowDialog(this, Globals.CHANGES_SAVED, Globals.DURATION_SHORT); NavigationService.GoBack(); if (OnSymbolicLocationChange != null) { OnSymbolicLocationChange(this, null); } } else { MessageBox.Show("An error occured. One or more changes could not be saved."); } } catch (Exception ex) { // Display the error from the response. MessageBox.Show(string.Format("The following error occured: {0}", ex.Message)); } } ); }