Controls the FdoJoin operation
Inheritance: IDisposable
Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FdoJoin"/> class.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <param name="reportFrequency">The report frequency.</param>
 public FdoJoin(FdoJoinOptions options, int reportFrequency)
     : this(options)
 {
     _ReportFrequency = reportFrequency;
 }
Esempio n. 2
0
        internal void SaveTask()
        {
            if (string.IsNullOrEmpty(_view.TaskName))
                throw new TaskValidationException(ResourceService.GetString("ERR_TASK_NAME_REQUIRED"));

            var leftPropNames = _view.LeftProperties;
            var rightPropNames = _view.RightProperties;
            var allPropNames = new List<string>();
            foreach (var p in leftPropNames)
            {
                var name = _view.LeftPrefix + p;
                if (allPropNames.Contains(name))
                    throw new TaskValidationException(ResourceService.GetStringFormatted("ERR_MERGED_CLASS_DUPLICATE_PROPERTY", name));

                allPropNames.Add(name);
            }
            foreach (var p in rightPropNames)
            {
                var name = _view.RightPrefix + p;
                if (allPropNames.Contains(name))
                    throw new TaskValidationException(ResourceService.GetStringFormatted("ERR_MERGED_CLASS_DUPLICATE_PROPERTY", name));

                allPropNames.Add(name);
            }

            FdoJoinOptions options = null;
            if (_join == null)
            {
                options = new FdoJoinOptions();
            }
            else
            {
                options = _join.Options;
                options.Reset();
            }
            options.SetLeft(
                _connMgr.GetConnection(_view.SelectedLeftConnection),
                _view.SelectedLeftSchema,
                _view.SelectedLeftClass);
            options.SetRight(
                _connMgr.GetConnection(_view.SelectedRightConnection),
                _view.SelectedRightSchema,
                _view.SelectedRightClass);
            options.SetTarget(
                _connMgr.GetConnection(_view.SelectedTargetConnection),
                _view.SelectedTargetSchema,
                _view.SelectedTargetClass);

            if (_view.BatchEnabled)
                options.BatchSize = _view.BatchSize;

            if (_view.TargetGeometryPropertyEnabled)
            {
                if (!string.IsNullOrEmpty(_view.LeftGeometryName) && _view.LeftGeometryChecked)
                {
                    options.GeometryProperty = _view.LeftGeometryName;
                    options.Side = FdoToolbox.Core.Configuration.JoinSide.Left;
                }
                else if (!string.IsNullOrEmpty(_view.RightGeometryName) && _view.RightGeometryChecked)
                {
                    options.GeometryProperty = _view.RightGeometryName;
                    options.Side = FdoToolbox.Core.Configuration.JoinSide.Right;
                }
            }

            options.SetJoinPairs(_view.GetJoinedProperties());
            
            options.JoinType = _view.SelectedJoinType;
            
            foreach (string leftProp in _view.LeftProperties)
            {
                options.AddLeftProperty(leftProp);
            }

            foreach (string rightProp in _view.RightProperties)
            {
                options.AddRightProperty(rightProp);
            }

            options.LeftPrefix = _view.LeftPrefix;
            options.RightPrefix = _view.RightPrefix;
            options.LeftFilter = _view.LeftFilter;
            options.RightFilter = _view.RightFilter;

            options.Validate();

            FdoJoin join = null;
            if (_join == null) //New join
            {
                join = new FdoJoin(options);
                _taskMgr.AddTask(_view.TaskName, join);
            }
            else //Join was loaded. Update its options
            {
                _join.Options = options;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FdoJoin"/> class.
 /// </summary>
 /// <param name="options">The options.</param>
 public FdoJoin(FdoJoinOptions options)
 {
     _options = options;
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FdoJoin"/> class.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <param name="reportFrequency">The report frequency.</param>
 public FdoJoin(FdoJoinOptions options, int reportFrequency) : this(options) { _ReportFrequency = reportFrequency; }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FdoJoin"/> class.
 /// </summary>
 /// <param name="options">The options.</param>
 public FdoJoin(FdoJoinOptions options)
 {
     _options = options;
 }
Esempio n. 6
0
        /// <summary>
        /// Saves the join options to xml
        /// </summary>
        /// <param name="opts">The opts.</param>
        /// <param name="name">The name.</param>
        /// <param name="file">The file.</param>
        public void ToXml(FdoJoinOptions opts, string name, string file)
        {
            FdoJoinTaskDefinition jdef = new FdoJoinTaskDefinition();
            jdef.name = name;
            jdef.JoinSettings = new FdoJoinSettings();
            if (!string.IsNullOrEmpty(opts.GeometryProperty))
            {
                jdef.JoinSettings.DesignatedGeometry = new FdoDesignatedGeometry();
                jdef.JoinSettings.DesignatedGeometry.Property = opts.GeometryProperty;
                jdef.JoinSettings.DesignatedGeometry.Side = opts.Side;
            }
            List<JoinKey> keys = new List<JoinKey>();
            foreach (string left in opts.JoinPairs.Keys)
            {
                JoinKey key = new JoinKey();
                key.left = left;
                key.right = opts.JoinPairs[left];
                keys.Add(key);
            }
            jdef.JoinSettings.JoinKeys = keys.ToArray();

            jdef.Left = new FdoJoinSource();
            jdef.Left.Class = opts.Left.ClassName;
            jdef.Left.ConnectionString = opts.Left.Connection.ConnectionString;
            jdef.Left.FeatureSchema = opts.Left.SchemaName;
            jdef.Left.Prefix = opts.LeftPrefix;
            jdef.Left.PropertyList = new List<string>(opts.LeftProperties).ToArray();
            jdef.Left.Provider = opts.Left.Connection.Provider;

            jdef.Right = new FdoJoinSource();
            jdef.Right.Class = opts.Right.ClassName;
            jdef.Right.ConnectionString = opts.Right.Connection.ConnectionString;
            jdef.Right.FeatureSchema = opts.Right.SchemaName;
            jdef.Right.Prefix = opts.RightPrefix;
            jdef.Right.PropertyList = new List<string>(opts.RightProperties).ToArray();
            jdef.Right.Provider = opts.Right.Connection.Provider;

            jdef.Target = new FdoJoinTarget();
            jdef.Target.Class = opts.Target.ClassName;
            jdef.Target.ConnectionString = opts.Target.Connection.ConnectionString;
            jdef.Target.FeatureSchema = opts.Target.SchemaName;
            jdef.Target.Provider = opts.Target.Connection.Provider;

            using (XmlTextWriter writer = new XmlTextWriter(file, Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                writer.Indentation = 4;

                XmlSerializer ser = new XmlSerializer(typeof(FdoJoinTaskDefinition));
                ser.Serialize(writer, jdef);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Loads join options from xml
        /// </summary>
        /// <param name="def">The deserialized definition</param>
        /// <param name="name">The name.</param>
        /// <param name="owner">if set to <c>true</c> [owner].</param>
        /// <returns></returns>
        private FdoJoinOptions JoinFromXml(FdoJoinTaskDefinition def, ref string name, bool owner)
        {
            FdoJoinOptions opts = new FdoJoinOptions(owner);
            name = def.name;
            if (def.JoinSettings.DesignatedGeometry != null)
            {
                opts.GeometryProperty = def.JoinSettings.DesignatedGeometry.Property;
                opts.Side = def.JoinSettings.DesignatedGeometry.Side;
            }
            foreach (JoinKey key in def.JoinSettings.JoinKeys)
            {
                opts.JoinPairs.Add(key.left, key.right);
            }
            string dummy = string.Empty;
            opts.JoinType = (FdoJoinType)Enum.Parse(typeof(FdoJoinType), def.JoinSettings.JoinType.ToString());
            opts.SetLeft(
                CreateConnection(def.Left.Provider, def.Left.ConnectionString, null, ref dummy),
                def.Left.FeatureSchema,
                def.Left.Class);
            foreach (string p in def.Left.PropertyList)
            {
                opts.AddLeftProperty(p);
            }
            opts.SetRight(
                CreateConnection(def.Right.Provider, def.Right.ConnectionString, null, ref dummy),
                def.Right.FeatureSchema,
                def.Right.Class);
            foreach (string p in def.Right.PropertyList)
            {
                opts.AddRightProperty(p);
            }

            opts.SetTarget(
                CreateConnection(def.Target.Provider, def.Target.ConnectionString, null, ref dummy),
                def.Target.FeatureSchema,
                def.Target.Class);

            opts.LeftPrefix = def.Left.Prefix;
            opts.RightPrefix = def.Right.Prefix;
            opts.LeftFilter = def.Left.Filter;
            opts.RightFilter = def.Right.Filter;

            return opts;
        }