Esempio n. 1
0
        public RoboCopyResults BuildResults(int exitCode)
        {
            var res = new RoboCopyResults();

            res.Status = new RoboCopyExitStatus(exitCode);

            var statisticLines = GetStatisticLines();

            if (statisticLines.Count >= 1)
            {
                res.DirectoriesStatistic = Statistic.Parse(statisticLines[0]);
            }

            if (statisticLines.Count >= 2)
            {
                res.FilesStatistic = Statistic.Parse(statisticLines[1]);
            }

            if (statisticLines.Count >= 3)
            {
                res.BytesStatistic = Statistic.Parse(statisticLines[2]);
            }

            if (statisticLines.Count >= 6)
            {
                res.SpeedStatistic = SpeedStatistic.Parse(statisticLines[4], statisticLines[5]);
            }

            res.LogLines = outputLines.ToArray();

            return(res);
        }
Esempio n. 2
0
        public static SpeedStatistic Parse(string line1, string line2)
        {
            var res = new SpeedStatistic();

            var   pattern = new Regex(@"\d+([\.,]\d+)?");
            Match match;

            match = pattern.Match(line1);
            if (match.Success)
            {
                res.BytesPerSec = Convert.ToDecimal(match.Value.Replace(',', '.'), CultureInfo.InvariantCulture);
            }

            match = pattern.Match(line2);
            if (match.Success)
            {
                res.MegaBytesPerMin = Convert.ToDecimal(match.Value.Replace(',', '.'), CultureInfo.InvariantCulture);
            }

            return(res);
        }