Beispiel #1
0
        private ColumnInfo BuildInheritedColumn(FieldInfo field, ColumnInfo ancestor)
        {
            var column = ancestor.Clone();

            column.Field                = field;
            column.Name                 = context.NameBuilder.BuildColumnName(field, ancestor);
            column.IsDeclared           = field.IsDeclared;
            column.IsPrimaryKey         = field.IsPrimaryKey;
            column.IsNullable           = field.IsNullable;
            column.IsSystem             = field.IsSystem;
            column.DefaultSqlExpression = field.DefaultSqlExpression;

            object defaultValue = null;

            if (field.IsEnum)
            {
                var underlyingType = Enum.GetUnderlyingType(field.ValueType.StripNullable());
                if (field.DefaultValue != null)
                {
                    defaultValue = Convert.ChangeType(field.DefaultValue, underlyingType);
                }
            }
            else
            {
                defaultValue = field.DefaultValue;
            }

            column.DefaultValue = defaultValue;

            return(column);
        }
Beispiel #2
0
        private DialogResult DoDetailsItemOnClick(ColumnInfo cData)
        {
            using (var form = new FieldPropertiesForm((ColumnInfo)cData.Clone()))
            {
                var res = form.ShowDialog();
                if (res != DialogResult.OK)
                {
                    return(res);
                }

                var cDatas = _settings.ColumnDatas;
                var index  = cData.ColumnIndex;
                var cd     = form.ColumnData;

                cDatas[index] = cd;

                // Apply site/variable/source/method/qualityControl to all columns if need
                for (int k = 0; k < cDatas.Count; k++)
                {
                    if (k == index)
                    {
                        continue;
                    }

                    var option = cDatas[k];

                    if (cd.ApplySiteToAllColumns)
                    {
                        option.Site = (Site)cd.Site.Clone();
                    }
                    if (cd.ApplyVariableToAllColumns)
                    {
                        option.Variable = (Variable)cd.Variable.Clone();
                    }
                    if (cd.ApplySourceToAllColumns)
                    {
                        option.Source = (Source)cd.Source.Clone();
                    }
                    if (cd.ApplyMethodToAllColumns)
                    {
                        option.Method = (Method)cd.Method.Clone();
                    }
                    if (cd.ApplyQualityControlToAllColumns)
                    {
                        option.QualityControlLevel = (QualityControlLevel)cd.QualityControlLevel.Clone();
                    }
                    if (cd.ApplyOffsetToAllColumns)
                    {
                        option.OffsetType  = (OffsetType)cd.OffsetType.Clone();
                        option.OffsetValue = cd.OffsetValue;
                    }
                }

                columnsToImportControl1.RefreshData();
                return(res);
            }
        }
        private DialogResult DoDetailsItemOnClick(ColumnInfo cData)
        {
            // Prepare parameters to pass into FieldPropertiesForm
            var cDataClone    = (ColumnInfo)cData.Clone();
            var dataSources   = new DataSources();
            var variablesRepo = RepositoryFactory.Instance.Get <IVariablesRepository>();
            var variables     = variablesRepo.GetAll().ToList();

            foreach (var data in _settings.ColumnDatas)
            {
                if (data.Variable != null && !variables.Contains(data.Variable))
                {
                    variables.Add(data.Variable);
                }
            }
            dataSources.Variables = variables;

            // Show form
            using (var form = new FieldPropertiesForm(cDataClone, dataSources))
            {
                var res = form.ShowDialog();
                if (res != DialogResult.OK)
                {
                    return(res);
                }

                var cDatas = _settings.ColumnDatas;
                var index  = cData.ColumnIndex;
                var cd     = form.ColumnData;

                cDatas[index] = cd;

                // Apply site/variable/source/method/qualityControl to all columns if need
                for (int k = 0; k < cDatas.Count; k++)
                {
                    if (k == index)
                    {
                        continue;
                    }

                    var option = cDatas[k];

                    if (cd.ApplySiteToAllColumns)
                    {
                        option.Site = (Site)cd.Site.Clone();
                    }
                    if (cd.ApplyVariableToAllColumns)
                    {
                        option.Variable = (Variable)cd.Variable.Clone();
                    }
                    if (cd.ApplySourceToAllColumns)
                    {
                        option.Source = (Source)cd.Source.Clone();
                    }
                    if (cd.ApplyMethodToAllColumns)
                    {
                        option.Method = (Method)cd.Method.Clone();
                    }
                    if (cd.ApplyQualityControlToAllColumns)
                    {
                        option.QualityControlLevel = (QualityControlLevel)cd.QualityControlLevel.Clone();
                    }
                    if (cd.ApplyOffsetToAllColumns)
                    {
                        option.OffsetType  = (OffsetType)cd.OffsetType.Clone();
                        option.OffsetValue = cd.OffsetValue;
                    }
                }

                columnsToImportControl1.RefreshData();
                return(res);
            }
        }