Пример #1
0
        public static List <DaySales> PrepareSalesData(string[] lines)
        {
            List <DaySales> DaySalesList = new List <DaySales>();
            //string[] lines = { "" };
            int lineNum = 1;

            foreach (string line in lines)
            {
                line.Trim();
                if (lineNum == 1)
                {
                    int camLength = Convert.ToInt32(line.Trim());
                    if (!SalesCampaign.CampaignLengthCheck(camLength))
                    {
                        Console.WriteLine("Campaign lenght not valid");
                        //throw new System.FormatException();
                    }
                    ;

                    if (Convert.ToInt32(line.Trim()) != lines.Length - 1)

                    {
                        Console.WriteLine("Corrupt input in sales data : {0}", lines);
                        //throw new System.FormatException();
                        //return null;
                    }
                    ++lineNum;
                    continue;
                }
                var SalesSplit = line.Trim().Split(new char[0]);

                SalesSplit = SalesSplit.Skip(1).ToArray();
                var daySale = new DaySales();
                foreach (var sale in SalesSplit)
                {
                    daySale.Orders.AddRange(sale.Split(',').Select(Int32.Parse).ToList());
                    if (daySale.Orders.Where(t => t <= 1000000).Count() == 0)
                    {
                        Console.WriteLine("Corrupt input in sales data as each sale should be below 1000000");
                    }
                    //throw new System.FormatException();//TODO check if the sales are below 1000000
                }
                DaySalesList.Add(daySale);
            }
            return(DaySalesList);
        }
        private void RunDayReport()
        {
            int userID = DailyReportUserChoiceIndex == 0 ? -1 : _users[DailyReportUserChoiceIndex - 1].ID;

            CurrentDaySalesReport = DaySales.GenerateDataForSingleDay(SelectedDailyReportDate, userID);
        }