Exemple #1
0
        // "Files/table.txt" -data -weightSum -costSum -withIndex -withTotalVolume
        // обычный запуск

        // "Files/table.txt" -data -weightSum -costSum -withIndex -withTotalVolume -withoutCost
        // чтоб проверить возможность убирать из отчёта некоторые столбцы

        // "Files/table.txt" -weightSum -costSum -withIndex -withTotalVolume
        // чтоб проверить вывод WARNING
        public static void Main(string[] args)
        {
//            var service = GetReportService(args);

//            var report = service.CreateReport();
            var extensionHandler = new ExtensionHandler(args);

            var report = extensionHandler.CreateReport();

            var reportBuilder = new ReportBuilder(report);

            reportBuilder.PrintReport();

            Console.WriteLine("");
            Console.WriteLine("Press enter...");
            Console.ReadLine();
        }
Exemple #2
0
        private static void PrintReport(Report report)
        {
            if (report.Config.WithData && report.Data != null && report.Data.Any())
            {
                var columnNames = new List <string> {
                    "Наименование", "Объём упаковки", "Масса упаковки", "Стоимость", "Количество"
                };
                var reportBuilder = new ReportBuilder(columnNames);

                if (report.Config.WithIndex)
                {
                    reportBuilder.AddColumn("№", 0);
                }
                if (report.Config.WithTotalVolume)
                {
                    reportBuilder.AddColumn("Суммарный объём", 6);
                }
                if (report.Config.WithTotalWeight)
                {
                    reportBuilder.AddColumn("Суммарный вес", 7);
                }

                Console.WriteLine(reportBuilder.GetHeaderRow());

                for (var i = 0; i < report.Data.Length; i++)
                {
                    var dataRow = report.Data[i];
                    Console.WriteLine(reportBuilder.GetRowTemplate(), i + 1, dataRow.Name, dataRow.Volume, dataRow.Weight, dataRow.Cost, dataRow.Count, dataRow.Volume * dataRow.Count, dataRow.Weight * dataRow.Count);
                }

                Console.WriteLine();
            }

            if (report.Rows != null && report.Rows.Any())
            {
                Console.WriteLine("Итого:");
                foreach (var reportRow in report.Rows)
                {
                    Console.WriteLine(string.Format("  {0,-20}\t{1}", reportRow.Name, reportRow.Value));
                }
            }
        }