private bool ShouldIncludeBasedOnPageFields(CacheRecordNode cacheRecord) { // If the report does not have page fields then do not filter items. if (!this.PageFieldsItemsToInclude.Any()) { return(true); } // Map of indices into a cacheRecord to cacheRecordItem values. foreach (var keyValue in this.PageFieldsItemsToInclude) { int cacheRecordValue = int.Parse(cacheRecord.Items[keyValue.Key].Value); if (!keyValue.Value.Any(v => v == cacheRecordValue)) { return(false); } } return(true); }
/// <summary> /// Determines whether the cache record should be included as data /// or if it should be filtered out based on a page field or a hidden item. /// </summary> /// <param name="cacheRecord">The <see cref="CacheRecordNode"/>.</param> /// <returns>True if the record should be included, or false if the record should be filtered out.</returns> public bool ShouldInclude(CacheRecordNode cacheRecord) { return(this.ShouldIncludeBasedOnPageFields(cacheRecord) && this.ShouldIncludeBasedOnHiddenFields(cacheRecord)); }
private bool ShouldIncludeBasedOnHiddenFields(CacheRecordNode cacheRecord) { foreach (var entry in this.HiddenFieldItems) { int fieldIndex = entry.Key; var hiddenFieldItemIndicies = entry.Value; // Ignore data field tuples, group pivot field tuples and custom field subtotal settings. if (fieldIndex == -2 || fieldIndex == 1048832) { continue; } var cacheField = myCacheDefinition.CacheFields[fieldIndex]; if (cacheField.IsGroupField) { int baseFieldIndex = cacheField.FieldGroup.BaseField; var cacheRecordSharedItemIndex = int.Parse(cacheRecord.Items[baseFieldIndex].Value); if (cacheField.IsDateGrouping) { var sharedItem = myCacheDefinition.CacheFields[baseFieldIndex].SharedItems[cacheRecordSharedItemIndex]; if (string.IsNullOrEmpty(sharedItem.Value)) { return(false); } var dateTime = DateTime.Parse(sharedItem.Value); var groupByType = cacheField.FieldGroup.GroupBy; var groupKey = this.GetGroupKey(dateTime, groupByType); var groupItemIndex = cacheField.FieldGroup.GroupItems.ToList().FindIndex(i => i.Value.IsEquivalentTo(groupKey)); if (groupItemIndex >= 0 && hiddenFieldItemIndicies.Contains(groupItemIndex)) { return(false); } } else { var hiddenDiscretePrIndicies = new List <int>(); for (int i = 0; i < cacheField.FieldGroup.DiscreteGroupingProperties.Count; i++) { var discreteProperty = cacheField.FieldGroup.DiscreteGroupingProperties[i]; if (hiddenFieldItemIndicies.Contains(int.Parse(discreteProperty.Value))) { hiddenDiscretePrIndicies.Add(i); } } if (hiddenDiscretePrIndicies.Contains(cacheRecordSharedItemIndex)) { return(false); } } } else { var sharedItemsCollection = myCacheDefinition.CacheFields[fieldIndex].SharedItems; int cacheRecordSharedItemIndex = int.Parse(cacheRecord.Items[fieldIndex].Value); var cacheRecordValue = sharedItemsCollection[cacheRecordSharedItemIndex].Value; var hiddenSharedCacheItems = hiddenFieldItemIndicies.Select(i => sharedItemsCollection[i]); if (hiddenSharedCacheItems.Any(i => i.Value == cacheRecordValue)) { return(false); } } } return(true); }