Ejemplo n.º 1
0
        protected void CheckSettingsAndFirstRow(DataTable dt, SettingsResultSetComparisonByIndex settings)
        {
            if (dt.Rows.Count == 0)
            {
                return;
            }

            var dr = dt.Rows[0];

            for (int i = 0; i < dr.Table.Columns.Count; i++)
            {
                CheckSettingsFirstRowCell(
                    settings.GetColumnRole(i)
                    , settings.GetColumnType(i)
                    , dr.Table.Columns[i]
                    , dr.IsNull(i) ? DBNull.Value : dr[i]
                    , new string[]
                {
                    "The column with index '{0}' is expecting a numeric value but the first row of your result set contains a value '{1}' not recognized as a valid numeric value or a valid interval."
                    , " Aren't you trying to use a comma (',' ) as a decimal separator? NBi requires that the decimal separator must be a '.'."
                    , "The column with index '{0}' is expecting a 'date & time' value but the first row of your result set contains a value '{1}' not recognized as a valid date & time value."
                }
                    );
            }
        }
Ejemplo n.º 2
0
 protected void WriteSettingsToDataTableProperties(DataTable dt, SettingsResultSetComparisonByIndex settings)
 {
     foreach (DataColumn column in dt.Columns)
     {
         WriteSettingsToDataTableProperties(
             column
             , settings.GetColumnRole(column.Ordinal)
             , settings.GetColumnType(column.Ordinal)
             , settings.GetTolerance(column.Ordinal)
             , settings.GetRounding(column.Ordinal)
             );
     }
 }
Ejemplo n.º 3
0
        public override KeyCollection GetKeys(DataRow row)
        {
            var keys = new List <object>();

            for (int i = 0; i < row.Table.Columns.Count; i++)
            {
                if (settings.GetColumnRole(i) == ColumnRole.Key)
                {
                    try
                    {
                        var value = FormatValue(settings.GetColumnType(i), row[i]);
                        keys.Add(value);
                    }
                    catch (FormatException)
                    {
                        var txt = "In the column with index '{0}', NBi can't convert the value '{0}' to the type '{1}'. Key columns must match with their respective types and don't support null, generic or interval values.";
                        var msg = string.Format(txt, i, row[i], settings.GetColumnType(i));
                        throw new NBiException(msg);
                    }
                    catch (InvalidCastException ex)
                    {
                        if (ex.Message.Contains("Object cannot be cast from DBNull to other types"))
                        {
                            var txt = "In the column with index '{0}', NBi can't convert the value 'DBNull' to the type '{1}'. Key columns must match with their respective types and don't support null, generic or interval values.";
                            var msg = string.Format(txt, i, row[i], settings.GetColumnType(i));
                            throw new NBiException(msg);
                        }
                        else
                        {
                            throw ex;
                        }
                    }
                }
            }
            return(new KeyCollection(keys.ToArray()));
        }