コード例 #1
0
        private IDataObject TransitSourceObject(IDataObject sourceObject)
        {
            var ctx = new ValueTransitContext(sourceObject, null);

            ctx.Trace        = (TraceMode | MapConfig.Current.TraceMode).HasFlag(TraceMode.Commands);
            ctx.DataPipeline = this;
            try
            {
                RunCommands(ctx);

                if (ctx.Flow == TransitionFlow.SkipObject && ctx.Target != null)
                {
                    //If object just created and skipped by migration logic - need to remove it from cache
                    //becaus it's invalid and must be removed from cache to avoid any referencing to this object
                    //by any migration logic (lookups, key ytansitions, etc.)
                    //If object is not new, it means that it's already saved and passed by migration validation
                    if (ctx.Target.IsNew)
                    {
                        _targetSystem.InvalidateObject(ctx.Target);
                    }

                    //Tracer.TraceEvent(MigrationEvent.ObjectSkipped, ctx, "Source object skipped");

                    return(null);
                }
            }
            catch (Exception e)
            {
                throw new DataMigrationException("Error occured while object processing", ctx, e);
            }

            return(ctx.Target);
        }
コード例 #2
0
        private void RunCommands(ValueTransitContext ctx)
        {
            foreach (var childTransition in Commands)
            {
                //every time after value transition finishes - reset current value to Source object
                ctx.ResetCurrentValue();

                childTransition.TraceColor = ConsoleColor.Yellow;

                TraceLine("", ctx);

                ctx.Execute(childTransition);

                if (ctx.Flow == TransitionFlow.SkipValue)
                {
                    ctx.Flow = TransitionFlow.Continue;
                    //Tracer.TraceEvent(MigrationEvent.ValueSkipped, ctx,"Value skipped");
                    continue;
                }

                if (ctx.Flow != TransitionFlow.Continue)
                {
                    break;
                }
            }
        }
コード例 #3
0
 private void TraceLine(string message, ValueTransitContext ctx)
 {
     if ((TraceMode | MapConfig.Current.TraceMode).HasFlag(TraceMode.Objects) || ctx?.Trace == true)
     {
         Tracer.TraceLine(message, ctx, ConsoleColor.Magenta);
     }
 }
コード例 #4
0
 public DataMigrationException(string message, ValueTransitContext ctx, Exception innerException) : base(message, innerException)
 {
     Context = ctx;
 }