Ejemplo n.º 1
1
        private DataTable CellSetToTable(CellSet cellset)
        {
            DataTable table = new DataTable("cellset");

            Axis columns = cellset.Axes[0];//获取列轴
            Axis rows = cellset.Axes[1]; //获取行轴
            CellCollection valuesCell = cellset.Cells;//获取度量值单元集合
            //行轴的级别标题为表的第一列
            table.Columns.Add(rows.Set.Hierarchies[0].Caption);
            //行轴的成各个成员的标题变成表的列
            for (int i = 0; i < columns.Set.Tuples.Count; i++)
            {
                table.Columns.Add(new DataColumn(columns.Set.Tuples[i].Members[0].Caption));
            }
            int valuesIndex = 0;
            DataRow row = null;
            //向表中填充数据
            for (int i = 0; i < rows.Set.Tuples.Count; i++)
            {
                row = table.NewRow();
                //表所有行的第一列值为相应行轴的成标题
                row[0] = rows.Set.Tuples[i].Members[0].Caption;
                for (int k = 1; k <= columns.Set.Tuples.Count; k++)
                {   //按顺序把度量值单元集合的值填充到表中
                    row[k] = valuesCell[valuesIndex].Value;
                    valuesIndex++;
                }
                table.Rows.Add(row);
            }

            return table;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据mdx语句、连接字符串
        /// </summary>
        /// <param name="strMdx"></param>
        /// <param name="ConnectionStringName"></param>
        /// <returns></returns>
        public DataTable GetDataByCon(string strMdx, string ConStr)
        {
            DataTable dt = new DataTable();

            try
            {
                using (AdomdConnection _connection = new AdomdConnection(ConStr))
                {
                    if (_connection != null)
                    {
                        if (_connection.State == ConnectionState.Closed)
                        {
                            _connection.Open();
                        }

                        AdomdCommand cmd = _connection.CreateCommand();
                        cmd.CommandText = strMdx;

                        var     executexml = cmd.ExecuteXmlReader();
                        CellSet cellset    = CellSet.LoadXml(executexml);
                        //_connection.GetSchemaDataSet
                        _connection.Close();
                        dt = ToDataTable(cellset);
                    }
                }

                return(dt);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        public void LoadData(DataTable dt)
        {
            moSet = null;
            moTable = dt;

            this.ClearGrid();

            this.ColumnsCount = dt.Columns.Count;
            this.RowsCount = 1;

            // set the column headers
            for (int i = 0; i<dt.Columns.Count; i++)
            {
                DataColumn oColumn = dt.Columns[i];
                SetHeaderValue(0, i, oColumn.Caption);
            }

            int iRow = 1;
            this.RowsCount = 1;
            foreach(DataRow oRow in dt.Rows)
            {
                this.RowsCount++;
                for (int iCol = 0; iCol < dt.Columns.Count; iCol++)
                {
                    string sValue = oRow[iCol].ToString();
                    SetCellValue(iRow, iCol, sValue);
                    //this[iRow, iCol] = new SourceGrid3.Cells.Real.Cell(sValue);
                }
                iRow++;
            }
        }
Ejemplo n.º 4
0
        public virtual CellSet ExecuteCellSet(out float elapsedSec)
        {
            // Open the connection
            using (var connection = new AdomdConnection())
            {
                var connectionString = command.Connection.ConnectionString;
                try
                { connection.ConnectionString = connectionString; }
                catch (ArgumentException ex)
                { throw new ConnectionException(ex, connectionString); }
                //TODO
                //try
                //    {connection.Open();}
                //catch (AdomdException ex)
                //    {throw new ConnectionException(ex);}

                Trace.WriteLineIf(NBiTraceSwitch.TraceVerbose, command.CommandText);
                foreach (AdomdParameter param in command.Parameters)
                {
                    Trace.WriteLineIf(NBiTraceSwitch.TraceVerbose, string.Format("{0} => {1}", param.ParameterName, param.Value));
                }

                // capture time before execution
                DateTime timeBefore = DateTime.Now;
                CellSet  cellSet    = null;

                try
                {
                    if (command.Connection.State != ConnectionState.Open)
                    {
                        command.Connection.Open();
                    }
                    cellSet = command.ExecuteCellSet();
                }
                catch (AdomdConnectionException ex)
                {
                    throw new ConnectionException(ex, connectionString);
                }
                catch (AdomdErrorResponseException ex)
                {
                    throw new ConnectionException(ex, connectionString);
                }
                finally
                {
                    if (command.Connection.State == ConnectionState.Open)
                    {
                        command.Connection.Close();
                    }
                }

                // capture time after execution
                DateTime timeAfter = DateTime.Now;

                // setting query runtime
                elapsedSec = (float)timeAfter.Subtract(timeBefore).TotalSeconds;
                Trace.WriteLineIf(NBiTraceSwitch.TraceInfo, string.Format("Time needed to execute query [ADOMD]: {0}", timeAfter.Subtract(timeBefore).ToString(@"d\d\.hh\h\:mm\m\:ss\s\ \+fff\m\s")));

                return(cellSet);
            }
        }
Ejemplo n.º 5
0
        public void TestCellsDeletion()
        {
            const string testKey   = "content";
            const string testValue = "the force is strong in this column";
            var          client    = CreateClient();
            var          set       = new CellSet();
            var          row       = new CellSet.Row {
                key = Encoding.UTF8.GetBytes(testKey)
            };

            set.rows.Add(row);

            var value = new Cell {
                column = Encoding.UTF8.GetBytes("d:starwars"), data = Encoding.UTF8.GetBytes(testValue)
            };

            row.values.Add(value);

            client.StoreCellsAsync(testTableName, set).Wait();
            CellSet cell = client.GetCellsAsync(testTableName, testKey).Result;

            // make sure the cell is in the table
            Assert.AreEqual(Encoding.UTF8.GetString(cell.rows[0].key), testKey);
            // delete cell
            client.DeleteCellsAsync(testTableName, testKey).Wait();
            // get cell again, 404 exception expected
            client.GetCellsAsync(testTableName, testKey).Wait();
        }
Ejemplo n.º 6
0
Archivo: Class9.cs Proyecto: ikvm/test
        private void method_19(CellSet cellSet_1)
        {
            Parser parser = new Parser(cellSet_1);

            if (base.int_2 >= 2)
            {
                int   startRow  = -1;
                int   endRow    = -1;
                Field topHeader = parser.TopHeader;
                if (topHeader != null)
                {
                    startRow = topHeader.StartRow;
                }
                Field dataField = parser.DataField;
                if (startRow == -1)
                {
                    startRow = dataField.StartRow;
                }
                endRow = dataField.EndRow;
                for (int i = 1; i < cellSet_1.Row; i++)
                {
                    if ((i < startRow) || (i > endRow))
                    {
                        this.method_20(cellSet_1, i);
                    }
                }
            }
        }
Ejemplo n.º 7
0
Archivo: Class9.cs Proyecto: ikvm/test
        private void method_21(CellSet cellSet_1, int int_10, int int_11, int int_12)
        {
            Parser   parser    = new Parser(cellSet_1);
            Operator @operator = new Operator(cellSet_1);

            if (parser.isMerged(int_10, int_11))
            {
                int    num3 = parser.getColSpan(int_10, int_11, true);
                string str3 = parser.getMergedExp(int_10, int_11);
                string exp  = new StringBuilder(str3.Substring(0, str3.IndexOf(",") + 1).ToString().ToString()).Append((int_11 - num3) + 1).Append(str3.Substring(str3.IndexOf("-"), (str3.LastIndexOf(",") + 1) - str3.IndexOf("-"))).Append(int_11 + int_12).ToString().ToString();
                for (int i = (int_11 - num3) + 1; i <= (int_11 + int_12); i++)
                {
                    if (i > int_11)
                    {
                        cellSet_1.setCell(int_10, i, cellSet_1.getCell(int_10, int_11));
                    }
                    @operator.setMergedExp(int_10, i, exp);
                }
            }
            else
            {
                string str = new StringBuilder(int_10.ToString().ToString()).Append(",").Append(int_11).Append("-").Append(int_10).Append(",").Append(int_11 + int_12).ToString().ToString();
                for (int j = int_11; j <= (int_11 + int_12); j++)
                {
                    if (j > int_11)
                    {
                        cellSet_1.setCell(int_10, j, cellSet_1.getCell(int_10, int_11));
                    }
                    @operator.setMergedExp(int_10, j, str);
                }
            }
        }
Ejemplo n.º 8
0
        private void method_5(ExcelFile excelFile_1, int int_2, CellSet cellSet_0)
        {
            Parser parser     = new Parser(cellSet_0);
            Field  leftHeader = parser.LeftHeader;

            if (leftHeader != null)
            {
                int num1 = leftHeader.StartColumn - 1;
                int num2 = leftHeader.EndColumn - 1;
            }
            Field titleField = parser.TitleField;
            Field topHeader  = parser.TopHeader;

            if ((titleField != null) && (topHeader != null))
            {
                int num3 = topHeader.EndRow - titleField.StartRow;
            }
            else if ((titleField != null) || (topHeader == null))
            {
                if ((titleField != null) && (topHeader == null))
                {
                    int num4 = titleField.EndRow - titleField.StartRow;
                }
            }
            else
            {
                int num5 = topHeader.EndRow - topHeader.StartRow;
            }
        }
Ejemplo n.º 9
0
Archivo: Class9.cs Proyecto: ikvm/test
        private void method_14(CellSet cellSet_1)
        {
            Parser   parser    = new Parser(cellSet_1);
            Operator @operator = new Operator(cellSet_1);

            for (int i = 1; i < parser.RowCount; i++)
            {
                for (int j = 1; j < parser.ColCount; j++)
                {
                    if (parser.isMergedFirstCell(i, j))
                    {
                        int num4 = parser.getColSpan(i, j, true);
                        int num7 = parser.ColCount - j;
                        num4 = (num4 <= num7) ? num4 : num7;
                        int    num6 = parser.getRowSpan(i, j, true);
                        string exp  = new StringBuilder(i.ToString().ToString()).Append(",").Append(j).Append("-").Append((i + num6) - 1).Append(",").Append((j + num4) - 1).ToString().ToString();
                        for (int k = i; k < (i + num6); k++)
                        {
                            for (int m = j; m < (j + num4); m++)
                            {
                                @operator.setMergedExp(k, m, exp);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public virtual bool sameRowTypeAs(CellExt other)
        {
            CellExt ext  = CellSet.getCell(Row, 0);
            CellExt ext2 = CellSet.getCell(other.Row, 0);
            object  obj2 = null;
            object  obj3 = null;

            if ((ext != null) && (ext.ExpMap.PropGetMap != null))
            {
                obj2 = ext.ExpMap.PropGetMap[803];
            }
            if (obj2 == null)
            {
                obj2 = PropertyDefine.CRT_NORMAL;
            }
            if ((ext2 != null) && (ext2.ExpMap.PropGetMap != null))
            {
                obj3 = ext2.ExpMap.PropGetMap[803];
            }
            if (obj3 == null)
            {
                obj3 = PropertyDefine.CRT_NORMAL;
            }
            if (!PropertyDefine.CRT_NORMAL.Equals(obj2) && !PropertyDefine.CRT_TABLE_HEADER.Equals(obj2))
            {
                return(obj2.Equals(obj3));
            }
            return(PropertyDefine.CRT_NORMAL.Equals(obj3) || PropertyDefine.CRT_TABLE_HEADER.Equals(obj3));
        }
Ejemplo n.º 11
0
        public void TestStoreSingleCell()
        {
            const string testKey   = "content";
            const string testValue = "the force is strong in this column";
            var          client    = CreateClient();
            var          set       = new CellSet();
            var          row       = new CellSet.Types.Row {
                Key = ByteString.CopyFromUtf8(testKey)
            };

            set.Rows.Add(row);

            var value = new Cell {
                Column = ByteString.CopyFromUtf8("d:starwars"), Data = ByteString.CopyFromUtf8(testValue)
            };

            row.Values.Add(value);

            client.StoreCellsAsync(TestTableName, set).Wait();

            var cells = client.GetCellsAsync(TestTableName, testKey).Result;

            Assert.Single(cells.Rows);
            Assert.Single(cells.Rows[0].Values);
            Assert.Equal(testValue, cells.Rows[0].Values[0].Data.ToStringUtf8());
        }
Ejemplo n.º 12
0
        public static BodyResourceData Load(IResourceGenerator generator, CelestialBody body, ConfigNode bodyNode)
        {
            if (bodyNode == null)
            {
                bodyNode = new ConfigNode();
            }
            var resources = generator.Load(body, bodyNode.GetNode("GeneratorData"));
            var scans     = new CellSet(KethaneData.GridLevel);

            var scanMask = bodyNode.GetValue("ScanMask");

            if (scanMask != null)
            {
                try
                {
                    scans = new CellSet(KethaneData.GridLevel, Misc.FromBase64String(scanMask));
                }
                catch (FormatException e)
                {
                    Debug.LogError(String.Format("[Kethane] Failed to parse {0} scan string, resetting ({1})", body.name, e.Message));
                }
            }

            return(new BodyResourceData(resources, scans));
        }
Ejemplo n.º 13
0
        public SCMonth[] GetSalesPrMonth()
        {
            StringBuilder result = new StringBuilder();

            using (AdomdConnection conn = new AdomdConnection("DataSource = localhost; Initial Catalog = FClubCube"))
            {
                conn.Open();
                AdomdCommand cmd = conn.CreateCommand();
                cmd.CommandText = @"SELECT [Measures].[Fact Sale Count] ON COLUMNS,
	                                NONEMPTY( {[Dim Date].[Month].[Month]} ) ON ROWS
                                    FROM [F Club DW]";
                CellSet cs = cmd.ExecuteCellSet();


                TupleCollection tuplesOnColumns = cs.Axes[0].Set.Tuples;

                TupleCollection tupleCollection = cs.Axes[1].Set.Tuples;
                SCMonth[]       monthSales      = new SCMonth[tupleCollection.Count];
                for (int row = 0; row < tupleCollection.Count; row++)
                {
                    SCMonth month = new SCMonth();
                    month.month = int.Parse(tupleCollection[row].Members[0].Caption);

                    for (int col = 0; col < tuplesOnColumns.Count; col++)
                    {
                        month.saleCount = int.Parse(cs.Cells[col, row].FormattedValue);
                        monthSales[row] = month;
                    }
                }

                conn.Close();

                return(monthSales);
            }
        }
Ejemplo n.º 14
0
Archivo: PdfCell.cs Proyecto: ikvm/test
 public PdfCell(CellSet cs, int row, int col, Parser cp)
 {
     this.cellSet_0 = cs;
     this.parser_0  = cp;
     this.int_0     = row;
     this.int_1     = col;
 }
Ejemplo n.º 15
0
        public void TestStoreSingleCell()
        {
            const string testKey   = "content";
            const string testValue = "the force is strong in this column";
            var          client    = CreateClient();
            var          set       = new CellSet();
            var          row       = new CellSet.Row {
                key = Encoding.UTF8.GetBytes(testKey)
            };

            set.rows.Add(row);

            var value = new Cell {
                column = Encoding.UTF8.GetBytes("d:starwars"), data = Encoding.UTF8.GetBytes(testValue)
            };

            row.values.Add(value);

            client.StoreCellsAsync(testTableName, set).Wait();

            CellSet cells = client.GetCellsAsync(testTableName, testKey).Result;

            Assert.AreEqual(1, cells.rows.Count);
            Assert.AreEqual(1, cells.rows[0].values.Count);
            Assert.AreEqual(testValue, Encoding.UTF8.GetString(cells.rows[0].values[0].data));
        }
Ejemplo n.º 16
0
        // Write a Tweet (CellSet) to HBase
        public void WriterThreadFunction()
        {
            try
            {
                while (threadRunning)
                {
                    if (queue.Count > 0)
                    {
                        CellSet set = new CellSet();
                        lock (queue)
                        {
                            do
                            {
                                ITweet tweet = queue.Dequeue();
                                CreateTweetByWordsCells(set, tweet);
                            } while (queue.Count > 0);
                        }

                        // Write the Tweet by words cell set to the HBase table
                        client.StoreCells(HBASETABLENAME, set);
                        Console.WriteLine("\tRows written: {0}", set.rows.Count);
                    }
                    Thread.Sleep(100);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex.Message);
            }
        }
Ejemplo n.º 17
0
        public void CellSet_Should_Initialize()
        {
            const int width  = 4;
            const int height = 7;

            var cellSet = new CellSet();

            cellSet.Init(new Size(width, height));

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    ((Cell)cellSet[x, y]).State = (x % 3 == 0) && (y % 2 == 0);
                }
            }

            // checks
            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    var cell = cellSet[x, y];
                    if ((x % 3 == 0) && (y % 2 == 0))
                    {
                        cell.Should().NotBeNull().And.BeLivingCell();
                    }
                    else
                    {
                        cell.Should().NotBeNull().And.BeDeadCell();
                    }
                }
            }
        }
Ejemplo n.º 18
0
 public PageBuilder(CellSet cellset, int pageWidth, int pageHeight, float scale)
 {
     this.bool_0 = false;
     this.bool_1 = true;
     this.bool_2 = false;
     this.method_1(cellset, pageWidth, pageHeight, 0, scale);
 }
Ejemplo n.º 19
0
        private CellSet CreateCellSet(params CellSet.Row[] rows)
        {
            var cellSet = new CellSet();

            cellSet.rows.AddRange(rows);
            return(cellSet);
        }
Ejemplo n.º 20
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string          connectionString = "Data Source=localhost;Catalog=MDX Step-by-Step;ConnectTo=11.0;Integrated Security=SSPI";
            AdomdConnection _connection      = new AdomdConnection(connectionString);

            if (_connection != null)
            {
                if (_connection.State == ConnectionState.Closed)
                {
                    _connection.Open();
                }
            }
            AdomdCommand  command = _connection.CreateCommand();
            StringBuilder sb      = new StringBuilder();

            sb.Append("WITH");
            sb.Append("  MEMBER [Product].[Category].[All Products].[X] AS 1+1");
            sb.Append("SELECT{ ([Date].[Calendar].[CY 2002]),([Date].[Calendar].[CY 2003])}*{([Measures].[Reseller Sales Amount]) } ON COLUMNS,");
            sb.Append("{ ([Product].[Category].[Accessories]),([Product].[Category].[Bikes]),([Product].[Category].[Clothing]),");
            sb.Append("([Product].[Category].[Components]),([Product].[Category].[X])} ON ROWS");
            sb.Append("  FROM [Step-by-Step]");
            command.CommandText = sb.ToString();


            var     xmlreader = command.ExecuteXmlReader();
            CellSet cellSet   = CellSet.LoadXml(xmlreader);

            _connection.Close();
            var dt = ToDataTable(cellSet);
            var v  = dt.Rows.Count;
        }
Ejemplo n.º 21
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            Stopwatch watch = Stopwatch.StartNew();

            try
            {
                ClearQueryresult();
                string mdx = txtMdx.Text;
                if (txtMdx.ActiveTextAreaControl.TextArea.SelectionManager.HasSomethingSelected)
                {
                    mdx = txtMdx.ActiveTextAreaControl.TextArea.SelectionManager.SelectedText;
                }
                CellSet cst = MdxHelper.ExecuteCellSet(Connection, mdx);
                watch.Stop();
                this.ShowMessage("查询耗时{0}毫秒,", watch.ElapsedMilliseconds);
                gvMdxresult.Tag       = cst;
                lastUseFormattedValue = sender == this.btnExecuteWithFormatted;
                //DataTable dt = cst.ToDataTable2(lastUseFormattedValue);

                BindCellSet(gvMdxresult, cst, lastUseFormattedValue);
                //gvMdxresult.DataSource = dt;
                ShowResult(gvMdxresult);
            }
            catch (AdomdException aex)
            {
                this.ShowMessage("Mdx查询出错{0},", aex.ToString());
            }
            catch (Exception ex)
            {
                this.ShowMessage("Mdx查询出错{0},", ex.ToString());
            }
            finally
            {
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Set new initial set of points.
        /// </summary>
        private void Restart()
        {
            if (CellSet == null)
            {
                return;
            }

            // prevent timer's start until cell set will be reinit
            SetCommandProviderMode(CommandProviderMode.None);
            PauseIteration();

            using (Application.Current.Dispatcher.DisableProcessing())
            {
                CellSet.Clear();
                var points = GenerateRandomPoints();
                CellSet.SetPoints(points);
            }

            // post recreating actions
            if (_postponedTimer)
            {
                StartTimer();
            }
            else
            {
                SetCommandProviderMode(CommandProviderMode.Init);
            }
        }
Ejemplo n.º 23
0
        public async Task TestCellsDeletion()
        {
            const string testKey   = "content";
            const string testValue = "the force is strong in this column";

            var client = CreateClient();
            var set    = new CellSet();
            var row    = new CellSet.Types.Row {
                Key = ByteString.CopyFromUtf8(testKey)
            };

            set.Rows.Add(row);

            var value = new Cell {
                Column = ByteString.CopyFromUtf8("d:starwars"), Data = ByteString.CopyFromUtf8(testValue)
            };

            row.Values.Add(value);

            client.StoreCellsAsync(TestTableName, set).Wait();
            var cell = client.GetCellsAsync(TestTableName, testKey).Result;

            // make sure the cell is in the table
            Assert.Equal(Encoding.UTF8.GetString(cell.Rows[0].Key.ToByteArray()), testKey);
            // delete cell
            client.DeleteCellsAsync(TestTableName, testKey).Wait();

            Assert.Null(await client.GetCellsAsync(TestTableName, testKey));
        }
Ejemplo n.º 24
0
        public static List <string> GetDistinctCellProperties(CellSet queryResult, string propertyName)
        {
            List <string> ret = new List <string>();
            CellProperty  cellProperty;
            string        propertyValue;

            if (queryResult == null)
            {
                return(ret);
            }

            foreach (Cell c in queryResult.Cells)
            {
                cellProperty = c.CellProperties.Find(propertyName);

                if (cellProperty != null)
                {
                    if (cellProperty.Value != null)
                    {
                        propertyValue = cellProperty.Value.ToString();
                        if (!ret.Contains(propertyValue))
                        {
                            ret.Add(propertyValue);
                        }
                    }
                }
            }

            return(ret);
        }
Ejemplo n.º 25
0
        private IEnumerable <CellSet> ReadProtobufStream(Stream stream)
        {
            List <CellSet> cells  = new List <CellSet>();
            var            reader = new BinaryReader(stream);

            while (true)
            {
                // read chunck length
                byte[] lengthBytes = new byte[2];
                int    readBytes   = reader.Read(lengthBytes, 0, lengthBytes.Length);
                if (readBytes <= 0)
                {
                    break;
                }
                sbyte[] slengthBytes = new sbyte[2];
                Buffer.BlockCopy(lengthBytes, 0, slengthBytes, 0, lengthBytes.Length);
                short   length   = (short)(((slengthBytes[0] & 0xFF) << 8) | (slengthBytes[1] & 0xFF));
                byte[]  cellSet  = new byte[length];
                int     byteread = stream.Read(cellSet, 0, length);
                CellSet sc       = Serializer.Deserialize <CellSet>(RecyclableMemoryStreamManager.GetStream("ReadProtobufStream", cellSet, 0, byteread));
                cells.Add(sc);
            }

            return(cells);
        }
Ejemplo n.º 26
0
        public void WriterThreadFunction()
        {
            while (threadRunning)
            {
                try
                {
                    if (queue.Count > 0)
                    {
                        var set = new CellSet();
                        lock (queue)
                        {
                            do
                            {
                                var tweet = queue.Dequeue();

                                CreateTweetByWordsCells(set, tweet);
                            } while (queue.Count > 0);
                        }

                        // Update count of rows as part of the same batch
                        CreateRowCountCell(set, rowCount + set.rows.Count);

                        client.StoreCellsAsync(TABLE_BY_WORDS_NAME, set).Wait();
                        rowCount += set.rows.Count;

                        Console.WriteLine("===== {0} rows written =====", set.rows.Count);
                    }
                    Thread.Sleep(100);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception: " + ex.Message + "\nStackTrace: \n" + ex.StackTrace);
                }
            }
        }
Ejemplo n.º 27
0
        private async Task <bool> StoreCellsAsyncInternal(string table, CellSet cells, RequestOptions options, string key = null, string query = null)
        {
            string path = key == null ? table + "/somefalsekey" : table + "/" + key;

            // note the fake row key to insert a set of cells
            using (Response webResponse = await PutRequestAsync(path, query, cells, options))
            {
                if (webResponse.WebResponse.StatusCode == HttpStatusCode.NotModified)
                {
                    return(false);
                }

                if (webResponse.WebResponse.StatusCode != HttpStatusCode.OK)
                {
                    using (var output = new StreamReader(webResponse.WebResponse.GetResponseStream()))
                    {
                        string message = output.ReadToEnd();
                        throw new WebException(
                                  string.Format(
                                      "Couldn't insert into table {0}! Response code was: {1}, expected 200! Response body was: {2}",
                                      table,
                                      webResponse.WebResponse.StatusCode,
                                      message));
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Automically checks if a row/family/qualifier value matches the expected value and deletes
        /// </summary>
        /// <param name="table">the table</param>
        /// <param name="cellToCheck">cell to check for deleting the row</param>
        /// <returns>true if the record was deleted; false if condition failed at check</returns>
        public async Task <bool> CheckAndDeleteAsync(string table, Cell cellToCheck, CellSet.Row rowToDelete = null, RequestOptions options = null)
        {
            table.ArgumentNotNullNorEmpty("table");
            cellToCheck.ArgumentNotNull("cellToCheck");

            CellSet.Row row;
            if (rowToDelete != null)
            {
                row = rowToDelete;
            }
            else
            {
                row = new CellSet.Row()
                {
                    key = cellToCheck.row
                };
            }

            row.values.Add(cellToCheck);
            var cellSet = new CellSet();

            cellSet.rows.Add(row);
            var optionToUse = options ?? _globalRequestOptions;

            return(await optionToUse.RetryPolicy.ExecuteAsync <bool>(() => StoreCellsAsyncInternal(table, cellSet, optionToUse, Encoding.UTF8.GetString(row.key), CheckAndDeleteQuery)));
        }
Ejemplo n.º 29
0
Archivo: Class9.cs Proyecto: ikvm/test
 private void method_18(int int_10, CellSet cellSet_1)
 {
     for (int i = 1; i < this.parser_1.RowCount; i++)
     {
         string str3 = this.parser_1.getMergedExp(i, int_10);
         string str2 = this.parser_1.getMergedExp(i, int_10 - 1);
         if ((str3.Length > 0) && str3.ToUpper().Equals(str2.ToUpper()))
         {
             int num8 = (int)(this.parser_1.getPropertyValue(i, int_10, 301));
             if (num8 == PropertyDefine.CDT_SUBREPORT)
             {
                 throw new SystemException("请加大纸张宽度,以使子报表能显示在一页中!");
             }
             int    srcRow = this.parser_1.getMergedStartRow(i, int_10);
             int    num4   = this.parser_1.getMergedEndCol(i, int_10);
             int    srcCol = this.parser_1.getMergedStartCol(i, int_10);
             string exp    = new StringBuilder(str3.Substring(0, str3.IndexOf(",") + 1).ToString().ToString()).Append(int_10).Append(str3.Substring(str3.IndexOf("-"))).ToString().ToString();
             for (int j = int_10; j <= num4; j++)
             {
                 if ((j == int_10) && (i == srcRow))
                 {
                     this.operator_1.copyCellTo(srcRow, srcCol, this.parser_1.CellSet, i, j, true);
                 }
                 this.operator_1.setMergedExp(i, j, exp);
             }
             exp = str2.Substring(0, str2.LastIndexOf(",") + 1).ToString() + ((int_10 - 1)).ToString();
             for (int k = this.int_6 - (int_10 - srcCol); k < this.int_6; k++)
             {
                 new Operator(cellSet_1).setMergedExp(i, k, exp);
             }
         }
     }
 }
Ejemplo n.º 30
0
        public CellSet ExecuteQuery(string query, ref String sessionId)
        {
            try
            {
                if (Connection != null)
                {
                    AdomdConnection conn = AdomdConnectionPool.GetConnection(Connection.ConnectionString, sessionId);
                    lock (conn)
                    {
                        sessionId = conn.SessionID;
                        using (AdomdCommand cmd = new AdomdCommand(query, conn))
                        {
                            DateTime start = DateTime.Now;
                            CellSet  cs    = cmd.ExecuteCellSet();
                            System.Diagnostics.Debug.WriteLine("MDX query executimg time: " + (DateTime.Now - start).ToString());

                            return(cs);
                        }
                    }
                }
                return(null);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.TraceError("{0} ExecuteQuery ERROR: {1}\r\n Connection String: {2} \r\n Query: {3}\r\n",
                                                    DateTime.Now.ToString(), ex.ToString(), Connection.ConnectionString, query);
                throw ex;
            }
        }
Ejemplo n.º 31
0
Archivo: Class9.cs Proyecto: ikvm/test
        private void method_20(CellSet cellSet_1, int int_10)
        {
            Parser   parser    = new Parser(cellSet_1);
            Operator @operator = new Operator(cellSet_1);
            int      num       = parser.ColCount - base.parser_0.ColCount;
            bool     flag      = false;

            for (int i = 1; i < base.parser_0.ColCount; i++)
            {
                bool flag2;
                if ((flag2 = (bool)(parser.getPropertyValue(int_10, i, 308))) && flag2)
                {
                    flag = true;
                    for (int j = i; j < base.parser_0.ColCount; j++)
                    {
                        @operator.copyCellTo(int_10, j, cellSet_1, int_10, j + num, true);
                    }
                    this.method_21(cellSet_1, int_10, i - 1, num);
                    break;
                }
            }
            if (!flag)
            {
                this.method_21(cellSet_1, int_10, base.parser_0.ColCount - 1, num);
            }
        }
Ejemplo n.º 32
0
        public String GetCellSetDescription(string query, ref String sessionId)
        {
            try
            {
                CellSet cs = ExecuteQuery(query, ref sessionId);
                if (cs != null)
                {
                    CellSetDescriptionProvider provider = new CellSetDescriptionProvider(cs);
                    provider.Connection.ConnectionString = Connection.ConnectionString;
                    provider.Connection.ConnectionID     = Connection.ConnectionID;

                    DateTime start1 = DateTime.Now;
                    var      res    = provider.Serialize();
                    System.Diagnostics.Debug.WriteLine("MDX query serialization time: " + (DateTime.Now - start1).ToString());
                    return(res);
                }
                return(string.Empty);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.TraceError("{0} GetCellSetDescription ERROR: {1}\r\n Connection String: {2} \r\n Query: {3}\r\n",
                                                    DateTime.Now.ToString(), ex.ToString(), Connection.ConnectionString, query);
                throw;
            }
        }
        private void BuildDescription(CellSet cs)
        {
            if (cs != null)
            {
                if (cs.OlapInfo != null &&
                    cs.OlapInfo.CubeInfo != null &&
                    cs.OlapInfo.CubeInfo.Cubes != null &&
                    cs.OlapInfo.CubeInfo.Cubes.Count > 0)
                {
                    m_CellSet.CubeName = cs.OlapInfo.CubeInfo.Cubes[0].CubeName;
                }

                DateTime start = DateTime.Now;
                int i = 0;
                // Оси
                foreach(Axis axis in cs.Axes)
                {
                    AxisData axis_data = BuildAxisDescription(axis);
                    axis_data.AxisNum = i;
                    m_CellSet.Axes.Add(axis_data);
                    i++;
                }
                System.Diagnostics.Debug.WriteLine("CellSetData building AXES time: " + (DateTime.Now - start).ToString());

                // Ось фильтров - пока эта информация не нужна
                // cs_descr.FilterAxis = BuildAxisDescription(cs.FilterAxis); 

                DateTime start1 = DateTime.Now;
                if (cs.Axes.Count == 1)
                {
                    for (int col = 0; col < cs.Axes[0].Positions.Count; col++)
                    {
                        CellData cell_descr = new CellData();
                        cell_descr.Axis0_Coord = col;
                        cell_descr.Axis1_Coord = -1;
                        cell_descr.Value = GetValue(col);
                        m_CellSet.Cells.Add(cell_descr);
                    }
                }

                if (cs.Axes.Count >= 2)
                { 
                    for(int col = 0; col < cs.Axes[0].Positions.Count; col++)
                    {
                        for (int row = 0; row < cs.Axes[1].Positions.Count; row++)
                        {
                            CellData cell_descr = new CellData();
                            cell_descr.Axis0_Coord = col;
                            cell_descr.Axis1_Coord = row;
                            cell_descr.Value = GetValue(col, row);
                            m_CellSet.Cells.Add(cell_descr);
                        }
                    }
                }

                System.Diagnostics.Debug.WriteLine("CellSetData building CELLS time: " + (DateTime.Now - start1).ToString());
            }
        }
Ejemplo n.º 34
0
        private static DataTable GetDataTableFromCellSet(CellSet cs)
        {
            //design the datatable
            DataTable dt = new DataTable();
            DataColumn dc = null;
            DataRow dr = null;

            //add the columns
            dt.Columns.Add(new DataColumn("Description"));
            //first column
            //get the other columns from axis
            string name = null;
            foreach (Position p in cs.Axes[0].Positions)
            {
                dc = new DataColumn();
                name = "";
                foreach (Member m in p.Members)
                {
                    name = name + m.Caption + " ";
                }
                dc.ColumnName = name;
                dt.Columns.Add(dc);
            }

            //add each row, row label first, then data cells
            int y = 0;
            y = 0;
            foreach (Position py in cs.Axes[1].Positions)
            {
                dr = dt.NewRow();
                //create new row

                // Do the row label
                name = "";
                foreach (Member m in py.Members)
                {
                    name = name + m.Caption + "";

                }
                dr[0] = name;
                //first cell in the row

                // Data cells
                int x = 0;
                for (x = 0; x <= cs.Axes[0].Positions.Count - 1; x++)
                {
                    dr[x + 1] = cs[x, y].FormattedValue;
                    //other cells in the row
                }

                dt.Rows.Add(dr);
                //add the row
                y = y + 1;
            }

            return dt;
        }
Ejemplo n.º 35
0
 public static List<CubeViewModel> BuildViewModel(CellSet cellSet)
 {
     var model =
         new List<CubeViewModel>
             {
                 new CubeViewModel
                     {
                         Column = BuildColums(cellSet),
                         Analytics = BuildAnalyticsRow(cellSet)
                     }
             };
     return model;
 }
Ejemplo n.º 36
0
        public void PutNew(string from, string content, DateTime date)
        {
            var rowKey = string.Format("{0}|{1}", from, date.ToString("yyyyMMddHH"));
            var cellSet = new CellSet
            {
                Table = "mail"
            };

            var timestamp = ToUnixMilliseconds(date);
            var identifier = GetIdentifier(rowKey, "m", timestamp.ToString());
            cellSet.Add(new Cell(identifier, content));

            _client.WriteCells(cellSet);
        }
Ejemplo n.º 37
0
 private static Column[] BuildColums(CellSet cellSet)
 {
     var result = new List<Column>();
     var tuplesOnColumns = cellSet.Axes[0].Set.Tuples;
     var i = 0;
     foreach (var column in tuplesOnColumns)
     {
         result.Add(new Column
         {
             HeaderName = column.Members[0].Caption,
             FormattedValue = cellSet.Cells[i].FormattedValue
         });
         i++;
     }
     return result.ToArray();
 }
Ejemplo n.º 38
0
 private static string BuildAnalyticsRow(CellSet cellSet)
 {
     var result = new StringBuilder();
     if (cellSet.Axes.Count > 0)
     {
         var tuplesOnRows = cellSet.Axes[0].Set.Tuples;
         foreach (var row in tuplesOnRows)
         {
             foreach (var t in row.Members)
             {
                 result.Append(t.Caption + "\n");
             }
         }
     }
     return result.ToString();
 }
Ejemplo n.º 39
0
        public static IEnumerable<Flat> Flatten(CellSet cellSet)
        {
            var valueMeasures = new List<string>();
            var axes = cellSet.Axes.Cast<Microsoft.AnalysisServices.AdomdClient.Axis>().ToList();
            var members = new List<MemberPair>();

            for (int i = 0; i < cellSet.Axes.Count; i++)
                for(int j = 0; j < cellSet.Axes[i].Positions.Count; j++)
                    for (int k = 0; k < cellSet.Axes[i].Positions[j].Members.Count; k++)
                    {
                        var levelName = cellSet.Axes[i].Positions[j].Members[k].ParentLevel.Caption;
                        if (levelName == "MeasuresLevel")
                        {
                            var name = cellSet.Axes[i].Positions[j].Members[i].Caption;
                            if(!valueMeasures.Contains(name))
                                valueMeasures.Add(name);
                        }
                        else
                        {
                            var caption = cellSet.Axes[i].Positions[j].Members[k].Caption;
                            members.Add(new MemberPair(levelName, caption));
                        }
                    }

            var valueCount = valueMeasures.Count;
            var memberCount = members.Select(x => x.Level).Distinct().Count();
            var totalLoops = valueCount == 0 ? 0 : cellSet.Cells.Count / valueCount;
            for (int i = 0; i < totalLoops; i++)
            {
                var flat = new Flat();
                for(int j = 0; j < valueCount; j++)
                {
                    flat.MeasureValues.Add(valueMeasures[j], cellSet[j + (i * valueCount)].Value);
                }
                for(int j = 0; j < memberCount; j++)
                {
                    flat.PositionValues.Add(members[j].Level, members[j + (i * memberCount)].Member);
                }
                yield return flat;
            }
        }
Ejemplo n.º 40
0
        public static BodyResourceData Load(IResourceGenerator generator, CelestialBody body, ConfigNode bodyNode)
        {
            if (bodyNode == null) { bodyNode = new ConfigNode(); }
            var resources = generator.Load(body, bodyNode.GetNode("GeneratorData"));
            var scans = new CellSet(KethaneData.GridLevel);

            var scanMask = bodyNode.GetValue("ScanMask");
            if (scanMask != null)
            {
                try
                {
                    scans = new CellSet(KethaneData.GridLevel, Misc.FromBase64String(scanMask));
                }
                catch (FormatException e)
                {
                    Debug.LogError(String.Format("[Kethane] Failed to parse {0} scan string, resetting ({1})", body.name, e.Message));
                }
            }

            return new BodyResourceData(resources, scans);
        }
Ejemplo n.º 41
0
		/// <summary>
		///    Finds the cells matching the query.
		/// </summary>
		/// <param name="query"></param>
		public CellSet FindCells(CellQuery query)
		{
			string resource = _resourceBuilder.BuildCellOrRowQuery(query);
			IRestResponse response = SendRequest(Method.GET, resource, Options.ContentType);
			_errorProvider.ThrowIfStatusMismatch(response, HttpStatusCode.OK, HttpStatusCode.NotFound);

			var set = new CellSet
			{
				Table = query.Table
			};

			if (response.StatusCode == HttpStatusCode.OK)
				set.AddRange(_converter.ConvertCells(response.Content, query.Table));

			return set;
		}
Ejemplo n.º 42
0
 public CellSet GetDuplicatedRows(ref object[,] data, int[] colKeys, int[] colVal)
 {
     HashRow[] hashTab = GetRowsKey(data, colKeys);
     int[] ptr = GetSortedHashPtr(ref hashTab);
     int len = hashTab.Length;
     var cells = new CellSet(data);
     HashRow hashRow1 = hashTab[ptr[0]];
     HashRow hashRow2;
     for (int i = 1; i < len; i++) {
         hashRow2 = hashTab[ptr[i]];
         if (hashRow1.IsNotNull && hashRow1 == hashRow2) {
             foreach (int col in colKeys)
                 cells.Diff[hashRow2.Row, col] = true;
             foreach (int col in colVal) {
                 if (ObjectsNotEquals(data[hashRow1.Row, col], data[hashRow2.Row, col]) == false)
                     cells.Diff[hashRow2.Row, col] = true;
             }
         } else
             hashRow1 = hashRow2;
     }
     return cells;
 }
Ejemplo n.º 43
0
 public CellSet GetDuplicatedCells(ref object[,] data)
 {
     HashCell[] hashTab = GetCellsKey(data);
     int[] ptr = GetSortedHashPtr(ref hashTab);
     var cells = new CellSet(data);
     for (int i = 1, iptr1, iptr2; i < ptr.Length; i++) {
         iptr1 = ptr[i - 1];
         iptr2 = ptr[i];
         if (hashTab[iptr2].IsNotNull && hashTab[iptr1] == hashTab[iptr2])
             cells.Diff[hashTab[iptr2].Row, hashTab[iptr2].Column] = true;
     }
     return cells;
 }
Ejemplo n.º 44
0
        public void BindCellSet(DataGridView grid, CellSet cs, bool useFormattedValue = false)
        {
            grid.Rows.Clear();
            grid.Columns.Clear();

            if (cs == null)
                return;
            try
            {

                //DataTable dt = new DataTable();

                int columnCountOfRowHeader = 0;

                #region 构造表头

                //当有行头时,添加行头占的列
                if (cs.Axes.Count > 1 && cs.Axes[1].Set.Tuples.Count > 0)
                {
                    columnCountOfRowHeader = cs.Axes[1].Set.Tuples[0].Members.Count;
                    for (int i = 0; i < columnCountOfRowHeader; i++)
                    {
                        Member member = cs.Axes[1].Set.Tuples[0].Members[i];
                        DataGridViewColumn column = new DataGridViewTextBoxColumn();
                        column.Name = member.UniqueName;
                        column.Tag = member;
                        grid.Columns.Add(column);
                    }
                }

                //继续添加列头
                foreach (Microsoft.AnalysisServices.AdomdClient.Tuple tp in cs.Axes[0].Set.Tuples)
                {

                    string columnName = "";
                    foreach (Member member in tp.Members)
                    {
                        columnName = columnName + member.Caption + " ";
                    }
                    DataGridViewColumn column = new DataGridViewTextBoxColumn();
                    column.Name = columnName.Trim();
                    column.Tag = null;

                    grid.Columns.Add(column);
                }

                #endregion

                #region 构造数据

                int rowCount = cs.Axes.Count <= 1 ? 0 : cs.Axes[1].Set.Tuples.Count;
                int cellIndex = 0;
                for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
                {

                    DataGridViewRow dr = new DataGridViewRow();
                    dr.CreateCells(grid);
                    if (cs.Axes.Count > 1)
                    {
                        for (int columnIndexOfRowHeader = 0; columnIndexOfRowHeader < columnCountOfRowHeader; columnIndexOfRowHeader++)
                        {
                            var member = cs.Axes[1].Set.Tuples[rowIndex].Members[columnIndexOfRowHeader];
                            dr.Cells[columnIndexOfRowHeader].Value = member.Caption;
                            dr.Cells[columnIndexOfRowHeader].Tag = member;
                        }
                    }

                    //数据列
                    for (int columnIndexOfData = columnCountOfRowHeader; columnIndexOfData < cs.Axes[0].Positions.Count + columnCountOfRowHeader; columnIndexOfData++)
                    {
                        try
                        {
                            Cell cell = cs[cellIndex++];
                            dr.Cells[columnIndexOfData].Tag = cell;

                            if (useFormattedValue)
                            {
                                dr.Cells[columnIndexOfData].Value = cell.FormattedValue;
                            }
                            else
                            {
                                dr.Cells[columnIndexOfData].Value = cell.Value;
                            }

                            if (dr.Cells[columnIndexOfData].ToString() == "null")
                            {
                                dr.Cells[columnIndexOfData].Value = "";
                            }
                        }
                        catch
                        {
                            dr.Cells[columnIndexOfData].Value = "";
                        }
                    }
                    grid.Rows.Add(dr);

                }

                #endregion

            }
            catch (Exception ex)
            {
                throw;
            }
        }
        internal string SerializeCells(CellSet cs)
        {
            if (cs == null)
                return String.Empty;

            var data = new List<object>();
            var propsList = new List<AdomdCellPropsObj>();
            var hash = new Dictionary<AdomdCellPropsObj, int>();
            var values = new object[cs.Cells.Count];
            data.Add(values);
            var displayValues = new string[cs.Cells.Count];
            data.Add(displayValues);
            var props = new int[cs.Cells.Count];
            data.Add(props);

            // Ячейки
            for (int indx = 0; indx < cs.Cells.Count; indx++)
            {
                Cell cell = cs.Cells[indx];

                object value = null;
                string displayName = string.Empty;

                if (cell != null)
                {
                    try
                    {
                        displayName = cell.FormattedValue;
                    }
                    catch (Exception)
                    {
                        displayName = CellValueData.ERROR;
                    }

                    try
                    {
                        value = cell.Value;
                    }
                    catch (Exception exc)
                    {
                        value = exc.ToString();
                    }

                    if (string.IsNullOrEmpty(displayName))
                    {
                        if (value == null)
                        {
                            displayName = String.Empty;
                        }
                        else
                        {
                            displayName = value.ToString();
                        }
                    }
                }

                values[indx] = value;
                displayValues[indx] = displayName;
                if (cell != null)
                {
                    var propObj = new AdomdCellPropsObj(cell.CellProperties);
                    int indProp = 0;
                    if (!hash.TryGetValue(propObj, out indProp))
                    {
                        indProp = propsList.Count;
                        hash[propObj] = indProp;
                        propsList.Add(propObj);
                    }
                    props[indx] = indProp;
                }
            }

            // Стили ячеек
            var propNames = new List<string>();
            var propNamesHash = new Dictionary<string, int>();

            for (int i = 0; i < propsList.Count; i++)
            {
                var po = propsList[i];
                var propVals = new object[propNames.Count];
                foreach (var p in po.props)
                {
                    switch (p.Name)
                    {
                        case "CellOrdinal":
                        case "VALUE":
                        case "FORMATTED_VALUE":
                            continue;
                        default:
                            int indx;
                            if (!propNamesHash.TryGetValue(p.Name, out indx))
                            {
                                indx = propNames.Count;
                                propNames.Add(p.Name);
                                propNamesHash[p.Name] = indx;
                                var newPropVals = new object[propNames.Count];
                                Array.Copy(propVals, newPropVals, propVals.Length);
                                propVals = newPropVals;
                            }
                            propVals[indx] = p.Value;
                            break;
                    }
                }
                data.Add(propVals);
            }
            data.Add(propNames.ToArray());

            var result = Jayrock.Json.Conversion.JsonConvert.ExportToString(data.ToArray());
            return result;
        }
Ejemplo n.º 46
0
        public CellSet[] CompareOppositeCells(ref object[,] dataA, ref object[,] dataB)
        {
            var cellsA = new CellSet(dataA);
            var cellsB = new CellSet(dataB);
            int nbMinRow = Math.Min(cellsA.RowLen, cellsB.RowLen);
            int nbMinCol = Math.Min(cellsA.ColLen, cellsB.ColLen);

            for (int ri = 1; ri <= nbMinRow; ri++)
                for (int ci = 1; ci <= nbMinCol; ci++)
                    if (ObjectsNotEquals(dataA[ri, ci], dataB[ri, ci]))
                        cellsA.Diff[ri, ci] = cellsB.Diff[ri, ci] = true;

            for (int ri = nbMinRow + 1; ri <= cellsA.RowLen; ri++)
                for (int ci = 1; ci <= cellsA.ColLen; ci++)
                    cellsA.Diff[ri, ci] = true;
            for (int ri = nbMinRow + 1; ri <= cellsB.RowLen; ri++)
                for (int ci = 1; ci <= cellsB.ColLen; ci++)
                    cellsB.Diff[ri, ci] = true;
            for (int ci = nbMinCol + 1; ci <= cellsA.ColLen; ci++)
                for (int ri = 1; ri <= cellsA.RowLen; ri++)
                    cellsA.Diff[ri, ci] = true;
            for (int ci = nbMinCol + 1; ci <= cellsB.ColLen; ci++)
                for (int ri = 1; ri <= cellsB.RowLen; ri++)
                    cellsB.Diff[ri, ci] = true;

            return new CellSet[] { cellsA, cellsB };
        }
Ejemplo n.º 47
0
        public CellSet[] CompareListOfCells(ref object[,] dataA, ref object[,] dataB, bool multi)
        {
            HashCell[] hashTabA = GetCellsKey(dataA);
            HashCell[] hashTabB = GetCellsKey(dataB);
            int[] ptrA = GetSortedHashPtr(ref hashTabA);
            int[] ptrB = GetSortedHashPtr(ref hashTabB);
            int lenA = hashTabA.Length;
            int lenB = hashTabB.Length;

            for (int i = 0, j = 0, nbMatch; i < lenA; i++) {
                int iptr = ptrA[i];
                if (hashTabA[iptr].IsNotNull) {
                    nbMatch = 0;
                    while (j < lenB) {
                        int jptr = ptrB[j];
                        if (hashTabB[jptr].IsNull)
                            j++;
                        else if (hashTabA[iptr] == hashTabB[jptr]) {
                            hashTabA[iptr].HasMatch = hashTabB[jptr].HasMatch = true;
                            j++;
                            nbMatch = 1;
                            if (multi == false)
                                break;
                        } else if (hashTabA[iptr] < hashTabB[jptr])
                            break;
                        else
                            j++;
                    }
                    if (multi)
                        j -= nbMatch;
                }
            }

            var cellsA = new CellSet(dataA);
            var cellsB = new CellSet(dataB);
            for (int i = 0; i < lenA; i++)
                if (hashTabA[i].IsNotNull && !hashTabA[i].HasMatch)
                    cellsA.Diff[hashTabA[i].Row, hashTabA[i].Column] = true;
            for (int j = 0; j < lenB; j++)
                if (hashTabB[j].IsNotNull && !hashTabB[j].HasMatch)
                    cellsB.Diff[hashTabB[j].Row, hashTabB[j].Column] = true;

            return new CellSet[] { cellsA, cellsB };
        }
Ejemplo n.º 48
0
        private static void DemonstrateWriting(IStargate stargate)
        {
            // update a single cell value:
            stargate.WriteValue("100", "access-logs", "elton|jericho|201510", "t", "2908");
            Console.WriteLine("Updated single cell");

            // set multiple cell values:
            var update = new Cell(new Identifier
            {
                Row = "elton|jericho|201510",
                CellDescriptor = new HBaseCellDescriptor
                {
                    Column = "t",
                    Qualifier = "2908"
                }
            }, "120");

            var insert = new Cell(new Identifier
            {
                Row = "elijah|jericho|201511",
                CellDescriptor = new HBaseCellDescriptor
                {
                    Column = "t",
                    Qualifier = "1117"
                }
            }, "360");

            var cells = new CellSet(new Cell[] { update, insert });
            cells.Table = "access-logs";

            stargate.WriteCells(cells);
            Console.WriteLine("Updated multiple cells");
        }
Ejemplo n.º 49
0
        /// <summary>
        /// Loads data into the grid using a Adomd.CellSet.
        /// </summary>
        /// <param name="set"></param>
        public void LoadData(CellSet set)
        {
            moTable = null;
            moSet = set;

            ClearGrid();

            // find the number of dimensions on the Rows and columns
            int iColDims = set.OlapInfo.AxesInfo.Axes[0].Hierarchies.Count;
            int iRowDims = 0;
            bool bHasRows = false;
            if (set.OlapInfo.AxesInfo.Axes.Count > 1)
            {
                iRowDims = set.OlapInfo.AxesInfo.Axes[1].Hierarchies.Count;
                bHasRows = true;
            }

            // find the number of data rows and columns needed
            int iNumCols = set.Axes[0].Set.Tuples.Count;

            int iNumRows = 1;
            if (bHasRows)
                iNumRows = set.Axes[1].Set.Tuples.Count;

            // figure out how many rows and columns we need
            // to display all the data and headers
            this.ColumnsCount = iRowDims + iNumCols;
            this.RowsCount = iColDims + iNumRows;

            // Set all of the column headers
            for (int iCol = 0; iCol < iNumCols; iCol++)
            {
                for (int iMember = 0; iMember < iColDims; iMember++)
                {
                    string sName = set.Axes[0].Positions[iCol].Members[iMember].Caption;
                    SetHeaderValue(iMember, iCol + iRowDims, sName);
                }
            }

            if (bHasRows)
            {
                // set all of the row headers
                for (int i = 0; i < iRowDims; i++)
                {
                    this.Rows[i].AutoSizeMode = SourceGrid3.AutoSizeMode.EnableAutoSize | SourceGrid3.AutoSizeMode.EnableStretch;
                }
                for (int iRow = 0; iRow < iNumRows; iRow++)
                {
                    for (int iMember = 0; iMember < iRowDims; iMember++)
                    {
                        string sName = set.Axes[1].Positions[iRow].Members[iMember].Caption;
                        SetHeaderValue(iRow + iColDims, iMember, sName);
                    }
                }
            }

            int iCurRow = iColDims;
            int iCurCol = iRowDims;
            int iDataCol = 0;

            // set the data in the grid1
            for(int iCell= 0; iCell<set.Cells.Count; iCell++)
            {
                Cell oCell = null ;
                string sValue = "";
                try
                {
                    oCell = set.Cells[iCell];
                    sValue = oCell.FormattedValue;
                }
                catch (Exception ex)
                {
                    sValue = ex.Message;
                }
                SourceGrid3.Cells.Real.Cell gridCell = SetCellValue(iCurRow, iCurCol, sValue);

                CheckCellProperties(oCell, gridCell);

                iDataCol++;
                iCurCol++;

                if (iDataCol >= iNumCols)
                {
                    iDataCol = 0;
                    iCurCol = iRowDims;
                    iCurRow++;
                }
            }

            this.AutoStretchColumnsToFitWidth = true;
            this.AutoSize();
            this.Columns.StretchToFit();
        }
Ejemplo n.º 50
0
 protected BodyResourceData(IBodyResources resources, CellSet scans)
 {
     Resources = resources;
     this.scans = scans;
 }
Ejemplo n.º 51
0
		/// <summary>
		///    Writes the cells to HBase.
		/// </summary>
		/// <param name="cells">The cells.</param>
		public void WriteCells(CellSet cells)
		{
			string contentType = Options.ContentType;
			var tableIdentifier = new Identifier { Table = cells.Table };
			string resource = _resourceBuilder.BuildBatchInsert(tableIdentifier);
			IRestResponse response = SendRequest(Method.POST, resource, contentType, contentType, _converter.ConvertCells(cells));
			_errorProvider.ThrowIfStatusMismatch(response, HttpStatusCode.OK);
		}
Ejemplo n.º 52
0
        public CellSet DeleteDuplicatedCells(ref object[,] data)
        {
            HashCell[] hashTab = GetCellsKey(data);
            int[] ptr = GetSortedHashPtr(ref hashTab);
            int len = hashTab.Length;
            var cells = new CellSet(data.GetLength(0), data.GetLength(1), false);

            for (int i = 1, iptr1, iptr2; i < len; i++) {
                iptr1 = ptr[i - 1];
                iptr2 = ptr[i];
                if (hashTab[iptr2].IsNotNull && hashTab[iptr1] == hashTab[iptr2])
                    hashTab[iptr2].HasMatch = true;
            }
            for (int i = 0, r = 1, c = 1; i < len; i++) {
                if (hashTab[i].IsNotNull && hashTab[i].HasMatch == false) {
                    cells.Data[r, c] = data[hashTab[i].Row, hashTab[i].Column];
                    if (c == cells.ColLen) {
                        r++; c = 1;
                    } else {
                        c++;
                    }
                }
            }
            return cells;
        }
Ejemplo n.º 53
0
        public CellSet DeleteDuplicatedRows(ref object[,] data, int[] colKeys, int[] colVal)
        {
            HashRow[] hashTab = GetRowsKey(data, colKeys);
            int[] ptr = GetSortedHashPtr(ref hashTab);
            int len = hashTab.Length;
            var cells = new CellSet(data.GetLength(0), data.GetLength(1), false);

            for (int i = 1, iptr1 = ptr[0], iptr2 = 0; i < len; i++) {
                iptr2 = ptr[i];
                if (hashTab[iptr1].IsNotNull && hashTab[iptr1] == hashTab[iptr2])
                    hashTab[iptr2].LinkedRow = hashTab[iptr1].Row;
                else
                    iptr1 = iptr2;
            }

            for (int r = 0, row = 0; r < len; r++) {
                if (hashTab[r].IsNotNull) {
                    bool hasDiff = false;
                    if (hashTab[r].LinkedRow != 0) {
                        foreach (int col in colVal) {
                            if (ObjectsNotEquals(data[hashTab[r].Row, col], data[hashTab[r].LinkedRow, col])) {
                                hasDiff = true;
                                break;
                            }
                        }
                    }
                    if (hashTab[r].LinkedRow == 0 || hasDiff) {
                        row++;
                        for (int ci = 1; ci <= cells.ColLen; ci++)
                            cells.Data[row, ci] = data[hashTab[r].Row, ci];
                        if (hasDiff) {
                            foreach (int col in colKeys)
                                cells.Diff[row, col] = true;
                            foreach (int col in colVal) {
                                if (ObjectsNotEquals(data[hashTab[r].Row, col], data[hashTab[r].LinkedRow, col]) == false)
                                    cells.Diff[row, col] = true;
                            }
                        }
                    }
                }
            }
            return cells;
        }
Ejemplo n.º 54
0
    /* Put the results of the MDX query into a dataTable.
     Call filterCellSet first if there are cells that do not
     correspond to a polygon in the shapefile. This method also
     populates the histogram dictionary. This allows us to create
     the histogram data without using the ESRI API which is too slow.
     */
    private DataTable dataTableFromCells(CellSet cells)
    {
        TupleCollection axis1 = cells.Axes[1].Set.Tuples;
        DataTable dt = createDataTable();

        for (int i = 0; i < axis1.Count; i++)
        {
            string region = axis1[i].Members[0].Caption;
            double measure;

            /*Ensure the value is not null and the region is not null or the empty string*/
            if (cells[0, i].Value != null && region != null && region != "")
            {
                measure = Convert.ToDouble(cells[0, i].Value);

                object[] row = new object[2];
                row[0] = region;
                row[1] = measure;

                dt.LoadDataRow(row, false);
                if (m_histogramDictionary.ContainsKey(measure))
                {
                    m_histogramDictionary[measure] = m_histogramDictionary[measure] + 1;
                }
                else
                {
                    m_histogramDictionary.Add(measure, 1);
                }

            }
        }
        return dt;
    }
 public CellSetDescriptionProvider(CellSet cs)
 {
     CS = cs;
 }