/// <summary> /// Cancels any edits the user is making without saving changes /// </summary> internal void CancelEdits(PopupManager popupManager) { try { popupManager.CancelEditing(); } catch (Exception ex) { UserPromptMessenger.Instance.RaiseMessageValueChanged(null, ex.Message, true, ex.StackTrace); } }
/// <summary> /// Cancels any edits the user is making without saving changes /// </summary> internal void CancelEdits(PopupManager popupManager) { try { // the API throws a System.FormatException when an invalid value is present rather than discarding the value // this is a workaround to clear all values before canceling, until the issue is resolved in the API foreach (var field in popupManager.EditableDisplayFields) { if (field.ValidationError != null) { field.Value = field.OriginalValue; } } popupManager.CancelEditing(); } catch (Exception ex) { UserPromptMessenger.Instance.RaiseMessageValueChanged(null, ex.Message, true, ex.StackTrace); } }
/// <summary> /// Updates the condition and DBH for the selected tree /// This is only used for the Update tree condition custom workflow /// </summary> internal static async Task UpdateIdentifiedFeature(ObservableCollection <OriginRelationshipViewModel> originRelatedRecords, Feature feature, PopupManager popupManager) { // if the webmap used in the app is not the tree dataset map, this method will not work if (WebmapURL != TreeDatasetWebmapUrl) { return; } // if there are no inspections available, reset condition and dbh and save feature if (originRelatedRecords.Count == 0) { feature.Attributes[TreeConditionAttribute] = ""; feature.Attributes[TreeDBHAttribute] = null; try { await feature.FeatureTable.UpdateFeature(feature); await feature.FeatureTable.ApplyEdits(); } catch (Exception ex) { UserPromptMessenger.Instance.RaiseMessageValueChanged( Resources.GetString("ConditionDBH_UpdateError_Title"), ex.Message, true, ex.StackTrace); } return; } var OrderedOriginRelationshipCollection = originRelatedRecords.OrderByDescending(x => x.PopupManager.DisplayedFields.First().Value); var lastInspection = OrderedOriginRelationshipCollection.First(); // if the condition and dbh are still the same, do not update feature if (lastInspection.PopupManager.DisplayedFields.Where(x => x.Field.FieldName == InspectionConditionAttribute) == popupManager.DisplayedFields.Where(x => x.Field.FieldName == TreeConditionAttribute) && lastInspection.PopupManager.DisplayedFields.Where(x => x.Field.FieldName == InspectionDBHAttribute) == popupManager.DisplayedFields.Where(x => x.Field.FieldName == TreeDBHAttribute)) { return; } else { // set the new atributes // set the condition to empty string if user left it blank // set the dbh to 0 if user left it blank feature.Attributes[TreeConditionAttribute] = lastInspection.PopupManager.DisplayedFields.Where(x => x.Field.FieldName == InspectionConditionAttribute).First().Value ?? ""; feature.Attributes[TreeDBHAttribute] = lastInspection.PopupManager.DisplayedFields.Where(x => x.Field.FieldName == InspectionDBHAttribute).First().Value ?? 0f; try { await feature.FeatureTable.UpdateFeature(feature); await feature.FeatureTable.ApplyEdits(); } catch (Exception ex) { UserPromptMessenger.Instance.RaiseMessageValueChanged( Resources.GetString("ConditionDBH_UpdateError_Title"), ex.Message, true, ex.StackTrace); } // HACK to refresh the popup manager when non editable fields are edited try { if (!popupManager.IsEditing) { popupManager.StartEditing(); } await popupManager.FinishEditingAsync(); } catch { popupManager.CancelEditing(); } } }