private void UpdateGroupedIndexList(DatabaseStatistics statistics) { var indexes = statistics.Indexes; var currentSelection = ItemSelection.GetSelectedItems().Select(i => i.Name).ToHashSet(); var indexGroups = from index in indexes let groupDetails = GetIndexGroup(index.Name) let indexGroup = groupDetails.Item1 let indexOrder = groupDetails.Item2 orderby indexOrder group index by indexGroup; var indexesAndGroupHeaders = indexGroups.SelectMany(group => new IndexListItem[] { new IndexGroupHeader { Name = group.Key } } .Concat(group.Select(index => new IndexItem { Name = index.Name, IndexStats = index }))); GroupedIndexes.Clear(); GroupedIndexes.AddRange(indexesAndGroupHeaders.ToList()); var selection = GroupedIndexes.OfType <IndexItem>().Where(i => currentSelection.Contains(i.Name)); ItemSelection.SetDesiredSelection(selection); }
private void UpdateGroupedIndexList(DatabaseStatistics statistics) { Indexes.Clear(); if (string.IsNullOrWhiteSpace(SearchText.Value)) { Indexes.AddRange(statistics.Indexes.Where(stats => stats != null) .Select(stats => new IndexItem { Name = stats.Name, GroupName = GetIndexGroup(stats), IndexStats = stats })); } else { Indexes.AddRange(statistics.Indexes .Where(stats => stats != null && stats.Name.IndexOf(SearchText.Value, StringComparison.InvariantCultureIgnoreCase) != -1) .Select(stats => new IndexItem { Name = stats.Name, GroupName = GetIndexGroup(stats), IndexStats = stats })); } CleanGroupIndexes(); foreach (var indexItem in Indexes) { var groupItem = GroupedIndexes.FirstOrDefault(@group => string.Equals(@group.GroupName, indexItem.GroupName, StringComparison.OrdinalIgnoreCase)); if (groupItem == null) { groupItem = new Group(indexItem.GroupName); GroupedIndexes.Add(groupItem); } groupItem.Items.Add(indexItem); } OnPropertyChanged(() => GroupedIndexes); }
private void CleanGroupIndexes() { if (currentDatabase != ApplicationModel.Database.Value.Name || currentSearch != SearchText.Value) { currentDatabase = ApplicationModel.Database.Value.Name; currentSearch = SearchText.Value; GroupedIndexes.Clear(); return; } foreach (var groupedIndex in GroupedIndexes) { groupedIndex.Items.Clear(); } }
private void UpdateGroupedIndexList(DatabaseStatistics statistics) { Indexes.Clear(); Indexes.AddRange(statistics.Indexes.Select(stats => new IndexItem { Name = stats.Name, GroupName = GetIndexGroup(stats), IndexStats = stats })); CleanGroupIndexes(); foreach (var indexItem in Indexes) { var groupItem = GroupedIndexes.FirstOrDefault(@group => string.Equals(@group.GroupName, indexItem.GroupName, StringComparison.OrdinalIgnoreCase)); if (groupItem == null) { groupItem = new Group(indexItem.GroupName); GroupedIndexes.Add(groupItem); } groupItem.Items.Add(indexItem); } OnPropertyChanged(() => GroupedIndexes); }
public List <IndexListItem> IndexesOfPriority(string deleteItems) { if (deleteItems == "All") { return(GroupedIndexes.ToList()); } if (deleteItems == "Idle") { return (GroupedIndexes.Where( item => item is IndexItem && ((IndexItem)item).IndexStats.Priority.HasFlag(IndexingPriority.Idle)).ToList()); } if (deleteItems == "Disabled") { return(GroupedIndexes.Where(item => item is IndexItem && ((IndexItem)item).IndexStats.Priority.HasFlag(IndexingPriority.Disabled)).ToList()); } if (deleteItems == "Abandoned") { return(GroupedIndexes.Where(item => item is IndexItem && ((IndexItem)item).IndexStats.Priority.HasFlag(IndexingPriority.Abandoned)).ToList()); } return(null); }