Example #1
0
        private object[] FillItemList(ColumnInfo[] columns, DataRow row, int rowIndex, Rule rule, ArrayList warningList)
        {
            ArrayList list = new ArrayList(columns.Length);

            for (int Index = 0; Index < columns.Length; Index++)
            {
                ColumnInfo Col        = columns[Index];
                RuleItem   ColMapping = rule[Col.Field.Name];
                object     value      = null;
                try
                {
                    if (ColMapping != null && ColMapping.FillType != FillTypes.None)
                    {
                        if ((Col.SupportedFillType & ColMapping.FillType) == ColMapping.FillType)
                        {
                            MdpImportWarning[] warnings = null;
                            switch (ColMapping.FillType)
                            {
                            case FillTypes.CopyValue:
                                value = row[ColMapping.SrcColumnName];
                                if (value != DBNull.Value && !string.IsNullOrEmpty(value.ToString()))
                                {
                                    value = ConvertDataType(ColMapping.SrcColumnType, ColMapping.DestColumnType, value, ColMapping.DestColumnName, Col.Field.AllowNulls, rowIndex, out warnings);
                                }
                                else
                                {
                                    value = null;
                                }
                                break;

                            case FillTypes.Custom:
                                value = ColMapping.CustomValue;
                                value = ConvertDataType(typeof(string), ColMapping.DestColumnType, value, ColMapping.DestColumnName, Col.Field.AllowNulls, rowIndex, out warnings);
                                break;

                            case FillTypes.Default:
                                value = null;
                                break;
                            }
                            if (warnings != null)
                            {
                                warningList.AddRange(warnings);
                            }

                            if (Col.IsSystemDictionary && value != null)
                            {
                                value = value.ToString();
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    throw new MdpImportException(e.Message, row, rowIndex, ColMapping, Col.Field, value);
                }
                list.Add(value);
            }
            return(list.ToArray());
        }
Example #2
0
        protected virtual void CreateUserRow(MetaObject metaObject, Rule rule, params object[] items)
        {
            for (int Index = 0; Index < this.UserColumnInfos.Length; Index++)
            {
                RuleItem mapping = rule[this.UserColumnInfos[Index].Field.Name];

                if (mapping == null || mapping.FillType != FillTypes.Default)
                {
                    metaObject[this.UserColumnInfos[Index].Field.Name] = items[Index];
                }
            }
        }
Example #3
0
        public MdpImportException(string message, DataRow row, int rowIndex, RuleItem colMapping, MetaField destField, object errorValue)
            : base(message)
        {
            _row        = row;
            _rowIndex   = rowIndex;
            _colMapping = colMapping;
            _destField  = destField;

            if (errorValue != null)
            {
                _errorValue = errorValue.ToString();
            }
            else
            {
                _errorValue = "<null>";
            }

            _errorInfo = true;
        }
Example #4
0
 public void Add(RuleItem item)
 {
     _items.Add(item);
 }
Example #5
0
        public MdpImportException(string message, DataRow row, int rowIndex, RuleItem colMapping, MetaField destField, object errorValue)
            : base(message)
        {
            _row = row;
            _rowIndex = rowIndex;
            _colMapping = colMapping;
            _destField = destField;

            if (errorValue != null)
                _errorValue = errorValue.ToString();
            else _errorValue = "<null>";

            _errorInfo = true;
        }