コード例 #1
0
        private static string ReadPropertyXml(XmlReader reader)
        {
            StringBuilder stringBuilder = new StringBuilder();
            XmlaReader    xmlaReader    = reader as XmlaReader;
            bool          skipElements  = true;

            try
            {
                if (xmlaReader != null)
                {
                    skipElements            = xmlaReader.SkipElements;
                    xmlaReader.SkipElements = false;
                }
                while (reader.IsStartElement())
                {
                    stringBuilder.Append(reader.ReadOuterXml());
                }
            }
            finally
            {
                if (xmlaReader != null)
                {
                    xmlaReader.SkipElements = skipElements;
                }
            }
            return(stringBuilder.ToString());
        }
 public override void Close()
 {
     if (!this.isClosed)
     {
         this.isClosed = true;
         if (!this.isDelegate)
         {
             this.srcReader.Close();
             return;
         }
         while (this.Depth >= 0 && (this.srcReader.NodeType != XmlNodeType.EndElement || this.strColumnName != this.srcReader.Name || this.strColumnNamespace != this.srcReader.NamespaceURI))
         {
             this.srcReader.Read();
         }
         this.srcReader.ReadEndElement();
         XmlaReader xmlaReader = this.srcReader as XmlaReader;
         if (xmlaReader != null)
         {
             xmlaReader.SkipElements = this.originalSkipElements;
         }
     }
 }
        internal ColumnXmlReader(XmlReader xmlReader, string columnName, string strNamespace)
        {
            this.strColumnName      = columnName;
            this.strColumnNamespace = strNamespace;
            this.srcReader          = xmlReader;
            this.strXml             = string.Empty;
            this.isDelegate         = true;
            this.isClosed           = false;
            this.startDepth         = this.srcReader.Depth;
            XmlaReader xmlaReader = this.srcReader as XmlaReader;

            if (xmlaReader != null)
            {
                this.originalSkipElements = xmlaReader.SkipElements;
                xmlaReader.SkipElements   = false;
            }
            do
            {
                xmlReader.Read();
            }while (!xmlReader.IsStartElement() && xmlReader.NodeType != XmlNodeType.EndElement && !xmlReader.EOF);
            this.isDataSet = (xmlReader.NamespaceURI == "urn:schemas-microsoft-com:xml-analysis:xmlDocumentDataset");
        }
        public XmlReader ExecuteXmlReader()
        {
            this.CheckCanExecute();
            XmlaReader xmlaReader = this.connection.IExecuteProvider.Execute(this, this.Properties, this.PrivateParameters);

            this.Connection.OpenedReader = null;
            if (xmlaReader == null)
            {
                return(null);
            }
            XmlReader result;

            try
            {
                XmlaClient.ReadUptoRoot(xmlaReader);
                if (!XmlaClient.IsRowsetResponseS(xmlaReader) && !XmlaClient.IsDatasetResponseS(xmlaReader))
                {
                    this.connection.MarkCacheNeedsCheckForValidness();
                }
                xmlaReader.MaskEndOfStream   = true;
                xmlaReader.SkipElements      = false;
                this.Connection.OpenedReader = xmlaReader;
                result = xmlaReader;
            }
            catch (AdomdUnknownResponseException)
            {
                if (xmlaReader != null)
                {
                    xmlaReader.Close();
                }
                throw;
            }
            catch (AdomdConnectionException)
            {
                throw;
            }
            catch (XmlException innerException)
            {
                if (xmlaReader != null)
                {
                    xmlaReader.Close();
                }
                throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, innerException);
            }
            catch (IOException innerException2)
            {
                if (this.connection != null)
                {
                    this.connection.Close(false);
                }
                throw new AdomdConnectionException(XmlaSR.ConnectionBroken, innerException2);
            }
            catch (XmlaException innerException3)
            {
                if (xmlaReader != null)
                {
                    xmlaReader.Close();
                }
                throw new AdomdErrorResponseException(innerException3);
            }
            catch
            {
                if (this.connection != null)
                {
                    this.connection.Close(false);
                }
                throw;
            }
            return(result);
        }
        public object Execute()
        {
            this.CheckCanExecute();
            XmlaReader xmlaReader = null;

            xmlaReader = this.connection.IExecuteProvider.Execute(this, this.Properties, this.PrivateParameters);
            this.Connection.OpenedReader = null;
            if (xmlaReader == null)
            {
                this.connection.MarkCacheNeedsCheckForValidness();
                return(null);
            }
            object result;

            try
            {
                object obj = null;
                if (XmlaClient.IsExecuteResponseS(xmlaReader))
                {
                    XmlaClient.StartExecuteResponseS(xmlaReader);
                    if (XmlaClient.IsDatasetResponseS(xmlaReader))
                    {
                        MDDatasetFormatter mDDatasetFormatter = SoapFormatter.ReadDataSetResponse(xmlaReader);
                        if (mDDatasetFormatter != null)
                        {
                            obj = new CellSet(this.connection, mDDatasetFormatter);
                        }
                    }
                    else if (XmlaClient.IsRowsetResponseS(xmlaReader))
                    {
                        obj = AdomdDataReader.CreateInstance(xmlaReader, CommandBehavior.Default, this.connection);
                    }
                    else if (XmlaClient.IsEmptyResultS(xmlaReader))
                    {
                        this.connection.MarkCacheNeedsCheckForValidness();
                        XmlaClient.ReadEmptyRootS(xmlaReader);
                    }
                    else
                    {
                        if (!XmlaClient.IsMultipleResult(xmlaReader) && !XmlaClient.IsAffectedObjects(xmlaReader))
                        {
                            this.connection.MarkCacheNeedsCheckForValidness();
                            throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, string.Format(CultureInfo.InvariantCulture, "Expected dataset, rowset, empty or multiple results, got {0}", new object[]
                            {
                                xmlaReader.Name
                            }));
                        }
                        this.connection.MarkCacheNeedsCheckForValidness();
                        XmlaClient.ReadMultipleResults(xmlaReader);
                    }
                }
                if (!(obj is AdomdDataReader))
                {
                    xmlaReader.Close();
                }
                else
                {
                    this.Connection.OpenedReader = obj;
                }
                result = obj;
            }
            catch (AdomdUnknownResponseException)
            {
                if (xmlaReader != null)
                {
                    xmlaReader.Close();
                }
                throw;
            }
            catch (AdomdConnectionException)
            {
                throw;
            }
            catch (XmlException innerException)
            {
                if (xmlaReader != null)
                {
                    xmlaReader.Close();
                }
                throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, innerException);
            }
            catch (IOException innerException2)
            {
                if (this.connection != null)
                {
                    this.connection.Close(false);
                }
                throw new AdomdConnectionException(XmlaSR.ConnectionBroken, innerException2);
            }
            catch (XmlaException innerException3)
            {
                if (xmlaReader != null)
                {
                    xmlaReader.Close();
                }
                throw new AdomdErrorResponseException(innerException3);
            }
            catch
            {
                if (this.connection != null)
                {
                    this.connection.Close(false);
                }
                throw;
            }
            return(result);
        }