/// <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); } }
/// <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); } }
/// <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; }