Пример #1
0
        private static void ProcessLine(SupplierIdMapping supplier, string line, StreamWriter mysqlFile)
        {
            var items = line.Split(new[] { ',' });

            if (items.Count() != 5)
            {
                Logger.Log("Invalid item : " + line);
            }
            var newPrice       = NormalizeNewPrice(items[1]);
            var oldPrice       = NormalizeOldPrice(items[2]);
            var savePercentage = GetSavePercentage(items[1], items[2]);

            mysqlFile.WriteLine(pattern, (int)supplier, items[0], newPrice, oldPrice, savePercentage, items[3], items[4]);
        }
Пример #2
0
 public static bool ProcessData()
 {
     using (var mysqlFile = new StreamWriter("insert.sql"))
     {
         foreach (var file in Directory.EnumerateFiles(".", "*.csv"))
         {
             SupplierIdMapping supplier;
             if (!SupplierIdMapping.TryParse(Path.GetFileNameWithoutExtension(file), out supplier))
             {
                 Logger.Log("supplier not defined " + Path.GetFileNameWithoutExtension(file));
                 return(false);
             }
             foreach (var line in File.ReadAllLines(file))
             {
                 ProcessLine(supplier, line, mysqlFile);
             }
         }
     }
     return(true);
 }