Пример #1
0
 /// <summary>
 /// Creates a flat representation of the hierarchy starting with the specifed element.
 /// </summary>
 /// <param name="element">The element to make flat.</param>
 /// <param name="collection">The collection that will store the flat elements.</param>
 /// <param name="type">An element type to specifiy which elements to get.</param>
 private void MakeFlat(OlapElement element, OlapElements collection, OlapElementType type)
 {
     for (int i = 0; i < element.AllChildren.Count; i++)
     {
         OlapElement element1 = element.AllChildren[i];
         if (element1.ElementInformation.ElementType == type)
         {
             collection.Collection.Add(element1);
         }
         MakeFlat(element1, collection, type);
     }
 }
 /// <summary>
 /// Initializes a new instance of the OlapElementInformation class.
 /// </summary>
 /// <param name="elementType">The type of the element.</param>
 /// <param name="parentCount">The number of parent elements.</param>
 /// <param name="childCount">The number of child elements.</param>
 public OlapElementInformation(OlapElementType elementType, int parentCount, int childCount)
 {
     _elementType = elementType;
     _parentCount = parentCount;
     _childCount  = childCount;
 }
Пример #3
0
        /// <summary>
        /// Gets the elements of the collection and all its children as flat collection.
        /// </summary>
        /// <param name="type">An element type to specifiy which elements to get.</param>
        /// <returns>All elements and their children store in this collection that have
        /// the specified type.</returns>
        public OlapElements FlatHierarchy(OlapElementType type)
        {
            OlapElements flatElements = null;

            Load();

            // if this collection includes all elements, making it flat means put all elements
            // into the result and filter by type in addition.
            if (_elementsLevel == OlapElementsLevel.OlapElementsLevelAll)
            {
                flatElements = new OlapElements(_dimension, null, OlapElementsLevel.OlapElementsLevelFlat);
                flatElements.IgnorePermissionsForChildren = true;
                flatElements.Initialized = true;
                flatElements.Invalid     = false;
                for (int i = 0; i < Collection.Count; i++)
                {
                    OlapElement element = Collection[i];
                    if (type == element.ElementInformation.ElementType)
                    {
                        flatElements.Collection.Add(element);
                    }
                }
            }
            else
            {
                flatElements = new OlapElements(_dimension, _element, OlapElementsLevel.OlapElementsLevelFlat);
                flatElements.IgnorePermissionsForChildren = true;
                flatElements.Initialized = true;
                flatElements.Invalid     = false;
                for (int i = 0; i < Collection.Count; i++)
                {
                    OlapElement element = Collection[i];
                    if (element.ElementInformation.ElementType == type)
                    {
                        flatElements.Collection.Add(element);
                    }
                    MakeFlat(element, flatElements, type);
                }
            }

            OlapElements result = null;

            result = new OlapElements(_dimension, null, OlapElementsLevel.OlapElementsLevelFlat);
            result.IgnorePermissionsForChildren = true;
            result.Initialized = true;
            result.Invalid     = false;

            for (int i = 0; i < flatElements.Count; i++)
            {
                if (flatElements[i].CanAccess)
                {
                    OlapElement element = flatElements[i];
                    if (!result.Collection.Contains(element))
                    {
                        result.Collection.Add(element);
                    }
                }
            }

            return(result);
        }
Пример #4
0
 /// <summary>
 /// Gets the all child elements as flat collection.
 /// </summary>
 /// <param name="type">An element type to specifiy which elements to get.</param>
 /// <returns>All children that have the specified type.</returns>
 public OlapElements ChildrenFlatHierarchy(OlapElementType type)
 {
     return(AllChildren.FlatHierarchy(type));
 }