public static PipelineBatch GetVirtualPipelineBatch(List <Item> pipelinesToRun, BatchSettings settings)
 {
     return(GetVirtualPipelineBatch(pipelinesToRun.Where(q => q != null).Select(q => q.GetItemModel()).ToList(), settings));
 }
        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 static PipelineBatch GetVirtualPipelineBatch(List <ID> pipelinesToRun, BatchSettings settings)
        {
            var db = Sitecore.Configuration.Factory.GetDatabase("master");

            return(GetVirtualPipelineBatch(pipelinesToRun.Select(w => db.GetItem(w)).Where(q => q != null).Select(q => q.GetItemModel()).ToList(), settings));
        }