Exemple #1
0
        internal virtual void TrackActivity(BatchTrackingContext batchTrackingContext)
        {
            var shouldProceed = batchTrackingContext != null &&
                                batchTrackingContext.MessagingStepActivityIdList != null &&
                                batchTrackingContext.MessagingStepActivityIdList.Length > 0;

            if (shouldProceed)
            {
                if (_logger.IsInfoEnabled)
                {
                    _logger.Debug("Associating the batch being released with its parts.");
                }
                var activityFactory = (IBatchProcessActivityFactory)_pipelineContext.ActivityFactory();
                var process         = batchTrackingContext.ProcessActivityId.IsNullOrEmpty()
                                        ? activityFactory.CreateProcess(_message, BizTalk.Factory.Areas.Batch.Processes.Release)
                                        : activityFactory.FindProcess(batchTrackingContext.ProcessActivityId);

                process.TrackActivity();
                process.AddSteps(
                    batchTrackingContext.MessagingStepActivityIdList
                    .Concat(new[] { _message.GetProperty(TrackingProperties.MessagingStepActivityId) }));
            }
            else
            {
                if (_logger.IsInfoEnabled)
                {
                    _logger.Debug("The batch being released cannot be associated with its parts because their ActivityIDs have not been captured.");
                }
            }
        }
Exemple #2
0
        public void TrackActivityWithAmbientProcessActivity()
        {
            var batchTrackingContext = new BatchTrackingContext {
                MessagingStepActivityIdList = new[] { ActivityId.NewActivityId(), ActivityId.NewActivityId(), ActivityId.NewActivityId() },
                ProcessActivityId           = ActivityId.NewActivityId()
            };

            var sut = BatchReleaseProcessActivityTracker.Create(PipelineContextMock.Object, MessageMock.Object);

            sut.TrackActivity(batchTrackingContext);

            ActivityFactory.Verify(af => af.CreateProcess(It.IsAny <IBaseMessage>(), It.IsAny <string>()), Times.Never());
            // ReSharper disable once ImplicitlyCapturedClosure
            ActivityFactory.Verify(af => af.FindProcess(batchTrackingContext.ProcessActivityId), Times.Once());

            ProcessMock.Verify(p => p.TrackActivity(), Times.Once());
            ProcessMock.Verify(
                p =>
                p.AddSteps(
                    It.Is <IEnumerable <string> >(
                        list =>
                        list.SequenceEqual(
                            batchTrackingContext.MessagingStepActivityIdList
                            .Concat(new[] { MessageMock.Object.GetProperty(TrackingProperties.MessagingStepActivityId) })))),
                Times.Once());
        }
Exemple #3
0
        public void TrackActivityWhenBatchTrackingContextOnlyHasProcessActivityId()
        {
            var batchTrackingContext = new BatchTrackingContext {
                ProcessActivityId = ActivityId.NewActivityId()
            };

            var sut = BatchReleaseProcessActivityTracker.Create(PipelineContextMock.Object, MessageMock.Object);

            sut.TrackActivity(batchTrackingContext);

            ActivityFactory.Verify(af => af.CreateProcess(It.IsAny <IBaseMessage>(), It.IsAny <string>()), Times.Never());
            ActivityFactory.Verify(af => af.FindProcess(It.IsAny <string>()), Times.Never());

            ProcessMock.Verify(p => p.TrackActivity(), Times.Never());
            ProcessMock.Verify(p => p.AddSteps(It.IsAny <IEnumerable <string> >()), Times.Never());
        }
Exemple #4
0
        public void TrackActivityWithoutAmbientProcessActivity()
        {
            var batchTrackingContext = new BatchTrackingContext {
                MessagingStepActivityIdList = new[] { ActivityId.NewActivityId(), ActivityId.NewActivityId(), ActivityId.NewActivityId() }
            };

            var sut = BatchReleaseProcessActivityTracker.Create(PipelineContextMock.Object, MessageMock.Object);

            sut.TrackActivity(batchTrackingContext);

            ActivityFactory.Verify(af => af.CreateProcess(MessageMock.Object, It.IsAny <string>()), Times.Once);
            ActivityFactory.Verify(af => af.FindProcess(It.IsAny <string>()), Times.Never);

            ProcessMock.Verify(p => p.TrackActivity(), Times.Once);
            ProcessMock.Verify(
                p => p.AddSteps(
                    It.Is <IEnumerable <string> >(
                        list => list.SequenceEqual(
                            batchTrackingContext.MessagingStepActivityIdList.Append(MessageMock.Object.GetProperty(TrackingProperties.MessagingStepActivityId))))),
                Times.Once);
        }