public static PricatLine Parse(String line)
        {
            var result = new PricatLine();
            var values = SplitRegex
                         .Split(line)
                         .Select(value => value.Trim('\"'))
                         .ToArray();

            if (values.Length != 65)
            {
                return(null);
            }

            result.Number                  = values[01];
            result.ArticleType             = values[05];
            result.ArticleID               = values[06];
            result.SupplierCode            = values[07];
            result.ArticleGroupCode        = values[13];
            result.ArticleGroupDescription = values[14];
            result.Description             = values[48];
            result.Brand             = values[17];
            result.Model             = values[18];
            result.ColorSupplier     = values[26];
            result.ColorCode         = values[30];
            result.SizeRulerSupplier = values[34];
            result.SizeSupplier      = values[35];
            result.SubsizeSupplier   = values[36];

            result.VAT         = values[59];
            result.NettoPrice  = values[60];
            result.AdvicePrice = values[62];
            result.LabelPrice  = values[63];

            return(result);
        }
        /// <summary>
        /// Load the content statistics from a folder.
        /// </summary>
        /// <param name="outputPath">The folder where the .mgstats file can be found.</param>
        /// <returns>Returns the content statistics or an empty collection.</returns>
        public static ContentStatsCollection Read(string outputPath)
        {
            var collection = new ContentStatsCollection();

            var filePath = Path.Combine(outputPath, Extension);

            try
            {
                int lineIndex = 0;
                foreach (string line in File.ReadLines(filePath))
                {
                    // The first line is the CSV header... if it doesn't match
                    // then assume the data is invalid or changed formats.
                    if (lineIndex++ == 0 && line != Header)
                    {
                        return(collection);
                    }

                    var columns = SplitRegex.Split(line);
                    if (columns.Length != 7)
                    {
                        continue;
                    }

                    var stats = new ContentStats(
                        sourceFile: columns[0].Trim('"'),
                        destFile: columns[1].Trim('"'),
                        processorType: columns[2].Trim('"'),
                        contentType: columns[3].Trim('"'),
                        sourceFileSize: long.Parse(columns[4]),
                        destFileSize: long.Parse(columns[5]),
                        buildSeconds: float.Parse(columns[6]));

                    if (!collection._statsBySource.ContainsKey(stats.SourceFile))
                    {
                        collection._statsBySource.Add(stats.SourceFile, stats);
                    }
                }
            }
            catch // (Exception ex)
            {
                // Assume the file didn't exist or was incorrectly
                // formatted... either way we start from fresh data.
                collection.Reset();
            }

            return(collection);
        }
Beispiel #3
0
        public static PricatEnvelop Parse(String line)
        {
            var result = new PricatEnvelop();
            var values = SplitRegex
                         .Split(line)
                         .Select(value => value.Trim('\"'))
                         .ToArray();

            if (values.Length != 5)
            {
                return(null);
            }

            result.Sender         = values[1];
            result.Receiver       = values[2];
            result.Reference      = values[3];
            result.TestIndication = values[4] == "1";

            return(result);
        }
Beispiel #4
0
        public static PricatHeader Parse(String line)
        {
            var result = new PricatHeader();
            var values = SplitRegex
                         .Split(line)
                         .Select(value => value.Trim('\"'))
                         .ToArray();

            if (values.Length != 9)
            {
                return(null);
            }

            result.MessageNumber = values[2];
            result.MessageDate   = values[3];
            result.SupplierType  = values[4];
            result.Supplier      = values[5];
            result.BuyerType     = values[6];
            result.Buyer         = values[7];
            result.Currency      = values[8];

            return(result);
        }
Beispiel #5
0
        private IList <string> SplitConsoleOutput(string errorMessage)
        {
            MatchCollection matches = SplitRegex.Matches(errorMessage);

            if (matches.Count == 0)
            {
                return(new List <string>());
            }

            var errorMessages = new List <string>();
            int startIndex, length;

            for (int i = 0; i < matches.Count - 1; i++)
            {
                startIndex = matches[i].Index;
                length     = matches[i + 1].Index - startIndex;
                errorMessages.Add(errorMessage.Substring(startIndex, length));
            }
            startIndex = matches[matches.Count - 1].Index;
            length     = errorMessage.Length - startIndex;
            errorMessages.Add(errorMessage.Substring(startIndex, length));

            return(errorMessages);
        }