/// <summary> /// Called when this process has finished processing. /// </summary> /// <param name="op">The op.</param> protected override void OnFinishedProcessing(FdoOperationBase op) { if (op is FdoBatchedOutputOperation) { FdoBatchedOutputOperation bop = op as FdoBatchedOutputOperation; string className = bop.ClassName; SendMessageFormatted("[{0}]: {1}", this.Name, op.Statistics.ToString()); } else if (op is FdoOutputOperation) { string className = (op as FdoOutputOperation).ClassName; SendMessageFormatted("[{0}]: {1}", this.Name, op.Statistics.ToString()); } }
/// <summary> /// Called when [finished processing]. /// </summary> /// <param name="op">The op.</param> protected override void OnFinishedProcessing(FdoOperationBase op) { if (op is FdoBatchedOutputOperation) { FdoBatchedOutputOperation bop = op as FdoBatchedOutputOperation; string className = bop.ClassName; SendMessageFormatted("[Join => {0}]: {1} features processed in {2}", className, bop.BatchInsertTotal, op.Statistics.Duration.ToString()); } else if (op is FdoOutputOperation) { string className = (op as FdoOutputOperation).ClassName; SendMessageFormatted("[Join => {0}]: {1} features processed in {2}", className, op.Statistics.OutputtedRows, op.Statistics.Duration.ToString()); } }
/// <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()); }