示例#1
0
        public static void WriteReportHelper(ResultSet results, char separator, TextWriter writer, CultureInfo ci)
        {
            for (int i = 0; i < results.ColumnInfos.Count; i++)
            {
                var columnInfo = results.ColumnInfos[i];
                if (columnInfo.IsHidden)
                    continue;

                if (i > 0)
                    writer.Write(separator);
                writer.WriteDsvField(columnInfo.Caption, separator);
            }
            writer.WriteLine();
            for (int iRow = 0; iRow < results.RowCount; iRow++)
            {
                for (int iColumn = 0; iColumn < results.ColumnInfos.Count; iColumn++)
                {
                    var columnInfo = results.ColumnInfos[iColumn];
                    if (columnInfo.IsHidden)
                        continue;

                    if (iColumn > 0)
                        writer.Write(separator);
                    string value = results.FormatValue(iRow, iColumn, ci);
                    writer.WriteDsvField(value, separator);
                }
                writer.WriteLine();
            }
        }
 private ResultSet SortResultSet(ResultSet resultSet)
 {
     var sortedRows = new List<object[]>();
     for (int i = 0; i < resultSet.RowCount; i++)
     {
         sortedRows.Add(resultSet.GetRow(i));
     }
     sortedRows.Sort((row1, row2) =>
     {
         for (int i= 0; i < resultSet.ColumnInfos.Count; i++)
         {
             var value1 = row1[i];
             var value2 = row2[i];
             var result = _dataSchema.Compare(value1, value2);
             if (0 != result)
             {
                 return result;
             }
         }
         return 0;
     });
     return new ResultSet(resultSet.ColumnInfos, sortedRows);
 }
示例#3
0
        public void SetResults(ResultSet resultSet)
        {
            dataGridView.Columns.Clear();
            foreach (var columnInfo in resultSet.ColumnInfos)
            {
                if (columnInfo.IsHidden)
                    continue;

                DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn
                                                       {
                                                           HeaderText = columnInfo.Caption,
                                                           DefaultCellStyle = {Format = columnInfo.Format},
                                                           FillWeight = FILL_WEIGHT
                                                       };
                if (columnInfo.IsNumeric)
                {
                    column.DefaultCellStyle.NullValue = TextUtil.EXCEL_NA; // Not L10N
                }
                dataGridView.Columns.Add(column);
            }
            for (int iRow = 0; iRow < resultSet.RowCount; iRow++ )
            {
                var gridRow = dataGridView.Rows[dataGridView.Rows.Add()];
                for (int iColumn = 0, iColumnGrid = 0; iColumn < resultSet.ColumnInfos.Count; iColumn++ )
                {
                    if (resultSet.ColumnInfos[iColumn].IsHidden)
                        continue;

                    gridRow.Cells[iColumnGrid++].Value = resultSet.GetValue(iRow, iColumn);
                }
            }
        }