示例#1
0
        private static void LoadComplexType(XmlSchemaComplexType complexType, FormattersHelpers.ColumnDefinitionDelegate definitionDelegate, object parent, int ordinal, bool requirePrePostInit)
        {
            int num = ordinal;
            XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence)complexType.Particle;

            if (requirePrePostInit)
            {
                definitionDelegate(-1, null, null, null, null, false, xmlSchemaSequence.Items.Count, null);
            }
            foreach (XmlSchemaElement xmlSchemaElement in xmlSchemaSequence.Items)
            {
                string name = (xmlSchemaElement.Name != null) ? xmlSchemaElement.Name : xmlSchemaElement.QualifiedName.Name;
                string columnCaptionFromSchemaElement = FormattersHelpers.GetColumnCaptionFromSchemaElement(xmlSchemaElement);
                string @namespace = xmlSchemaElement.QualifiedName.Namespace;
                if (FormattersHelpers.IsNestedRowsetColumn(xmlSchemaElement))
                {
                    object obj = definitionDelegate(num, name, @namespace, columnCaptionFromSchemaElement, null, true, parent, null);
                    FormattersHelpers.ColumnDefinitionDelegate columnDefinitionDelegate = obj as FormattersHelpers.ColumnDefinitionDelegate;
                    if (columnDefinitionDelegate == null)
                    {
                        columnDefinitionDelegate = definitionDelegate;
                    }
                    else
                    {
                        obj = parent;
                    }
                    FormattersHelpers.LoadComplexType((XmlSchemaComplexType)xmlSchemaElement.ElementSchemaType, columnDefinitionDelegate, obj, 0, requirePrePostInit);
                }
                else
                {
                    Type   type             = null;
                    string strColumnXsdType = null;
                    FormattersHelpers.GetSchemaElementTypeAndName(xmlSchemaElement, out type, out strColumnXsdType);
                    definitionDelegate(num, name, @namespace, columnCaptionFromSchemaElement, type, false, parent, strColumnXsdType);
                }
                num++;
            }
            if (requirePrePostInit)
            {
                definitionDelegate(-2, null, null, null, null, false, xmlSchemaSequence.Items.Count, null);
            }
        }
 private void ReadCubeInfo(XmlReader reader)
 {
     if (!reader.IsStartElement("CubeInfo", "urn:schemas-microsoft-com:xml-analysis:mddataset"))
     {
         FormattersHelpers.CheckException(reader);
         return;
     }
     if (reader.IsEmptyElement)
     {
         reader.Skip();
         return;
     }
     reader.ReadStartElement();
     this.CreateCubesInfosTable();
     this.cubesInfos.BeginLoadData();
     while (reader.IsStartElement("Cube", "urn:schemas-microsoft-com:xml-analysis:mddataset"))
     {
         reader.ReadStartElement();
         DataRow dataRow = this.cubesInfos.NewRow();
         if (reader.IsStartElement("CubeName", "urn:schemas-microsoft-com:xml-analysis:mddataset"))
         {
             dataRow["CubeName"] = FormattersHelpers.ReadDataSetProperty(reader, typeof(string));
         }
         if (reader.IsStartElement("LastDataUpdate", "http://schemas.microsoft.com/analysisservices/2003/engine"))
         {
             dataRow["LastDataUpdate"] = MDDatasetFormatter.GetDateTimeIfValid(reader);
         }
         if (reader.IsStartElement("LastSchemaUpdate", "http://schemas.microsoft.com/analysisservices/2003/engine"))
         {
             dataRow["LastSchemaUpdate"] = MDDatasetFormatter.GetDateTimeIfValid(reader);
         }
         this.cubesInfos.Rows.Add(dataRow);
         FormattersHelpers.CheckException(reader);
         reader.ReadEndElement();
     }
     this.cubesInfos.EndLoadData();
     FormattersHelpers.CheckException(reader);
     reader.ReadEndElement();
 }
示例#3
0
 internal override void WriteXmlaProperty(DictionaryEntry entry)
 {
     if (entry.Key is IXmlaPropertyKey)
     {
         IXmlaPropertyKey xmlaPropertyKey = (IXmlaPropertyKey)entry.Key;
         if (entry.Value != null && xmlaPropertyKey.Name != null && xmlaPropertyKey.Name.Length > 0)
         {
             string localName = XmlConvert.EncodeLocalName(xmlaPropertyKey.Name);
             if (xmlaPropertyKey.Namespace == null || xmlaPropertyKey.Namespace.Length == 0)
             {
                 this.writer.WriteElementString(localName, FormattersHelpers.ConvertToXml(entry.Value));
                 return;
             }
             this.writer.WriteElementString(localName, xmlaPropertyKey.Namespace, FormattersHelpers.ConvertToXml(entry.Value));
             return;
         }
     }
     else
     {
         this.writer.WriteElementString((string)entry.Key, FormattersHelpers.ConvertToXml(entry.Value));
     }
 }
示例#4
0
            public object ConstructDataTableColumnDelegate(int ordinal, string name, string theNamespace, string caption, Type type, bool isNested, object parent, string strColumnXsdType)
            {
                object result = parent;

                if (parent == null)
                {
                    if (isNested)
                    {
                        DataColumn dataColumn = new DataColumn(name, typeof(int));
                        dataColumn.Caption       = name;
                        dataColumn.AutoIncrement = true;
                        FormattersHelpers.SetColumnNamespace(dataColumn, theNamespace);
                        this.datatable.Columns.Add(dataColumn);
                        result = this.datatable;
                    }
                    else
                    {
                        RowsetFormatter.AddColumn(this.datatable, name, theNamespace, caption, type, this.setColumnTypes, strColumnXsdType, this.columnsToConvertTimeFor);
                    }
                }
                return(result);
            }
示例#5
0
 public static void LoadSchema(XmlReader xmlReader, FormattersHelpers.ColumnDefinitionDelegate definitionDelegate, bool requirePrePostInit)
 {
     try
     {
         xmlReader.MoveToContent();
         XmlSchema xmlSchema;
         if (xmlReader is XmlaReader)
         {
             xmlSchema = ((XmlaReader)xmlReader).ReadSchema();
         }
         else
         {
             xmlSchema = XmlSchema.Read(xmlReader, null);
             xmlReader.ReadEndElement();
         }
         xmlReader.MoveToContent();
         XmlSchemaSet xmlSchemaSet = new XmlSchemaSet();
         xmlSchemaSet.Add(xmlSchema);
         xmlSchemaSet.Compile();
         foreach (XmlSchemaObject current in xmlSchema.Items)
         {
             if (current is XmlSchemaComplexType)
             {
                 XmlSchemaComplexType xmlSchemaComplexType = (XmlSchemaComplexType)current;
                 if (xmlSchemaComplexType.Name == FormattersHelpers.RowElement)
                 {
                     FormattersHelpers.LoadComplexType(xmlSchemaComplexType, definitionDelegate, null, 0, requirePrePostInit);
                     break;
                 }
             }
         }
     }
     catch (XmlSchemaException innerException)
     {
         throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, innerException);
     }
 }
示例#6
0
        public static object ReadDataSetProperty(XmlReader reader, Type type)
        {
            object result = null;

            if (!reader.IsEmptyElement)
            {
                using (FormattersHelpers.GetWhitespaceHandlingRestorer(reader, WhitespaceHandling.All))
                {
                    reader.ReadStartElement();
                    if (reader.NodeType == XmlNodeType.Text)
                    {
                        result = ((FormattersHelpers.GetValueDelegate)FormattersHelpers.typeConvertersHash[type])(reader.ReadString());
                    }
                    else
                    {
                        string text = FormattersHelpers.ReadWhiteSpace(reader);
                        if (reader.NodeType == XmlNodeType.EndElement)
                        {
                            result = text;
                        }
                        else if ((result = XmlaClient.CheckAndGetDatasetError(reader)) == null)
                        {
                            FormattersHelpers.CheckException(reader);
                            if (type == typeof(object))
                            {
                                result = FormattersHelpers.ReadPropertyXml(reader);
                            }
                        }
                    }
                    reader.ReadEndElement();
                    return(result);
                }
            }
            reader.Read();
            result = ((FormattersHelpers.GetValueDelegate)FormattersHelpers.typeConvertersHash[type])(string.Empty);
            return(result);
        }
        private bool BeginNewRow()
        {
            bool result;

            try
            {
                if (this.xmlReader.IsStartElement(this.rowElement, this.rowNamespace))
                {
                    this.readersXmlDepth = this.xmlReader.Depth + 1;
                    this.xmlReader.ReadStartElement();
                    this.currentColumn = 0;
                    result             = true;
                }
                else
                {
                    FormattersHelpers.CheckException(this.xmlReader);
                    result = false;
                }
            }
            catch (AdomdUnknownResponseException)
            {
                if (this.xmlReader != null)
                {
                    this.xmlReader.Close();
                }
                throw;
            }
            catch (AdomdConnectionException)
            {
                throw;
            }
            catch (XmlException innerException)
            {
                if (this.xmlReader != null)
                {
                    this.xmlReader.Close();
                }
                throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, innerException);
            }
            catch (IOException innerException2)
            {
                if (this.owner != null)
                {
                    this.owner.CloseConnection(false);
                }
                throw new AdomdConnectionException(XmlaSR.ConnectionBroken, innerException2);
            }
            catch (XmlaException innerException3)
            {
                if (this.xmlReader != null)
                {
                    this.xmlReader.Close();
                }
                throw new AdomdErrorResponseException(innerException3);
            }
            catch
            {
                if (this.owner != null)
                {
                    this.owner.CloseConnection(false);
                }
                throw;
            }
            return(result);
        }
        static NamespacesMgr()
        {
            NamespacesMgr.AdomdVersionTimeStamp           = new DateTime(2003, 11, 1, CultureInfo.InvariantCulture.Calendar);
            NamespacesMgr.NamespaceCompatibilityXmlSchema = null;
            NamespacesMgr.compatibilityDataSet            = null;
            NamespacesMgr.known = new string[]
            {
                "http://schemas.xmlsoap.org/soap/envelope/",
                "urn:schemas-microsoft-com:xml-analysis",
                "http://schemas.microsoft.com/analysisservices/2003/engine",
                "http://schemas.microsoft.com/analysisservices/2003/engine/2",
                "http://schemas.microsoft.com/analysisservices/2003/engine/2/2",
                "http://schemas.microsoft.com/analysisservices/2008/engine/100",
                "http://schemas.microsoft.com/analysisservices/2008/engine/100/100",
                "http://schemas.microsoft.com/analysisservices/2010/engine/200",
                "http://schemas.microsoft.com/analysisservices/2010/engine/200/200",
                "http://schemas.microsoft.com/analysisservices/2011/engine/300",
                "http://schemas.microsoft.com/analysisservices/2011/engine/300/300",
                "http://schemas.microsoft.com/analysisservices/2012/engine/400",
                "http://schemas.microsoft.com/analysisservices/2012/engine/400/400",
                "http://schemas.microsoft.com/analysisservices/2012/engine/410",
                "http://schemas.microsoft.com/analysisservices/2012/engine/410/410",
                "http://schemas.microsoft.com/analysisservices/2013/engine/500",
                "http://schemas.microsoft.com/analysisservices/2013/engine/500/500",
                "urn:schemas-microsoft-com:xml-analysis:rowset",
                "urn:schemas-microsoft-com:xml-analysis:mddataset",
                "urn:schemas-microsoft-com:xml-analysis:exception",
                "http://www.w3.org/2001/XMLSchema",
                "http://www.w3.org/2001/XMLSchema-instance",
                "urn:schemas-microsoft-com:xml-analysis:empty",
                "http://schemas.microsoft.com/analysisservices/2003/xmla",
                "http://schemas.microsoft.com/analysisservices/2003/ext",
                "http://schemas.microsoft.com/analysisservices/2003/xmla-multipleresults",
                "urn:schemas-microsoft-com:xml-analysis:fault",
                "",
                "urn:schemas-microsoft-com:xml-analysis:xmlDocumentDataset",
                "urn:schemas-microsoft-com:xml-sql"
            };
            NamespacesMgr.NamespaceCompatibilityXmlSchema = string.Format(CultureInfo.InvariantCulture, "<xsd:schema targetNamespace=\"{0}\" xmlns = \"{1}\" xmlns:sql=\"{2}\" xmlns:xsd=\"{3}\" elementFormDefault=\"qualified\">\r\n\t\t\t\t<xsd:element name=\"{4}\">\r\n\t\t\t\t\t<xsd:complexType>\r\n\t\t\t\t\t\t<xsd:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n\t\t\t\t\t\t\t<xsd:element name=\"{5}\" type=\"{5}\"/>\r\n\t\t\t\t\t\t</xsd:sequence>\r\n\t\t\t\t\t</xsd:complexType>\r\n\t\t\t\t</xsd:element>\r\n\t\t\t\t<xsd:complexType name=\"{5}\">\r\n\t\t\t\t\t<xsd:sequence>\r\n\t\t\t\t\t\t<xsd:element sql:field=\"{6}\" name=\"{6}\" type=\"xsd:string\"/>\r\n\t\t\t\t\t\t<xsd:element sql:field=\"{7}\" name=\"{7}\" minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n\t\t\t\t\t\t\t<xsd:complexType>\r\n\t\t\t\t\t\t\t\t<xsd:sequence>\r\n\t\t\t\t\t\t\t\t\t<xsd:element sql:field=\"{8}\" name=\"{8}\" type=\"xsd:string\" minOccurs=\"0\"/>\r\n\t\t\t\t\t\t\t\t\t<xsd:element sql:field=\"{9}\" name=\"{9}\" type=\"xsd:dateTime\" minOccurs=\"0\"/>\r\n\t\t\t\t\t\t\t\t</xsd:sequence>\r\n\t\t\t\t\t\t\t</xsd:complexType>\r\n\t\t\t\t\t\t</xsd:element>\r\n\t\t\t\t\t</xsd:sequence>\r\n\t\t\t\t</xsd:complexType>\r\n\t\t\t</xsd:schema>", new object[]
            {
                "urn:schemas-microsoft-com:xml-analysis:rowset",
                "urn:schemas-microsoft-com:xml-analysis:rowset",
                "urn:schemas-microsoft-com:xml-sql",
                "http://www.w3.org/2001/XMLSchema",
                "root",
                "row",
                "Namespace",
                "Compatibility",
                "ProductBranch",
                "VersionTimeStamp"
            });
            XmlReader xmlReader = null;

            try
            {
                xmlReader = XmlReader.Create(new StringReader(NamespacesMgr.NamespaceCompatibilityXmlSchema));
                RowsetFormatter.DataSetCreator dataSetCreator = new RowsetFormatter.DataSetCreator(null, false, null);
                FormattersHelpers.LoadSchema(xmlReader, new FormattersHelpers.ColumnDefinitionDelegate(dataSetCreator.ConstructDataSetColumnDelegate));
                NamespacesMgr.compatibilityDataSet = dataSetCreator.DataSet;
            }
            finally
            {
                if (xmlReader != null)
                {
                    xmlReader.Close();
                }
            }
        }
        private void ReadCells(XmlReader reader)
        {
            if (!reader.IsStartElement("CellData", "urn:schemas-microsoft-com:xml-analysis:mddataset"))
            {
                if (reader.IsEmptyElement)
                {
                    FormattersHelpers.CheckException(reader);
                }
                return;
            }
            if (reader.IsEmptyElement)
            {
                FormattersHelpers.CheckException(reader);
                reader.Skip();
                return;
            }
            this.cellTable.BeginLoadData();
            DataColumn column = this.cellTable.Columns["CellOrdinal"];

            reader.ReadStartElement("CellData", "urn:schemas-microsoft-com:xml-analysis:mddataset");
            while (reader.IsStartElement("Cell", "urn:schemas-microsoft-com:xml-analysis:mddataset"))
            {
                DataRow dataRow   = this.cellTable.NewRow();
                string  attribute = reader.GetAttribute("CellOrdinal");
                dataRow[column] = XmlConvert.ToInt32(attribute);
                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    while (reader.IsStartElement())
                    {
                        FormattersHelpers.CheckException(reader);
                        DataColumn dataColumn = this.cellTable.Columns[reader.Name];
                        if (dataColumn == null)
                        {
                            throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, string.Format(CultureInfo.InvariantCulture, "Unexpected element {0}", new object[]
                            {
                                reader.Name
                            }));
                        }
                        if (!FormattersHelpers.IsNullContentElement(reader))
                        {
                            Type elementType = FormattersHelpers.GetElementType(reader, "http://www.w3.org/2001/XMLSchema-instance", dataColumn);
                            dataRow[dataColumn] = FormattersHelpers.ReadDataSetProperty(reader, elementType);
                        }
                        else
                        {
                            reader.Skip();
                        }
                    }
                    reader.ReadEndElement();
                }
                else
                {
                    FormattersHelpers.CheckException(reader);
                    reader.ReadStartElement();
                }
                this.cellTable.Rows.Add(dataRow);
            }
            FormattersHelpers.CheckException(reader);
            reader.ReadEndElement();
            this.cellTable.EndLoadData();
        }
        private void ReadCellInfo(XmlReader reader)
        {
            this.cellTable        = new DataTable();
            this.cellTable.Locale = CultureInfo.InvariantCulture;
            Collection <int> collection = new Collection <int>();

            this.cellTable.ExtendedProperties["MemberProperties"] = collection;
            DataColumn dataColumn = new DataColumn("CellOrdinal", typeof(int));

            dataColumn.Caption   = "CellOrdinal";
            dataColumn.Namespace = "urn:schemas-microsoft-com:xml-analysis:mddataset";
            this.cellTable.Columns.Add(dataColumn);
            collection.Add(this.cellTable.Columns.Count - 1);
            reader.MoveToContent();
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("CellInfo", "urn:schemas-microsoft-com:xml-analysis:mddataset");
                while (reader.IsStartElement())
                {
                    FormattersHelpers.CheckException(reader);
                    if (reader.Name != "CellOrdinal")
                    {
                        //goto IL_136;
                    }
                    if (reader.NamespaceURI != "urn:schemas-microsoft-com:xml-analysis:mddataset")
                    {
                        goto Block_4;
                    }
IL_1BF:
                    reader.Skip();
                    continue;
Block_4:
                    try
                    {
IL_136:
                        dataColumn           = new DataColumn(reader.Name, typeof(object));
                        dataColumn.Namespace = reader.NamespaceURI;
                        FormattersHelpers.SetColumnType(dataColumn, FormattersHelpers.GetElementType(reader));
                        dataColumn.Caption = reader.GetAttribute("name");
                        this.cellTable.Columns.Add(dataColumn);
                        collection.Add(this.cellTable.Columns.Count - 1);
                    }
                    catch (DuplicateNameException)
                    {
                        collection.Add(this.cellTable.Columns.IndexOf(reader.Name));
                    }
                    goto IL_1BF;
                }
                reader.ReadEndElement();
                return;
            }
            FormattersHelpers.CheckException(reader);
            if (reader.IsStartElement("CellInfo", "urn:schemas-microsoft-com:xml-analysis:mddataset"))
            {
                reader.Skip();
                return;
            }
            throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, string.Format(CultureInfo.InvariantCulture, "Expected element {0}:{1}, got {2}", new object[]
            {
                "urn:schemas-microsoft-com:xml-analysis:mddataset",
                "CellInfo",
                reader.Name
            }));
        }
示例#11
0
        private static void PopulateRow(XmlReader reader, DataTable datatable, InlineErrorHandlingType inlineErrorHandling, int parentRowIndex, DataColumn parentColumn)
        {
            DataRow dataRow = RowsetFormatter.CreateNewRow(datatable, parentColumn, parentRowIndex);

            while (reader.IsStartElement())
            {
                FormattersHelpers.CheckException(reader);
                if (!FormattersHelpers.IsNullContentElement(reader))
                {
                    string     localName  = reader.LocalName;
                    DataColumn dataColumn = datatable.Columns[localName];
                    if (dataColumn == null)
                    {
                        throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, string.Format(CultureInfo.InvariantCulture, "Unknown column {0}", new object[]
                        {
                            localName
                        }));
                    }
                    string columnNamespace = FormattersHelpers.GetColumnNamespace(dataColumn);
                    if (reader.NamespaceURI == columnNamespace)
                    {
                        if (RowsetFormatter.IsNestedColumn(dataColumn))
                        {
                            DataTable dataTable = RowsetFormatter.FindNestedTable(dataColumn);
                            if (dataTable != null)
                            {
                                RowsetFormatter.PopulateMultiRow(reader, localName, columnNamespace, dataTable, inlineErrorHandling, (int)dataRow[dataColumn]);
                            }
                            else
                            {
                                reader.Skip();
                            }
                        }
                        else
                        {
                            Type   elementType        = FormattersHelpers.GetElementType(reader, "http://www.w3.org/2001/XMLSchema-instance", dataColumn);
                            bool   throwOnInlineError = inlineErrorHandling == InlineErrorHandlingType.Throw;
                            object obj = FormattersHelpers.ReadRowsetProperty(reader, localName, columnNamespace, elementType, throwOnInlineError, elementType.IsArray && FormattersHelpers.GetColumnXsdTypeName(dataColumn) != "base64Binary", FormattersHelpers.GetConvertToLocalTime(dataColumn));
                            if (inlineErrorHandling == InlineErrorHandlingType.StoreInErrorsCollection)
                            {
                                XmlaError xmlaError = obj as XmlaError;
                                if (xmlaError == null)
                                {
                                    dataRow[localName] = obj;
                                }
                                else
                                {
                                    dataRow.SetColumnError(localName, xmlaError.Description);
                                }
                            }
                            else
                            {
                                dataRow[localName] = obj;
                            }
                        }
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                else
                {
                    reader.Skip();
                }
            }
            datatable.Rows.Add(dataRow);
        }
        private object ColumnDef(int ordinal, string name, string colNamespace, string caption, Type type, bool isNested, object parent, string strColumnXsdType)
        {
            if (ordinal == -1)
            {
                this.columnCount    = (int)parent;
                this.dtStore        = new DataTable();
                this.dtStore.Locale = CultureInfo.InvariantCulture;
                if (this.nestedDataReaders == null)
                {
                    this.nestedDataReaders = new XmlaDataReader[this.columnCount];
                }
                return(null);
            }
            if (ordinal == -2)
            {
                if (this.parentReader != null)
                {
                    this.dtStore.Columns.Add(string.Empty, this.currentRow.GetType());
                }
                return(null);
            }
            Type type2 = type;

            FormattersHelpers.ColumnDefinitionDelegate result = null;
            if (strColumnXsdType == "xmlDocument")
            {
                type2 = typeof(object);
            }
            if (isNested)
            {
                type2 = typeof(XmlaDataReader);
                this.nestedDataReaders[ordinal]              = new XmlaDataReader(this);
                this.nestedDataReaders[ordinal].rowElement   = name;
                this.nestedDataReaders[ordinal].rowNamespace = colNamespace;
                result = new FormattersHelpers.ColumnDefinitionDelegate(this.nestedDataReaders[ordinal].ColumnDef);
            }
            DataRow dataRow = this.schemaTable.NewRow();

            this.columnXmlNameLookup[name] = ordinal;
            this.columnNameLookup[caption] = ordinal;
            dataRow["ColumnName"]          = caption;
            dataRow["ColumnOrdinal"]       = ordinal;
            dataRow["ColumnSize"]          = 0;
            if (type2 == typeof(decimal))
            {
                dataRow["NumericPrecision"] = 19;
                dataRow["NumericScale"]     = 4;
            }
            else
            {
                dataRow["NumericPrecision"] = 0;
                dataRow["NumericScale"]     = 0;
            }
            dataRow["DataType"]        = type2;
            dataRow["ProviderType"]    = type2;
            dataRow["IsLong"]          = false;
            dataRow["AllowDBNull"]     = true;
            dataRow["IsReadOnly"]      = true;
            dataRow["IsRowVersion"]    = false;
            dataRow["IsUnique"]        = false;
            dataRow["IsKeyColumn"]     = false;
            dataRow["IsAutoIncrement"] = false;
            dataRow["BaseSchemaName"]  = null;
            dataRow["BaseCatalogName"] = null;
            dataRow["BaseTableName"]   = null;
            dataRow["BaseColumnName"]  = null;
            this.schemaTable.Rows.Add(dataRow);
            if (isNested)
            {
                this.dtStore.Columns.Add(name, this.currentRow.GetType());
            }
            else
            {
                DataColumn column = this.dtStore.Columns.Add(name, typeof(object));
                FormattersHelpers.SetColumnXsdTypeName(column, strColumnXsdType);
            }
            return(result);
        }
示例#13
0
 public static void LoadSchema(XmlReader xmlReader, FormattersHelpers.ColumnDefinitionDelegate definitionDelegate)
 {
     FormattersHelpers.LoadSchema(xmlReader, definitionDelegate, false);
 }
示例#14
0
 public static Type GetElementType(XmlReader reader)
 {
     return(FormattersHelpers.GetElementType(reader, null, typeof(object)));
 }
示例#15
0
        public static object ReadRowsetProperty(XmlReader reader, string elementName, string elementNamespace, Type type, bool throwOnInlineError, bool isArray, bool convertToLocalTime)
        {
            object result = null;

            if (isArray)
            {
                ArrayList arrayList   = new ArrayList();
                Type      elementType = type.GetElementType();
                while (reader.IsStartElement(elementName, elementNamespace))
                {
                    object obj = FormattersHelpers.ReadRowsetProperty(reader, elementName, elementNamespace, elementType, throwOnInlineError, false, convertToLocalTime);
                    if (obj is XmlaError)
                    {
                        if (throwOnInlineError)
                        {
                            throw XmlaResultCollection.ExceptionOnError(new XmlaResult
                            {
                                Messages =
                                {
                                    (XmlaError)obj
                                }
                            });
                        }
                        while (reader.IsStartElement(elementName, elementNamespace))
                        {
                            reader.Skip();
                        }
                        result = obj;
                        break;
                    }
                    else
                    {
                        arrayList.Add(obj);
                    }
                }
                Array array = Array.CreateInstance(elementType, arrayList.Count);
                arrayList.CopyTo(array);
                result = array;
            }
            else
            {
                if (!reader.IsEmptyElement)
                {
                    using (FormattersHelpers.GetWhitespaceHandlingRestorer(reader, WhitespaceHandling.All))
                    {
                        reader.ReadStartElement(elementName, elementNamespace);
                        if (reader.NodeType == XmlNodeType.Text)
                        {
                            result = FormattersHelpers.ConvertFromXml(reader.ReadString(), type, convertToLocalTime);
                        }
                        else
                        {
                            string text = FormattersHelpers.ReadWhiteSpace(reader);
                            if (reader.NodeType == XmlNodeType.EndElement)
                            {
                                result = text;
                            }
                            else
                            {
                                bool flag         = false;
                                bool skipElements = false;
                                if (type == typeof(object) || type == typeof(string))
                                {
                                    flag         = true;
                                    skipElements = ((XmlaReader)reader).SkipElements;
                                    ((XmlaReader)reader).SkipElements = false;
                                }
                                try
                                {
                                    if ((result = XmlaClient.CheckAndGetRowsetError(reader, throwOnInlineError)) == null)
                                    {
                                        FormattersHelpers.CheckException(reader);
                                        if (flag)
                                        {
                                            result = FormattersHelpers.ReadPropertyXml(reader);
                                        }
                                    }
                                }
                                finally
                                {
                                    if (flag)
                                    {
                                        ((XmlaReader)reader).SkipElements = skipElements;
                                    }
                                }
                            }
                        }
                        reader.ReadEndElement();
                        return(result);
                    }
                }
                reader.Skip();
                result = FormattersHelpers.ConvertFromXml(string.Empty, type, convertToLocalTime);
            }
            return(result);
        }
 private void CompletePreviousRow()
 {
     try
     {
         if (!this.xmlReader.IsStartElement(this.rowElement, this.rowNamespace))
         {
             while (this.xmlReader.IsStartElement() && this.xmlReader.Depth == this.readersXmlDepth)
             {
                 if (this.xmlReader.IsEmptyElement)
                 {
                     FormattersHelpers.CheckException(this.xmlReader);
                 }
                 int ordinalFromXmlName = this.GetOrdinalFromXmlName(this.xmlReader.LocalName);
                 if (ordinalFromXmlName == -1)
                 {
                     throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, string.Format(CultureInfo.InvariantCulture, "Unexpected element {0}", new object[]
                     {
                         this.xmlReader.Name
                     }));
                 }
                 this.xmlReader.Skip();
             }
             this.currentColumn = this.FieldCount;
             if (this.xmlReader.MoveToContent() == XmlNodeType.EndElement && this.xmlReader.LocalName == this.rowElement && this.xmlReader.NamespaceURI == this.rowNamespace)
             {
                 this.xmlReader.ReadEndElement();
             }
         }
     }
     catch (AdomdUnknownResponseException)
     {
         if (this.xmlReader != null)
         {
             this.xmlReader.Close();
         }
         throw;
     }
     catch (AdomdConnectionException)
     {
         throw;
     }
     catch (XmlException innerException)
     {
         if (this.xmlReader != null)
         {
             this.xmlReader.Close();
         }
         throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, innerException);
     }
     catch (IOException innerException2)
     {
         if (this.owner != null)
         {
             this.owner.CloseConnection(false);
         }
         throw new AdomdConnectionException(XmlaSR.ConnectionBroken, innerException2);
     }
     catch (XmlaException innerException3)
     {
         if (this.xmlReader != null)
         {
             this.xmlReader.Close();
         }
         throw new AdomdErrorResponseException(innerException3);
     }
     catch
     {
         if (this.owner != null)
         {
             this.owner.CloseConnection(false);
         }
         throw;
     }
 }
 private void LoadResponseSchema()
 {
     FormattersHelpers.ColumnDefinitionDelegate definitionDelegate = new FormattersHelpers.ColumnDefinitionDelegate(this.ColumnDef);
     FormattersHelpers.LoadSchema(this.xmlReader, definitionDelegate, true);
 }
        private void ReadMembers(XmlReader reader)
        {
            if (!reader.IsStartElement("Axes", "urn:schemas-microsoft-com:xml-analysis:mddataset"))
            {
                if (reader.IsEmptyElement)
                {
                    FormattersHelpers.CheckException(reader);
                }
                return;
            }
            if (reader.IsEmptyElement)
            {
                FormattersHelpers.CheckException(reader);
                reader.Skip();
                return;
            }
            this.BeginLoadAxisTables();
            reader.ReadStartElement("Axes", "urn:schemas-microsoft-com:xml-analysis:mddataset");
            int num = 0;

            while (reader.IsStartElement("Axis", "urn:schemas-microsoft-com:xml-analysis:mddataset"))
            {
                string attribute = reader.GetAttribute("name");
                reader.ReadStartElement();
                IDSFDataSet iDSFDataSet;
                if (attribute != "SlicerAxis")
                {
                    iDSFDataSet = this.axesList[num++];
                }
                else
                {
                    iDSFDataSet = this.filterAxis;
                }
                reader.MoveToContent();
                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement("Tuples", "urn:schemas-microsoft-com:xml-analysis:mddataset");
                    while (reader.IsStartElement("Tuple", "urn:schemas-microsoft-com:xml-analysis:mddataset"))
                    {
                        reader.ReadStartElement();
                        while (reader.IsStartElement("Member", "urn:schemas-microsoft-com:xml-analysis:mddataset"))
                        {
                            DataTable dataTable = iDSFDataSet[reader.GetAttribute("Hierarchy")];
                            reader.ReadStartElement();
                            DataRow dataRow = dataTable.NewRow();
                            DataColumnCollection columns = dataTable.Columns;
                            while (reader.IsStartElement())
                            {
                                FormattersHelpers.CheckException(reader);
                                DataColumn dataColumn = columns[reader.Name];
                                if (dataColumn == null)
                                {
                                    throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, string.Format(CultureInfo.InvariantCulture, "Unexpected element {0}", new object[]
                                    {
                                        reader.Name
                                    }));
                                }
                                if (!FormattersHelpers.IsNullContentElement(reader))
                                {
                                    Type elementType = FormattersHelpers.GetElementType(reader, "http://www.w3.org/2001/XMLSchema-instance", dataColumn);
                                    dataRow[dataColumn] = FormattersHelpers.ReadDataSetProperty(reader, elementType);
                                }
                                else
                                {
                                    reader.Skip();
                                }
                            }
                            dataTable.Rows.Add(dataRow);
                            reader.ReadEndElement();
                        }
                        FormattersHelpers.CheckException(reader);
                        reader.ReadEndElement();
                    }
                    FormattersHelpers.CheckException(reader);
                    reader.ReadEndElement();
                }
                else
                {
                    FormattersHelpers.CheckException(reader);
                    reader.ReadStartElement();
                }
                reader.ReadEndElement();
            }
            FormattersHelpers.CheckException(reader);
            reader.ReadEndElement();
            this.EndLoadAxisTables();
        }
        private object SequentialReadXmlValue(int ordinal)
        {
            if (ordinal < this.currentColumn)
            {
                throw new ArgumentException(XmlaSR.NonSequentialColumnAccessError, "ordinal");
            }
            if (ordinal >= this.FieldCount)
            {
                throw new ArgumentOutOfRangeException("ordinal");
            }
            object result;

            try
            {
                this.currentColumn = ordinal + 1;
                object obj = null;
                while (this.xmlReader.IsStartElement() && this.xmlReader.Depth == this.readersXmlDepth)
                {
                    int ordinalFromXmlName = this.GetOrdinalFromXmlName(this.xmlReader.LocalName);
                    if (ordinalFromXmlName == -1)
                    {
                        FormattersHelpers.CheckException(this.xmlReader);
                        throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, string.Format(CultureInfo.InvariantCulture, "Unexpected element {0}", new object[]
                        {
                            this.xmlReader.Name
                        }));
                    }
                    bool flag         = false;
                    bool skipElements = false;
                    if (FormattersHelpers.GetColumnXsdTypeName(this.dtStore.Columns[ordinalFromXmlName]) == "xmlDocument")
                    {
                        flag         = true;
                        skipElements = ((XmlaReader)this.xmlReader).SkipElements;
                        ((XmlaReader)this.xmlReader).SkipElements = false;
                    }
                    try
                    {
                        FormattersHelpers.CheckException(this.xmlReader);
                    }
                    finally
                    {
                        if (flag)
                        {
                            ((XmlaReader)this.xmlReader).SkipElements = skipElements;
                        }
                    }
                    if (ordinalFromXmlName == ordinal)
                    {
                        if (!FormattersHelpers.IsNullContentElement(this.xmlReader))
                        {
                            obj = this.ReadColumnValue(ordinal);
                            break;
                        }
                        this.xmlReader.Skip();
                        break;
                    }
                    else
                    {
                        if (ordinalFromXmlName >= ordinal)
                        {
                            break;
                        }
                        string name = this.xmlReader.Name;
                        while (this.xmlReader.IsStartElement(name))
                        {
                            this.xmlReader.Skip();
                        }
                    }
                }
                result = obj;
            }
            catch (AdomdUnknownResponseException)
            {
                if (this.xmlReader != null)
                {
                    this.xmlReader.Close();
                }
                throw;
            }
            catch (AdomdConnectionException)
            {
                throw;
            }
            catch (XmlException innerException)
            {
                if (this.xmlReader != null)
                {
                    this.xmlReader.Close();
                }
                throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, innerException);
            }
            catch (IOException innerException2)
            {
                if (this.owner != null)
                {
                    this.owner.CloseConnection(false);
                }
                throw new AdomdConnectionException(XmlaSR.ConnectionBroken, innerException2);
            }
            catch (XmlaException innerException3)
            {
                if (this.xmlReader != null)
                {
                    this.xmlReader.Close();
                }
                throw new AdomdErrorResponseException(innerException3);
            }
            catch
            {
                if (this.owner != null)
                {
                    this.owner.CloseConnection(false);
                }
                throw;
            }
            return(result);
        }
 private void ReadAxesInfo(XmlReader reader)
 {
     reader.MoveToContent();
     if (reader.IsEmptyElement)
     {
         FormattersHelpers.CheckException(reader);
         if (reader.IsStartElement("AxesInfo", "urn:schemas-microsoft-com:xml-analysis:mddataset"))
         {
             reader.Skip();
         }
         return;
     }
     reader.ReadStartElement("AxesInfo", "urn:schemas-microsoft-com:xml-analysis:mddataset");
     while (reader.IsStartElement("AxisInfo", "urn:schemas-microsoft-com:xml-analysis:mddataset"))
     {
         MDDatasetFormatter.DataSetFormatterAxis dataSetFormatterAxis = new MDDatasetFormatter.DataSetFormatterAxis(reader.GetAttribute("name"));
         if (!reader.IsEmptyElement)
         {
             reader.ReadStartElement();
             while (reader.IsStartElement("HierarchyInfo", "urn:schemas-microsoft-com:xml-analysis:mddataset"))
             {
                 DataTable dataTable = new DataTable(reader.GetAttribute("name"));
                 dataTable.Locale = CultureInfo.InvariantCulture;
                 dataSetFormatterAxis.AddTable(dataTable);
                 Collection <int> collection = new Collection <int>();
                 dataTable.ExtendedProperties["MemberProperties"] = collection;
                 reader.ReadStartElement();
                 DataColumnCollection columns = dataTable.Columns;
                 while (reader.IsStartElement())
                 {
                     FormattersHelpers.CheckException(reader);
                     try
                     {
                         DataColumn dataColumn = new DataColumn(reader.Name, typeof(object));
                         dataColumn.Namespace = reader.NamespaceURI;
                         FormattersHelpers.SetColumnType(dataColumn, FormattersHelpers.GetElementType(reader));
                         dataColumn.Caption = reader.GetAttribute("name");
                         columns.Add(dataColumn);
                         collection.Add(columns.Count - 1);
                     }
                     catch (DuplicateNameException)
                     {
                         collection.Add(columns.IndexOf(reader.Name));
                     }
                     reader.Skip();
                 }
                 reader.ReadEndElement();
             }
             FormattersHelpers.CheckException(reader);
             reader.ReadEndElement();
         }
         else
         {
             FormattersHelpers.CheckException(reader);
             reader.Skip();
         }
         if ("SlicerAxis" == dataSetFormatterAxis.DataSetName)
         {
             this.filterAxis = dataSetFormatterAxis;
         }
         else
         {
             this.axesList.Add(dataSetFormatterAxis);
         }
     }
     FormattersHelpers.CheckException(reader);
     reader.ReadEndElement();
 }