private async Task Run(string args, IOperationProgress progressObserver, CancellationToken token) { var dismName = WindowsCommandLineUtils.Dism; ISubject <string> outputSubject = new Subject <string>(); IDisposable stdOutputSubscription = null; if (progressObserver != null) { stdOutputSubscription = outputSubject .Select(GetPercentage) .Where(d => !double.IsNaN(d)) .Subscribe(progressObserver.Percentage); } Log.Verbose("We are about to run DISM: {ExecName} {Parameters}", dismName, args); var processResults = await ProcessMixin.RunProcess(dismName, args, outputSubject, cancellationToken : token); progressObserver?.Percentage.OnNext(double.NaN); if (processResults.ExitCode != 0) { Log.Error("There has been a problem during deployment: DISM failed {Results}", processResults); throw new DeploymentException($"There has been a problem during deployment: DISM exited with code {processResults.ExitCode}"); } stdOutputSubscription?.Dispose(); }
private static async Task Execute(IEnumerable <string> args, IOperationProgress progress) { var optionsProvider = new WindowsDeploymentOptionsProvider(); var deployer = GetDeployer(optionsProvider, progress); var parserResult = Parser.Default .ParseArguments <WindowsDeploymentCmdOptions, EnableDualBootCmdOptions, DisableDualBootCmdOptions, NonWindowsDeploymentCmdOptions>(args); await parserResult .MapResult( (WindowsDeploymentCmdOptions opts) => { optionsProvider.Options = new WindowsDeploymentOptions() { ImageIndex = opts.Index, ImagePath = opts.WimImage, SizeReservedForWindows = ByteSize.FromGigaBytes(opts.ReservedSizeForWindowsInGb), UseCompact = opts.UseCompact, }; return(deployer.Deploy()); }, (EnableDualBootCmdOptions opts) => deployer.ToggleDualBoot(true), (DisableDualBootCmdOptions opts) => deployer.ToggleDualBoot(false), (NonWindowsDeploymentCmdOptions opts) => deployer.Deploy(), HandleErrors); }
public ProgressViewModel(IReactiveCommand command, IOperationProgress operationProgress, object parent, Func <object, IDialogService> dialogFactory, IOperationContext operationContext) { this.operationContext = operationContext; dialog = dialogFactory(parent); Command = command; progress = operationProgress.Percentage .Where(d => !double.IsNaN(d)) .ToProperty(this, model => model.Progress); isProgressVisible = operationProgress.Percentage .Select(d => !double.IsNaN(d)) .CombineLatest(command.IsExecuting, (isNumber, isExecuting) => isNumber && isExecuting) .ToProperty(this, x => x.IsProgressVisible); isProgressIndeterminate = operationProgress.Percentage .Select(double.IsPositiveInfinity) .ToProperty(this, x => x.IsProgressIndeterminate); downloaded = operationProgress.Value .Select(x => ByteSize.FromBytes(x)) .Sample(TimeSpan.FromSeconds(1)) .ToProperty(this, model => model.Downloaded); isExecuting = command.IsExecuting .ToProperty(this, x => x.IsExecuting); dialog.HandleExceptionsFromCommand(command, HandleException).DisposeWith(disposables); command.ThrownExceptions.Subscribe(OnException); MessageBus.Current.Listen <CloseMessage>().Subscribe(x => isCloseRequested = true); }
public Task CaptureImage(IPartition windowsVolume, string destination, IOperationProgress progressObserver = null, CancellationToken cancellationToken = default(CancellationToken)) { Log.Verbose("Capturing image"); return(Task.CompletedTask); }
public async Task Download(string url, string path, IOperationProgress progressObserver = null, int timeout = 30) { using (var fileStream = File.OpenWrite(path)) { await Download(url, fileStream, progressObserver, timeout); } }
private async Task Download(string url, Stream destination, IOperationProgress progressObserver = null, int timeout = 30) { long?totalBytes = 0; long bytesWritten = 0; await ObservableMixin.Using(() => client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead), s => { totalBytes = s.Content.Headers.ContentLength; if (!totalBytes.HasValue) { progressObserver?.Percentage.OnNext(double.PositiveInfinity); } return(ObservableMixin.Using(() => s.Content.ReadAsStreamAsync(), contentStream => contentStream.ReadToEndObservable())); }) .Do(bytes => { bytesWritten += bytes.Length; if (totalBytes.HasValue) { progressObserver?.Percentage.OnNext((double)bytesWritten / totalBytes.Value); } progressObserver?.Value?.OnNext(bytesWritten); }) .Timeout(TimeSpan.FromSeconds(timeout)) .Select(bytes => Observable.FromAsync(async() => { await destination.WriteAsync(bytes, 0, bytes.Length); return(Unit.Default); })) .Merge(1); }
public Flash(IFileSystem fileSystem, IImageFlasher flasher, IOperationContext operationContext, IFileSystemOperations fileSystemOperations, IOperationProgress progress) : base(fileSystemOperations, operationContext) { this.fileSystem = fileSystem; this.flasher = flasher; this.progress = progress; }
private void FetchLogsFromPatcher() { string log = patcher.FetchLog(); while (log != null) { if (logToConsole) { Debug.Log(log); } patcherLogText.text = log; log = patcher.FetchLog(); } IOperationProgress progress = patcher.FetchProgress(); while (progress != null) { if (logToConsole) { Debug.Log(string.Concat(progress.Percentage, "% ", progress.ProgressInfo)); } patcherProgressText.text = progress.ProgressInfo; patcherProgressbar.value = progress.Percentage; progress = patcher.FetchProgress(); } }
public void SetProgress(IOperationProgress progress) { if (!Cancel && LogProgress) { this.progress = progress; } }
public ApplyWindowsImage(IFileSystemOperations fileSystemOperations, IOperationContext operationContext, IWindowsImageService windowsImageService, IOperationProgress progress) : base(fileSystemOperations, operationContext) { this.windowsImageService = windowsImageService; this.progress = progress; }
public void SetOperationProgress(IOperationProgress progress) { foreach (var s in m_sinks) { s.SetOperationProgress(progress); } }
private async Task ExtractContents(ICollection <ZipArchiveEntry> entries, string destination, IEntry baseEntry = null, IOperationProgress progressObserver = null) { var total = entries.Count; var copied = 0; foreach (var entry in entries) { var filePath = entry.Key.Substring(baseEntry?.Key.Length ?? 0); var destFile = Path.Combine(destination, filePath.Replace("/", "\\")); var dir = Path.GetDirectoryName(destFile); if (!fileSystemOperations.DirectoryExists(dir)) { fileSystemOperations.CreateDirectory(dir); } using (var destStream = File.Open(destFile, FileMode.OpenOrCreate)) using (var stream = entry.OpenEntryStream()) { await stream.CopyToAsync(destStream); copied++; progressObserver?.Percentage.OnNext(copied / (double)total); } } progressObserver?.Percentage.OnNext(double.NaN); }
public FetchGitHubBranch(string repositoryUrl, string branchName, IZipExtractor zipExtractor, IDownloader downloader, IGitHubClient gitHubClient, IOperationProgress progressObserver, IDeploymentContext deploymentContext, IFileSystemOperations fileSystemOperations, IOperationContext operationContext) : base(repositoryUrl, branchName, zipExtractor, downloader, gitHubClient, progressObserver, deploymentContext, fileSystemOperations, operationContext) { }
public DeployWindows(IDeploymentContext deploymentContext, IWindowsDeployer deployer, IOperationProgress progressObserver, IFileSystemOperations fileSystemOperations, IOperationContext operationContext) : base(deploymentContext, fileSystemOperations, operationContext) { this.deploymentContext = deploymentContext; this.deployer = deployer; this.progressObserver = progressObserver; }
public FProgress(IErrorOutput errorOutput, IOperationProgress operationProgress) { this.errorOutput = errorOutput; this.operationProgress = operationProgress; InitializeComponent(); RestoreFormState = false; }
public DownloadUefi(string destination, IFileSystemOperations fileSystemOperations, IZipExtractor extractor, IOperationProgress progress, IDownloader downloader) { this.destination = destination; this.fileSystemOperations = fileSystemOperations; this.extractor = extractor; this.progress = progress; this.downloader = downloader; }
private static IWoaDeployer GetDeployer(WindowsDeploymentOptionsProvider op, IOperationProgress progress) { var container = CompositionRoot.CreateContainer(op, progress); var deployer = container.Locate <IWoaDeployer>(); return(deployer); }
public Flash(string imagePath, IImageFlasher flasher, IDeploymentContext deploymentContext, IOperationContext operationContext, IFileSystemOperations fileSystemOperations, IOperationProgress progress) : base(deploymentContext, fileSystemOperations, operationContext) { this.imagePath = imagePath; this.flasher = flasher; this.progress = progress; }
public async Task Deploy(WindowsDeploymentOptions options, IDevice device, IOperationProgress progressObserver = null, CancellationToken cancellationToken = default) { Log.Information("Applying Windows Image"); progressObserver?.Percentage.OnNext(double.NaN); var partition = await device.GetWindowsPartition(); await imageService.ApplyImage(partition, options.ImagePath, options.ImageIndex, options.UseCompact, progressObserver, cancellationToken); }
public async Task ExtractToFolder(Stream stream, string destination, IOperationProgress progressObserver = null) { await ExtractCore(stream, destination, zipArchive => { var contents = zipArchive.Entries.Where(x => !x.IsDirectory); return(contents); }, progressObserver : progressObserver); }
public async Task <Stream> GetStream(string url, IOperationProgress progress = null, int timeout = 30) { var tmpFile = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); var stream = File.Create(tmpFile, BufferSize, FileOptions.DeleteOnClose); await Download(url, stream, progress, timeout); return(stream); }
public ScannedImageHelper(ThumbnailRenderer thumbnailRenderer, IOperationFactory operationFactory, IOperationProgress operationProgress, AppConfigManager appConfigManager, IUserConfigManager userConfigManager, OcrRequestQueue ocrRequestQueue, OcrManager ocrManager) { this.thumbnailRenderer = thumbnailRenderer; this.operationFactory = operationFactory; this.operationProgress = operationProgress; this.appConfigManager = appConfigManager; this.userConfigManager = userConfigManager; this.ocrRequestQueue = ocrRequestQueue; this.ocrManager = ocrManager; }
public MakeWindowsBootable(IFileSystem fileSystem, IFileSystemOperations fileSystemOperations, IBootCreator bootCreator, IOperationContext operationContext, IWindowsImageService windowsImageService, IOperationProgress progress) : base(fileSystemOperations, operationContext) { this.fileSystem = fileSystem; this.fileSystemOperations = fileSystemOperations; this.bootCreator = bootCreator; this.windowsImageService = windowsImageService; this.progress = progress; }
public async Task ExtractFirstChildToFolder(Stream stream, string destination, IOperationProgress progressObserver = null) { await ExtractCore(stream, destination, zipArchive => { var baseEntry = FirstChild(zipArchive.Entries); var contents = zipArchive.Entries.Where(x => x.Key.StartsWith(baseEntry.Key) && !x.IsDirectory); return(contents); }, FirstChild, progressObserver); }
public void ListenerCallOverallProgressChanged(IOperationProgress progress) { if (Listener != null) { try { Listener.OverallProgressChanged(progress); } catch { } } }
public OperationProgressNotifyWidget(IOperationProgress operationProgress, IOperation op) { InitializeComponent(); this.operationProgress = operationProgress; this.op = op; cancelToolStripMenuItem.Visible = op.AllowCancel; op.StatusChanged += Op_StatusChanged; op.Finished += Op_Finished; }
public async Task ExtractRelativeFolder(Stream stream, string relativeZipPath, string destination, IOperationProgress progressObserver = null) { await ExtractCore(stream, destination, zipArchive => { relativeZipPath = relativeZipPath.EndsWith("/") ? relativeZipPath : relativeZipPath + "/"; var contents = zipArchive.Entries.Where(x => x.Key.StartsWith(relativeZipPath) && !x.IsDirectory); return(contents); }, progressObserver : progressObserver, baseEntry : entries => entries.First(x => x.IsDirectory && x.Key.Equals(relativeZipPath))); }
public Fetch(string url, string destination, IZipExtractor extractor, IDownloader downloader, IOperationProgress progressObserver, IDeploymentContext deploymentContext, IFileSystemOperations fileSystemOperations, IOperationContext operationContext) : base(deploymentContext, fileSystemOperations, operationContext) { this.url = url; this.destination = destination; this.extractor = extractor; this.fileSystemOperations = fileSystemOperations; this.downloader = downloader; this.progressObserver = progressObserver; }
public FViewer(ChangeTracker changeTracker, IOperationFactory operationFactory, WinFormsExportHelper exportHelper, AppConfigManager appConfigManager, ScannedImageRenderer scannedImageRenderer, KeyboardShortcutManager ksm, IUserConfigManager userConfigManager, IOperationProgress operationProgress) { this.changeTracker = changeTracker; this.operationFactory = operationFactory; this.exportHelper = exportHelper; this.appConfigManager = appConfigManager; this.scannedImageRenderer = scannedImageRenderer; this.ksm = ksm; this.userConfigManager = userConfigManager; this.operationProgress = operationProgress; InitializeComponent(); }
public static void Update([NotNull] this IOperationScope scope, [NotNull] IOperationProgress progress) { if (scope == null) { throw new ArgumentNullException(nameof(scope)); } if (progress == null) { throw new ArgumentNullException(nameof(progress)); } scope.Runner.RootTracker.UpdateOperation(scope.Operation, progress); }