public void ApplySettings(PipelineBatch pipelineBatch) { var telemetryPlugin = new TelemetryActivitySettings { Enabled = TelemetryEnabled }; pipelineBatch.AddPlugin(telemetryPlugin); var supportedModesPlugin2 = new MultiModeSupportSettings { SupportedModes = new List <string>() }; pipelineBatch.AddPlugin(supportedModesPlugin2); var pipelineBatchSummary = new PipelineBatchSummary() { IncludeStackTraceForExceptions = IsIncludeStackTraceForExceptions }; foreach (var logLevel in LogLevels) { pipelineBatchSummary.LogLevels.Add(logLevel); } pipelineBatch.AddPlugin(pipelineBatchSummary); SitecoreItemSettings newPlugin = new SitecoreItemSettings() { ItemId = Guid.Parse(pipelineBatch.Identifier) }; pipelineBatch.AddPlugin(newPlugin); pipelineBatch.AddPlugin(VerificationLogSettings); }
protected static void AddVerificationLogPlugin(PipelineBatch pipelineBatch) { VerificationLogSettings newPlugin = new VerificationLogSettings() { SaveJson = false, VerificationEnabled = false, VerificationLog = null }; pipelineBatch.AddPlugin(newPlugin); }
protected virtual PipelineBatchContext GetPipelineBatchContext(PipelineBatch pipelineBatch) { var pipelineBatchContext = new PipelineBatchContext(); var newPlugin = new PipelineBatchRuntimeSettings { ShouldPersistSummary = true, PipelineBatchMode = string.Empty }; pipelineBatchContext.AddPlugin(newPlugin); return(pipelineBatchContext); }
protected static void AddPlugins(PipelineBatch pipelineBatch) { TelemetryActivitySettings telemetryPlugin = new TelemetryActivitySettings() { Enabled = false }; pipelineBatch.AddPlugin <TelemetryActivitySettings>(telemetryPlugin); MultiModeSupportSettings newPlugin2 = new MultiModeSupportSettings() { SupportedModes = new List <string>() }; pipelineBatch.AddPlugin <MultiModeSupportSettings>(newPlugin2); }
protected static void AddRequiredPlugins(PipelineBatch pipelineBatch) { PipelineBatchSummary pipelineBatchSummary = new PipelineBatchSummary() { IncludeStackTraceForExceptions = true }; AddLogLevel(pipelineBatchSummary); pipelineBatch.AddPlugin <PipelineBatchSummary>(pipelineBatchSummary); SitecoreItemSettings newPlugin = new SitecoreItemSettings() { ItemId = Guid.Parse(pipelineBatch.Identifier) }; pipelineBatch.AddPlugin(newPlugin); }
public void RunPipelineBatch(PipelineBatch pipelineBatch, User currentUser, IPlugin[] plugins) { if (PipelineBatchRunner == null) { return; } if (currentUser == null) { currentUser = Sitecore.Context.User; } using (new UserSwitcher(currentUser)) { var pipelineBatchContext = GetPipelineBatchContext(pipelineBatch); plugins.ForEach(q => pipelineBatchContext.AddPlugin(q)); PipelineBatchRunner.Run(pipelineBatch, pipelineBatchContext); } }
public static PipelineBatch GetVirtualPipelineBatch(List <ItemModel> pipelinesToRun, BatchSettings settings) { if (pipelinesToRun == null) { return(null); } var db = Sitecore.Configuration.Factory.GetDatabase("master"); var virtualBatch = new PipelineBatch(); virtualBatch.Enabled = true; var hash = GetHash(pipelinesToRun.Select(q => q.GetItemId().ToID().ToShortID().ToString()) .Aggregate((f, s) => f + "|" + s)); virtualBatch.Identifier = hash; virtualBatch.PipelineBatchProcessor = new VirtualPipelineBatchProcessor(); virtualBatch.Tenant = GetTenant(db.GetItem(pipelinesToRun.First().GetItemId().ToID())); settings.ApplySettings(virtualBatch); foreach (var pipeline in pipelinesToRun) { if (pipeline == null) { continue; } var pipelineModel = GetPipeline(pipeline); virtualBatch.Pipelines.Add(pipelineModel); } if (!virtualBatch.Pipelines.Any()) { return(null); } virtualBatch.Name = "VirtualBatch (" + virtualBatch.Pipelines.Select(q => q.Name.Replace(" ", ".")).Aggregate((q, w) => q + "|" + w) + ")"; return(virtualBatch); }
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); } }
protected virtual void Run(PipelineBatch batch, IPlugin[] plugins) { if (batch == null) { return; } var pipelineBatchRunner = (InProcessPipelineBatchRunner)PipelineBatchRunner; if (pipelineBatchRunner != null && (!pipelineBatchRunner.IsRunningRemotely(batch) || !PipelineBatchRunner.IsRunning(batch.Identifier))) { const string category = "Data Exchange"; var parameters = new object[] { batch, GetUser(), plugins }; var options = new JobOptions(batch.Name, category, "Data Exchange Framework", this, "RunPipelineBatch", parameters); PipelineBatchRunner.CurrentProcesses[batch.Identifier] = JobManager.Start(options); } }
public static List <PipelineBatch> GetVirtualPipelineBatches(string formId) { var result = new List <PipelineBatch>(); var pipelines = FindAccotiatedPipelines(formId); if (pipelines == null) { return(null); } var db = Sitecore.Configuration.Factory.GetDatabase("master"); foreach (var pipeline in pipelines) { var pipelineModel = GetPipeline(pipeline); var virtualBatch = new PipelineBatch(); virtualBatch.Enabled = true; virtualBatch.Name = "VirtualBatch." + pipelineModel.Name.Replace(" ", "."); virtualBatch.Identifier = pipelineModel.Identifier; virtualBatch.PipelineBatchProcessor = new VirtualPipelineBatchProcessor(); virtualBatch.Tenant = GetTenant(db.GetItem(pipeline.GetItemId().ToID())); if (pipeline != null) { virtualBatch.Pipelines.Add(pipelineModel); } AddRequiredPlugins(virtualBatch); AddPlugins(virtualBatch); AddVerificationLogPlugin(virtualBatch); result.Add(virtualBatch); } return(result); }
protected override void OnStartingProcessing(PipelineBatch pipelineBatch, PipelineBatchContext pipelineBatchContext, ILogger logger) { _logger = logger; base.OnStartingProcessing(pipelineBatch, pipelineBatchContext, logger); }