private Common.DataReader.ReaderResultSet ConvertToReaderResult(Common.Protobuf.ReaderResultSet readerResultSetProto) { if (readerResultSetProto == null) { return(null); } Common.DataReader.ReaderResultSet readerResultSet = new Common.DataReader.ReaderResultSet(); readerResultSet.IsGrouped = readerResultSetProto.isGrouped; readerResultSet.NodeAddress = readerResultSetProto.nodeAddress; readerResultSet.NextIndex = readerResultSetProto.nextIndex; readerResultSet.ReaderID = readerResultSetProto.readerId; Common.DataReader.RecordSet recordSet = null; if (readerResultSetProto.recordSet != null) { recordSet = new Common.DataReader.RecordSet(); RecordSet recordSetProto = readerResultSetProto.recordSet; foreach (RecordColumn columnProto in recordSetProto.columns) { Common.DataReader.RecordColumn column = new Common.DataReader.RecordColumn(columnProto.name); column.AggregateFunctionType = (Common.Enum.AggregateFunctionType)Convert.ToInt32(columnProto.aggregateFunctionType); column.ColumnType = (Common.Enum.ColumnType)Convert.ToInt32(columnProto.columnType); column.DataType = (Common.Enum.ColumnDataType)Convert.ToInt32(columnProto.dataType); column.IsFilled = columnProto.isFilled; column.IsHidden = columnProto.isHidden; recordSet.AddColumn(column); } PopulateRows(recordSet, recordSetProto.rows); } readerResultSet.RecordSet = recordSet; return(readerResultSet); }
private void PopulateRows(Common.DataReader.RecordSet recordSet, List <RecordRow> rows) { try { if (recordSet != null && rows != null) { foreach (RecordRow rowProto in rows) { Common.DataReader.RecordRow row = recordSet.CreateRow(); if (recordSet.Columns != null) { for (int i = 0; i < recordSet.Columns.Count; i++) { if (rowProto.values[i] != null) { if (recordSet.Columns[i].DataType != null) { switch (recordSet.Columns[i].DataType) { case Common.Enum.ColumnDataType.AverageResult: Common.Queries.AverageResult avgResult = new Common.Queries.AverageResult(); avgResult.Sum = Convert.ToDecimal(rowProto.values[i].avgResult.sum); avgResult.Count = Convert.ToDecimal(rowProto.values[i].avgResult.count); row[i] = avgResult; break; case Common.Enum.ColumnDataType.CompressedValueEntry: Value val = rowProto.values[i].binaryObject; UserBinaryObject ubObject = UserBinaryObject.CreateUserBinaryObject(val.data.ToArray()); byte[] bytes = ubObject.GetFullObject(); CompressedValueEntry cmpEntry = new CompressedValueEntry(); cmpEntry.Flag = new BitSet((byte)rowProto.values[i].flag); cmpEntry.Value = bytes; row[i] = ConvertToUserObject(cmpEntry); break; default: row[i] = Common.DataReader.RecordSet.ToObject( rowProto.values[i].stringValue, recordSet.Columns[i].DataType); break; } } } } } recordSet.AddRow(row); } } } catch (ArgumentOutOfRangeException ex) { throw new InvalidReaderException("Reader state has been lost.: ", ex); } }
private Common.DataReader.ReaderResultSet ConvertToReaderResult( Common.Protobuf.ReaderResultSet readerResultSetProto) { if (readerResultSetProto == null) { return(null); } Common.DataReader.ReaderResultSet readerResultSet = new Common.DataReader.ReaderResultSet(); readerResultSet.IsGrouped = readerResultSetProto.isGrouped; readerResultSet.NodeAddress = readerResultSetProto.nodeAddress; readerResultSet.NextIndex = readerResultSetProto.nextIndex; readerResultSet.ReaderID = readerResultSetProto.readerId; List <Common.Queries.OrderByArgument> orderByArgs = new List <Common.Queries.OrderByArgument>(); foreach (Common.Protobuf.OrderByArgument obaProto in readerResultSetProto.orderByArguments) { Common.Queries.OrderByArgument arg = new Common.Queries.OrderByArgument(); arg.AttributeName = obaProto.attributeName; arg.Order = (Common.Queries.Order)Convert.ToInt32(obaProto.order); orderByArgs.Add(arg); } readerResultSet.OrderByArguments = orderByArgs; Common.DataReader.RecordSet recordSet = null; if (readerResultSetProto.recordSet != null) { recordSet = new Common.DataReader.RecordSet(); Common.Protobuf.RecordSet recordSetProto = readerResultSetProto.recordSet; foreach (Common.Protobuf.RecordColumn columnProto in recordSetProto.columns) { Common.DataReader.RecordColumn column = new Common.DataReader.RecordColumn(columnProto.name); column.AggregateFunctionType = (Common.Enum.AggregateFunctionType)Convert.ToInt32(columnProto.aggregateFunctionType); column.ColumnType = (Common.Enum.ColumnType)Convert.ToInt32(columnProto.columnType); column.DataType = (Common.Enum.ColumnDataType)Convert.ToInt32(columnProto.dataType); column.IsFilled = columnProto.isFilled; column.IsHidden = columnProto.isHidden; recordSet.AddColumn(column); } PopulateRows(recordSet, recordSetProto.rows); } readerResultSet.RecordSet = recordSet; return(readerResultSet); }