Beispiel #1
0
        public static void uploadFromConvertedExcel(Excel sheet)
        {
            FTP    ftpClient      = new FTP();
            String directory      = Path.GetDirectoryName(sheet.getPath());
            String imageDirectory = directory + "\\images\\";

            if (!Directory.Exists(imageDirectory))
            {
                Directory.CreateDirectory(imageDirectory);
                Console.WriteLine("Created " + imageDirectory);
            }
            FTP.checkIfFilesExist(imageDirectory + "Debug\\", "ImagesManquantes.txt");
            StreamWriter file     = new StreamWriter(imageDirectory + "\\Debug\\ImagesManquantes.txt", true);
            int          rowCount = sheet.getRowCount();
            ArrayList    items    = new ArrayList();

            for (int i = 1; i < rowCount; i++)
            {
                ProduitDB item = new ProduitDB();
                item.sku      = sheet.readCell(i, 0);
                item.imageURL = sheet.readCell(i, 28);
                ftpClient.downloadFile(item, imageDirectory, file);
                items.Add(item);
            }
            file.Close();
            Console.WriteLine("Terminé");
            ftpClient.setCredentials("MBMPromotion", "M8mProm071on#2019!");
            for (var i = 0; i < items.Count; i++)
            {
                ProduitDB item = (ProduitDB)items[i];
                ftpClient.uploadFile(item, imageDirectory);
            }
        }
Beispiel #2
0
        public ProduitDB getProduit()
        {
            ProduitDB produit = new ProduitDB();

            produit.productName = this.name;
            produit.sku         = this.code;
            produit.description = this.description;
            return(produit);
        }
        public static void uploadPictures(Excel sheet)
        {
            FTP    ftpClient      = new FTP();
            String directory      = Path.GetDirectoryName(sheet.getPath());
            String imageDirectory = directory + "\\images\\";

            if (!Directory.Exists(imageDirectory))
            {
                Directory.CreateDirectory(imageDirectory);
            }
            FTP.checkIfFilesExist(imageDirectory + "Debug\\", "ImagesManquantes.txt");
            StreamWriter file        = new StreamWriter(imageDirectory + "\\Debug\\ImagesManquantes.txt", true);
            int          rowCount    = sheet.getRowCount();
            ArrayList    bankerItems = new ArrayList();

            for (int i = 1; i < rowCount; i++)
            {
                BankersItem item = new BankersItem();
                item.sku          = sheet.readCell(i, 0);
                item.defaultImage = sheet.readCell(i, 8);
                item.colors       = sheet.readCell(i, 9).Split('|');
                bankerItems.Add(item);
            }
            ArrayList dbItems = new ArrayList();

            for (int i = 0; i < bankerItems.Count; i++)
            {
                BankersItem item = (BankersItem)bankerItems[i];
                if (item.colors.Length > 0)
                {
                    ProduitDB itemGroup = new ProduitDB();
                    itemGroup.sku      = item.sku + "_Group";
                    itemGroup.imageURL = item.defaultImage;
                    ftpClient.downloadFile(itemGroup, imageDirectory, file);
                    dbItems.Add(itemGroup);
                    for (int j = 0; j < item.colors.Length; j++)
                    {
                        ProduitDB itemDB = new ProduitDB();
                        itemDB.sku      = item.sku + "_" + item.colors[j];
                        itemDB.sku      = itemDB.sku.Replace("/", "_");
                        itemDB.sku      = itemDB.sku.Replace(" ", "_");
                        itemDB.sku      = itemDB.sku.Replace("\\", "_");
                        itemDB.imageURL = item.defaultImage;
                        ftpClient.downloadFile(itemDB, imageDirectory, file);
                        dbItems.Add(itemDB);
                    }
                }
            }
            file.Close();
            Console.WriteLine("Terminé");
            ftpClient.setCredentials("MBMPromotion", "M8mProm071on#2019!");
            for (var i = 0; i < dbItems.Count; i++)
            {
                ProduitDB item = (ProduitDB)dbItems[i];
                ftpClient.uploadFile(item, imageDirectory);
            }
        }
Beispiel #4
0
        public static void uploadPictures(Excel sheet)
        {
            FTP    ftpClient      = new FTP();
            String directory      = Path.GetDirectoryName(sheet.getPath());
            String imageDirectory = directory + "\\images\\Debug\\";

            FTP.checkIfFilesExist(imageDirectory, "ImagesManquantes.txt");
            StreamWriter file       = new StreamWriter(imageDirectory + "ImagesManquantes.txt", true);
            int          rowCount   = sheet.getRowCount();
            ArrayList    debcoItems = new ArrayList();

            for (int i = 1; i < rowCount; i++)
            {
                DebcoItem item = new DebcoItem();
                item.itemID   = sheet.readCell(i, 0);
                item.imageURL = sheet.readCell(i, 57);
                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) };
                debcoItems.Add(item);
            }
            ArrayList dbItems = new ArrayList();

            for (int i = 0; i < debcoItems.Count; i++)
            {
                DebcoItem item = (DebcoItem)debcoItems[i];
                if (item.colors.Length > 0)
                {
                    ProduitDB itemGroup = new ProduitDB();
                    itemGroup.sku      = item.itemID + "_Group";
                    itemGroup.imageURL = item.imageURL;
                    ftpClient.downloadFile(itemGroup, imageDirectory, file);
                    dbItems.Add(itemGroup);
                    for (int j = 0; j < item.colors.Length; j++)
                    {
                        if (!item.colors[j].Equals(""))
                        {
                            ProduitDB itemDB = new ProduitDB();
                            itemDB.sku      = item.itemID + "_" + item.colors[j];
                            itemDB.sku      = itemDB.sku.Replace("/", "_");
                            itemDB.sku      = itemDB.sku.Replace(" ", "_");
                            itemDB.sku      = itemDB.sku.Replace("\\", "_");
                            itemDB.imageURL = item.imageURL;
                            ftpClient.downloadFile(itemDB, imageDirectory, file);
                            dbItems.Add(itemDB);
                        }
                    }
                }
            }
            file.Close();
            Console.WriteLine("Terminé");
            ftpClient.setCredentials("MBMPromotion", "M8mProm071on#2019!");
            for (var i = 0; i < dbItems.Count; i++)
            {
                ProduitDB item = (ProduitDB)dbItems[i];
                ftpClient.uploadFile(item, imageDirectory);
            }
        }
Beispiel #5
0
        public void uploadFile(ProduitDB item, String directory)
        {
            String filePath = directory + item.sku + ".jpg";

            Console.WriteLine("Uploading from " + directory + item.sku + ".jpg");
            if (File.Exists(filePath))
            {
                client.UploadFile("ftp://www.mbmpromotion.com/PhotoImport/" + item.sku + ".jpg", filePath);
            }
        }
Beispiel #6
0
        public ProduitDB getProduit()
        {
            ProduitDB produit = new ProduitDB();

            produit.productName = this.name;
            produit.sku         = this.itemID;
            produit.description = this.description;
            produit.imageURL    = this.imageURL;
            return(produit);
        }
Beispiel #7
0
 public ProduitDB[] getChildProducts()
 {
     ProduitDB[] childProducts = new ProduitDB[this.colorSizes.Count];
     for (int i = 0; i < this.colorSizes.Count; i++)
     {
         ProduitDB produit = this.getProduit();
         produit.sku      = this.itemID + "_" + this.colorSizes[i].color + "_" + this.colorSizes[i].size;
         childProducts[i] = produit;
     }
     return(childProducts);
 }
Beispiel #8
0
 public void downloadFile(ProduitDB item, String directory, StreamWriter writer)
 {
     if (!item.imageURL.Equals(""))
     {
         client.DownloadFile(item.imageURL, directory + item.sku + ".jpg");
         Console.WriteLine("Downloading" + item.sku + "");
     }
     else
     {
         Console.WriteLine("Writing" + item.sku + "");
         writer.WriteLine(item.sku);
     }
 }
Beispiel #9
0
        public ProduitDB getProduit()
        {
            ProduitDB produit = new ProduitDB();

            produit.productName = this.nameEn;
            produit.sku         = this.itemID;
            produit.description = this.descriptionEn;
            produit.imageURL    = imageURL;
            for (int i = 0; i < this.quantities.Count; i++)
            {
                produit.priceSets.Add(new PriceSet(0, this.nameEn, (int)this.quantities[i], (double)this.prices[i]));
            }
            return(produit);
        }
Beispiel #10
0
 public ProduitDB[] getChildProducts()
 {
     ProduitDB[] childProducts = new ProduitDB[this.colors.Length];
     for (int i = 0; i < this.colors.Length; i++)
     {
         if (!this.colors[i].Equals(""))
         {
             ProduitDB produit = this.getProduit();
             produit.sku      = this.itemID + "_" + this.colors[i];
             produit.sku      = TextManager.setItemName(produit.sku);
             childProducts[i] = produit;
         }
     }
     return(childProducts);
 }
        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();
        }
        public static List <ProduitDB> getProducts(List <OutsideItem> outsideProducts)
        {
            List <ProduitDB> products = new List <ProduitDB>();

            for (int i = 0; i < outsideProducts.Count; i++)
            {
                ProduitDB parentProduct = outsideProducts[i].getProduit();
                products.Add(parentProduct);
                ProduitDB[] childrenProducts = outsideProducts[i].getChildProducts();
                foreach (ProduitDB produitDB in childrenProducts)
                {
                    products.Add(produitDB);
                }
            }
            return(products);
        }
Beispiel #14
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();
        }
Beispiel #15
0
        public ProduitDB[] getChildProducts()
        {
            List <ProduitDB> childProducts = new List <ProduitDB>();

            for (int i = 0; i < this.colors.Count; i++)
            {
                if (!this.colors[i].Equals(""))
                {
                    for (int j = 0; j < this.sizes.Count; j++)
                    {
                        ProduitDB produit = this.getProduit();
                        produit.sku = this.code + "_" + this.colors[i] + "_" + this.sizes[j];
                        childProducts.Add(produit);
                    }
                }
            }
            return(childProducts.ToArray <ProduitDB>());
        }
        public static void mergeFiles(Excel convertedSheet, Excel onlineSheet)
        {
            int convertedCount = convertedSheet.getRowCount();
            int onlineCount    = onlineSheet.getRowCount();
            List <ProduitDB> convertedProducts = new List <ProduitDB>();
            List <String>    productSkus       = new List <String>();

            for (int i = 1; i < convertedCount; i++)
            {
                ProduitDB produitDB = new ProduitDB();
                produitDB.productName = convertedSheet.readCell(i, 0);
                produitDB.sku         = convertedSheet.readCell(i, 1);
                productSkus.Add(produitDB.sku);
                produitDB.productType = convertedSheet.readCell(i, 2);
                produitDB.description = convertedSheet.readCell(i, 3);
                produitDB.setupPrice  = convertedSheet.readDoubleCell(i, 4);
                produitDB.priceSetId  = Int32.Parse(convertedSheet.readCell(i, 5));
                produitDB.active      = true;
                convertedProducts.Add(produitDB);
            }
            for (int i = 1; i < onlineCount; i++)
            {
            }
        }
        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();
        }