internal AxisCollection(AdomdConnection connection, CellSet cellset, string cubeName)
 {
     this.connection         = connection;
     this.cellset            = cellset;
     this.cubeName           = cubeName;
     this.internalCollection = cellset.Formatter.AxesList;
 }
 internal Axis(AdomdConnection connection, IDSFDataSet dataset, string cubeName, CellSet cellSet, int axisOrdinal)
 {
     this.cellset     = cellSet;
     this.axisOrdinal = axisOrdinal;
     this.set         = new Set(connection, dataset, cubeName, this);
     this.positions   = new PositionCollection(connection, this.set, cubeName);
 }
 internal Cell(DataTable cellsTable, int cellOrdinal, DataRow cellRow, CellSet cellSet)
 {
     this.cellsTable  = cellsTable;
     this.cellOrdinal = cellOrdinal;
     this.cellRow     = cellRow;
     this.cellSet     = cellSet;
     this.cellProps   = null;
 }
 internal CellCollection(CellSet cellset)
 {
     this.cellset            = cellset;
     this.internalCollection = cellset.Formatter.CellTable.Rows;
     AxisCollection.Enumerator enumerator = cellset.Axes.GetEnumerator();
     while (enumerator.MoveNext())
     {
         Axis current = enumerator.Current;
         this.count *= current.Set.Tuples.Count;
     }
     this.valueColumnIndex    = cellset.Formatter.CellTable.Columns.IndexOf("Value");
     this.fmtValueColumnIndex = cellset.Formatter.CellTable.Columns.IndexOf("FmtValue");
     this.ordinalColumnIndex  = cellset.Formatter.CellTable.Columns.IndexOf("CellOrdinal");
     this.firstCellOrdinal    = -1;
     this.lastCellOrdinal     = -1;
     if (cellset.Formatter.CellTable.Rows.Count > 0)
     {
         this.firstCellOrdinal = (int)cellset.Formatter.CellTable.Rows[0][this.ordinalColumnIndex];
         this.lastCellOrdinal  = (int)cellset.Formatter.CellTable.Rows[cellset.Formatter.CellTable.Rows.Count - 1][this.ordinalColumnIndex];
     }
 }
        private MemberCollection ExecuteMembersQuery(string memberMdxQuery, Level parentLevel, Member parentMember, int memberAxisPosition, int memberHierarhcyPosition)
        {
            if (memberAxisPosition < 0)
            {
                throw new ArgumentOutOfRangeException("memberAxisPosition");
            }
            if (memberHierarhcyPosition < 0)
            {
                throw new ArgumentOutOfRangeException("memberHierarhcyPosition");
            }
            AdomdConnection connection = this.Connection;

            if (connection == null)
            {
                throw new NotSupportedException(SR.NotSupportedWhenConnectionMissing);
            }
            AdomdUtils.CheckConnectionOpened(connection);
            AdomdCommand adomdCommand = new AdomdCommand(memberMdxQuery, connection);
            CellSet      cellSet      = adomdCommand.ExecuteCellSet();

            if (memberAxisPosition >= cellSet.Axes.Count)
            {
                throw new ArgumentOutOfRangeException("memberAxisPosition");
            }
            Axis        axis        = cellSet.Axes[memberAxisPosition];
            IDSFDataSet axisDataset = axis.Set.AxisDataset;
            DataTable   memberHierarchyDataTable = null;

            if (memberHierarhcyPosition != 0 || axisDataset.Count != 0)
            {
                if (memberHierarhcyPosition >= axisDataset.Count)
                {
                    throw new ArgumentOutOfRangeException("memberHierarhcyPosition");
                }
                memberHierarchyDataTable = axisDataset[memberHierarhcyPosition];
            }
            return(new MemberCollection(connection, memberHierarchyDataTable, this.Name, parentLevel, parentMember));
        }
Пример #6
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);
        }
Пример #8
0
 public CellSet(AsAdomdClient.CellSet obj)
 {
     _obj = obj;
 }
        private static void CellsetToDataTable(AdomdClient.CellSet cellset, DataTable table, int rowsLimit)
        {
            #region Argument exception

            if (table == null)
            {
                throw new ArgumentNullException("table");
            }

            if (cellset == null)
            {
                throw new ArgumentNullException("cellset");
            }

            if (rowsLimit < 0)
            {
                throw new ArgumentOutOfRangeException("rowsLimit");
            }

            #endregion

            if (rowsLimit == 0)
            {
                return;
            }

            int columnsHeaders = 0;
            int rowsHeaders    = 0;
            int columnsOn0     = 0;
            int rowsOn1        = 0;

            if (cellset.Axes.Count == 0)
            {
                #region Axes.Count == 0

                columnsHeaders = 0;
                rowsHeaders    = 0;
                columnsOn0     = cellset.FilterAxis.Positions.Count;
                rowsOn1        = 1;

                for (int i = 0; i < columnsOn0; i++)
                {
                    table.Columns.Add();
                }

                var values = new object[columnsOn0];

                for (int i = 0; i < columnsOn0; i++)
                {
                    values[i] = cellset[i].Value;
                }

                table.Rows.Add(values);

                #endregion
            }
            else if (cellset.Axes.Count == 1)
            {
                #region Axes.Count == 1

                if (cellset.Axes[0].Positions.Count == 0)
                {
                    return;
                }

                columnsHeaders = cellset.Axes[0].Positions[0].Members.Count;
                rowsHeaders    = 0;
                columnsOn0     = cellset.Axes[0].Positions.Count;
                rowsOn1        = 1;

                int rowCount    = rowsOn1 + columnsHeaders;
                int columnCount = columnsOn0 + rowsHeaders;

                for (int i = 0; i < columnCount; i++)
                {
                    table.Columns.Add();
                }

                for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
                {
                    var values = new object[columnCount];

                    for (int columnIdx = 0; columnIdx < columnCount; columnIdx++)
                    {
                        if (rowIdx < columnsHeaders)
                        {
                            values[columnIdx] = cellset.Axes[0].Positions[columnIdx - rowsHeaders].Members[rowIdx].Caption;
                        }
                        else
                        {
                            var value = cellset[columnIdx - rowsHeaders].Value;
                            if (value != null)
                            {
                                values[columnIdx] = value;
                            }
                        }
                    }

                    table.Rows.Add(values);
                }

                #endregion
            }
            else if (cellset.Axes.Count == 2)
            {
                #region Axes.Count == 2

                if (cellset.Axes[0].Positions.Count == 0 || cellset.Axes[1].Positions.Count == 0)
                {
                    return; // No data returned for the selection
                }
                // number of dimensions on the column
                columnsHeaders = cellset.Axes[0].Positions[0].Members.Count;
                // number of dimensions on the row
                rowsHeaders = cellset.Axes[1].Positions[0].Members.Count;

                // number of columns on Axes[0] --> excluding columns for row headers
                columnsOn0 = cellset.Axes[0].Positions.Count;
                // number of rows on Axes[1] --> excluding rows for column headers
                rowsOn1 = cellset.Axes[1].Positions.Count;

                if (rowsOn1 > rowsLimit)
                {
                    rowsOn1 = rowsLimit;
                    table.ExtendedProperties.Add("RowsFiltered", rowsLimit);
                }

                // total rows and columns
                int rowCount    = rowsOn1 + columnsHeaders; // number of rows + rows for column headers
                int columnCount = columnsOn0 + rowsHeaders; // number of columns + columns for row headers

                for (int i = 0; i < columnCount; i++)
                {
                    table.Columns.Add();
                }

                for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
                {
                    var values = new object[columnCount];

                    for (int columnIdx = 0; columnIdx < columnCount; columnIdx++)
                    {
                        // check if we are writing to a ROW having column header
                        if (rowIdx < columnsHeaders)
                        {
                            // check if we are writing to a cell having row header
                            if (columnIdx < rowsHeaders)
                            {
                                // this should be empty cell -- it's on top left of the grid
                                values[columnIdx] = string.Empty;
                            }
                            else
                            {
                                // this is a column header cell -- use member caption for header
                                values[columnIdx] = cellset.Axes[0].Positions[columnIdx - rowsHeaders].Members[rowIdx].Caption;
                            }
                        }
                        // we are here.. so we are writing a row having data (not column headers), check if we are writing to a cell having row header
                        else if (columnIdx < rowsHeaders)
                        {
                            // this is a row header cell -- use member caption for header
                            values[columnIdx] = cellset.Axes[1].Positions[rowIdx - columnsHeaders].Members[columnIdx].Caption;
                        }
                        else
                        {
                            // this is data cell.. so we write the Formatted value of the cell.
                            var value = cellset[columnIdx - rowsHeaders, rowIdx - columnsHeaders].Value;
                            if (value != null)
                            {
                                values[columnIdx] = value;
                            }
                        }
                    }

                    table.Rows.Add(values);
                }
                ;

                #endregion
            }
            else
            {
                throw new ApplicationException("Queries with more than two axes are not supported [" + cellset.Axes.Count + "]");
            }

            table.ExtendedProperties.Add("ColumnsHeadersCount", columnsHeaders);
            table.ExtendedProperties.Add("RowsHeadersCount", rowsHeaders);
            table.ExtendedProperties.Add("ColumnsOn0Count", columnsOn0);
            table.ExtendedProperties.Add("RowsOn1Count", rowsOn1);
            table.ExtendedProperties.Add("AxesCount", cellset.Axes.Count);
        }