Inheritance: object, System.ComponentModel.INotifyPropertyChanged
Ejemplo n.º 1
0
        /// <summary>
        /// Saves this process to a file
        /// </summary>
        /// <param name="file">The file to save this process to</param>
        /// <param name="name">The name of the process</param>
        public override void Save(string file, string name)
        {
            FdoJoinTaskDefinition join = new FdoJoinTaskDefinition();
            join.name = name;
            join.Left = new FdoJoinSource();
            join.Right = new FdoJoinSource();
            join.Target = new FdoJoinTarget();
            join.JoinSettings = new FdoJoinSettings();

            join.Left.Class = _options.Left.ClassName;
            join.Left.ConnectionString = _options.Left.Connection.ConnectionString;
            join.Left.FeatureSchema = _options.Left.SchemaName;
            join.Left.Prefix = _options.LeftPrefix;
            join.Left.PropertyList = new List<string>(_options.LeftProperties).ToArray();
            join.Left.Provider = _options.Left.Connection.Provider;
            join.Left.Filter = _options.LeftFilter;

            join.Right.Class = _options.Right.ClassName;
            join.Right.ConnectionString = _options.Right.Connection.ConnectionString;
            join.Right.FeatureSchema = _options.Right.SchemaName;
            join.Right.Prefix = _options.RightPrefix;
            join.Right.PropertyList = new List<string>(_options.RightProperties).ToArray();
            join.Right.Provider = _options.Right.Connection.Provider;
            join.Right.Filter = _options.RightFilter;

            join.Target.Class = _options.Target.ClassName;
            join.Target.ConnectionString = _options.Target.Connection.ConnectionString;
            join.Target.FeatureSchema = _options.Target.SchemaName;
            join.Target.Provider = _options.Target.Connection.Provider;

            join.JoinSettings.DesignatedGeometry = new FdoDesignatedGeometry();
            if (!string.IsNullOrEmpty(_options.GeometryProperty))
            {
                join.JoinSettings.DesignatedGeometry.Property = _options.GeometryProperty;
                join.JoinSettings.DesignatedGeometry.Side = _options.Side;
            }
            join.JoinSettings.JoinType = (JoinType)Enum.Parse(typeof(JoinType), _options.JoinType.ToString());
            List<JoinKey> keys = new List<JoinKey>();
            foreach (string key in _options.JoinPairs.Keys)
            {
                JoinKey k = new JoinKey();
                k.left = key;
                k.right = _options.JoinPairs[key];
                keys.Add(k);
            }
            join.JoinSettings.JoinKeys = keys.ToArray();

            XmlSerializer serializer = new XmlSerializer(typeof(FdoJoinTaskDefinition));
            using (StreamWriter writer = new StreamWriter(file, false))
            {
                serializer.Serialize(writer, join);
            }
        }
Ejemplo n.º 2
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);
            }
        }