Пример #1
0
        private List <string> newList()
        {
            List <string> newProduct = new List <string>();

            newProduct.Add("id");                                           //id
            newProduct.Add("Артикул *");                                    //артикул
            newProduct.Add("Название товара *");                            //название
            newProduct.Add("Стоимость товара *");                           //стоимость
            newProduct.Add("Стоимость со скидкой");                         //со скидкой
            newProduct.Add("Раздел товара *");                              //раздел товара
            newProduct.Add("Товар в наличии *");                            //в наличии
            newProduct.Add("Поставка под заказ *");                         //поставка
            newProduct.Add("Срок поставки (дни) *");                        //срок поставки
            newProduct.Add("Краткий текст");                                //краткий текст
            newProduct.Add("Текст полностью");                              //полностью текст
            newProduct.Add("Заголовок страницы (title)");                   //заголовок страницы
            newProduct.Add("Описание страницы (description)");              //описание
            newProduct.Add("Ключевые слова страницы (keywords)");           //ключевые слова
            newProduct.Add("ЧПУ страницы (slug)");                          //ЧПУ
            newProduct.Add("С этим товаром покупают");                      //с этим товаром покупают
            newProduct.Add("Рекламные метки");
            newProduct.Add("Показывать на сайте *");                        //показывать
            newProduct.Add("Удалить *");                                    //удалить
            files.fileWriterCSV(newProduct, "naSite");
            return(newProduct);
        }
Пример #2
0
        private void WriteTovarInCSV(string[] tovarDB)
        {
            string article  = tovarDB[0];
            string name     = tovarDB[1];
            string price    = tovarDB[2];
            string miniText = tovarDB[3];
            string fullText = tovarDB[4];
            string razdel   = tovarDB[5];

            string slug = chpu.vozvr(name);

            slug = nethouse.Remove(slug, 64);

            miniText = Replace(miniTextTemplate, name, article, miniText, "");
            fullText = Replace(fullTextTemplate, name, article, "", fullText);

            string titleText       = ReplaceSEO(titleTextTemplate, name, article);
            string descriptionText = ReplaceSEO(descriptionTextTemplate, name, article);
            string keywordsText    = ReplaceSEO(keywordsTextTemplate, name, article);

            titleText       = nethouse.Remove(titleText, 255);
            descriptionText = nethouse.Remove(descriptionText, 200);
            keywordsText    = nethouse.Remove(keywordsText, 100);

            newProduct = new List <string>();
            newProduct.Add("");                            //id
            newProduct.Add("\"" + article + "\"");         //артикул
            newProduct.Add("\"" + name + "\"");            //название
            newProduct.Add("\"" + price + "\"");           //стоимость
            newProduct.Add("\"" + "" + "\"");              //со скидкой
            newProduct.Add("\"" + razdel + "\"");          //раздел товара
            newProduct.Add("\"" + "100" + "\"");           //в наличии
            newProduct.Add("\"" + "0" + "\"");             //поставка
            newProduct.Add("\"" + "1" + "\"");             //срок поставки
            newProduct.Add("\"" + miniText + "\"");        //краткий текст
            newProduct.Add("\"" + fullText + "\"");        //полностью текст
            newProduct.Add("\"" + titleText + "\"");       //заголовок страницы
            newProduct.Add("\"" + descriptionText + "\""); //описание
            newProduct.Add("\"" + keywordsText + "\"");    //ключевые слова
            newProduct.Add("\"" + slug + "\"");            //ЧПУ
            newProduct.Add("");                            //с этим товаром покупают
            newProduct.Add("");                            //рекламные метки
            newProduct.Add("\"" + "1" + "\"");             //показывать
            newProduct.Add("\"" + "0" + "\"");             //удалить

            files.fileWriterCSV(newProduct, "naSite");
        }
Пример #3
0
        private void GetWriteInCSV(List <string> tovarJMC)
        {
            string article         = tovarJMC[0];
            string newArticle      = tovarJMC[1];
            string name            = tovarJMC[2];
            string price           = tovarJMC[3];
            string razdel          = tovarJMC[4];
            string miniDescription = tovarJMC[5];
            string slug            = tovarJMC[6];

            miniDescription = nethouse.ReplaceAmpersandsChar(miniDescription);
            name            = nethouse.ReplaceAmpersandsChar(name);
            miniDescription = miniDescription.Replace("\"", "");
            name            = name.Replace("\"", "");

            string minitext        = "<p>" + miniDescription + "</p>" + minitextTemplate;
            string fullText        = fullTextTemplate;
            string descriptionText = descriptionTextTemplate;
            string titleText       = titleTextTemplate;
            string keywordsText    = keywordsTextTemplate;

            titleText       = ReplaceSEO("title", titleText, name, article.Replace(";", " "), newArticle.Replace(";", " "));
            descriptionText = ReplaceSEO("description", descriptionText, name, article, newArticle);
            keywordsText    = ReplaceSEO("keywords", keywordsText, name, article, newArticle);

            minitext = Replace(minitext, name, article);
            minitext = minitext.Remove(minitext.LastIndexOf("<p>"));

            fullText = Replace(fullText, name, article);
            fullText = fullText.Remove(fullText.LastIndexOf("<p>"));

            newProduct = new List <string>();
            newProduct.Add("");                            //id
            newProduct.Add("\"" + newArticle + "\"");      //артикул
            newProduct.Add("\"" + name + "\"");            //название
            newProduct.Add("\"" + price + "\"");           //стоимость
            newProduct.Add("\"" + "" + "\"");              //со скидкой
            newProduct.Add("\"" + razdel + "\"");          //раздел товара
            newProduct.Add("\"" + "100" + "\"");           //в наличии
            newProduct.Add("\"" + "0" + "\"");             //поставка
            newProduct.Add("\"" + "1" + "\"");             //срок поставки
            newProduct.Add("\"" + minitext + "\"");        //краткий текст
            newProduct.Add("\"" + fullText + "\"");        //полностью текст
            newProduct.Add("\"" + titleText + "\"");       //заголовок страницы
            newProduct.Add("\"" + descriptionText + "\""); //описание
            newProduct.Add("\"" + keywordsText + "\"");    //ключевые слова
            newProduct.Add("\"" + slug + "\"");            //ЧПУ
            newProduct.Add("");                            //с этим товаром покупают
            newProduct.Add("");                            //рекламные метки
            newProduct.Add("\"" + "1" + "\"");             //показывать
            newProduct.Add("\"" + "0" + "\"");             //удалить

            files.fileWriterCSV(newProduct, "naSite");
        }
Пример #4
0
        private void WriteTovarInCSV(List <string> product)
        {
            string name                = product[0];
            string article             = product[1];
            string price               = product[2];
            string category            = product[3];
            string miniDescriptionText = product[4];
            string slug                = product[5];

            string miniText = minitextTemplate;
            string fullText = fullTextTemplate;

            miniText = ReplaceNameTovar(name, miniText);
            fullText = ReplaceNameTovar(name, fullText);

            miniText = miniDescriptionText + "<br >" + miniText;

            string titleText       = titleTextTemplate;
            string descriptionText = descriptionTextTemplate;
            string keywordsText    = keywordsTextTemplate;

            titleText       = ReplaceSEO(titleText, name, article);
            descriptionText = ReplaceSEO(descriptionText, name, article);
            keywordsText    = ReplaceSEO(keywordsText, name, article);

            if (name.Length > 255)
            {
                name = name.Remove(255);
            }
            if (article.Length > 128)
            {
                article = article.Remove(128);
            }

            if (titleText.Length > 255)
            {
                titleText = titleText.Remove(255);
                titleText = titleText.Remove(titleText.LastIndexOf(" "));
            }
            if (descriptionText.Length > 200)
            {
                descriptionText = descriptionText.Remove(200);
                descriptionText = descriptionText.Remove(descriptionText.LastIndexOf(" "));
            }
            if (keywordsText.Length > 100)
            {
                keywordsText = keywordsText.Remove(100);
                keywordsText = keywordsText.Remove(keywordsText.LastIndexOf(" "));
            }

            newProduct = new List <string>();
            newProduct.Add("");                                   //id
            newProduct.Add("\"" + article.Trim() + "\"");         //артикул
            newProduct.Add("\"" + name.Trim() + "\"");            //название
            newProduct.Add("\"" + price.Trim() + "\"");           //стоимость
            newProduct.Add("\"" + "" + "\"");                     //со скидкой
            newProduct.Add("\"" + category.Trim() + "\"");        //раздел товара
            newProduct.Add("\"" + "100" + "\"");                  //в наличии
            newProduct.Add("\"" + "0" + "\"");                    //поставка
            newProduct.Add("\"" + "1" + "\"");                    //срок поставки
            newProduct.Add("\"" + miniText.Trim() + "\"");        //краткий текст
            newProduct.Add("\"" + fullText.Trim() + "\"");        //полностью текст
            newProduct.Add("\"" + titleText.Trim() + "\"");       //заголовок страницы
            newProduct.Add("\"" + descriptionText.Trim() + "\""); //описание
            newProduct.Add("\"" + keywordsText.Trim() + "\"");    //ключевые слова
            newProduct.Add("\"" + slug.Trim() + "\"");            //ЧПУ
            newProduct.Add("");                                   //с этим товаром покупают
            newProduct.Add("");                                   //рекламные метки
            newProduct.Add("\"" + "1" + "\"");                    //показывать
            newProduct.Add("\"" + "0" + "\"");                    //удалить

            if (price != "0")
            {
                files.fileWriterCSV(newProduct, "naSite");
            }
        }
Пример #5
0
        private void CreateCSV(CookieDictionary cookie)
        {
            ControlsFormEnabledFalse();

            File.Delete("naSite.csv");
            List <string> newProduct = newList();

            razdelCSV = "";
            string miniRazdelCSV = "";

            int countTovars = 0;

            FileInfo       file2 = new FileInfo("Каталог.xlsx");
            ExcelPackage   p2    = new ExcelPackage(file2);
            ExcelWorksheet w2    = p2.Workbook.Worksheets[1];
            int            q2    = w2.Dimension.Rows;

            FileInfo       file = new FileInfo(fileUrls);
            ExcelPackage   p    = new ExcelPackage(file);
            ExcelWorksheet w    = p.Workbook.Worksheets[1];
            int            q    = w.Dimension.Rows;

            cookieWW = httprequest.webCookie("http://w-motors.ru/");
            for (int i = numberStart; q > i; i++)
            {
                if (w.Cells[i, 3].Value == null && w.Cells[i, 2].Value == null)
                {
                    i++;
                    razdelCSV = (string)w.Cells[i, 2].Value;
                    razdelCSV = razdelCSV.Trim();
                }
                else if (w.Cells[i, 3].Value == null)
                {
                    miniRazdelCSV = (string)w.Cells[i, 2].Value;
                    miniRazdelCSV = razdelCSV.Trim();
                }
                else
                {
                    if (razdelCSV == "Авто" || razdelCSV == "Боковой прицеп" || razdelCSV == "Велосипед ЗиП" || razdelCSV == "Бензопила, мотокоса" || razdelCSV == "Зимние виды товаров" || razdelCSV == "Охота, Рыбалка, Туризм" || razdelCSV == "Сварочное оборудование" || razdelCSV == "Станки деревообрабатывающие" || razdelCSV == "Прочие товары (автохимия, зарядники, инструмент, литература, масла, наклейки)" || razdelCSV == "Мототехника, Снегоходы, Прицепы, Мотоблоки" || razdelCSV == "Мотоодежда, экипировка" || razdelCSV == "Шлемы" || razdelCSV == "ЛАМПЫ" ||
                        razdelCSV == "1 ТЕХНИКА: Мотоциклы, Снегоходы, Прицепы, Мотоблоки, Снегоуборщики" ||
                        razdelCSV == "Бензо Генераторы, Мотопомпы, Компрессоры, Насосные станции" ||
                        razdelCSV == "Бензопила, мотокоса" ||
                        razdelCSV == "Велосипеды в сборе,  велоЗиП" ||
                        razdelCSV == "Зимние виды товаров" ||
                        razdelCSV == "Мотоодежда, экипировка" ||
                        razdelCSV == "Охота, Рыбалка, Туризм, Одежда, Обувь" ||
                        razdelCSV == "Сварочное оборудование" ||
                        razdelCSV == "Станки деревообрабатывающие")
                    {
                        continue;
                    }


                    string article = (string)w.Cells[i, 3].Value;
                    string name    = (string)w.Cells[i, 5].Value;
                    double price   = (double)w.Cells[i, 10].Value;
                    price   = Math.Round(price + (price * 0.05));
                    article = "WM_" + article;

                    for (int j = 2; q2 > j; j++)
                    {
                        string articlePriceB18 = "";
                        try
                        {
                            articlePriceB18 = (string)w2.Cells[j, 2].Value.ToString();
                        }
                        catch
                        {
                            continue;
                        }
                        if (articlePriceB18 == article)
                        {
                            double pricePriceB18 = (double)w2.Cells[j, 4].Value;
                            if (pricePriceB18 != price)
                            {
                                string id              = (string)w2.Cells[j, 1].Value.ToString();
                                string namePriceB18    = (string)w2.Cells[j, 3].Value.ToString();
                                string priceSales      = "";
                                string tovarsPriceB18  = "";
                                string reklamaPriceB18 = "";
                                try
                                {
                                    priceSales      = (string)w2.Cells[j, 5].Value.ToString();
                                    tovarsPriceB18  = (string)w2.Cells[j, 16].Value.ToString();
                                    reklamaPriceB18 = (string)w2.Cells[j, 2].Value.ToString();
                                }
                                catch
                                {
                                }
                                string razdelPriceB18      = (string)w2.Cells[j, 6].Value.ToString();
                                string nalichiePriceB18    = (string)w2.Cells[j, 7].Value.ToString();
                                string postavkaPriceB18    = (string)w2.Cells[j, 8].Value.ToString();
                                string srokPriceB18        = (string)w2.Cells[j, 9].Value.ToString();
                                string miniTextPriceB18    = (string)w2.Cells[j, 10].Value.ToString();
                                string fultextPriceB18     = (string)w2.Cells[j, 11].Value.ToString();
                                string titlePriceB18       = (string)w2.Cells[j, 12].Value.ToString();
                                string descriptionPriceB18 = (string)w2.Cells[j, 13].Value.ToString();
                                string keywordsPriceB18    = (string)w2.Cells[j, 14].Value.ToString();
                                string slugPriceB18        = (string)w2.Cells[j, 15].Value.ToString();

                                newProduct = new List <string>();
                                newProduct.Add("\"" + id + "\"");                                        //id
                                newProduct.Add("\"" + articlePriceB18 + "\"");                           //артикул
                                newProduct.Add("\"" + namePriceB18 + "\"");                              //название
                                newProduct.Add("\"" + price.ToString() + "\"");                          //стоимость
                                newProduct.Add("\"" + priceSales + "\"");                                //со скидкой
                                newProduct.Add("\"" + razdelPriceB18 + "\"");                            //раздел товара
                                newProduct.Add("\"" + "100" + "\"");                                     //в наличии
                                newProduct.Add("\"" + "0" + "\"");                                       //поставка
                                newProduct.Add("\"" + "1" + "\"");                                       //срок поставки
                                newProduct.Add("\"" + miniTextPriceB18.Replace("\"", "\"\"") + "\"");    //краткий текст
                                newProduct.Add("\"" + fultextPriceB18.Replace("\"", "\"\"") + "\"");     //полностью текст
                                newProduct.Add("\"" + titlePriceB18.Replace("\"", "\"\"") + "\"");       //заголовок страницы
                                newProduct.Add("\"" + descriptionPriceB18.Replace("\"", "\"\"") + "\""); //описание
                                newProduct.Add("\"" + keywordsPriceB18.Replace("\"", "\"\"") + "\"");    //ключевые слова
                                newProduct.Add("\"" + slugPriceB18 + "\"");                              //ЧПУ
                                newProduct.Add("\"" + tovarsPriceB18 + "\"");                            //с этим товаром покупают
                                newProduct.Add("\"" + reklamaPriceB18 + "\"");                           //рекламные метки
                                newProduct.Add("\"" + "1" + "\"");                                       //показывать
                                newProduct.Add("\"" + "0" + "\"");                                       //удалить
                                files.fileWriterCSV(newProduct, "naSite");
                            }
                        }
                    }


                    /*List<string> tovarWW = GetTovarWW(article, name, price);
                     *
                     * string resultSearch = SearchInBike18(tovarWW);
                     * if (resultSearch == null || resultSearch == "")
                     * {
                     *  //WriteTovarInCSV(tovarWW);
                     *  countTovars++;
                     * }
                     * else
                     * {
                     *  UpdatePrice(cookie, resultSearch, tovarWW);
                     *  //обновить цену
                     * }*/
                }

                /*if (countTovars == 40000)
                 * {
                 *  cookie = nethouse.CookieNethouse(tbLogin.Text, tbPasswords.Text);
                 *  UploadCSVInNethoise(cookie);
                 *  countTovars = 0;
                 *  File.Delete("naSite.csv");
                 *  newProduct = newList();
                 * }*/

                SaveNumberStart(i);
            }

            SaveNumberStart(9);

            cookie = nethouse.CookieNethouse(tbLogin.Text, tbPasswords.Text);
            UploadCSVInNethoise(cookie);

            ControlsFormEnabledTrue();
        }
Пример #6
0
        private void ActualSooters()
        {
            ControlsFormEnabledFalse();
            CookieContainer cookieNethouse = nethouse.CookieNethouse(tbLogin.Text, tbPassword.Text);

            if (cookieNethouse.Count == 1)
            {
                MessageBox.Show("Логин или пароль для сайта Nethouse введены не верно", "Ошибка логина/пароля");
                ControlsFormEnabledTrue();
                return;
            }
            tbHistory.Invoke(new Action(() => tbHistory.AppendText("Авторизация пройдена\n")));

            string otvAvtobest = webRequest.getRequestEncod("http://avtobest-moto.ru/?mc=sh&ct=2&ctype_moto=143&page=1");

            string          pagesStr = new Regex("(?<=Страницы:).*(?=</div>)").Match(otvAvtobest).ToString();
            MatchCollection pages    = new Regex("(?<=\">).*(?=</a>)").Matches(pagesStr);
            List <string>   avtobest = new List <string>();
            int             i        = -1;

            tbHistory.Invoke(new Action(() => tbHistory.AppendText("Получение товаров с сайта автобест\n")));
            do
            {
                i++;
                if (i != 0)
                {
                    otvAvtobest = webRequest.getRequestEncod("http://avtobest-moto.ru/?mc=sh&ct=2&ctype_moto=143&page=" + pages[i - 1].ToString());
                }

                MatchCollection tableAvtobestTovar = new Regex("(?<=<tr>)[\\w\\W]*?(?=</tr>)").Matches(otvAvtobest);
                foreach (Match s in tableAvtobestTovar)
                {
                    string str = s.ToString();
                    string art = new Regex("(?<=<td><span class=\"green\">).*?(?=</span>)").Match(str).ToString();
                    string url = new Regex("(?<=<td><a href=\").*(?=\">)").Match(str).ToString();
                    url = "http://avtobest-moto.ru" + url;
                    string price = new Regex("(?<=class=\"red\"><b>).*(?= руб.</b>)").Match(str).ToString();
                    price = price.Replace(" ", "");
                    avtobest.Add(art + ";" + url + ";" + price);
                }
            } while (pages.Count > i);
            tbHistory.Invoke(new Action(() => tbHistory.AppendText("Товары с автобест обработаны\n")));

            List <string> scooters = new List <string>();

            string          otv     = webRequest.getRequest("https://bike18.ru/products/category/skutery-iz-yaponii?page=all");
            MatchCollection product = new Regex("(?<=<a href=\").*(?=\"><div class=\"-relative item-image\")").Matches(otv);

            tbHistory.Invoke(new Action(() => tbHistory.AppendText("Получение товаров с сайта байк18\n")));
            for (int n = 0; product.Count > n; n++)
            {
                string        urlTovar    = product[n].ToString();
                List <string> listProduct = nethouse.GetProductList(cookieNethouse, urlTovar);
                string        article     = listProduct[6].ToString();
                string        priceB18    = listProduct[9].ToString();
                bool          b           = false;
                string        priceAB     = "";
                foreach (string str in avtobest)
                {
                    string[] s         = str.Split(';');
                    string   articleAB = s[0].ToString();
                    priceAB = s[2].ToString();

                    if (article.Contains(articleAB))
                    {
                        b = true;
                        break;
                    }

                    if (!b)
                    {
                        nethouse.DeleteProduct(cookieNethouse, urlTovar);
                        break;
                    }
                }

                if (b)
                {
                    scooters.Add(article);
                    if (priceAB != "" && priceAB != priceB18)
                    {
                        UpdatePriceBike18(cookieNethouse, priceAB, listProduct);
                    }
                }
            }

            tbHistory.Invoke(new Action(() => tbHistory.AppendText("Создание списка новых товаров\n")));

            foreach (string str in avtobest)
            {
                List <string> final     = new List <string>();
                string[]      s         = str.Split(';');
                string        articleAB = s[0].ToString();
                string        urlAB     = s[1].ToString();
                bool          b         = false;
                foreach (string strB18 in scooters)
                {
                    if (articleAB.Contains(strB18))
                    {
                        b = true;
                        break;
                    }
                }

                if (!b)
                {
                    final.Add(urlAB);
                    files.fileWriterCSV(final, "scooters");
                }
            }
            tbHistory.Invoke(new Action(() => tbHistory.AppendText("Файл с новыми товара находиться в папке с программой\n")));
            ControlsFormEnabledTrue();
        }