Exemplo n.º 1
0
        void ProcessUtility_ProcessMessageFired(object?sender, EventArgs <string> e)
        {
            _logger.LogDebug($"Received message from process utility: {e.Parameter}");
            var messages = e.Parameter.Split(MessageSplitters, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());

            foreach (var message in messages)
            {
                _logger.LogTrace($"Processing {message}...");
                var match = ProgressRegex.Match(message);
                if (!match.Success)
                {
                    continue;
                }

                var groups   = match.Groups;
                var filePath = DecodeFromUtf8(groups[1].Value).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
                var current  = int.Parse(groups[2].Value, CultureInfo.InvariantCulture);
                var total    = int.Parse(groups[3].Value, CultureInfo.InvariantCulture);
                _logger.LogTrace($"Progress detected:  {current} of {total}");
                if (current > total)
                {
                    _logger.LogWarning("Incorrect percentage");
                    return;
                }

                var eventArgs = new FilePathProgressEventArgs(current, total, filePath);
                _logger.LogTrace($"Reporting progress: {eventArgs}...");
                OnProgress(eventArgs);
            }
        }
Exemplo n.º 2
0
 void OnProgress(FilePathProgressEventArgs eventArgs)
 {
     Progress?.Invoke(this, eventArgs);
 }