Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
        public static String getCategoryContext(String category, CatConversionList conversionList)
        {
            ArrayList categoryList = conversionList.categories;

            for (int i = 0; i < categoryList.Count; i++)
            {
                ItemCategorie categoryCheck = (ItemCategorie)categoryList[i];
                if (category.Equals(categoryCheck.nomCategorie))
                {
                    if (categoryCheck.categorieContext.Equals(""))
                    {
                        return(getCategoryContext(categoryCheck.categorieParent, conversionList));
                    }
                    else
                    {
                        return(categoryCheck.categorieContext);
                    }
                }
            }
            return("N/A");
        }
Ejemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (comboBox2.Text.Equals("Nettoyage"))
            {
                if (comboBox1.Text.Equals("Sanmar"))
                {
                }
                else
                {
                    Excel productExcel  = new Excel(textBox1.Text, 1);
                    Excel disabledExcel = Excel.createAndUseFile(productExcel.getPath());
                    int   maxRow        = 1;
                    disabledExcel.writeBoldCell(0, 0, "Code");
                    disabledExcel.writeBoldCell(0, 1, "Status");
                    for (int i = 1; i < productExcel.getRowCount(); i++)
                    {
                        if (productExcel.readCell(i, 0).EndsWith("_"))
                        {
                            disabledExcel.writeCell(maxRow, 0, productExcel.readCell(i, 0));
                            disabledExcel.writeCell(maxRow, 1, "Disable");
                            maxRow++;
                        }
                    }
                    disabledExcel.save();
                    MessageBox.Show("Nettoyage complété!");
                }
            }
            else if (comboBox1.Text.Equals("Bankers"))
            {
                Excel bankersExcel = new Excel(textBox1.Text, 1);
                if (comboBox2.Text.Equals("Conversion"))
                {
                    Excel bankersExcelEn = new Excel(textBox2.Text, 1);
                    BankersConversion.convertBankers(bankersExcel, bankersExcelEn);
                    MessageBox.Show("Conversion terminée avec succès!");
                }
                else if (comboBox2.Text.Equals("Ajouter images"))
                {
                    BankersConversion.uploadPictures(bankersExcel);
                    MessageBox.Show("Les images ont été ajoutées avec succès!");
                }
                else if (comboBox2.Text.Equals("Categories"))
                {
                    CatConversionList catConversionList = new CatConversionList();
                    String            directory         = "C:\\Users\\Caroline\\Documents\\Database\\Bankers\\debug\\";
                    FTP.checkIfFilesExist(directory, "CatManquantes.txt");
                    StreamWriter file           = new StreamWriter(directory + "CatManquantes.txt", true);
                    ArrayList    categoriesList = new ArrayList();
                    int          maxRows        = bankersExcel.getRowCount();
                    for (int i = 1; i < maxRows; i++)
                    {
                        String[] categories = bankersExcel.readCell(i, 6).Split('|');
                        for (int j = 0; j < categories.Length; j++)
                        {
                            catConversionList.debugCategories(categories[j], file, categoriesList);
                        }
                    }
                    file.Close();
                    MessageBox.Show("Vérification terminée!");
                }
                else if (comboBox2.Text.Equals("Couleurs"))
                {
                    Excel attributeExcel = new Excel(textBox3.Text, 1);
                    DebcoConversion.addColors(bankersExcel, attributeExcel);
                    MessageBox.Show("Les couleurs ont été ajoutées avec succès!");
                }
                else if (comboBox2.Text.Equals("Merge"))
                {
                }
            }
            else if (comboBox1.Text.Equals("Debco"))
            {
                Excel debcoExcel = new Excel(textBox1.Text, 1);

                if (comboBox2.Text.Equals("Categories"))
                {
                    String            directory         = "C:\\Users\\Caroline\\Documents\\Database\\Debco\\debug\\";
                    CatConversionList catConversionList = new CatConversionList();
                    FTP.checkIfFilesExist(directory, "CatManquantes.txt");
                    StreamWriter file           = new StreamWriter(directory + "CatManquantes.txt", true);
                    ArrayList    categoriesList = new ArrayList();
                    int          maxRows        = debcoExcel.getRowCount();
                    for (int i = 1; i < maxRows; i++)
                    {
                        String categorie = debcoExcel.readCell(i, 104);
                        catConversionList.debugCategories(categorie, file, categoriesList);
                    }
                    file.Close();
                    MessageBox.Show("Vérification terminée!");
                }
                else if (comboBox2.Text.Equals("Conversion"))
                {
                    DebcoConversion.convertDebco(debcoExcel);
                    MessageBox.Show("Conversion terminée avec succès!");
                }
                else if (comboBox2.Text.Equals("Ajouter images"))
                {
                    DebcoConversion.uploadPictures(debcoExcel);
                    MessageBox.Show("Les images ont été ajoutées avec succès!");
                }
                else if (comboBox2.Text.Equals("Couleurs"))
                {
                    Excel attributeExcel = new Excel(textBox2.Text, 1);
                    DebcoConversion.addColors(debcoExcel, attributeExcel);
                    MessageBox.Show("Les couleurs ont été ajoutées avec succès!");
                }
            }
            else if (comboBox1.Text.Equals("Leeds et Bullet"))
            {
                if (comboBox2.Text.Equals("Conversion"))
                {
                    Console.WriteLine("Creating file");
                    XMLFile infoFile    = new XMLFile(textBox1.Text);
                    XMLFile pricesFile  = new XMLFile(textBox2.Text);
                    XMLFile imagesFiles = new XMLFile(textBox3.Text);
                    Console.WriteLine("Done");
                    PcnaConversion.convertPcna(infoFile, pricesFile, imagesFiles);
                    MessageBox.Show("Conversion complétée");
                }
                else if (comboBox2.Text.Equals("Ajouter images"))
                {
                    Excel sheet = new Excel(textBox1.Text, 1);
                    FTP.uploadFromConvertedExcel(sheet);
                    MessageBox.Show("Images mises en ligne!");
                }
                else if (comboBox2.Text.Equals("Couleurs"))
                {
                    Excel convertedSheet  = new Excel(textBox1.Text, 1);
                    Excel attributesSheet = new Excel(textBox2.Text, 1);
                    TasksWithConvertedExcel.ajouterCouleurs(convertedSheet, attributesSheet);
                    MessageBox.Show("Couleurs ajoutées!");
                }
            }
            else if (comboBox1.Text.Equals("Sanmar"))
            {
                if (comboBox2.Text.Equals("Conversion"))
                {
                    Excel sanmarExcel   = new Excel(textBox1.Text, 1);
                    Excel sanmarExcelFr = new Excel(textBox2.Text, 1);
                    SanmarConversion.convertSanmar(sanmarExcel, sanmarExcelFr, textBox3.Text);
                    MessageBox.Show("Conversion terminée");
                }
                else if (comboBox2.Text.Equals("Items manquants"))
                {
                    String itemFile = textBox1.Text;
                    String descFile = textBox2.Text;
                    SanmarConversion.checkItemsReallyThere(itemFile, descFile);
                    MessageBox.Show("Vérification terminée");
                }
                else if (comboBox2.Text.Equals("Ajouter images"))
                {
                    Excel sheet = new Excel(textBox1.Text, 1);
                    FTP.uploadFromConvertedExcel(sheet);
                    MessageBox.Show("Images mises en ligne!");
                }
                else if (comboBox2.Text.Equals("Couleurs"))
                {
                    Excel convertedSheet  = new Excel(textBox1.Text, 1);
                    Excel attributesSheet = new Excel(textBox2.Text, 1);
                    TasksWithConvertedExcel.ajouterCouleurs(convertedSheet, attributesSheet);
                    MessageBox.Show("Couleurs ajoutées!");
                }
            }
        }
Ejemplo n.º 5
0
        public static List <ProduitDB> readPcnaXML(XMLFile infoFile, XMLFile pricesFile, XMLFile imagesFile)
        {
            double            USDtoCAD          = 1.35;
            ArrayList         produits          = new ArrayList();
            CatConversionList catConversionList = new CatConversionList();
            XElement          xmlImage          = imagesFile.file.Element(imagesFile.ns + "MediaContents");
            XElement          xmlPrice          = pricesFile.file.Element(pricesFile.ns + "ItemPrices");
            XElement          xmlInfo           = infoFile.file.Element(infoFile.ns + "Items");
            var items = from el in xmlInfo.Elements(infoFile.ns + "Item")
                        select new
            {
                name     = (String)el.Element(infoFile.ns + "Description"),
                division = (String)el.Element(infoFile.ns + "Division"),
                apparel  = (Boolean)el.Element(infoFile.ns + "Flags").Element(infoFile.ns + "Apparel"),
                colors   = from prop in el.Element(infoFile.ns + "VariantProperties").Elements(infoFile.ns + "VariantProperty")
                           where (String)prop.Attribute("Type") == "AvailableColors"
                           select(String) prop.Attribute("Value"),
                description = (String)el.Element(infoFile.ns + "MarketingDescription"),
                code        = (String)el.Element(infoFile.ns + "Style"),
                skus        = from codes in el.Element(infoFile.ns + "Skus").Elements(infoFile.ns + "Sku")
                              select new
                {
                    sku       = (String)codes.Attribute("Number"),
                    color     = (String)codes.Element(infoFile.ns + "Color").Attribute("MarketColor"),
                    size      = (String)codes.Element(infoFile.ns + "Size"),
                    CANprices = (from item in xmlPrice.Elements(pricesFile.ns + "ItemPrice")
                                 where (String)item.Element(pricesFile.ns + "SKU") == (String)codes.Attribute("Number")
                                 select new
                    {
                        pricesQty = from price in item.Element(pricesFile.ns + "Prices").Elements(pricesFile.ns + "Price")
                                    where (String)price.Element(pricesFile.ns + "PriceType") == "Canadian"
                                    select new
                        {
                            price = (double)price.Element(pricesFile.ns + "PriceValue"),
                            qty = (int)price.Element(pricesFile.ns + "FromQty")
                        }
                    }),
                    USprices = (from item in xmlPrice.Elements(pricesFile.ns + "ItemPrice")
                                where (String)item.Element(pricesFile.ns + "SKU") == (String)codes.Attribute("Number")
                                select new
                    {
                        pricesQty = from price in item.Element(pricesFile.ns + "Prices").Elements(pricesFile.ns + "Price")
                                    where (String)price.Element(pricesFile.ns + "PriceType") == "Canadian"
                                    select new
                        {
                            price = (double)price.Element(pricesFile.ns + "PriceValue"),
                            qty = (int)price.Element(pricesFile.ns + "FromQty")
                        }
                    }),
                    imageURL = (from image in xmlImage.Elements(imagesFile.ns + "MediaContent")
                                where (String)image.Element(imagesFile.ns + "Sku") == (String)codes.Attribute("Number")
                                select new
                    {
                        sku = image.Element(imagesFile.ns + "Sku").Value,
                        url = (from img in image.Element(imagesFile.ns + "Media").Elements(imagesFile.ns + "Medium")
                               where img.Element(imagesFile.ns + "MediumSize").Value == "Large"
                               select new
                        {
                            size = img.Element(imagesFile.ns + "MediumSize").Value,
                            img = (String)img.Element(imagesFile.ns + "Url").Value
                        })
                    })
                },
                category = (String)el.Element(infoFile.ns + "Category"),
                giftSet  = (Boolean)el.Element(infoFile.ns + "Flags").Element(infoFile.ns + "GiftSet"),
                sizes    = (from sku in el.Element(infoFile.ns + "Skus").Elements(infoFile.ns + "Sku")
                            select sku.Element(infoFile.ns + "Size")).Distinct()
            };
            List <OutsideItem> pcnaItems = new List <OutsideItem>();

            foreach (var item in items)
            {
                Boolean  added    = false;
                PcnaItem pcnaItem = new PcnaItem();
                pcnaItem.code = item.code;
                List <String> codeStrings = item.skus.Cast <String>().ToList();
                pcnaItem.codes       = codeStrings.ToArray <String>();
                pcnaItem.division    = item.division;
                pcnaItem.description = item.description;
                pcnaItem.name        = item.name;
                pcnaItem.category    = item.category;
                pcnaItem.apparel     = item.apparel;
                pcnaItem.giftSet     = item.giftSet;
                pcnaItem.colors      = item.colors.Cast <String>().ToList();
                pcnaItem.sizes       = item.sizes.Cast <String>().ToList();
                pcnaItems.Add(pcnaItem);
            }
            Console.WriteLine("Fini d'écrire les objets");
            return(ConversionUtils.getProducts(pcnaItems));
        }