Exemplo n.º 1
0
        public JsonResult GenerationToCSV()
        {
            Stopwatch sw = Stopwatch.StartNew();
            const int QtyMatchingVendors    = ((QtyVendors * VendorsСoincidence) / 100);
            const int QtyNotMatchingVendors = QtyVendors - QtyMatchingVendors;
            const int NewPriceProducts      = ((QtyVendors * ProductsFromOneVendor) * ProductsWithNewPrice / 100);

            List <CsvModel> MatchingVendorsWithProducts    = gen.GenerateVendorsAndProductsCSV(QtyMatchingVendors, ProductsFromOneVendor);
            List <CsvModel> NotMatchingVendorsWithProducts = gen.GenerateVendorsAndProductsCSV(QtyNotMatchingVendors, ProductsFromOneVendor, false);
            List <CsvModel> VendorsToCSV = MatchingVendorsWithProducts.Concat(NotMatchingVendorsWithProducts).ToList();

            // Забиваем новые цены, тестовое значение 555
            for (int i = 0; i < NewPriceProducts; i++)
            {
                VendorsToCSV[i].Price = 555;
            }

            string Path     = env.WebRootPath;
            string fileName = string.Format("{0}\\test.csv", Path + "\\CsvFiles\\");

            CsvWriter.Write(VendorsToCSV, fileName, false);

            sw.Stop();
            return(Json(sw.Elapsed.ToString()));
        }