public void ImportingTaskStart() { var temporaryDirectory = TemporaryFileService.AllocateTemporaryDirectory(TimeSpan.FromHours(1)); DirectoryHelpers.DirectoryCopy(Modification.RepositoryPath, temporaryDirectory, true); Directory.Move(temporaryDirectory, finalRepositoryPath); Modification = ModificationLoader.FromPath(finalRepositoryPath); PhaseFactory.SetModification(Modification); ViewModel.SetModification(Modification); var enabledComponent = Modification.GetComponent <EnabledComponent>(); enabledComponent.IsEnabled = true; var thumbnailDirectory = Path.Combine(finalRepositoryPath, "thumbnails"); FileSystemProxy.PrepareDirectory(thumbnailDirectory); var thumbnailGenerationTask = Task.Factory.StartNew(() => { using (var ms = new MemoryStream()) using (var writer = new BinaryWriter(ms)) { PofSerializer.Serialize(writer, new ThumbnailGenerationParameters { DestinationDirectory = thumbnailDirectory, SourceDirectory = importedDirectoryPath, ThumbnailsToGenerate = 3 }); ExeggutorService.SpawnHatchling( "thumbnail-generator", new SpawnConfiguration { InstanceName = "thumbnail-generator-" + DateTime.UtcNow.GetUnixTime(), Arguments = ms.GetBuffer() }); var thumbnailComponent = Modification.GetComponent <ThumbnailComponent>(); thumbnailComponent.SelectThumbnailIfUnselected(); } }, TaskCreationOptions.LongRunning); var contentDirectory = Path.Combine(finalRepositoryPath, "content"); FileSystemProxy.PrepareDirectory(contentDirectory); for (var i = 0; i < relativeImportedFilePaths.Length; i++) { var sourceFile = Path.Combine(importedDirectoryPath, relativeImportedFilePaths[i]); var destinationFile = Path.Combine(contentDirectory, relativeImportedFilePaths[i]); FileSystemProxy.PrepareParentDirectory(destinationFile); FileSystemProxy.CopyFile(sourceFile, destinationFile); UpdateProgress(0.333 * ((double)i / relativeImportedFilePaths.Length)); } LeagueBuildUtilities.ResolveModification(Modification, CancellationToken.None); UpdateProgress(0.666); LeagueBuildUtilities.CompileModification(Modification, CancellationToken.None); UpdateProgress(1); thumbnailGenerationTask.Wait(); PhaseManager.Transition(PhaseFactory.Idle()); }
internal void HandleUninitializedToPreclientPhaseTransition(ILeagueSession session, LeagueSessionPhaseChangedArgs e) { logger.Info("Handling Uninitialized to Preclient Phase Transition!"); var modifications = modificationLoader.EnumerateModifications(); foreach (var modification in modifications) { var resolutionChain = resolutionChainsByModificationName.GetOrAdd( modification.RepositoryName, add => new CompletionChain(cancellationToken => leagueBuildUtilities.ResolveModification(modification, cancellationToken)) ); var compilationChain = compilationChainsByModificationName.GetOrAdd( modification.RepositoryName, add => new CompletionChain(cancellationToken => leagueBuildUtilities.CompileModification(modification, cancellationToken)) ); var resolutionLink = resolutionChain.CreateLink("resolution_" + DateTime.Now.ToFileTimeUtc()); var compilationLink = compilationChain.CreateLink("compilation_" + DateTime.Now.ToFileTimeUtc()); resolutionLink.Tail(compilationLink.StartAndWaitForChain); resolutionChain.StartNext(resolutionLink); } radsService.Suspend(); }