Beispiel #1
0
 private void RecordSourceSystemEntity(IProcessedArgs <TEntity> args)
 {
     if (this.loggingConfigurationProvider.MigrationConfiguration.SourceSystemEntity &&
         args.SourceSystemEntity != null &&
         !EntityTransactionOutcomesThatRecordSourceSystemEntity.Contains(args.Outcome))
     {
         SerializedEntity serializedEntity =
             this.GetSerializedSourceSystemEntity(args);
         if (serializedEntity != null)
         {
             if (args.SourceSystemEntityId != null)
             {
                 var entity =
                     new IdentityOperationSourceSystemEntity(
                         this.operationExecutive.CurrentOperation,
                         this.context.EntityType.Id,
                         this.context.SourceSystem.Id,
                         args.SourceSystemEntityId,
                         serializedEntity);
                 this.safeRepository
                 .CreateIdentityOperationSourceSystemEntity(entity);
             }
             else
             {
                 var entity = new OperationSerializedEntity(
                     this.operationExecutive.CurrentOperation,
                     serializedEntity);
                 this.safeRepository
                 .CreateOperationSourceSystemEntity(entity);
             }
         }
     }
 }
Beispiel #2
0
        private void RecordTransaction(IProcessedArgs <TEntity> args)
        {
            EntityTransaction transaction = this.RecordTransactionEntry(args);

            this.RecordDestinationSystemEntity(transaction, args);
            this.RecordValueChanges(transaction, args);
        }
Beispiel #3
0
        private void Process(TEntity entity)
        {
            this.eventDispatcher.Processing(new ProcessingArgs(
                                                this.operationExecutive.CurrentOperation.TimeStamp, entity));
            IProcessedArgs <TEntity> processedArgs = this.processor.Process(entity);

            this.eventDispatcher.Processed(processedArgs);
        }
Beispiel #4
0
 /// <summary>
 /// Called when a source system entity has been processed.
 /// </summary>
 /// <param name="args">The event data.</param>
 public override void OnProcessed(IProcessedArgs <TEntity> args)
 {
     this.results[args.Outcome]++;
     aggregateResults[args.Outcome]++;
     this.entitiesProcessed++;
     if ((DateTime.Now - this.lastRefreshDateTime).TotalMilliseconds
         >= RefreshInterval ||
         this.entitiesProcessed == this.entityCount)
     {
         this.PrintResults();
         this.lastRefreshDateTime = DateTime.Now;
     }
 }
Beispiel #5
0
        GetSerializedSourceSystemEntity(IProcessedArgs <TEntity> args)
        {
            SerializedEntity serializedEntity;

            if (args.SerializedSourceSystemEntity != null)
            {
                serializedEntity = new SerializedEntity(
                    args.SerializedSourceSystemEntity.DataHash,
                    args.SerializedSourceSystemEntity.Data,
                    args.SerializedSourceSystemEntity.Label);
            }
            else
            {
                serializedEntity = this.SerializeEntity(args.SourceSystemEntity);
            }
            return(serializedEntity);
        }
Beispiel #6
0
 private void RecordValueChanges(
     EntityTransaction transaction, IProcessedArgs <TEntity> args)
 {
     if (this.loggingConfigurationProvider.MigrationConfiguration.ValueChanges)
     {
         foreach (ValueChange valueChange in args.ValueChanges)
         {
             this.safeRepository.CreateValueChange(
                 new PersistenceValueChange(
                     Guid.NewGuid(),
                     transaction.Id,
                     valueChange.ValueName,
                     args.Outcome != EntityTransactionOutcome.NewEntityCreated
                         ? valueChange.PreviousValue?.ToString()
                         : null,
                     valueChange.NewValue?.ToString()));
         }
     }
 }
Beispiel #7
0
        /// <summary>
        /// Called when a source system entity has been processed.
        /// </summary>
        /// <param name="args">The event data.</param>
        public override void OnProcessed(IProcessedArgs <TEntity> args)
        {
            bool shouldRecordTransaction = this.ShouldRecordTransaction(args);
            bool hasMessages             =
                args.LogMessages.Count() > 0 ||
                args.Exception != null;

            if (shouldRecordTransaction || hasMessages)
            {
                if (shouldRecordTransaction)
                {
                    this.RecordTransaction(args);
                }
                this.RecordSourceSystemEntity(args);
                this.RecordMessages(args, args.SourceSystemEntityId);
                this.operationExecutive
                .CurrentOperation
                .UpdateIdentityCorrelationId(args.SourceSystemEntityId);
            }
        }
Beispiel #8
0
 private void RecordDestinationSystemEntity(
     EntityTransaction transaction, IProcessedArgs <TEntity> args)
 {
     if (this
         .loggingConfigurationProvider
         .MigrationConfiguration
         .DestinationSystemEntity &&
         args.DestinationSystemEntity != null)
     {
         SerializedEntity serializedDestinationSystemEntity =
             this.SerializeEntity(args.DestinationSystemEntity);
         if (serializedDestinationSystemEntity != null)
         {
             this.safeRepository
             .CreateOperationDestinationSystemEntity(
                 new OperationSerializedEntity(
                     transaction, serializedDestinationSystemEntity));
         }
     }
 }
Beispiel #9
0
        private bool ShouldRecordTransaction(IProcessedArgs <TEntity> args)
        {
            bool shouldRecordTransaction = true;

            if (this
                .loggingConfigurationProvider
                .MigrationConfiguration
                .ExcludedOutcomes
                .Contains(args.Outcome))
            {
                if (!this
                    .loggingConfigurationProvider
                    .MigrationConfiguration
                    .AlwaysLogMessages ||
                    args.LogMessages.Count() == 0)
                {
                    shouldRecordTransaction = false;
                }
            }
            return(shouldRecordTransaction);
        }
Beispiel #10
0
        private EntityTransaction RecordTransactionEntry(IProcessedArgs <TEntity> args)
        {
            EntityTransaction transaction;
            Guid?mappingId =
                this
                .mappingDataRepository
                .GetMappingData(
                    this.context.EntityType.Id,
                    this.context.SourceSystem.Id,
                    args.SourceSystemEntityId)
                ?.MappingId;

            if (mappingId.HasValue)
            {
                var mappingEntityTransaction = new MappingEntityTransaction(
                    this.operationExecutive.CurrentOperation,
                    (int)args.Outcome,
                    mappingId.Value);
                this.safeRepository
                .CreateMappingEntityTransaction(mappingEntityTransaction);
                transaction = mappingEntityTransaction;
            }
            else
            {
                var identityEntityTransaction = new IdentityEntityTransaction(
                    this.operationExecutive.CurrentOperation,
                    (int)args.Outcome,
                    this.context.EntityType.Id,
                    this.context.SourceSystem.Id,
                    args.SourceSystemEntityId);
                this.safeRepository
                .CreateIdentityEntityTransaction(identityEntityTransaction);
                transaction = identityEntityTransaction;
            }
            return(transaction);
        }
Beispiel #11
0
 /// <summary>
 /// Called when a source system entity has been processed.
 /// </summary>
 /// <param name="args">The event data.</param>
 void IEventReceiver <IProcessedArgs <TEntity> > .Occurred(
     IProcessedArgs <TEntity> args)
 {
     this.OnProcessed(args);
 }
Beispiel #12
0
 /// <summary>
 /// Called when a source system entity has been processed.
 /// </summary>
 /// <param name="args">The event data.</param>
 public virtual void OnProcessed(IProcessedArgs <TEntity> args)
 {
 }
Beispiel #13
0
 /// <summary>
 /// To be called when a source system entity has been processed.
 /// </summary>
 /// <param name="args">The event data.</param>
 public void Processed(IProcessedArgs <TEntity> args)
 {
     this.Dispatch(args);
 }