internal void OnDeleteRouteButtonClick() { QueuedTask.Run(() => { using (var cursor = RoutesStandaloneTable.GetSelection().Search(null)) { var operation = new EditOperation(); cursor.MoveNext(); var routeRow = cursor.Current; string routeID = (string)routeRow[RouteID]; string routeName = (string)routeRow[RouteName]; operation.Name = $"Delete route: {routeName}"; operation.Delete(RoutesStandaloneTable, routeRow.GetObjectID()); var query = new QueryFilter() { WhereClause = $"{RouteID} = '{routeID}'" }; using (var segsCursor = RouteToTrailSegmentsTable.Search(query)) using (var headsCursor = RouteToTrailheadsTable.Search(query)) { while (segsCursor.MoveNext()) { operation.Delete(RouteToTrailSegmentsTable, segsCursor.Current.GetObjectID()); } while (headsCursor.MoveNext()) { operation.Delete(RouteToTrailheadsTable, headsCursor.Current.GetObjectID()); } } operation.Execute(); if (operation.IsSucceeded) { Notification notification = new Notification(); notification.Title = FrameworkApplication.Title; notification.Message = $"Route: \"{routeName}\" deleted successfully!"; FrameworkApplication.AddNotification(notification); RoutesStandaloneTable.ClearSelection(); } else { MessageBox.Show(operation.ErrorMessage); } } }); }
/// <summary> /// This model class validates the selected features in a map. /// </summary> /// <param name="map">The map to validate</param> /// <returns></returns> public static Task <string> ValidateMap(Map map) { return(QueuedTask.Run <string>(() => { StringBuilder validationStringBuilder = new StringBuilder(); // Get the selection from the map Dictionary <MapMember, List <long> > mapMembersWithSelection = map.GetSelection(); // Step through each MapMember (FeatureLayer or StandaloneTable) that contains selected features foreach (KeyValuePair <MapMember, List <long> > dictionaryItem in mapMembersWithSelection) { if (dictionaryItem.Key is FeatureLayer) { FeatureLayer featureLayer = dictionaryItem.Key as FeatureLayer; using (Table table = featureLayer.GetTable()) { validationStringBuilder.Append(ValidateTable(table, featureLayer.GetSelection())); } } else if (dictionaryItem.Key is StandaloneTable) { StandaloneTable standaloneTable = dictionaryItem.Key as StandaloneTable; using (Table table = standaloneTable.GetTable()) { validationStringBuilder.Append(ValidateTable(table, standaloneTable.GetSelection())); } } } return validationStringBuilder.ToString(); })); }