withSIX.Sync.Core.Transfer.Protocols.Handlers.RsyncOutputParser.ParseOutput C# (CSharp) Method

ParseOutput() public method

public ParseOutput ( Process sender, string data, ITransferProgress progress ) : void
sender System.Diagnostics.Process
data string
progress ITransferProgress
return void
        public override void ParseOutput(Process sender, string data, ITransferProgress progress) {
            //        3.51M  43%  177.98kB/s    0:00:25
            // sent 1.39K bytes  received 1.01K bytes  1.60K bytes/sec
            // total size is 114.55K  speedup is 47.57
            if (data == null)
                return;
            progress.UpdateOutput(data);

            var matches = RSYNC_START.Matches(data);
            if (matches.Count > 0) {
                var match = matches[0];


                var speed = match.Groups[2].Value.TryDouble();
                var speedUnit = match.Groups[3].Value;
                progress.Update(GetByteSize(speed, speedUnit), match.Groups[1].Value.TryDouble());

                TimeSpan ts;
                if (TimeSpan.TryParse(match.Groups[4].Value, out ts))
                    progress.Eta = ts;

                return;
            }

            matches = RSYNC_END.Matches(data);
            if (matches.Count > 0) {
                var match = matches[0];
                var sent = match.Groups[1].Value.TryDouble();
                var sentUnit = match.Groups[2].Value;

                var received = match.Groups[3].Value.TryDouble();
                var receivedUnit = match.Groups[4].Value;

                // Rsync final message omits B(yte) indication
                progress.FileSizeTransfered = GetByteSize(sent, sentUnit + "b") +
                                              GetByteSize(received, receivedUnit + "b");
                progress.Completed = true;
                return;
            }

            progress.Eta = null;
            progress.Update(null, 0);
        }
    }

Usage Example

Ejemplo n.º 1
0
 LaunchAndProcessInfo BuildProcessInfo(ITransferProgress progress, string source, string destination,
                                       RsyncOptions options) => new LaunchAndProcessInfo(GetProcessStartInfo(source, destination, options))
 {
     StandardOutputAction = (process, data) => _parser.ParseOutput(process, data, progress),
     StandardErrorAction  = (process, data) => _parser.ParseOutput(process, data, progress),
     MonitorOutput        = _processManager.DefaultMonitorOutputTimeOut,
     MonitorResponding    = _processManager.DefaultMonitorRespondingTimeOut
 };
All Usage Examples Of withSIX.Sync.Core.Transfer.Protocols.Handlers.RsyncOutputParser::ParseOutput
RsyncOutputParser