Esempio n. 1
0
        public static CellSet LoadXml(XmlReader xmlTextReader)
        {
            if (xmlTextReader == null)
            {
                throw new ArgumentNullException("xmlTextReader");
            }
            if (xmlTextReader.ReadState != ReadState.Initial && xmlTextReader.ReadState != ReadState.Interactive)
            {
                throw new ArgumentException(SR.CellSet_InvalidStateOfReader(xmlTextReader.ReadState.ToString()), "xmlTextReader");
            }
            CellSet result;

            try
            {
                XmlReader reader;
                if (xmlTextReader is XmlaReader)
                {
                    ((XmlaReader)xmlTextReader).SkipElements = true;
                    reader = xmlTextReader;
                }
                else
                {
                    reader = new SkippingWrapperReader(xmlTextReader);
                }
                MDDatasetFormatter formatter = SoapFormatter.ReadDataSetResponse(reader);
                CellSet            cellSet   = new CellSet(formatter);
                result = cellSet;
            }
            catch (XmlaException innerException)
            {
                throw new AdomdErrorResponseException(innerException);
            }
            catch (XmlException innerException2)
            {
                throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, innerException2);
            }
            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);
        }