示例#1
0
        public FileMigrationResult MigrateFiles()
        {
            IList <MediaFile> mediaFiles = _session.QueryOver <MediaFile>().List();

            List <Guid> guids =
                mediaFiles.Where(
                    mediaFile =>
                    MediaFileExtensions.GetFileSystem(mediaFile.FileUrl, _allFileSystems.Values) !=
                    CurrentFileSystem)
                .Select(file => file.Guid).ToList();

            if (!guids.Any())
            {
                return(new FileMigrationResult
                {
                    MigrationRequired = false,
                    Message = "Migration not required"
                });
            }

            BatchCreationResult result = _createBatch.Create(guids.Chunk(10)
                                                             .Select(set => new MigrateFilesBatchJob
            {
                Data = JsonConvert.SerializeObject(set.ToHashSet()),
            }));

            return(new FileMigrationResult
            {
                MigrationRequired = true,
                Message = string.Format(
                    "Batch created. Click <a target=\"_blank\" href=\"{0}\">here</a> to view and start.".AsResource(
                        _kernel),
                    _urlHelper.Action("Show", "BatchRun", new { id = result.InitialBatchRun.Id }))
            });
        }
示例#2
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));
        }
示例#3
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));
        }
示例#4
0
        public Batch CreateBatch(HashSet <ProductImportDataTransferObject> productsToImport)
        {
            List <BatchJob> jobs = productsToImport.Select(item => new ImportProductBatchJob
            {
                Data        = JsonConvert.SerializeObject(item),
                ProductName = item.Name,
                UrlSegment  = item.UrlSegment
            } as BatchJob).ToList();

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

            return(_createBatch.Create(jobs).Batch);
        }
        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);
        }