Esempio n. 1
0
 public void PostUrl(ProductUrl urlProduct) //Post the URL into the PUrl_table
 {
     using (new TimeMeasure("PostProduct - URL"))
     {
         using (var _dbcontext = new DatabaseContext())
         {
             _dbcontext.ProductUrls.AddOrUpdate(urlProduct);
             _dbcontext.SaveChanges();
             //Debug.WriteLine("Added Url: " + urlProduct.Url);
         }
     }
 }
        public ActionResult IsCart(string productId, string returnUrl, string productName)
        {
            ProductUrl product = new ProductUrl
            {
                Product_ID   = productId,
                Product_Name = productName,
                Return_Url   = returnUrl
            };

            return(PartialView("../Product/ProductModal", product));
            //return View("../Product/ProductModal" , product);
        }
Esempio n. 3
0
        public bool Parse(XmlNode profileBodyNode)
        {
            bool result = false;

            if (profileBodyNode != null)
            {
                foreach (XmlNode childNode in profileBodyNode.ChildNodes)
                {
                    if (childNode.Name == "vendorName")
                    {
                        VendorName = childNode.InnerXml;
                    }
                    else if (childNode.Name == "deviceFamily")
                    {
                        if (!DeviceFamily.Parse(childNode))
                        {
                            result = false;
                            break;
                        }
                    }
                    else if (childNode.Name == "productFamily")
                    {
                        ProductFamily = childNode.InnerXml;
                    }
                    else if (childNode.Name == "productName")
                    {
                        ProductName = childNode.InnerXml;
                        result      = true;
                    }
                    else if (childNode.Name == "productText")
                    {
                        if (!ProductText.Parse(childNode))
                        {
                            result = false;
                            break;
                        }
                    }
                    else if (childNode.Name == "productUrl")
                    {
                        if (!ProductUrl.Parse(childNode))
                        {
                            result = false;
                            break;
                        }
                    }
                    else if (childNode.Name == "productPicture")
                    {
                        ProductPicture = childNode.InnerXml;
                    }
                    else if (childNode.Name == "orderNumber")
                    {
                        OrderNumber = childNode.InnerXml;
                    }
                    else if (childNode.Name == "version")
                    {
                        if (!DeviceVersion.Parse(childNode))
                        {
                            result = false;
                            break;
                        }
                    }
                }

                if (result)
                {
                    UpdateDeviceVersion();
                    UpdateProductName();
                    UpdateProductPicture();
                }
            }

            return(result);
        }
Esempio n. 4
0
        public static void checkUrls()
        {
            List <string> imageLinks = null;


            imageLinks = new List <string>(File.ReadAllLines(@"выгрузка.csv"));
            List <ProductUrl> productUrls = new List <ProductUrl>();

            foreach (string s in imageLinks)
            {
                ProductUrl newProductUrl = new ProductUrl(s.Split(';'));
                productUrls.Add(newProductUrl);
            }

            int           a         = 0;
            int           g         = 0;
            List <string> BADURL    = new List <string>();
            List <string> exMess    = new List <string>();
            List <string> tofile404 = new List <string>();

            foreach (ProductUrl current in productUrls)
            {
                g++;
                List <string> badUrls = new List <string>();
                foreach (string s in current.urls)
                {
                    a++;
                    if (!s.Contains("https"))
                    {
                        // logging(current.product+" BAD");
                        BADURL.Add(current.product + ";" + s);
                        continue;
                    }
                    WebRequest webRequest = HttpWebRequest.Create(s);
                    webRequest.Method = "HEAD";
                    try
                    {
                        using (WebResponse webResponse = webRequest.GetResponse())
                        {
                            //   logging("OK");
                        }
                    }
                    catch (WebException ex)
                    {
                        //logging(current.product+ " " +ex.Message);
                        exMess.Add(current.product + ";" + s + ";" + ex.Message);
                        badUrls.Add(s);
                    }
                    finally
                    {
                    }

                    if (a % 100 == 0)
                    {
                        File.AppendAllLines("Bad.txt", BADURL);
                        File.AppendAllLines("ex.txt", exMess);

                        BADURL.Clear();
                        exMess.Clear();
                    }
                }

                if (badUrls.Count != 0)
                {
                    string tofile = current.product + ";";

                    foreach (string url in badUrls)
                    {
                        tofile += url + ";";
                    }
                    tofile404.Add(tofile);
                }

                //  if (g % 100 == 0)
                //{
                Console.Clear();
                decimal procente = Convert.ToDecimal(g) / Convert.ToDecimal(productUrls.Count);
                procente = 100 * procente;
                Console.WriteLine(g.ToString() + "/" + productUrls.Count + "  " + Math.Round(procente, 4).ToString() + " %");
                //  File.WriteAllText("D:/progress.txt", g.ToString() + "/" + productUrls.Count + "  " + procente.ToString() + " %" + Environment.NewLine);
                // }
            }
            File.WriteAllLines("404.txt", tofile404);
        }