private static ResultsetFormatter ReadDiscoverResponsePrivate(XmlReader reader, InlineErrorHandlingType inlineErrorHandling, DataTable inTable, bool schemaOnly, Dictionary <string, bool> columnsToConvertTimeFor) { XmlaClient.StartDiscoverResponseS(reader); if (XmlaClient.IsRowsetResponseS(reader)) { return(SoapFormatter.ReadRowsetResponsePrivate(reader, inlineErrorHandling, inTable, schemaOnly, columnsToConvertTimeFor)); } if (!XmlaClient.IsEmptyResultS(reader)) { throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, string.Format("Expected rowset or empty result, got {0}", reader.Name)); } XmlaClient.ReadEmptyRootS(reader); XmlaClient.EndDiscoverResponseS(reader); return(null); }
private bool InternalNextResult(bool first) { if (!first) { this.InitResultData(); this.SkipRootContents(); } if (XmlaClient.IsEmptyResultS(this.xmlReader)) { if (this.IsAffectedObjects) { throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, "Got an empty result inside AffectedObjects"); } this.RowsetName = null; this.xmlReader.ReadStartElement("root", "urn:schemas-microsoft-com:xml-analysis:empty"); this.GenerateSchemaForEmptyResult(); this.emptyResult = true; this.EnsureResultForNewRowset(); return(true); } else { if (this.xmlReader.IsStartElement("root", "urn:schemas-microsoft-com:xml-analysis:rowset")) { this.RowsetName = this.xmlReader.GetAttribute("name"); this.rowsetNames.Add(this.RowsetName); XmlaClient.StartRowsetResponseS(this.xmlReader); this.LoadResponseSchema(); this.dataReady = true; this.emptyResult = false; this.EnsureResultForNewRowset(); return(true); } if (first) { throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, "Expected at least one root element"); } this.CheckForMessages(); XmlaClient.EndElementS(this.xmlReader, this.IsAffectedObjects ? "AffectedObjects" : "results", "http://schemas.microsoft.com/analysisservices/2003/xmla-multipleresults"); this.isMultipleResult = false; return(false); } }
private static ResultsetFormatter ReadExecuteResponsePrivate(XmlReader reader, InlineErrorHandlingType inlineErrorHandling) { XmlaClient.StartExecuteResponseS(reader); if (XmlaClient.IsDatasetResponseS(reader)) { return(SoapFormatter.ReadDataSetResponsePrivate(reader)); } if (XmlaClient.IsRowsetResponseS(reader)) { return(SoapFormatter.ReadRowsetResponsePrivate(reader, inlineErrorHandling, null, false, null)); } if (!XmlaClient.IsEmptyResultS(reader)) { throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, string.Format("Expected dataset, rowset, or empty result, got {0}", reader.Name)); } XmlaClient.ReadEmptyRootS(reader); XmlaClient.EndExecuteResponseS(reader); return(null); }
internal XmlaDataReader(XmlReader xmlReader, CommandBehavior commandBehavior, bool isXmlReaderAtRoot, IXmlaDataReaderOwner owner) { this.columnNameLookup = new Hashtable(); this.columnXmlNameLookup = new Hashtable(); this.rowsetNames = new List <string>(); this.rowElement = FormattersHelpers.RowElement; this.rowNamespace = FormattersHelpers.RowElementNamespace; this.readersXmlDepth = -1; //base..ctor(); try { this.InternalInitialize(xmlReader, commandBehavior, owner); if (!isXmlReaderAtRoot) { XmlaClient.ReadUptoRoot(xmlReader); } this.IsAffectedObjects = XmlaClient.IsAffectedObjectsResponseS(xmlReader); this.isMultipleResult = (this.IsAffectedObjects || XmlaClient.IsMultipleResultResponseS(xmlReader)); this.Results = new XmlaResultCollection(); this.CollectTopLevelAttributes(); if (XmlaClient.IsRowsetResponseS(xmlReader)) { this.RowsetName = xmlReader.GetAttribute("name"); this.rowsetNames.Add(this.RowsetName); this.EnsureResultForNewRowset(); XmlaClient.StartRowsetResponseS(xmlReader); this.LoadResponseSchema(); } else if (XmlaClient.IsMultipleResultResponseS(xmlReader) || XmlaClient.IsAffectedObjectsResponseS(xmlReader)) { XmlaClient.StartElementS(xmlReader, this.IsAffectedObjects ? "AffectedObjects" : "results", "http://schemas.microsoft.com/analysisservices/2003/xmla-multipleresults"); if (XmlaClient.IsRootElementS(xmlReader)) { this.InternalNextResult(true); } else { if (!this.IsAffectedObjects) { throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, "Expected at least one root element"); } this.StartEmptyAffectedObjects(); } } else { if (XmlaClient.IsDatasetResponseS(xmlReader)) { throw new AdomdUnknownResponseException(XmlaSR.Resultset_IsNotRowset, string.Format(CultureInfo.InvariantCulture, "Got {0}:{1}", new object[] { "urn:schemas-microsoft-com:xml-analysis:mddataset", "root" })); } if (!XmlaClient.IsEmptyResultS(xmlReader)) { throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, string.Format(CultureInfo.InvariantCulture, "Expected {0}:{1}, got {2}", new object[] { "urn:schemas-microsoft-com:xml-analysis:empty", "root", xmlReader.Name })); } XmlaClient.ReadEmptyRootS(xmlReader); throw new AdomdUnknownResponseException(XmlaSR.Resultset_IsNotRowset, string.Format(CultureInfo.InvariantCulture, "Unexpected node {0}", new object[] { xmlReader.Name })); } } catch (AdomdUnknownResponseException) { xmlReader.Close(); throw; } catch (AdomdConnectionException) { throw; } catch (XmlException innerException) { xmlReader.Close(); throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, innerException); } catch (IOException innerException2) { if (this.owner != null) { owner.CloseConnection(false); } throw new AdomdConnectionException(XmlaSR.ConnectionBroken, innerException2); } catch (XmlaException innerException3) { xmlReader.Close(); throw new AdomdErrorResponseException(innerException3); } catch { if (this.owner != null) { owner.CloseConnection(false); } throw; } }
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); }
public ResultsetFormatter ReadResponse(XmlReader reader, InlineErrorHandlingType inlineErrorHandling) { ResultsetFormatter result; try { ResultsetFormatter resultsetFormatter = null; if (XmlaClient.IsExecuteResponseS(reader)) { resultsetFormatter = SoapFormatter.ReadExecuteResponsePrivate(reader, inlineErrorHandling); } else if (XmlaClient.IsDiscoverResponseS(reader)) { resultsetFormatter = SoapFormatter.ReadDiscoverResponsePrivate(reader, inlineErrorHandling, null, false, null); } else { if (!XmlaClient.IsEmptyResultS(reader)) { throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, string.Format(CultureInfo.InvariantCulture, "Expected execute or discover response, or empty result, got {0}", new object[] { reader.Name })); } XmlaClient.ReadEmptyRootS(reader); } result = resultsetFormatter; } catch (XmlException innerException) { throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, innerException); } catch (IOException innerException2) { if (this.client != null) { this.client.Disconnect(false); } throw new AdomdConnectionException(XmlaSR.ConnectionBroken, innerException2); } catch (AdomdUnknownResponseException) { throw; } catch (XmlaException) { throw; } catch { if (this.client != null) { this.client.Disconnect(false); } throw; } finally { this.EndReceival(reader); } return(result); }