Пример #1
0
 private FdoRow ConvertValues(FdoRow row)
 {
     foreach (string propertyName in _rules.Keys)
     {
         if (row[propertyName] != null)
         {
             FdoDataPropertyConversionRule rule = _rules[propertyName];
             LiteralValue old = ValueConverter.GetConvertedValue(row[propertyName]);
             if (old.LiteralValueType == LiteralValueType.LiteralValueType_Data)
             {
                 DataValue converted = ValueConverter.ConvertDataValue((DataValue)old, rule.TargetDataType, rule.NullOnFailure, rule.Truncate);
                 row[propertyName] = ValueConverter.GetClrValue(converted);
                 if (converted != null)
                 {
                     converted.Dispose();
                 }
                 else
                 {
                     if (!rule.NullOnFailure)
                     {
                         throw new FdoException("Converting " + old + " to " + rule.TargetDataType + " resulted in a NULL value");
                     }
                 }
                 old.Dispose();
             }
         }
     }
     return(row);
 }
Пример #2
0
        private FdoRow ConvertValues(FdoRow row)
        {
            foreach (string propertyName in _rules.Keys)
            {
                if (row[propertyName] != null)
                {
                    FdoDataPropertyConversionRule rule = _rules[propertyName];
                    LiteralValue old = ValueConverter.GetConvertedValue(row[propertyName]);
                    if (old.LiteralValueType == LiteralValueType.LiteralValueType_Data)
                    {
                        DataValue converted = ValueConverter.ConvertDataValue((DataValue)old, rule.TargetDataType, rule.NullOnFailure, rule.Truncate);
                        row[propertyName] = ValueConverter.GetClrValue(converted);

                        converted.Dispose();
                        old.Dispose();
                    }
                }
            }
            return(row);
        }
Пример #3
0
        private void Load(FdoBulkCopyOptions def, string name)
        {
            txtName.Text = name;

            grdConnections.Rows.Clear();

            foreach (string connName in def.ConnectionNames)
            {
                this.AddParticipatingConnection(connName);
            }

            TreeNode root = mTreeView.Nodes[0];

            foreach (FdoClassCopyOptions task in def.ClassCopyOptions)
            {
                //Init w/ defaults
                CopyTaskNodeDecorator dec = AddNewTask(
                    root,
                    task.SourceConnectionName,
                    task.SourceSchema,
                    task.SourceClassName,
                    task.TargetConnectionName,
                    task.TargetSchema,
                    task.TargetClassName,
                    task.Name,
                    task.CreateIfNotExists);

                _tasks[dec.DecoratedNode.Index] = dec;
                root.Expand();

                btnSave.Enabled = (root.Nodes.Count > 0);

                //Options
                dec.Options.BatchSize    = task.BatchSize;
                dec.Options.Delete       = task.DeleteTarget;
                dec.Options.SourceFilter = task.SourceFilter;
                dec.Options.Flatten      = task.FlattenGeometries;

                var checkProps = new List <string>(task.CheckSourceProperties);
                //Property Mappings
                foreach (string srcProp in task.SourcePropertyNames)
                {
                    string dstProp           = task.GetTargetProperty(srcProp);
                    bool   createIfNotExists = checkProps.Contains(srcProp);
                    try
                    {
                        dec.PropertyMappings.MapProperty(srcProp, dstProp, createIfNotExists);
                    }
                    catch (MappingException ex)
                    {
                        LoggingService.Info("Skipping mapping: " + srcProp + " => " + dstProp + " (" + ex.Message + ")");
                    }
                    FdoDataPropertyConversionRule   rule = task.GetDataConversionRule(srcProp);
                    PropertyConversionNodeDecorator cd   = dec.PropertyMappings.GetConversionRule(srcProp);
                    if (rule != null)
                    {
                        cd.NullOnFailedConversion = rule.NullOnFailure;
                        cd.Truncate = rule.Truncate;
                    }
                }

                //Expression Mappings
                foreach (string alias in task.SourceAliases)
                {
                    string expr              = task.GetExpression(alias);
                    string dstProp           = task.GetTargetPropertyForAlias(alias);
                    bool   createIfNotExists = checkProps.Contains(alias);
                    dec.ExpressionMappings.AddExpression(alias, expr);
                    dec.ExpressionMappings.MapExpression(alias, dstProp, createIfNotExists);

                    FdoDataPropertyConversionRule   rule = task.GetDataConversionRule(alias);
                    PropertyConversionNodeDecorator cd   = dec.ExpressionMappings.GetConversionRule(alias);

                    if (rule != null)
                    {
                        cd.NullOnFailedConversion = rule.NullOnFailure;
                        cd.Truncate = rule.Truncate;
                    }
                }
            }
        }