Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7625


Ignore:
Timestamp:
03/15/12 17:51:45 (13 years ago)
Author:
mkommend
Message:

#1734: merged changes in data importer from the heureka rep

Location:
branches/HeuristicLab.DataImporter
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/Aggregation/AggregateCommandBase.cs

    r7267 r7625  
    7474    public override void Execute() {
    7575      base.Execute();
     76      if (!ColumnGroup.Columns.Any()) return;
    7677      if (!ColumnGroup.Sorted)
    7778        throw new CommandExecutionException("ColumnGroup must be sorted to use aggregation commands.", this);
  • branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/Aggregation/DeleteRowsWithDuplicateKeyValuesCommand.cs

    r7267 r7625  
    5050    public override void Execute() {
    5151      base.Execute();
     52      if (!ColumnGroup.Columns.Any()) return;
    5253      if (!ColumnGroup.Sorted)
    5354        throw new CommandExecutionException("ColumnGroup must be sorted to delete rows with duplicate key.", this);
  • branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/ChangeDataset/AlignColumnGroupsCommand.cs

    r7267 r7625  
    5656      this.removePos2 = this.DataSet.IndexOfColumnGroup(oldColumnGroup2);
    5757
     58      if (!oldColumnGroup1.Columns.Any() || !oldColumnGroup2.Columns.Any()) return;
     59
    5860      if (oldColumnGroup1.SortedColumnsCount < 1 || oldColumnGroup1.SortedColumnsCount != oldColumnGroup2.SortedColumnsCount)
    5961        throw new CommandExecutionException("Both ColumnGroups must be sorted by at least one column and must be sorted by the same number of columns.", this);
     
    6466        if (this.oldColumnGroup1.Columns.ElementAt(oldColumnGroup1.SortedColumnIndexes.ElementAt(i)).DataType !=
    6567            this.oldColumnGroup2.Columns.ElementAt(oldColumnGroup2.SortedColumnIndexes.ElementAt(i)).DataType)
    66           throw new CommandExecutionException("Both ColumnGroups must be sorted by columns of the same type",this);
     68          throw new CommandExecutionException("Both ColumnGroups must be sorted by columns of the same type", this);
    6769      }
    6870
  • branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Data/Command/DeleteColumnCommand.cs

    r7267 r7625  
    4848      base.Execute();
    4949      this.oldSortedColumnIndices = new List<int>(ColumnGroup.SortedColumnIndexes);
     50      if (!ColumnGroup.Columns.Any()) return;
     51
    5052      ColumnBase column;
    5153      foreach (int columnIndex in AffectedColumns.Reverse()) {
     
    6264    public override void UndoExecute() {
    6365      base.UndoExecute();
    64       for (int i = 0; i < AffectedColumns.Length; i++)
     66      for (int i = 0; i < deletedColumns.Count; i++)
    6567        ColumnGroup.InsertColumn(AffectedColumns[i], deletedColumns[i]);
    6668
  • branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.DbExplorer.Interfaces/DbExplorerBase.cs

    r7267 r7625  
    101101              filterColumns.Add(col);
    102102            }
    103           cmdText += "count(*) from " + EscapeSqlString(table.OwnerName )+ "." + EscapeSqlString(table.TableName);
     103          cmdText += "count(*) from " + EscapeSqlString(table.OwnerName) + "." + EscapeSqlString(table.TableName);
    104104          cmd.CommandText = cmdText;
    105105
     
    222222              //fill columns with values
    223223              for (int i = 0; i < reader.FieldCount; i++) {
    224                 if (reader.IsDBNull(i))
     224                if (reader.IsDBNull(i)) {
    225225                  columnGroup.Columns.ElementAt(i).AddValue(null);
    226                 else if (columnGroup.Columns.ElementAt(i).DataType == typeof(double?))
    227                   columnGroup.Columns.ElementAt(i).AddValue(Convert.ToDouble(reader.GetValue(i)));
    228                 else if (columnGroup.Columns.ElementAt(i).DataType == typeof(DateTime?))
    229                   columnGroup.Columns.ElementAt(i).AddValue(reader.GetDateTime(i));
    230                 else
    231                   columnGroup.Columns.ElementAt(i).AddValue(reader.GetValue(i).ToString());
     226                } else if (columnGroup.Columns.ElementAt(i).DataType == typeof(double?)) {
     227                  try { columnGroup.Columns.ElementAt(i).AddValue(Convert.ToDouble(reader.GetValue(i))); }
     228                  catch (DbException) { columnGroup.Columns.ElementAt(i).AddValue(null); }
     229                } else if (columnGroup.Columns.ElementAt(i).DataType == typeof(DateTime?)) {
     230                  try { columnGroup.Columns.ElementAt(i).AddValue(reader.GetDateTime(i)); }
     231                  catch (DbException) { columnGroup.Columns.ElementAt(i).AddValue(null); }
     232                } else {
     233                  try { columnGroup.Columns.ElementAt(i).AddValue(reader.GetValue(i).ToString()); }
     234                  catch (DbException) { columnGroup.Columns.ElementAt(i).AddValue(null); }
     235                }
    232236              }
    233237              actRow++;
     
    235239                FireNewRowLoaded(actRow);
    236240            }
     241            if (initColumns) {
     242              for (int i = 0; i < reader.FieldCount; i++) {
     243                if (reader.GetName(i).ToUpper().Contains("ZEIT"))
     244                  columnGroup.AddColumn(new DateTimeColumn(reader.GetName(i)));
     245                else
     246                  columnGroup.AddColumn(new DoubleColumn(reader.GetName(i)));
     247              }
     248            }
    237249            reader.Close();
    238250          }  //end using reader
Note: See TracChangeset for help on using the changeset viewer.