Esempio n. 1
0
        private void ParseLine(Products currentProduct, string line, DateTime asOf)
        {
            if (line.Length > 0)
            {
                var expression = new System.Text.RegularExpressions.Regex(@"\s\s+");
                var parts      = expression.Split(line.TrimEnd());
                if (parts[0].Length > 0 && parts.Length > 1)
                {
                    var b = new Models.Buyer();
                    b.Name = parts[0];

                    switch (currentProduct)
                    {
                    case Products.WinterWheat:
                        ParseColumn(b, parts[1], WINTER_WHEAT, "Ordinary", asOf);
                        ParseColumn(b, parts[2], WINTER_WHEAT, "11 pct", asOf);
                        ParseColumn(b, parts[3], WINTER_WHEAT, "12 pct", asOf);
                        ParseColumn(b, parts[4], WINTER_WHEAT, "13 pct", asOf);
                        break;

                    case Products.SpringWheat:
                        ParseColumn(b, parts[1], SPRING_WHEAT, "13 pct", asOf);
                        ParseColumn(b, parts[2], SPRING_WHEAT, "14 pct", asOf);
                        ParseColumn(b, parts[3], SPRING_WHEAT, "15 pct", asOf);
                        break;

                    case Products.DurumWheat:
                        ParseColumn(b, parts[1], DURUM_WHEAT, "13 pct", asOf);
                        ParseColumn(b, parts[2], "Barley", "Malt", asOf);
                        ParseColumn(b, parts[3], "Barley", "Feed", asOf);
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        private void ParseColumn(Models.Buyer buyer, string priceRange, string productName, string quality, DateTime asOf)
        {
            if (priceRange.TrimEnd() != "--" && priceRange.TrimEnd() != "nb" && priceRange.TrimEnd() != "na")
            {
                var p = new Models.Product();
                p.Name    = productName;
                p.Quality = quality;

                var price = new Models.Price();
                price.AsOf = asOf;

                if (priceRange.Contains("-"))
                {
                    var prices = priceRange.Split('-');
                    price.MinPrice = decimal.Parse(prices[0]);
                    price.MaxPrice = decimal.Parse(prices[1]);
                }
                else
                {
                    price.MinPrice = decimal.Parse(priceRange);
                    price.MaxPrice = decimal.Parse(priceRange);
                }
                var bp = new Models.BuyerProduct();
                bp.Id      = Guid.NewGuid().ToString();
                bp.Buyer   = buyer;
                bp.Product = p;
                bp.Price   = price;
                this.items.Add(bp);
            }
        }