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 })) }); }
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); }