Exemple #1
0
        public ImportDataColumn Clone()
        {
            var retValue = new ImportDataColumn
            {
                ColumnName        = ColumnName,
                Required          = Required,
                Description       = Description,
                DisplayName       = DisplayName,
                SkipNullValueRows = SkipNullValueRows,
                Source            = Source
            };

            if (Dimensions != null)
            {
                retValue.Dimensions = DimensionHelper.Clone(Dimensions);
                if (ActiveDimension != null)
                {
                    retValue.ActiveDimension     = DimensionHelper.FindDimension(retValue.Dimensions, ActiveDimension.Name);
                    retValue.ActiveUnit          = retValue.ActiveDimension.FindUnit(ActiveUnit.Name);
                    retValue.IsUnitExplicitlySet = IsUnitExplicitlySet;
                }
            }
            if (MetaData != null)
            {
                retValue.MetaData = MetaData.Clone();
            }

            retValue.ColumnNameOfRelatedColumn = ColumnNameOfRelatedColumn;
            return(retValue);
        }
Exemple #2
0
        /// <summary>
        /// This method sets the active dimension and unit to a valid one depending on meta data settings.
        /// </summary>
        public void SetColumnUnitDependingOnMetaData()
        {
            if (MetaData == null || MetaData.Rows.Count == 0)
            {
                return;
            }
            if (Dimensions == null)
            {
                return;
            }
            if (CurrentlySupportedDimensions.Count == 0)
            {
                return;
            }
            if (CurrentlySupportedDimensions.Contains(ActiveDimension))
            {
                return;
            }
            if (!string.IsNullOrEmpty(ColumnNameOfRelatedColumn) && Table != null)
            {
                var relatedColumn = Table.Columns.ItemByName(ColumnNameOfRelatedColumn);
                if (relatedColumn.IsUnitExplicitlySet)
                {
                    try
                    {
                        var relatedDim = DimensionHelper.FindDimension(CurrentlySupportedDimensions,
                                                                       relatedColumn.ActiveDimension.Name);
                        if (relatedDim != null)
                        {
                            ActiveDimension = relatedDim;
                            DimensionHelper.TakeOverInputParameters(relatedDim, _activeDimension);
                            var unitName = relatedColumn.ActiveUnit.Name;
                            ActiveUnit = relatedDim.HasUnit(unitName) ? relatedDim.FindUnit(unitName) : ActiveDimension.GetDefaultUnit();

                            IsUnitExplicitlySet = false;
                            return;
                        }
                    } catch (DimensionNotFound) {}
                }
            }

            ActiveDimension = CurrentlySupportedDimensions.Contains(
                DimensionHelper.GetDefaultDimension(Dimensions))
                              ? DimensionHelper.GetDefaultDimension(Dimensions)
                              : CurrentlySupportedDimensions[0];
            ActiveUnit          = ActiveDimension.GetDefaultUnit();
            IsUnitExplicitlySet = false;
        }
Exemple #3
0
        private void setDimensionOfRelatedColumn(ImportDataColumn relatedColumn)
        {
            var newRelatedColumnDimension = bestDimensionSupportedByRelatedColumn(relatedColumn);

            if (newRelatedColumnDimension == null)
            {
                return;
            }

            if (!shouldChangeRelatedColumnDimensionTo(newRelatedColumnDimension))
            {
                return;
            }

            relatedColumn.ActiveDimension     = newRelatedColumnDimension;
            relatedColumn.IsUnitExplicitlySet = false;
            DimensionHelper.TakeOverInputParameters(_activeDimension, newRelatedColumnDimension);
        }
Exemple #4
0
        public new ImportDataTable Clone()
        {
            var retValue = (ImportDataTable)base.Clone();

            retValue.File  = File;
            retValue.Sheet = Sheet;
            foreach (ImportDataColumn col in Columns)
            {
                var newCol = retValue.Columns.ItemByName(col.ColumnName);
                newCol.DisplayName               = col.DisplayName;
                newCol.Description               = col.Description;
                newCol.Source                    = col.Source;
                newCol.SkipNullValueRows         = col.SkipNullValueRows;
                newCol.ColumnNameOfRelatedColumn = col.ColumnNameOfRelatedColumn;
                if (col.MetaData != null)
                {
                    newCol.MetaData = col.MetaData.Clone();
                }
                if (col.Dimensions == null)
                {
                    continue;
                }
                newCol.Dimensions = DimensionHelper.Clone(col.Dimensions);
            }
            if (MetaData != null)
            {
                retValue.MetaData = MetaData.Clone();
            }

            //this second run overt the columns is necessary to avoid side effects on unit setting by setting the dimensions.
            foreach (ImportDataColumn col in Columns)
            {
                if (col.ActiveDimension == null)
                {
                    continue;
                }
                var newCol = retValue.Columns.ItemByName(col.ColumnName);
                newCol.ActiveDimension     = DimensionHelper.FindDimension(newCol.Dimensions, col.ActiveDimension.Name);
                newCol.ActiveUnit          = newCol.ActiveDimension.FindUnit(col.ActiveUnit.Name);
                newCol.IsUnitExplicitlySet = col.IsUnitExplicitlySet;
            }
            return(retValue);
        }
Exemple #5
0
 private Dimension bestDimensionSupportedByRelatedColumn(ImportDataColumn relatedColumn)
 {
     return(DimensionHelper.FindDimension(relatedColumn.CurrentlySupportedDimensions, _activeDimension.Name));
 }