Пример #1
0
 public ADOTabularColumn( ADOTabularTable table, string internalReference, string name, string caption,  string description,
                         bool isVisible, ADOTabularColumnType columnType, string contents)
 {
     Table = table;
     InternalReference = internalReference;
     Name = name ?? internalReference;
     Caption = caption ?? internalReference ?? name;
     Description = description;
     IsVisible = isVisible;
     ColumnType = columnType;
     Contents = contents;
 }
Пример #2
0
        public ADOTabularColumnCollection(IADOTabularConnection adoTabConn, ADOTabularTable table)
        {
            Contract.Requires(adoTabConn != null, "The adoTabConn parameter must not be null");

            Table       = table;
            _adoTabConn = adoTabConn;
            if (_cols == null)
            {
                _cols = _adoTabConn.Visitor.Visit(this);
            }
            _colsByRef = new SortedDictionary <string, ADOTabularColumn>();
        }
Пример #3
0
        private ADOTabularTable BuildTableFromEntitySet(XmlReader rdr, string eEntitySet)
        {
            string caption     = null;
            string description = "";
            string refname     = null;
            bool   isVisible   = true;
            string name        = null;

            while (!(rdr.NodeType == XmlNodeType.EndElement &&
                     rdr.LocalName == eEntitySet))
            {
                while (rdr.MoveToNextAttribute())
                {
                    switch (rdr.LocalName)
                    {
                    case "ReferenceName":
                        name = rdr.Value;
                        break;

                    case "Caption":
                        caption = rdr.Value;
                        break;

                    case "Description":
                        description = rdr.Value;
                        break;

                    case "Hidden":
                        isVisible = !bool.Parse(rdr.Value);
                        break;

                    case "Name":
                        refname = rdr.Value;
                        break;
                    }
                }
                rdr.Read();
            }

            // the names of the properties in the CSDL metadata are somewhat confusing
            // Name           - cannot contain spaces and is used for internally referencing
            //                - maps to InternalReference in ADOTabular
            // Reference Name - this is the name used by DAX queries/expressions
            //                - will be blank if Name does not contain spaces
            //                - if this is missing the Name property is used
            // Caption        - this is what the end user sees (may be translated)
            //                - if this is missing the Name property is used
            var tab = new ADOTabularTable(_conn, refname, name, caption, description, isVisible);

            return(tab);
        }
        public ADOTabularMeasureCollection(IADOTabularConnection adoTabConn, ADOTabularTable table)
        {
            _table = table;
            if (adoTabConn == null)
            {
                throw new ArgumentNullException(nameof(adoTabConn));
            }
            _adoTabConn = adoTabConn;

            if (_measures == null)
            {
                _measures = _adoTabConn.Visitor.Visit(this);
            }
        }
Пример #5
0
        // TODO - can we delete this??
        //public ADOTabularColumn(ADOTabularTable table, DataRow dr, ADOTabularObjectType colType)
        //{
        //    Table = table;
        //    ObjectType = colType;
        //    if (colType == ADOTabularObjectType.Column)
        //    {
        //        Caption = dr["HIERARCHY_CAPTION"].ToString();
        //        Name = dr["HIERARCHY_NAME"].ToString();
        //        IsVisible = bool.Parse(dr["HIERARCHY_IS_VISIBLE"].ToString());
        //        Description = dr["DESCRIPTION"].ToString();
        //    }
        //    else
        //    {
        //        Caption = dr["MEASURE_CAPTION"].ToString();
        //        Name = dr["MEASURE_NAME"].ToString();
        //        IsVisible = bool.Parse(dr["MEASURE_IS_VISIBLE"].ToString());
        //        Description = dr["DESCRIPTION"].ToString();
        //    }
        //}

        public ADOTabularColumn(ADOTabularTable table, string internalReference, string name, string caption, string description,
                                bool isVisible, ADOTabularObjectType columnType, string contents)
        {
            Table             = table;
            InternalReference = internalReference;
            Name        = name ?? internalReference;
            Caption     = caption ?? internalReference ?? name;
            Description = description;
            IsVisible   = isVisible;
            ObjectType  = columnType;
            Contents    = contents;
            Role        = $"{Table.InternalReference}_{InternalReference}";
            Variations  = new List <ADOTabularVariation>();
        }
Пример #6
0
        public ADOTabularColumn(ADOTabularTable table, string internalReference, string name, string caption, string description,
                                bool isVisible, ADOTabularObjectType columnType, string contents)
        {
            Contract.Requires(table != null, "The table parameter must not be null");

            Table             = table;
            InternalReference = internalReference;
            Name        = name ?? internalReference;
            Caption     = caption ?? internalReference ?? name;
            Description = description;
            IsVisible   = isVisible;
            ObjectType  = columnType;
            Contents    = contents;
            Role        = $"{Table.InternalReference}_{InternalReference}";
            Variations  = new List <ADOTabularVariation>();
        }
 public ADOTabularHierarchy(ADOTabularTable table, string internalName, string name, string caption, string description,
                            bool isVisible, ADOTabularObjectType columnType, string contents, string structure)
     : base(table, internalName, name, caption, description, isVisible, columnType, contents)
 {
     _levels    = new List <ADOTabularLevel>();
     _structure = structure;
     if (structure == "Unnatural")
     {
         if (description.Length > 0)
         {
             Description += '\n';
         }
         Description += "WARNING: Unnatural Hierarchy - may have a negative performance impact";
         ObjectType   = ADOTabularObjectType.UnnaturalHierarchy;
     }
 }
Пример #8
0
 public ADOTabularColumn(ADOTabularTable table, DataRow dr, ADOTabularColumnType colType)
 {
     Table      = table;
     ColumnType = colType;
     if (colType == ADOTabularColumnType.Column)
     {
         Caption     = dr["HIERARCHY_CAPTION"].ToString();
         Name        = dr["HIERARCHY_NAME"].ToString();
         IsVisible   = bool.Parse(dr["HIERARCHY_IS_VISIBLE"].ToString());
         Description = dr["DESCRIPTION"].ToString();
     }
     else
     {
         Caption     = dr["MEASURE_CAPTION"].ToString();
         Name        = dr["MEASURE_NAME"].ToString();
         IsVisible   = bool.Parse(dr["MEASURE_IS_VISIBLE"].ToString());
         Description = dr["DESCRIPTION"].ToString();
     }
 }
Пример #9
0
 public ADOTabularColumn(ADOTabularTable table, DataRow dr, ADOTabularColumnType colType)
 {
     Table = table;
     ColumnType = colType;
     if (colType == ADOTabularColumnType.Column)
     {
         Caption = dr["HIERARCHY_CAPTION"].ToString();
         Name = dr["HIERARCHY_NAME"].ToString();
         IsVisible = bool.Parse(dr["HIERARCHY_IS_VISIBLE"].ToString());
         Description = dr["DESCRIPTION"].ToString();
     }
     else
     {
         Caption = dr["MEASURE_CAPTION"].ToString();
         Name = dr["MEASURE_NAME"].ToString();
         IsVisible = bool.Parse(dr["MEASURE_IS_VISIBLE"].ToString());
         Description = dr["DESCRIPTION"].ToString();
     }
 }
Пример #10
0
        private string GetHierarchStructure(ADOTabularTable table, string hierName, string hierCap)
        {
            if (_hierStructure == null)
            {
                return("");
            }
            if (_hierStructure.Count == 0)
            {
                return("");
            }
            if (!_hierStructure.ContainsKey(table.Caption))
            {
                return("");
            }
            if (!_hierStructure[table.Caption].ContainsKey(hierCap ?? hierName))
            {
                return("");
            }

            return(_hierStructure[table.Caption][hierCap ?? hierName]);
        }
Пример #11
0
        public ADOTabularColumn(ADOTabularTable table, string internalReference, string name, string caption, string description,
                                bool isVisible, ADOTabularObjectType columnType, string contents)
        {
            Contract.Requires(table != null, "The table parameter must not be null");

            Table             = table;
            InternalReference = internalReference;
            Name        = name ?? internalReference;
            Caption     = caption ?? internalReference ?? name;
            Description = description;
            IsVisible   = isVisible;
            ObjectType  = columnType;
            Contents    = contents;
            Role        = $"{Table.InternalReference}_{InternalReference}";
            Variations  = new List <ADOTabularVariation>();
            // tag measures that return the formatString for a calculation group
            if (columnType == ADOTabularObjectType.Measure && name == $"_{caption} FormatString")
            {
                ObjectType = ADOTabularObjectType.MeasureFormatString;
                Caption   += " (FormatString)";
            }
        }
Пример #12
0
 public ADOTabularKpi(ADOTabularTable table, string internalName, string name, string caption, string description,
                      bool isVisible, ADOTabularObjectType columnType, string contents, KpiDetails kpi)
     : base(table, internalName, name, caption, description, isVisible, columnType, contents)
 {
     _kpi = kpi;
 }
Пример #13
0
        private void ProcessHierarchy(XmlReader rdr, ADOTabularTable table, string eEntityType)
        {
            var    hierName          = "";
            string hierCap           = null;
            var    hierHidden        = false;
            ADOTabularHierarchy hier = null;
            ADOTabularLevel     lvl  = null;
            string lvlName           = "";
            string lvlCaption        = "";
            string lvlRef            = "";

            while (!(rdr.NodeType == XmlNodeType.EndElement &&
                     rdr.LocalName == "Hierarchy"))
            {
                if (rdr.NodeType == XmlNodeType.Element &&
                    rdr.LocalName == "Hierarchy")
                {
                    while (rdr.MoveToNextAttribute())
                    {
                        switch (rdr.LocalName)
                        {
                        case "Hidden":
                            hierHidden = bool.Parse(rdr.Value);
                            break;

                        case "Name":
                            hierName = rdr.Value;
                            break;

                        case "Caption":
                            hierCap = rdr.Value;
                            break;
                        }
                    }
                    string structure = GetHierarchStructure(table, hierName, hierCap);
                    hier = new ADOTabularHierarchy(table, hierName, hierName, hierCap ?? hierName, "", hierHidden, ADOTabularObjectType.Hierarchy, "", structure);
                    table.Columns.Add(hier);
                    rdr.Read();
                }

                while (!(rdr.NodeType == XmlNodeType.EndElement &&
                         rdr.LocalName == "Level"))
                {
                    if ((rdr.NodeType == XmlNodeType.Element) &&
                        (rdr.LocalName == "Level"))
                    {
                        while (rdr.MoveToNextAttribute())
                        {
                            switch (rdr.LocalName)
                            {
                            case "Name":
                                lvlName = rdr.Value;
                                break;

                            case "Caption":
                                lvlCaption = rdr.Value;
                                break;
                            }
                        }
                    }

                    if ((rdr.NodeType == XmlNodeType.Element) &&
                        (rdr.LocalName == "PropertyRef"))
                    {
                        while (rdr.MoveToNextAttribute())
                        {
                            switch (rdr.LocalName)
                            {
                            case "Name":
                                lvlRef = rdr.Value;
                                break;
                            }
                        }
                    }

                    rdr.Read();
                } //End of Level

                lvl           = new ADOTabularLevel(table.Columns.GetByPropertyRef(lvlRef));
                lvl.LevelName = lvlName;
                lvl.Caption   = lvlCaption;
                hier.Levels.Add(lvl);
                lvlName    = "";
                lvlCaption = "";
                lvlRef     = "";
                while (true)
                {
                    if (rdr.NodeType == XmlNodeType.Element && rdr.LocalName == "Level")
                    {
                        break;
                    }
                    if (rdr.NodeType == XmlNodeType.EndElement && rdr.LocalName == "Hierarchy")
                    {
                        break;
                    }
                    rdr.Read();
                }
            }
        }
Пример #14
0
        private KpiDetails ProcessKpi(XmlReader rdr, ADOTabularTable table)
        {
            KpiDetails kpi = new KpiDetails();

            while (!(rdr.NodeType == XmlNodeType.EndElement &&
                     rdr.LocalName == "Kpi"))
            {
                while (rdr.MoveToNextAttribute())
                {
                    if (rdr.LocalName == "StatusGraphic")
                    {
                        kpi.Graphic = rdr.Value;
                    }
                }
                if (rdr.NodeType == XmlNodeType.Element &&
                    rdr.LocalName == "KpiGoal")
                {
                    while (!(rdr.NodeType == XmlNodeType.EndElement &&
                             rdr.LocalName == "KpiGoal"))
                    {
                        if (rdr.NodeType == XmlNodeType.Element &&
                            rdr.LocalName == "PropertyRef")
                        {
                            while (rdr.MoveToNextAttribute())
                            {
                                if (rdr.LocalName == "Name")
                                {
                                    kpi.Goal = rdr.Value;
                                }
                            }
                        }
                        rdr.Read();
                    }
                }


                if (rdr.NodeType == XmlNodeType.Element &&
                    rdr.LocalName == "KpiStatus")
                {
                    while (!(rdr.NodeType == XmlNodeType.EndElement &&
                             rdr.LocalName == "KpiStatus"))
                    {
                        if (rdr.NodeType == XmlNodeType.Element &&
                            rdr.LocalName == "PropertyRef")
                        {
                            while (rdr.MoveToNextAttribute())
                            {
                                if (rdr.LocalName == "Name")
                                {
                                    kpi.Status = rdr.Value;
                                }
                            }
                        }
                        rdr.Read();
                    }
                }

                rdr.Read();
            }
            return(kpi);
        }
Пример #15
0
        private void ProcessDiplayFolder(XmlReader rdr, ADOTabularTable aDOTabularTable)
        {
            var    folderName = "";
            string folderCap  = null;
            string objRef     = "";

            while (!(rdr.NodeType == XmlNodeType.EndElement &&
                     rdr.LocalName == "DisplayFolder"))
            {
                if (rdr.NodeType == XmlNodeType.Element &&
                    rdr.LocalName == "DisplayFolder")
                {
                    while (rdr.MoveToNextAttribute())
                    {
                        switch (rdr.LocalName)
                        {
                        case "Name":
                            folderName = rdr.Value;
                            break;

                        case "Caption":
                            folderCap = rdr.Value;
                            break;
                        }
                    }
                    rdr.Read();
                }

                while (rdr.NodeType != XmlNodeType.Element && rdr.NodeType != XmlNodeType.EndElement)
                {
                    rdr.Read();
                }

                if ((rdr.NodeType == XmlNodeType.Element) &&
                    (rdr.LocalName == "PropertyRef"))
                {
                    while (rdr.MoveToNextAttribute())
                    {
                        switch (rdr.LocalName)
                        {
                        case "Name":
                            objRef = rdr.Value;
                            break;
                        }
                    }

                    var tabularObj = aDOTabularTable.Columns.GetByPropertyRef(objRef);
                    tabularObj.DisplayFolder = folderCap;
                    objRef = "";
                }

                if (rdr.NodeType == XmlNodeType.EndElement && rdr.LocalName == "DisplayFolder")
                {
                    break;
                }
                rdr.Read();

                //while (true)
                //{
                //if (rdr.NodeType == XmlNodeType.Element && rdr.LocalName == "Level") break;
                //    if (rdr.NodeType == XmlNodeType.EndElement && rdr.LocalName == "DisplayFolder") break;
                //    rdr.Read();
                //}
            }
        }
Пример #16
0
        private void ProcessDisplayFolder(XmlReader rdr, ADOTabularTable table, IADOTabularFolderReference parent)
        {
            var    folderReference = "";
            string folderCaption   = null;
            string objRef          = "";

            while (!(rdr.NodeType == XmlNodeType.EndElement &&
                     rdr.LocalName == "DisplayFolder"))
            {
                if (rdr.NodeType == XmlNodeType.Element &&
                    rdr.LocalName == "DisplayFolder")
                {
                    while (rdr.MoveToNextAttribute())
                    {
                        switch (rdr.LocalName)
                        {
                        case "Name":
                            folderReference = rdr.Value;
                            break;

                        case "Caption":
                            folderCaption = rdr.Value;
                            break;
                        }
                    }
                    // create folder and add to parent's folders
                    IADOTabularFolderReference folder = new ADOTabularDisplayFolder(folderCaption, folderReference);
                    parent.FolderItems.Add(folder);

                    rdr.ReadToNextElement();

                    // recurse down to child items
                    ProcessDisplayFolder(rdr, table, folder);
                    rdr.Read();
                    //rdr.ReadToNextElement(); // read the end element
                }

                // Reset DisplayFolder local variables
                folderCaption   = null;
                folderReference = String.Empty;

                if ((rdr.NodeType == XmlNodeType.Element) &&
                    (rdr.LocalName == "PropertyRef" ||
                     rdr.LocalName == "HierarchyRef"
                    ))
                {
                    while (rdr.MoveToNextAttribute())
                    {
                        switch (rdr.LocalName)
                        {
                        case "Name":
                            objRef = rdr.Value;
                            break;
                        }
                    }

                    // create reference object
                    IADOTabularObjectReference reference = new ADOTabularObjectReference("", objRef);
                    parent.FolderItems.Add(reference);
                    var column = table.Columns.GetByPropertyRef(objRef);
                    if (column != null)
                    {
                        column.IsInDisplayFolder = true;
                    }
                    objRef = "";

                    rdr.Read();
                }

                if ((rdr.LocalName != "DisplayFolder" && rdr.LocalName != "PropertyRef" && rdr.LocalName != "DisplaFolders"))

                {
                    if (rdr.NodeType != XmlNodeType.Element && rdr.NodeType != XmlNodeType.EndElement)
                    {
                        rdr.ReadToNextElement();
                    }
                    //else
                    //    rdr.Read();
                }

                if (rdr.NodeType == XmlNodeType.EndElement && rdr.LocalName == "DisplayFolders")
                {
                    rdr.Read();
                    break;
                }

                //rdr.Read();
            }
        }
Пример #17
0
        private void ProcessHierarchy(XmlReader rdr, ADOTabularTable table,string eEntityType)
        {
            var hierName = "";
            string hierCap = null;
            var hierHidden = false;
            ADOTabularHierarchy hier = null;
            ADOTabularLevel lvl = null;
            string lvlName = "";
            string lvlCaption = "";
            string lvlRef = "";

            while (!(rdr.NodeType == XmlNodeType.EndElement
                    && rdr.LocalName == "Hierarchy"))
            {
                if (rdr.NodeType == XmlNodeType.Element
                    && rdr.LocalName == "Hierarchy")
                {
                    while (rdr.MoveToNextAttribute())
                    {
                        switch (rdr.LocalName)
                        {
                            case "Hidden":
                                hierHidden = bool.Parse(rdr.Value);
                                break;
                            case "Name":
                                hierName = rdr.Value;
                                break;
                            case "Caption":
                                hierCap = rdr.Value;
                                break;
                        }
                    }
                    hier = new ADOTabularHierarchy(table, hierName, hierName, hierCap ?? hierName, "", hierHidden, ADOTabularColumnType.Hierarchy, "", _hierStructure[table.Caption][hierCap ?? hierName]);
                    table.Columns.Add(hier);
                    rdr.Read();
                }

                while (!(rdr.NodeType == XmlNodeType.EndElement
                    && rdr.LocalName == "Level"))
                {
                    if ((rdr.NodeType == XmlNodeType.Element)
                        && (rdr.LocalName == "Level"))
                    {
                        while (rdr.MoveToNextAttribute())
                        {
                            switch (rdr.LocalName)
                            {
                                case "Name":
                                    lvlName = rdr.Value;
                                    break;
                                case "Caption":
                                    lvlCaption = rdr.Value;
                                    break;
                            }
                        }
                    }

                    if ((rdr.NodeType == XmlNodeType.Element)
                        && (rdr.LocalName == "PropertyRef"))
                    {
                        while (rdr.MoveToNextAttribute())
                        {
                            switch (rdr.LocalName)
                            {
                                case "Name":
                                    lvlRef = rdr.Value;
                                    break;
                            }
                        }
                    }

                    rdr.Read();
                } //End of Level

                lvl = new ADOTabularLevel(table.Columns.GetByPropertyRef(lvlRef));
                lvl.LevelName = lvlName;
                lvl.Caption = lvlCaption;
                hier.Levels.Add(lvl);
                lvlName = "";
                lvlCaption = "";
                lvlRef = "";
                while ( true )
                {
                    if (rdr.NodeType == XmlNodeType.Element && rdr.LocalName == "Level") break;
                    if (rdr.NodeType == XmlNodeType.EndElement && rdr.LocalName == "Hierarchy") break;
                    rdr.Read();
                }
            }
        }
Пример #18
0
        public ADOTabularStandardColumn(ADOTabularTable table, string internalName, string name, string caption, string description,
                                        bool isVisible, ADOTabularColumnType columnType, string contents)
            : base(table, internalName, name, caption, description, isVisible, columnType, contents)

        {
        }
Пример #19
0
        private void AddColumnsToTable(XmlReader rdr
                                       , ADOTabularTableCollection tables
                                       , string eEntityType)
        {
            var eProperty   = rdr.NameTable.Add("Property");
            var eMeasure    = rdr.NameTable.Add("Measure");
            var eSummary    = rdr.NameTable.Add("Summary");
            var eStatistics = rdr.NameTable.Add("Statistics");
            var eMinValue   = rdr.NameTable.Add("MinValue");
            var eMaxValue   = rdr.NameTable.Add("MaxValue");

            // this routine effectively processes and <EntityType> element and it's children
            string          caption              = "";
            string          description          = "";
            bool            isVisible            = true;
            string          name                 = null;
            string          refName              = "";
            string          tableId              = "";
            string          dataType             = "";
            string          contents             = "";
            string          minValue             = "";
            string          maxValue             = "";
            string          formatString         = "";
            string          keyRef               = "";
            long            stringValueMaxLength = 0;
            long            distinctValueCount   = 0;
            bool            nullable             = true;
            ADOTabularTable tab = null;

            IFormatProvider invariantCulture = System.Globalization.CultureInfo.InvariantCulture;

            List <ADOTabularVariation> _variations = new List <ADOTabularVariation>();

            KpiDetails kpi = new KpiDetails();

            var colType = ADOTabularObjectType.Column;

            while (!(rdr.NodeType == XmlNodeType.EndElement &&
                     rdr.LocalName == eEntityType))
            {
                //while (rdr.NodeType == XmlNodeType.Whitespace)
                //{
                //    rdr.Read();
                //}

                if (rdr.NodeType == XmlNodeType.Element &&
                    rdr.Name == eEntityType)
                {
                    while (rdr.MoveToNextAttribute())
                    {
                        switch (rdr.LocalName)
                        {
                        case "Name":
                            tableId = rdr.Value;
                            tab     = tables.GetById(tableId);
                            break;
                        }
                    }
                }

                if (rdr.NodeType == XmlNodeType.Element &&
                    rdr.LocalName == "Key")
                {
                    // TODO - store table Key
                    keyRef = GetKeyReference(rdr);
                }

                if (rdr.NodeType == XmlNodeType.Element &&
                    rdr.LocalName == "Hierarchy")
                {
                    ProcessHierarchy(rdr, tab);
                }

                if (rdr.NodeType == XmlNodeType.Element &&
                    rdr.Name == "bi:EntityType")
                {
                    //    rdr.MoveToAttribute("Contents");
                    var contentAttr = rdr.GetAttribute("Contents");

                    bool isDateTable = contentAttr == "Time";
                    tab.IsDateTable = isDateTable;
                }

                if (rdr.NodeType == XmlNodeType.Element &&
                    rdr.LocalName == "DisplayFolder")
                {
                    Debug.WriteLine("FoundFolder");

                    ProcessDisplayFolder(rdr, tab, tab);
                }

                if (rdr.NodeType == XmlNodeType.Element &&
                    rdr.LocalName == "Kpi")
                {
                    kpi = ProcessKpi(rdr);
                }

                string defaultAggregateFunction;
                if (rdr.NodeType == XmlNodeType.Element &&
                    (rdr.LocalName == eProperty ||
                     rdr.LocalName == eMeasure ||
                     rdr.LocalName == eSummary ||
                     rdr.LocalName == eStatistics ||
                     rdr.LocalName == eMinValue ||
                     rdr.LocalName == eMaxValue))
                {
                    if (rdr.LocalName == eMeasure)
                    {
                        colType = ADOTabularObjectType.Measure;
                    }

                    if (rdr.LocalName == eSummary)
                    {
                        description = rdr.ReadElementContentAsString();
                    }

                    while (rdr.MoveToNextAttribute())
                    {
                        switch (rdr.LocalName)
                        {
                        case "Name":
                            refName = rdr.Value;
                            break;

                        case "ReferenceName":      // reference name will always come after the Name and will override it if present
                            name = rdr.Value;
                            break;

                        case "Type":
                            dataType = rdr.Value;
                            break;

                        case "Caption":
                            caption = rdr.Value;
                            break;

                        case "Contents":
                            contents = rdr.Value;
                            break;

                        case "Hidden":
                            isVisible = !bool.Parse(rdr.Value);
                            break;

                        case "Description":
                            description = rdr.Value;
                            break;

                        case "DistinctValueCount":
                            distinctValueCount = long.Parse(rdr.Value, invariantCulture);
                            break;

                        case "StringValueMaxLength":
                            stringValueMaxLength = long.Parse(rdr.Value, invariantCulture);
                            break;

                        case "FormatString":
                            formatString = rdr.Value;
                            break;

                        case "DefaultAggregateFunction":
                            defaultAggregateFunction = rdr.Value;
                            break;

                        case "Nullable":
                            nullable = bool.Parse(rdr.Value);
                            break;
                            // Precision Scale
                            //TODO - Add RowCount
                        }
                    }
                }

                if (rdr.NodeType == XmlNodeType.Element &&
                    rdr.LocalName == "Variations")
                {
                    _variations = ProcessVariations(rdr);
                }


                if (rdr.NodeType == XmlNodeType.EndElement &&
                    rdr.LocalName == eProperty &&
                    rdr.LocalName == "Property")
                {
                    if (caption.Length == 0)
                    {
                        caption = refName;
                    }
                    if (!string.IsNullOrWhiteSpace(caption))
                    {
                        if (kpi.IsBlank())
                        {
                            var col = new ADOTabularColumn(tab, refName, name, caption, description, isVisible, colType, contents)
                            {
                                DataType             = Type.GetType($"System.{dataType}"),
                                Nullable             = nullable,
                                MinValue             = minValue,
                                MaxValue             = maxValue,
                                DistinctValues       = distinctValueCount,
                                FormatString         = formatString,
                                StringValueMaxLength = stringValueMaxLength
                            };
                            col.Variations.AddRange(_variations);
                            tables.Model.AddRole(col);
                            tab.Columns.Add(col);
                            _conn.Columns.Add(col.OutputColumnName, col);
                        }
                        else
                        {
                            colType = ADOTabularObjectType.KPI;
                            var kpiCol = new ADOTabularKpi(tab, refName, name, caption, description, isVisible, colType, contents, kpi)
                            {
                                DataType = Type.GetType($"System.{dataType}")
                            };
                            tab.Columns.Add(kpiCol);
                            _conn.Columns.Add(kpiCol.OutputColumnName, kpiCol);
                        }
                    }


                    // reset temp column variables
                    kpi                      = new KpiDetails();
                    refName                  = "";
                    caption                  = "";
                    name                     = null;
                    description              = "";
                    isVisible                = true;
                    contents                 = "";
                    dataType                 = "";
                    stringValueMaxLength     = -1;
                    formatString             = "";
                    defaultAggregateFunction = "";
                    nullable                 = true;
                    colType                  = ADOTabularObjectType.Column;
                    _variations              = new List <ADOTabularVariation>();
                }
                if (!rdr.Read())
                {
                    break;             // quit the read loop if there is no more data
                }
            }

            // Set Key column
            var keyCol = tab?.Columns.GetByPropertyRef(keyRef);

            if (keyCol != null)
            {
                keyCol.IsKey = true;
            }

            //TODO - link up back reference to backing measures for KPIs
        }
Пример #20
0
        private KpiDetails ProcessKpi(XmlReader rdr, ADOTabularTable table)
        {
            KpiDetails kpi = new KpiDetails();
            while (!(rdr.NodeType == XmlNodeType.EndElement
                    && rdr.LocalName == "Kpi"))
            {
                while (rdr.MoveToNextAttribute())
                    {
                        if (rdr.LocalName == "StatusGraphic")
                        {
                                kpi.Graphic = rdr.Value;
                        }
                    }
                if (rdr.NodeType == XmlNodeType.Element
                    && rdr.LocalName == "KpiGoal")
                {
                    while (!(rdr.NodeType == XmlNodeType.EndElement
                    && rdr.LocalName == "KpiGoal"))
                    {
                        if (rdr.NodeType == XmlNodeType.Element
                            && rdr.LocalName == "PropertyRef")
                        {
                            while (rdr.MoveToNextAttribute())
                            {
                                if (rdr.LocalName == "Name")
                                {
                                    kpi.Goal = rdr.Value;
                                }
                            }
                        }
                        rdr.Read();
                    }
                }

                if (rdr.NodeType == XmlNodeType.Element
                    && rdr.LocalName == "KpiStatus")
                {
                    while (!(rdr.NodeType == XmlNodeType.EndElement
                    && rdr.LocalName == "KpiStatus"))
                    {
                        if (rdr.NodeType == XmlNodeType.Element
                            && rdr.LocalName == "PropertyRef")
                        {
                            while (rdr.MoveToNextAttribute())
                            {
                                if (rdr.LocalName == "Name")
                                {
                                    kpi.Status = rdr.Value;
                                }
                            }
                        }
                        rdr.Read();
                    }
                }

                rdr.Read();
            }
            return kpi;
        }
Пример #21
0
        private ADOTabularTable BuildTableFromEntitySet(XmlReader rdr, string eEntitySet)
        {
            string caption = null;
            string description = "";
            string refname = null;
            bool isVisible = true;
            string name = null;
            while (!(rdr.NodeType == XmlNodeType.EndElement
                     && rdr.LocalName == eEntitySet))
            {
                while (rdr.MoveToNextAttribute())
                {
                    switch (rdr.LocalName)
                    {
                        case "ReferenceName":
                            name = rdr.Value;
                            break;
                        case "Caption":
                            caption = rdr.Value;
                            break;
                        case "Description":
                            description = rdr.Value;
                            break;
                        case "Hidden":
                            isVisible = !bool.Parse(rdr.Value);
                            break;
                        case "Name":
                            refname = rdr.Value;
                            break;
                    }
                }
                rdr.Read();
            }

            // the names of the properties in the CSDL metadata are somewhat confusing
            // Name           - cannot contain spaces and is used for internally referencing
            //                - maps to InternalReference in ADOTabular
            // Reference Name - this is the name used by DAX queries/expressions
            //                - will be blank if Name does not contain spaces
            //                - if this is missing the Name property is used
            // Caption        - this is what the end user sees (may be translated)
            //                - if this is missing the Name property is used
            var tab = new ADOTabularTable(_conn, refname, name, caption, description, isVisible);

            return tab;
        }
Пример #22
0
 private void TagKpiComponentColumns(ADOTabularTable tab)
 {
     foreach( var c in tab.Columns )
     {
         if (c.ColumnType == ADOTabularColumnType.KPI)
         {
             var k = (ADOTabularKpi)c;
             k.Goal.ColumnType = ADOTabularColumnType.KPIGoal;
             k.Status.ColumnType = ADOTabularColumnType.KPIStatus;
         }
     }
 }
Пример #23
0
 public TreeViewTable(ADOTabularTable table, GetChildrenDelegate getChildren)
     : base(getChildren)
 {
     _table = table;
 }
Пример #24
0
 public ADOTabularKpi( ADOTabularTable table,string internalName, string name, string caption,  string description,
                         bool isVisible, ADOTabularColumnType columnType, string contents, KpiDetails kpi)
     : base(table, internalName,name, caption,description,isVisible,columnType,contents)
 {
     _kpi = kpi;
 }