Esempio n. 1
0
 /// <summary>
 /// Build a new Google.DataTable.Net.Wrapper.DataTable()
 /// </summary>
 /// <returns></returns>
 public DataTable Build()
 {
     try
     {
         if (_dataTable.Columns.Any())
         {
             //user has configured columns
             foreach (var r in _source)
             {
                 var row = _dataTable.AddRow(_dataTable.NewRow());
                 row.AddCellRange(_colFunc.Select(c => c(r)).ToArray());
             }
         }
         else
         {
             /*
              * No columns configured. For the time being this is a handy
              * way of transforming the object into a DataTable, by
              * reusing the already available code.
              * */
             //TODO: Test with large amount of data.
             System.Data.DataTable dt = ToDataTable(_source.ToList());
             _dataTable = SystemDataTableConverter.Convert(dt);
         }
         return(_dataTable);
     }
     finally
     {
         _dataTable = null;
         _source    = null;
         _colFunc   = null;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Converts a System.Data.DataTable into a  Google.DataTable.Net.Wrapper.DataTable
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static DataTable ToGoogleDataTable(this System.Data.DataTable source)
        {
            if (source == null)
            {
                return(null);
            }

            return(SystemDataTableConverter.Convert(source));
        }
Esempio n. 3
0
        public void ConverterReturnsColumns()
        {
            using (var sysDt = new System.Data.DataTable())
            {
                sysDt.Columns.Add("firstcolumn", typeof(string));
                sysDt.Columns.Add("secondcolumn", typeof(int));
                sysDt.Columns.Add("thirdcolumn", typeof(decimal));
                sysDt.Locale = CultureInfo.InvariantCulture;

                var dataTable = SystemDataTableConverter.Convert(sysDt);

                Assert.That(dataTable != null);
                Assert.That(dataTable.Columns.Count() == 3);
                Assert.That(dataTable.Columns.ElementAt(0).ColumnType == ColumnType.String);
                Assert.That(dataTable.Columns.ElementAt(1).ColumnType == ColumnType.Number);
                Assert.That(dataTable.Columns.ElementAt(2).ColumnType == ColumnType.Number);
            }
        }
Esempio n. 4
0
        public void ConverterReturnsColumnsAndRows()
        {
            using (var sysDt = new System.Data.DataTable())
            {
                sysDt.Columns.Add("firstcolumn", typeof(string));
                sysDt.Columns.Add("secondcolumn", typeof(int));
                sysDt.Columns.Add("thirdcolumn", typeof(decimal));
                sysDt.Locale = CultureInfo.InvariantCulture;

                var row1 = sysDt.NewRow();
                row1[0] = "Ciao";
                row1[1] = 10;
                row1[2] = 2.2;
                sysDt.Rows.Add(row1);

                var dataTable = SystemDataTableConverter.Convert(sysDt);

                Assert.That(dataTable != null);
                Assert.That(dataTable.Rows.Count() == 1);
                Assert.That((string)dataTable.Rows.ElementAt(0).Cells.ElementAt(0).Value == "Ciao");
                Assert.That((int)dataTable.Rows.ElementAt(0).Cells.ElementAt(1).Value == 10);
                Assert.That((decimal)dataTable.Rows.ElementAt(0).Cells.ElementAt(2).Value == 2.2m);
            }
        }
Esempio n. 5
0
 public void ConverterThrowsErrorIfDataTableParameterIsNull()
 {
     SystemDataTableConverter.Convert(null);
 }
 //[ExpectedException(typeof(ArgumentNullException))]
 public void ConverterThrowsErrorIfDataTableParameterIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => SystemDataTableConverter.Convert(null));
 }
        public static string getChartDataValues(string procedure, int brief, string startDate, string endDate, string[] filters)
        {
            var dt = (new Report()).sp_ExecuteProcedure(procedure, brief, startDate, endDate, filters);

            return(SystemDataTableConverter.Convert(dt).GetJson());
        }