Ejemplo n.º 1
0
        public void ExportAdv(Adv24au adv)
        {
            var ftpClient = new MyFtpClient("ftp://localhost/", "poolsar", "rolton");

            // выкладываем картинку
            var srcImagePath = adv.Product.GetImagePath();
            var fileInfo = new FileInfo(srcImagePath);
            string filePath = string.Format("localhost/prestashop/imgimport/{0}", fileInfo.Name);
            ftpClient.WriteFileBinary(filePath, fileInfo.FullName);
            adv.Image = "http://" + filePath;

            //  выкладываем csv

            var sb = new StringBuilder();
            //  sb.AppendLine("\"ID налога\";\"Фото\";\"Имя\";\"Категория\";\"Цена\";\"Количество\";");

            var csvString = CSVConstants.GetCsvString(adv);
            sb.AppendLine(csvString);

            csvString = sb.ToString();

            ftpClient.WriteFileText("localhost/prestashop/admin8706/import/20140325213015-imgimport2.csv", csvString);

            //  отправляем запрос на импорт
            string columnsBody = CSVConstants.GetCsvColumns();
            MakeRequests(columnsBody);

            WebStoreLib.WebStoreController.SetNumbersByIdsInReferences(adv);

            Context.Save();
        }
Ejemplo n.º 2
0
        public void ExportAdvs(Adv24au[] advs)
        {
            var exportCats = advs.Where(a => a.Category.Number == 0 || a.Category.Number == null).Select(a => a.Category).ToArray();

            ExportAdvCategory(exportCats);

            var ftpClient = new MyFtpClient("ftp://localhost/", "poolsar", "rolton");

            var withNewImages = advs.Where(a => a.PrepareExport().UpdateImages).ToList();

            foreach (var adv in withNewImages)
            {
                // выкладываем картинку
                var srcImagePath = adv.Product.GetImagePath();
                var fileInfo = new FileInfo(srcImagePath);
                string filePath = string.Format("localhost/prestashop/imgimport/{0}", fileInfo.Name);
                ftpClient.WriteFileBinary(filePath, fileInfo.FullName);
                adv.Image = "http://" + filePath;
            }

            //  выкладываем csv

            var sb = new StringBuilder();
            string csvString;
            foreach (var adv in advs)
            {
                csvString = CSVConstants.GetCsvString(adv);
                sb.AppendLine(csvString);
            }
            csvString = sb.ToString();

            ftpClient.WriteFileText("localhost/prestashop/admin8706/import/20140325213015-imgimport2.csv", csvString);

            //  отправляем запрос на импорт
            string columnsBody = CSVConstants.GetCsvColumns();
            MakeRequests(columnsBody);

            var newAdvs = advs.Where(a => a.Number == 0).ToArray();
            if (newAdvs.Any())
            {
                WebStoreLib.WebStoreController.SetNumbersByIdsInReferences(newAdvs);
            }

            Context.Save();
        }