示例#1
0
        public bool CreateBatch(MergeWebpageConfirmationModel model)
        {
            var list = new List <BatchJob>();

            list.AddRange(model.ChangedPages.FindAll(x => x.ParentId == model.Webpage.Id).Select(pageModel => new MoveWebpageBatchJob
            {
                WebpageId   = pageModel.Id,
                NewParentId = model.MergedInto?.Id
            }));

            list.AddRange(model.ChangedPages.FindAll(x => x.OldUrl != x.NewUrl).Select(pageModel =>
                                                                                       new UpdateUrlBatchJob
            {
                WebpageId = pageModel.Id,
                NewUrl    = pageModel.NewUrl
            }));

            list.Add(new CompleteMergeBatchJob
            {
                WebpageId    = model.Webpage.Id,
                MergedIntoId = model.MergedInto.Id
            });

            var result = _createBatch.Create(list);

            return(_controlBatchRun.Start(result.InitialBatchRun));
        }
示例#2
0
        public bool CreateBatch(MoveWebpageConfirmationModel model)
        {
            var itemsToUpdate = model.ChangedPages.FindAll(x => x.OldUrl != x.NewUrl);

            if (!itemsToUpdate.Any())
            {
                return(true);
            }

            var result = _createBatch.Create(itemsToUpdate.Select(x => new UpdateUrlBatchJob
            {
                NewUrl    = x.NewUrl,
                WebpageId = x.Id
            }));

            return(_controlBatchRun.Start(result.InitialBatchRun));
        }
        public Batch CreateBatch(List <DocumentImportDTO> items, bool autoStart = true)
        {
            List <BatchJob> jobs = items.Select(item => new ImportDocumentBatchJob
            {
                Data       = JsonConvert.SerializeObject(item),
                UrlSegment = item.UrlSegment
            } as BatchJob).ToList();

            jobs.Add(new RebuildUniversalSearchIndex());
            jobs.AddRange(IndexingHelper.IndexDefinitionTypes.Select(definition => new RebuildLuceneIndex
            {
                IndexName = definition.SystemName
            }));

            BatchCreationResult batchCreationResult = _createBatch.Create(jobs);

            if (autoStart)
            {
                _controlBatchRun.Start(batchCreationResult.InitialBatchRun);
            }
            return(batchCreationResult.Batch);
        }
示例#4
0
 public int?Start(BatchRun run)
 {
     return(_controlBatchRun.Start(run) ? run.Id : (int?)null);
 }