예제 #1
0
        public static void convertPcna(XMLFile infoFile, XMLFile pricesFile, XMLFile imagesFile)
        {
            List <ProduitDB> produits   = XMLFile.readPcnaXML(infoFile, pricesFile, imagesFile);
            Excel            excelFinal = Excel.createAndUseFile(pricesFile.getPath().Replace(".xml", ".xlsx"));

            ProduitDB.writeDBHeader(excelFinal);
            Console.WriteLine("Finished creating items");
            for (int i = 0; i < produits.Count; i++)
            {
                ProduitDB produit = (ProduitDB)produits[i];
                ProduitDB.writeDBItem(excelFinal, i + 1, produit);
            }
            excelFinal.save();
            //XMLFile.writeFile(imagesFile);
        }
        public static void convertBankers(Excel sheet, Excel sheetEn)
        {
            int rowCount       = sheet.getRowCount();
            int firstSheetCols = sheet.getColumnCount();

            sheet.changeSheet(2);
            int secondSheetCols               = sheet.getColumnCount();
            List <OutsideItem> bankerItems    = new List <OutsideItem>();
            CatConversionList  categoriesList = new CatConversionList();

            for (int i = 1; i < rowCount; i++)
            {
                BankersItem item = new BankersItem();
                sheet.changeSheet(1);
                item.sku            = sheet.readCell(i, 0);
                item.productName    = sheet.readCell(i, 2);
                item.productNameEn  = sheetEn.readCell(i, 2);
                item.description    = sheet.readCell(i, 3);
                item.descriptionEn  = sheetEn.readCell(i, 3);
                item.lineName       = sheet.readCell(i, 4);
                item.categories     = sheet.readCell(i, 6).Split('|');
                item.searchKeywords = sheet.readCell(i, 7).Split('|');
                item.defaultImage   = sheet.readCell(i, 8);
                item.colors         = sheet.readCell(i, 9).Split('|');
                item.size           = sheet.readCell(i, 10);
                sheet.changeSheet(2);
                int index = 5;
                while (!sheet.readCell(i, index).Equals("") && index < sheet.getColumnCount())
                {
                    int    quantity = Int32.Parse(sheet.readDoubleCell(i, index) + "");
                    Double price    = Double.Parse(sheet.readDoubleCell(i, index + 1) + "");
                    item.quantities.Add(quantity);
                    item.prices.Add(price);
                    index += 3;
                }
                bankerItems.Add(item);
            }
            List <ProduitDB> dbItems = ConversionUtils.getProducts(bankerItems);
            Excel            output  = Excel.createAndUseFile(sheet.getPath());

            ProduitDB.writeDBHeader(output);
            for (var i = 0; i < dbItems.Count; i++)
            {
                ProduitDB item = (ProduitDB)dbItems[i];
                ProduitDB.writeDBItem(output, (i + 1), item);
            }
            output.save();
        }
예제 #3
0
        public static void convertDebco(Excel sheet)
        {
            int rowCount = sheet.getRowCount();
            int colCount = sheet.getColumnCount();
            List <OutsideItem> debcoItems     = new List <OutsideItem>();
            CatConversionList  categoriesList = new CatConversionList();

            for (int i = 1; i < rowCount; i++)
            {
                DebcoItem item = new DebcoItem();
                item.itemID = sheet.readCell(i, 0);
                Console.WriteLine(item.itemID);
                item.nameEn        = sheet.readCell(i, 1).ToLower();
                item.nameFr        = sheet.readCell(i, 2).ToLower();
                item.descriptionEn = sheet.readCell(i, 3);
                item.descriptionFr = sheet.readCell(i, 5);
                item.quantities    = new ArrayList();
                item.imageURL      = sheet.readCell(i, 57);
                item.prices        = new ArrayList();
                for (int j = 0; j < 5; j++)
                {
                    if (sheet.readCell(i, 8 + (2 * j)).Equals(""))
                    {
                        break;
                    }
                    int    quantity = Int32.Parse(sheet.readDoubleCell(i, 8 + (2 * j)) + "");
                    Double price    = Double.Parse(sheet.readDoubleCell(i, 9 + (2 * j)) + "");
                    item.quantities.Add(quantity);
                    item.prices.Add(price);
                }
                item.colors        = new String[] { sheet.readCell(i, 33), sheet.readCell(i, 34), sheet.readCell(i, 35), sheet.readCell(i, 36), sheet.readCell(i, 37), sheet.readCell(i, 38), sheet.readCell(i, 39), sheet.readCell(i, 40), sheet.readCell(i, 41), sheet.readCell(i, 42), sheet.readCell(i, 43), sheet.readCell(i, 44), sheet.readCell(i, 45), sheet.readCell(i, 46), sheet.readCell(i, 47) };
                item.category      = sheet.readCell(i, 104);
                item.majorCategory = sheet.readCell(i, 105);
                debcoItems.Add(item);
            }
            List <ProduitDB> dbItems = ConversionUtils.getProducts(debcoItems);
            Excel            output  = Excel.createAndUseFile(sheet.getPath());

            ProduitDB.writeDBHeader(output);
            for (int i = 0; i < dbItems.Count; i++)
            {
                ProduitDB item = (ProduitDB)dbItems[i];
                ProduitDB.writeDBItem(output, (i + 1), item);
            }
            output.save();
        }
예제 #4
0
        public static void convertSanmar(Excel sheet, Excel sheetFr, String descTextFile)
        {
            String[] descText  = System.IO.File.ReadAllLines(descTextFile);
            String   directory = Path.GetDirectoryName(sheet.getPath());

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
                Console.WriteLine("Created " + directory);
            }
            if (!File.Exists(directory + "/debug.txt"))
            {
                FileStream fs = File.Create(directory + "/debug.txt");
                fs.Close();
            }
            CatConversionList  catConversionList = new CatConversionList();
            List <OutsideItem> sanmarItems       = new List <OutsideItem>();
            ArrayList          sanmarItemsFr     = new ArrayList();
            ArrayList          sanmarDescFr      = loadDescriptionsFrItems(descText);
            String             itemId            = "";
            SanmarItem         item = new SanmarItem();

            for (int i = 1; i < sheet.getRowCount() + 1; i++)
            {
                if (itemId.Equals(sheet.readCell(i, 2)))
                {
                    item.colorSizes.Add(new ColorSize(sheet.readCell(i, 3), sheet.readCell(i, 4)));
                }
                else
                {
                    if (!itemId.Equals(""))
                    {
                        sanmarItems.Add(item);
                        item = new SanmarItem();
                    }
                    itemId      = sheet.readCell(i, 2);
                    item.itemID = itemId;
                    item.colorSizes.Add(new ColorSize(sheet.readCell(i, 3), sheet.readCell(i, 4)));
                    item.imageURL   = sheet.readCell(i, 11);
                    item.categories = sheet.readCell(i, 12).Split(new String[] { "; " }, StringSplitOptions.None);
                    item.name       = sheet.readCell(i, 13);
                    if (sheet.readCell(i, 16).Contains("Call For Pricing"))
                    {
                        item.price = getPrice(sheet.readCell(i, 2));
                    }
                    else
                    {
                        item.price = Math.Round(sheet.readDoubleCell(i, 17) / 0.46, 2);
                    }
                    item.description = sheet.readCell(i, 14).Replace("\n", "<br>") + "<br/><b><font style=\"font-size:20px\">Discounts on volume may be applicable.<br/><br/>Contact us for a price with an embroidery or a serigraphy.</b></font><br/>";
                }
            }
            for (int i = 0; i < sheetFr.getRowCount(); i++)
            {
                if (!sheetFr.readCell(i, 0).Equals(""))
                {
                    item        = new SanmarItem();
                    item.name   = sheetFr.readCell(i, 1);
                    item.itemID = sheetFr.readCell(i + 1, 1);
                    sanmarItemsFr.Add(item);
                }
            }
            List <ProduitDB> itemsDB = ConversionUtils.getProducts(sanmarItems);
            Excel            output  = Excel.createAndUseFile(sheet.getPath());

            ProduitDB.writeDBHeader(output);
            for (int i = 0; i < itemsDB.Count; i++)
            {
                ProduitDB.writeDBItem(output, (i + 1), (ProduitDB)itemsDB[i]);
            }
            output.save();
        }