5

I am wondering where in code to update the Entities submitted. I would have expected the Iterate Data and Run Pipeline1 pipeline to handle the count with each iteration. But mine stays 0 all the way through.

Sitecore 9.1 DEF 2.1

enter image description here

5

Sitecore.DataExchange.Plugins.PipelineBatchSummary class has a property EntitySubmitedCount

This property is used in ShowPipelineBatchStatusCommand:

PipelineBatchSummary pipelineBatchSummary2 = pipelineBatchSummary1;
          DateTime dateTime;
          if (pipelineBatchSummary2 != null)
          {
            dateTime = pipelineBatchSummary2.RequestedAt;
            str = Environment.NewLine + Translate.Text("Entities submitted: {0}", (object) pipelineBatchSummary2.EntitySubmitedCount);
            foreach (KeyValuePair<string, object> statuse in pipelineBatchSummary2.Statuses)
              str = str + Environment.NewLine + statuse.Key + ": " + statuse.Value;
          }
          else
            dateTime = DateTime.Now;
          TimeSpan timeSpan = DateTime.UtcNow - dateTime;
          Sitecore.Context.ClientPage.ClientResponse.Alert(Translate.Text("{0} started at {1} and is running on {2} server for {3}.", (object) contextItem.Name, (object) DateUtil.FormatShortDateTime(dateTime), (object) "local", (object) timeSpan.ToString("hh\\:mm\\:ss")) + str);
          Sitecore.Context.ClientPage.ClientResponse.Timer(string.Format("item:load(id={0})", (object) contextItem.ID), 2);

Where is increased this property?

In the class: Sitecore.DataExchange.Providers.XConnect.Processors.PipelineSteps.BaseSubmitXConnectBatchStepProcessor it's next method:

protected virtual void OnBatchProcessed(
      Guid batchId,
      ICollection<IXdbOperation> operations,
      PipelineContext pipelineContext,
      IXdbContext client = null)
    {
      if (operations != null)
        pipelineContext.PipelineBatchContext.CurrentPipelineBatch.GetPipelineBatchSummary().EntitySubmitedCount += operations.Count<IXdbOperation>((Func<IXdbOperation, bool>) (o =>
        {
          if (o.Status != XdbOperationStatus.Succeeded)
            return o.Status == XdbOperationStatus.Created;
          return true;
        }));
      if (!this.VerificationLogEnabled(pipelineContext.PipelineBatchContext.CurrentPipelineBatch))
        return;
      if (operations != null)
        this.SetVerificationLogStatuses(pipelineContext, operations);
      this.SubmitVerificationLogEntries(pipelineContext);
    }

where EntitySubmitedCount is increased.

This method is called from method SubmitBatch:

protected virtual void SubmitBatch(
      string batchDescription,
      IXdbContext client,
      PipelineStep pipelineStep,
      PipelineContext pipelineContext,
      ILogger logger)
    {
      if (client == null)
      {
        this.SubmitVerificationLogEntries(pipelineContext);
      }
      else
      {
        string[] logDetails = this.GetLogDetails(batchDescription, client, pipelineStep, pipelineContext, logger);
        if (!this.ShouldSubmitBatch(client, pipelineStep, pipelineContext, logger))
        {
          this.Log(new Action<string>(logger.Info), pipelineContext, "Batch will not be submitted to xConnect.", logDetails);
          this.SubmitVerificationLogEntries(pipelineContext);
        }
        else
        {
          try
          {
            this.Log(new Action<string>(logger.Info), pipelineContext, "Submitting batch to xConnect.", logDetails);
            IRetryerOnException retryer = this.GetRetryer(pipelineStep, pipelineContext, logger);
            if (retryer == null)
              client.SubmitAsync().Wait();
            else
              retryer.Retry((Action) (() => client.SubmitAsync().Wait()));
          }
          catch (Exception ex)
          {
            pipelineContext.CriticalError = true;
            throw new XConnectClientException("Exception while submitting batch to xConnect.", ex);
          }
          this.OnBatchProcessed(client.LastBatchId, (ICollection<IXdbOperation>) client.LastBatch, pipelineContext, client);
        }
      }
    }

SubmitBatch method is called inside some PipelineSteps.

I hope it helps you my answer.

2

I was able to track this down. You can just add pipelineContext.PipelineBatchContext.CurrentPipelineBatch.GetPipelineBatchSummary().EntitySubmitedCount += 1; to your pipeline, but I have several pipelines and several that are reusable. So I made my own pipeline to handle the incremental update of the count.

The converter

This basically does nothing but handle my custom pipeline template ({4F1AACC2-BC1D-41EC-AB49-D21A2F78D661})

namespace Sitecore.Feature.Def.Converters.PipelineSteps
{
    using Sitecore.DataExchange.Attributes;
    using Sitecore.DataExchange.Converters.PipelineSteps;
    using Sitecore.DataExchange.Models;
    using Sitecore.DataExchange.Repositories;
    using Sitecore.Services.Core.Model;

    [SupportedIds(TemplateId)]
    public class IncrementBatchPipelineStepConverter : BasePipelineStepConverter
    {
        public const string TemplateId = "{4F1AACC2-BC1D-41EC-AB49-D21A2F78D661}";
        public IncrementBatchPipelineStepConverter(IItemModelRepository repository) : base(repository)
        {
        }

        protected override void AddPlugins(ItemModel source, PipelineStep pipelineStep)
        {
        }
    }
}

The processor

This is where I add the EntitySubmitedCount

namespace Sitecore.Feature.Def.Processors.PipelineSteps
{
    using Sitecore.DataExchange.Contexts;
    using Sitecore.DataExchange.Models;
    using Sitecore.Services.Core.Diagnostics;
    using Sitecore.DataExchange.Extensions;
    using Sitecore.DataExchange.Processors.PipelineSteps;

    public class IncrementBatchPipelineStepProcessor : BasePipelineStepProcessor
    {
        protected override void ProcessPipelineStep(
            PipelineStep pipelineStep,
            PipelineContext pipelineContext,
            ILogger logger)
        {
            pipelineContext.PipelineBatchContext.CurrentPipelineBatch.GetPipelineBatchSummary().EntitySubmitedCount += 1;
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.