public static void Status(string msg, Percent progress, bool alsoLog = false) { WorkQueue.AsyncLocalCurrentQueue.Value?.Report(msg, progress); if (alsoLog) { Utils.Log(msg); } }
private void UpdateStatus() { if (_inner.Length == 0) { return; } if (_queue != null) { _queue.Report(_message, Percent.FactoryPutInRange(_inner.Position, _inner.Length)); } else { Utils.Status(_message, Percent.FactoryPutInRange(_inner.Position, _inner.Length)); } }
private static readonly string[] Suffix = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }; // Longs run out around EB public static void CopyToWithStatus(this Stream istream, long maxSize, Stream ostream, string status) { var buffer = new byte[1024 * 64]; if (maxSize == 0) { maxSize = 1; } long totalRead = 0; while (true) { var read = istream.Read(buffer, 0, buffer.Length); if (read == 0) { break; } totalRead += read; ostream.Write(buffer, 0, read); Status(status, Percent.FactoryPutInRange(totalRead, maxSize)); } }
private void UpdateStatus() { if (DateTime.Now - _lastUpdate < TimeSpan.FromMilliseconds(500)) { return; } _lastUpdate = DateTime.Now; if (_inner.Length == 0) { return; } if (_queue != null) { _queue.Report(_message, Percent.FactoryPutInRange(_inner.Position, _inner.Length)); } else { Utils.Status(_message, Percent.FactoryPutInRange(_inner.Position, _inner.Length)); } }
public void MakeUpdate(int max, int curr) { MakeUpdate(Percent.FactoryPutInRange(curr, max == 0 ? 1 : max)); }
public void MakeUpdate(Percent progress) { _progress.OnNext(OverAllStatus(progress)); }
public void MakeUpdate(Percent progress) { // Need to convert from single step progress to overall progress for output subject _progress.OnNext(OverAllStatus(progress)); }
private static void ExtractAllWithInno(string source, string dest) { Utils.Log($"Extracting {Path.GetFileName(source)}"); var info = new ProcessStartInfo { FileName = @"Extractors\innounp.exe", Arguments = $"-x -y -b -d\"{dest}\" \"{source}\"", RedirectStandardError = true, RedirectStandardInput = true, RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true }; var p = new Process { StartInfo = info }; p.Start(); ChildProcessTracker.AddProcess(p); try { p.PriorityClass = ProcessPriorityClass.BelowNormal; } catch (Exception e) { Utils.Error(e, "Error while setting process priority level for innounp.exe"); } var name = Path.GetFileName(source); try { while (!p.HasExited) { var line = p.StandardOutput.ReadLine(); if (line == null) { break; } if (line.Length <= 4 || line[3] != '%') { continue; } int.TryParse(line.Substring(0, 3), out var percentInt); Utils.Status($"Extracting {name} - {line.Trim()}", Percent.FactoryPutInRange(percentInt / 100d)); } } catch (Exception e) { Utils.Error(e, "Error while reading StandardOutput for innounp.exe"); } p.WaitForExitAndWarn(TimeSpan.FromSeconds(30), $"Extracting {name}"); if (p.ExitCode == 0) { return; } Utils.Log(p.StandardOutput.ReadToEnd()); Utils.Log($"Extraction error extracting {source}"); }
private static void ExtractAllWith7Zip(string source, string dest) { Utils.Log(new GenericInfo($"Extracting {Path.GetFileName(source)}", $"The contents of {source} are being extracted to {dest} using 7zip.exe")); var info = new ProcessStartInfo { FileName = @"Extractors\7z.exe", Arguments = $"x -bsp1 -y -o\"{dest}\" \"{source}\" -mmt=off", RedirectStandardError = true, RedirectStandardInput = true, RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true }; var p = new Process { StartInfo = info }; p.Start(); ChildProcessTracker.AddProcess(p); try { p.PriorityClass = ProcessPriorityClass.BelowNormal; } catch (Exception) { } var name = Path.GetFileName(source); try { while (!p.HasExited) { var line = p.StandardOutput.ReadLine(); if (line == null) { break; } if (line.Length <= 4 || line[3] != '%') { continue; } int.TryParse(line.Substring(0, 3), out var percentInt); Utils.Status($"Extracting {name} - {line.Trim()}", Percent.FactoryPutInRange(percentInt / 100d)); } } catch (Exception) { } p.WaitForExitAndWarn(TimeSpan.FromSeconds(30), $"Extracting {name}"); if (p.ExitCode == 0) { Utils.Status($"Extracting {name} - 100%", Percent.One, alsoLog: true); return; } Utils.Error(new _7zipReturnError(p.ExitCode, source, dest, p.StandardOutput.ReadToEnd())); }
public void SetProgress(long inSize, long outSize) { Utils.Status("Extracting OMOD", Percent.FactoryPutInRange(inSize, _total)); }
public void MakeUpdate(Percent progress) { _progress.OnNext(progress); }
public void MakeUpdate(int max, int curr) { MakeUpdate(Percent.FactoryPutInRange(curr, max == 0 ? 1 : max)); _stepName.OnNext($"({_internalCurrentStep}/{_internalMaxStep}) {_currentStepName}, {curr} of {max}"); }