/// <summary> /// Add a decorator to the enumerable for additional processing /// </summary> /// <param name="operation">The operation.</param> /// <param name="enumerator">The enumerator.</param> protected override IEnumerable <FdoRow> DecorateEnumerable(IFdoOperation operation, IEnumerable <FdoRow> enumerator) { ThreadSafeEnumerator <FdoRow> threadedEnumerator = new ThreadSafeEnumerator <FdoRow>(); ThreadPool.QueueUserWorkItem(delegate { try { foreach (FdoRow t in new EventRaisingEnumerator(operation, enumerator)) { threadedEnumerator.AddItem(t); } } catch (Exception e) { Error(e, "Failed to execute operation {0}", operation); threadedEnumerator.MarkAsFinished(); } finally { threadedEnumerator.MarkAsFinished(); } }); return(threadedEnumerator); }
/// <summary> /// Add a decorator to the enumerable for additional processing /// </summary> /// <param name="operation">The operation.</param> /// <param name="enumerator">The enumerator.</param> protected override IEnumerable<FdoRow> DecorateEnumerable(IFdoOperation operation, IEnumerable<FdoRow> enumerator) { ThreadSafeEnumerator<FdoRow> threadedEnumerator = new ThreadSafeEnumerator<FdoRow>(); ThreadPool.QueueUserWorkItem(delegate { try { foreach (FdoRow t in new EventRaisingEnumerator(operation, enumerator)) { threadedEnumerator.AddItem(t); } } catch (Exception e) { Error(e, "Failed to execute operation {0}", operation); threadedEnumerator.MarkAsFinished(); } finally { threadedEnumerator.MarkAsFinished(); } }); return threadedEnumerator; }
/// <summary> /// Sets the right part of the join /// </summary> /// <value>The right.</value> public FdoJoinOperation Right(IFdoOperation value) { right.Register(value); return(this); }
/// <summary> /// Add a decorator to the enumerable for additional processing /// </summary> /// <param name="operation">The operation.</param> /// <param name="enumerator">The enumerator.</param> protected override IEnumerable<FdoRow> DecorateEnumerable(IFdoOperation operation, IEnumerable<FdoRow> enumerator) { return new EventRaisingEnumerator(operation, enumerator); }
/// <summary> /// Initializes a new instance of the <see cref="EventRaisingEnumerator"/> class. /// </summary> /// <param name="operation">The operation.</param> /// <param name="inner">The innerEnumerator.</param> public EventRaisingEnumerator(IFdoOperation operation, IEnumerable <FdoRow> inner) { this.operation = operation; this.inner = inner; }
/// <summary> /// Adds the specified operation to this branching operation /// </summary> /// <param name="op"></param> /// <returns></returns> public FdoBranchingOperation Add(IFdoOperation op) { operations.Add(op); return(this); }
/// <summary> /// Adds the specified operation to this branching operation /// </summary> /// <param name="op"></param> /// <returns></returns> public FdoBranchingOperation Add(IFdoOperation op) { operations.Add(op); return this; }
/// <summary> /// Sets the right part of the join /// </summary> /// <value>The right.</value> public FdoJoinOperation Right(IFdoOperation value) { right.Register(value); return this; }
/// <summary> /// Registers the specified operation. /// </summary> /// <param name="op">The operation.</param> public new void Register(IFdoOperation op) { throw new NotSupportedException("Bulk Copy does not support direct registration of operations"); }
/// <summary> /// Add a decorator to the enumerable for additional processing /// </summary> /// <param name="operation">The operation.</param> /// <param name="enumerator">The enumerator.</param> protected abstract IEnumerable<FdoRow> DecorateEnumerable(IFdoOperation operation, IEnumerable<FdoRow> enumerator);
/// <summary> /// Add a decorator to the enumerable for additional processing /// </summary> /// <param name="operation">The operation.</param> /// <param name="enumerator">The enumerator.</param> protected abstract IEnumerable <FdoRow> DecorateEnumerable(IFdoOperation operation, IEnumerable <FdoRow> enumerator);
/// <summary> /// Registers the operation at the end of the operations queue /// </summary> /// <param name="operation">The operation.</param> public TDerived RegisterLast(IFdoOperation operation) { lastOperations.Add(operation); Debug("RegisterLast {0} in {1}", operation.Name, Name); return((TDerived)this); }
/// <summary> /// Sets the left part of the join /// </summary> /// <value>The left.</value> public FdoJoinOperation Left(IFdoOperation value) { left.Register(value); return this; }
/// <summary> /// Sets the left part of the join /// </summary> /// <value>The left.</value> public FdoJoinOperation Left(IFdoOperation value) { left.Register(value); return(this); }
/// <summary> /// Initializes this instance. /// </summary> protected override void Initialize() { FdoConnection srcConn = Options.Parent.GetConnection(Options.SourceConnectionName); FdoConnection dstConn = Options.Parent.GetConnection(Options.TargetConnectionName); //Register delete operation first if delete target specified if (Options.DeleteTarget) { using (var svc = dstConn.CreateFeatureService()) { var cls = svc.GetClassByName(Options.TargetSchema, Options.TargetClassName); //We can't delete if the class in question doesn't exist if (cls != null) { FdoDeleteOperation op = new FdoDeleteOperation(dstConn, Options.TargetClassName); //There's info here worth bubbling up op.OnInfo += (sender, e) => { SendMessageFormatted("[{0}:{1}] {2}", this.Name, "Delete", e.Message); }; Register(op); } } } if (Options.PreCopyTargetModifier != null) { var op = new PreClassCopyModifyOperation(Options, srcConn, dstConn); //There's info here worth bubbling up op.OnInfo += (sender, e) => { SendMessageFormatted("[{0}:{1}] {2}", this.Name, "PreCopy", e.Message); }; Register(op); } IFdoOperation input = new FdoInputOperation(srcConn, CreateSourceQuery()); IFdoOperation output = null; IFdoOperation convert = null; IFdoOperation reproject = null; NameValueCollection propertyMappings = new NameValueCollection(); string[] srcProps = this.Options.SourcePropertyNames; string[] srcAliases = this.Options.SourceAliases; if (srcProps.Length > 0) { foreach (string srcProp in srcProps) { propertyMappings.Add(srcProp, Options.GetTargetProperty(srcProp)); } } if (srcAliases.Length > 0) { foreach (string srcAlias in srcAliases) { propertyMappings.Add(srcAlias, Options.GetTargetPropertyForAlias(srcAlias)); } } if (propertyMappings.Count > 0) { if (Options.BatchSize > 0) { FdoBatchedOutputOperation bat = new FdoBatchedOutputOperation(dstConn, Options.TargetClassName, propertyMappings, Options.BatchSize); bat.BatchInserted += delegate(object sender, BatchInsertEventArgs e) { SendMessageFormatted("[Bulk Copy => {0}] {1} feature batch written", Options.TargetClassName, e.BatchSize); }; bat.OnInfo += (sender, e) => { SendMessageFormatted("[{0}:{1}] {2}", this.Name, "BatchOutput", e.Message); }; output = bat; } else { var outop = new FdoOutputOperation(dstConn, Options.TargetClassName, propertyMappings); outop.OnInfo += (sender, e) => { SendMessageFormatted("[{0}:{1}] {2}", this.Name, "Output", e.Message); }; output = outop; } } else { if (Options.BatchSize > 0) { FdoBatchedOutputOperation bat = new FdoBatchedOutputOperation(dstConn, Options.TargetClassName, Options.BatchSize); bat.BatchInserted += delegate(object sender, BatchInsertEventArgs e) { SendMessageFormatted("[Bulk Copy => {0}] {1} feature batch written", Options.TargetClassName, e.BatchSize); }; bat.OnInfo += (sender, e) => { SendMessageFormatted("[{0}:{1}] {2}", this.Name, "BatchOutput", e.Message); }; output = bat; } else { var outop = new FdoOutputOperation(dstConn, Options.TargetClassName); outop.OnInfo += (sender, e) => { SendMessageFormatted("[{0}:{1}] {2}", this.Name, "Output", e.Message); }; output = outop; } } if (Options.ConversionRules.Count > 0) { FdoDataValueConversionOperation op = new FdoDataValueConversionOperation(Options.ConversionRules); op.OnInfo += (sender, e) => { SendMessageFormatted("[{0}:{1}] {2}", this.Name, "DataValueConvert", e.Message); }; convert = op; } //TODO: // //Compare the WKTs of the source and target spatial contexts by their association (Pre-copy modifiers should've //created and/or assigned the correct contexts). If they are different, set up a re-projection operation using //the source and target WKTs, which will do a vertex by vertex transformation of all the geometries that pass //through it. // //I found this solution in a dream I had. (I am *NOT* kidding!) // //I N C E P T I O N? Register(input); if (convert != null) { Register(convert); } if (Options.FlattenGeometries) { Register(new FdoFlattenGeometryOperation()); } if (Options.ForceWkb) { Register(new FdoForceWkbOperation()); } if (reproject != null) //Will always be null atm { Register(reproject); } Register(output); //This is to dispose of any FDO objects stored in the FdoRows being sent through Register(new FdoCleanupOperation()); }
/// <summary> /// Add a decorator to the enumerable for additional processing /// </summary> /// <param name="operation">The operation.</param> /// <param name="enumerator">The enumerator.</param> protected override IEnumerable <FdoRow> DecorateEnumerable(IFdoOperation operation, IEnumerable <FdoRow> enumerator) { return(new EventRaisingEnumerator(operation, enumerator)); }