Пример #1
0
        public virtual ITroubleshooterResult Troubleshoot(
            TroubleshooterContext context)
        {
            if (context == null)
            {
                return(TroubleshooterResult.FailResult("The context object passed to the troubleshooter is null."));
            }

            ItemModel configuration = context.Configuration as ItemModel;

            if (configuration == null)
            {
                return(TroubleshooterResult.FailResult("The configuration object on the troubleshooter context is null or could not be converted into an item model."));
            }

            IConverter <ItemModel, PipelineStep> converter = configuration.GetConverter <PipelineStep>(context.ItemModelRepository);

            if (converter == null)
            {
                return(TroubleshooterResult.FailResult(string.Format("No pipeline step converter was resolved. Item id: {0}", configuration.GetItemId().ToString())));
            }

            ConvertResult <PipelineStep> convertResult = converter.Convert(configuration);

            if (!convertResult.WasConverted)
            {
                return(TroubleshooterResult.FailResult("The configuration object on the troubleshooter context could not be converted into a pipeline step."));
            }

            return(this.Troubleshoot(convertResult.ConvertedValue, context));
        }
        protected static Pipeline GetPipeline(ItemModel itemModel)
        {
            var converter = itemModel?.GetConverter <Pipeline>(Sitecore.DataExchange.Context.ItemModelRepository);

            if (converter == null)
            {
                return(null);
            }

            var convertResult = converter.Convert(itemModel);

            return(convertResult.WasConverted ? convertResult.ConvertedValue : null);
        }
        public bool Sync()
        {
            try
            {
                Guid pipelineItemId = Guid.Parse(SalesforceDefPipelineBatchId);
                IItemModelRepository itemModelRepo          = Sitecore.DataExchange.Context.ItemModelRepository;
                ItemModel            pipelineBatchItemModel = itemModelRepo.Get(pipelineItemId);
                var                  converter            = pipelineBatchItemModel.GetConverter <PipelineBatch>(Sitecore.DataExchange.Context.ItemModelRepository);
                var                  convertResult        = converter.Convert(pipelineBatchItemModel);
                PipelineBatch        pipelineBatch        = convertResult.ConvertedValue;
                PipelineBatchContext pipelineBatchContext = new PipelineBatchContext();
                var                  runner = new InProcessPipelineBatchRunner();
                runner.RunAsync(pipelineBatch, pipelineBatchContext);

                Log.Info("Successfully synced xConnect contact to Salesforce on session end via DEF", this);
                return(true);
            }
            catch (Exception ex)
            {
                Log.Error($"Error syncing xConnect contact to Salesforce on session end via DEF. PipelineBatchId = {SalesforceDefPipelineBatchId}", ex, this);
                return(false);
            }
        }