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); } } }); }
private void ShowRoute() { Reset(); QueuedTask.Run(() => { using (var routesCursor = RoutesStandaloneTable.GetSelection().Search()) { routesCursor.MoveNext(); var routeID = (string)routesCursor.Current[RouteID]; if (SelectedRoute == routeID) { return; } SelectedRoute = routeID; SegmentsLayer.ClearSelection(); HeadsLayer.ClearSelection(); RouteToTrailSegmentsTable.ClearSelection(); var routeIDQuery = $"{RouteID} = '{routeID}'"; RouteToTrailSegmentsTable.Select(new QueryFilter() { WhereClause = routeIDQuery }); RouteToTrailheadsTable.Select(new QueryFilter() { WhereClause = routeIDQuery }); SegmentsLayer.Select(new QueryFilter() { WhereClause = $"{USNG_SEG} IN (SELECT {USNG_SEG} FROM UtahTrails.TRAILSADMIN.{RouteToTrailSegments}_evw WHERE {routeIDQuery})" }); HeadsLayer.Select(new QueryFilter() { WhereClause = $"{USNG_TH} IN (SELECT {USNG_TH} FROM UtahTrails.TRAILSADMIN.{RouteToTrailheads}_evw WHERE {routeIDQuery})" }); MapView.Active.ZoomToAsync(new [] { SegmentsLayer, HeadsLayer }, true); } }); }