Ejemplo n.º 1
0
        private void ThreadProcessData(ImgLink img)
        {
            Console.WriteLine("Start Check: " + img.linkimg);
            var _bolService = new BOLService.BOLService();

            try
            {
                var req = (HttpWebRequest)HttpWebRequest.Create(img.linkimg);
                req.Method = "HEAD";
                using (var resp = req.GetResponse())
                {
                    if (!resp.ContentType.ToLower(CultureInfo.InvariantCulture).StartsWith("image/"))
                    {
                        Console.WriteLine("Invalid: " + img.linkimg);
                        _bolService.UpdateBadURL(img.ID, true);
                    }
                    else
                    {
                        _bolService.UpdateBadURL(img.ID, false);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                _bolService.UpdateBadURL(img.ID);
            }
            Console.WriteLine("End Check: " + img.linkimg);
        }
Ejemplo n.º 2
0
        public ActionResult MakeBadURL(int idImage)
        {
            var bolService = new BOLService.BOLService();

            bolService.UpdateBadURL(idImage);
            return(Json(true));
        }
Ejemplo n.º 3
0
        private static void ClearInvalidURLImage()
        {
            var _bolService = new BOLService.BOLService();
            var lstImgs     = _bolService.GetListImgForCheck(50);

            if (lstImgs.Count > 0)
            {
                foreach (ImgLink img in lstImgs)
                {
                    try
                    {
                        var req = (HttpWebRequest)HttpWebRequest.Create(img.linkimg);
                        req.Method = "HEAD";
                        using (var resp = req.GetResponse())
                        {
                            if (!resp.ContentType.ToLower(CultureInfo.InvariantCulture).StartsWith("image/"))
                            {
                                Console.WriteLine("Invalid: " + img.linkimg);
                            }
                            _bolService.UpdateStatus(img.ID);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error: " + ex.Message);
                        _bolService.UpdateBadURL(img.ID);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static void CheckValidImageURL()
        {
            var bolService  = new BOLService.BOLService();
            int totalRecord = bolService.TotalImages();
            int iCounter    = totalRecord / 1000;

            for (int i = 0; i <= iCounter; i++)
            {
                Console.WriteLine("Group: " + i);
                var lst = bolService.GetImgLinks(i, 1000);
                foreach (ImgLink link in lst)
                {
                    Console.WriteLine(link.linkimg);
                    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(link.linkimg);
                    request.Method = "HEAD";
                    try
                    {
                        request.GetResponse();
                        continue;
                    }
                    catch
                    {
                        bolService.UpdateBadURL(link.ID);
                    }
                }
            }
        }