Ejemplo n.º 1
0
        private static bool SaveRecomment(Blog blog, string coverImgUrl)
        {
            if (coverImgUrl == "")
            {
                return(true);
            }
            string fileName = CrawlerUtility.GetFileContent(coverImgUrl, Const.CoverFileDirectory, "http://www.zimuzu.tv/");

            if (string.IsNullOrEmpty(fileName))
            {
                return(true);
            }
            string localFilePath = Const.CoverFileDirectory + fileName;
            var    image         = Domain.Helper.ImgHandler.ZoomPicture(Image.FromFile(localFilePath), 200, 110);

            image.Save(localFilePath);
            string yunUrl = UploadUtility.UploadLocalFile(localFilePath);

            Console.WriteLine("localFile:{0} upload to yunUrl:{1}", localFilePath, yunUrl);
            var recomment = new Recomment()
            {
                BlogId    = blog.Id,
                CoverName = fileName,
                Title     = blog.Title,
                TimeStamp = DateTime.Now,
                Category  = SetCategoryByTitle(blog.Title)
            };

            if (!string.IsNullOrEmpty(yunUrl))
            {
                recomment.YunUrl      = yunUrl;
                recomment.ImageStatus = ImageStatus.Yun;
            }
            return(SyncUtility.SyncRecomment(recomment));
        }
Ejemplo n.º 2
0
            private static bool SaveRecomment(Blog blog, string imageUrl, string category)
            {
                if (imageUrl == "")
                {
                    return(true);
                }
                string fileName = CrawlerUtility.GetFileContent(imageUrl, Const.CoverFileDirectory, "http://www.ed2kers.com/");

                if (string.IsNullOrEmpty(fileName))
                {
                    fileName = imageUrl;
                }
                string localFilePath = Const.CoverFileDirectory + fileName;

                string yunUrl = "";

                //UploadUtility.UploadLocalFile(localFilePath);
                Info("localFile:{0} upload to yunUrl:{1}", localFilePath, yunUrl);
                var recomment = new Recomment()
                {
                    BlogId    = blog.Id,
                    CoverName = fileName,
                    Title     = blog.Title,
                    TimeStamp = DateTime.Now,
                    Category  = SetCategory(category)
                };

                if (!string.IsNullOrEmpty(yunUrl))
                {
                    recomment.YunUrl      = yunUrl;
                    recomment.ImageStatus = ImageStatus.Yun;
                }
                return(SyncUtility.SyncRecomment(recomment));
            }
Ejemplo n.º 3
0
 private static bool SaveBlog(Blog blog, List <Link> linkList)
 {
     blog.HtmlContent = "<html><body>" + blog.HtmlContent + "</body></html>";
     blog.Id          = SyncUtility.SyncBlog(blog);
     if (blog.Id == 0)
     {
         return(false);
     }
     return(SyncUtility.SyncLinks(blog.Id, linkList));
 }
Ejemplo n.º 4
0
        private static bool SaveRecomment(Blog blog, string imageUrl, string category)
        {
            if (imageUrl == "")
            {
                return(true);
            }
            string fileName = CrawlerUtility.GetFileContent(imageUrl, Const.CoverFileDirectory, "http://www.mp4ba.com/");

            if (fileName == "")
            {
                return(true);
            }

            var recomment = new Recomment()
            {
                BlogId    = blog.Id,
                Title     = blog.Title,
                CoverName = fileName,
                TimeStamp = DateTime.Now
            };

            if (category.Contains("电影"))
            {
                recomment.Category = RecommentCategory.电影;
            }
            if (category.Contains("电视剧"))
            {
                recomment.Category = RecommentCategory.剧集;
            }
            if (category == "欧美电视剧")
            {
                recomment.Category = RecommentCategory.美剧;
            }
            if (category == "日韩电视剧")
            {
                recomment.Category = RecommentCategory.韩剧;
            }
            if (category == "综艺娱乐")
            {
                recomment.Category = RecommentCategory.综艺;
            }
            string localFilePath = Const.CoverFileDirectory + fileName;
            var    image         = Domain.Helper.ImgHandler.ZoomPicture(Image.FromFile(localFilePath), 200, 110);

            image.Save(localFilePath);
            string yunUrl = UploadUtility.UploadLocalFile(localFilePath);

            Console.WriteLine("localFile:{0} upload to yunUrl:{1}", localFilePath, yunUrl);
            if (!string.IsNullOrEmpty(yunUrl))
            {
                recomment.YunUrl      = yunUrl;
                recomment.ImageStatus = ImageStatus.Yun;
            }
            return(SyncUtility.SyncRecomment(recomment));
        }
Ejemplo n.º 5
0
        private static bool AppendBlogLinks(string resourceId, int blogId)
        {
            string      linkUrl  = "http://www.zimuzu.tv/resource/list/" + resourceId;
            List <Link> linkList = GetBlogLink(linkUrl);

            if (linkList.Count == 0)
            {
                return(true);
            }
            return(SyncUtility.SyncLinks(blogId, linkList));
        }
Ejemplo n.º 6
0
 private static bool SaveBlog(Blog blog, Link link)
 {
     blog.HtmlContent = "<html><body>" + blog.HtmlContent + "</body></html>";
     blog.Id          = SyncUtility.SyncBlog(blog);
     if (blog.Id == 0)
     {
         return(false);
     }
     SyncUtility.SyncLinks(blog.Id, new List <Link> {
         link
     });
     return(true);
 }
Ejemplo n.º 7
0
        private static bool AppendBlogLinks(string resourceId, int blogId)
        {
            string linkUrl  = string.Format("http://www.ed2000.com/ShowFile-{0}.html", resourceId);
            string coverUrl = "";
            var    linkList = GetIntroDetail(linkUrl, new Blog()
            {
                Id = blogId
            }, out coverUrl);

            if (linkList.Count == 0)
            {
                return(true);
            }
            return(SyncUtility.SyncLinks(blogId, linkList));
        }
Ejemplo n.º 8
0
 private static bool SaveBlog(Blog blog, ImageUrl imageUrl, List <Link> linkList)
 {
     blog.HtmlContent = "<html><body><p>" + blog.Content + "</p></body></html>";
     blog.Id          = SyncUtility.SyncBlog(blog);
     if (blog.Id == 0)
     {
         return(false);
     }
     SyncUtility.SyncLinks(blog.Id, linkList);
     if (imageUrl != null)
     {
         imageUrl.BlogId = blog.Id;
         SyncUtility.SyncImageUrl(imageUrl);
     }
     return(true);
 }
Ejemplo n.º 9
0
        private static bool SaveRecomment(Blog blog, string imageUrl, string category)
        {
            if (imageUrl == "http://verycd.gdajie.com/img/default_cover.jpg" || imageUrl == "")
            {
                return(true);
            }
            string fileName = CrawlerUtility.GetFileContent(imageUrl, Const.CoverFileDirectory, "http://www.gdajie.com/");

            if (string.IsNullOrEmpty(fileName))
            {
                return(true);
            }
            string localFilePath = Const.CoverFileDirectory + fileName;

            try
            {
                using (var localImage = Image.FromFile(localFilePath))
                {
                    var image = ImgHandler.ZoomPicture(localImage, 200, 110);
                    image.Save(localFilePath);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "localFilePath:{0}", localFilePath);
                return(true);
            }

            string yunUrl = UploadUtility.UploadLocalFile(localFilePath);

            Info("localFile:{0} upload to yunUrl:{1}", localFilePath, yunUrl);
            var recomment = new Recomment()
            {
                BlogId    = blog.Id,
                CoverName = fileName,
                Title     = blog.Title,
                TimeStamp = DateTime.Now,
                Category  = SetCategory(category)
            };

            if (!string.IsNullOrEmpty(yunUrl))
            {
                recomment.YunUrl      = yunUrl;
                recomment.ImageStatus = ImageStatus.Yun;
            }
            return(SyncUtility.SyncRecomment(recomment));
        }
Ejemplo n.º 10
0
        private static bool SaveRecomment(Blog blog, string imageUrl, string category)
        {
            if (imageUrl == "http://verycd.gdajie.com/img/default_cover.jpg" || imageUrl == "")
            {
                return(true);
            }
            string fileName = CrawlerUtility.GetFileContent(imageUrl, Const.CoverFileDirectory, "http://www.gdajie.com/");

            if (string.IsNullOrEmpty(fileName))
            {
                return(true);
            }
            string localFilePath = Const.CoverFileDirectory + fileName;
            var    image         = Domain.Helper.ImgHandler.ZoomPicture(Image.FromFile(localFilePath), 200, 110);

            image.Save(localFilePath);
            string yunUrl = UploadUtility.UploadLocalFile(localFilePath);

            Console.WriteLine("localFile:{0} upload to yunUrl:{1}", localFilePath, yunUrl);
            var recomment = new Recomment()
            {
                BlogId    = blog.Id,
                CoverName = fileName,
                Title     = blog.Title,
                TimeStamp = DateTime.Now,
                Category  = SetCategory(category)
            };

            if (!string.IsNullOrEmpty(yunUrl))
            {
                recomment.YunUrl      = yunUrl;
                recomment.ImageStatus = ImageStatus.Yun;
            }
            return(SyncUtility.SyncRecomment(recomment));
            //Context.Set<Recomment>().Add(recomment);
            //Context.SaveChanges();
        }
Ejemplo n.º 11
0
 private static bool SaveBlog(Blog blog, List <Link> linkList)
 {
     blog.HtmlContent = "<html><body>" + blog.HtmlContent + "</body></html>";
     //blog.UserId = 1;
     //blog.UserName = "******";
     //blog.TimeStamp=DateTime.Now;
     //blog.Status=BlogStatus.Publish;
     blog.Id = SyncUtility.SyncBlog(blog);
     if (blog.Id == 0)
     {
         return(false);
     }
     return(SyncUtility.SyncLinks(blog.Id, linkList));
     //Context.Set<Blog>().Add(blog);
     //Context.SaveChanges();
     //SearchService.AddBlog(blog);
     //foreach (var link in linkList)
     //{
     //    link.BlogId = blog.Id;
     //    link.TimeStamp = DateTime.Now;
     //    Context.Set<Link>().Add(link);
     //}
     //Context.SaveChanges();
 }
Ejemplo n.º 12
0
        private void UpdateServiceProcess()
        {
            while (true)
            {
                try
                {
                    var blogImageList  = ImageUrlDao.GetToUploadList();
                    int blogImageCount = blogImageList.Count;
                    MessageLog("updating blogImageCount:" + blogImageCount);
                    int successCount = 0;
                    foreach (ImageUrl image in blogImageList)
                    {
                        string localPath = Const.BlogFileDirectory + image.Url;
                        string yunUrl    = UploadUtility.UploadLocalFile(localPath);
                        if (yunUrl == "")
                        {
                            Thread.Sleep(5 * 60 * 1000);
                            continue;
                        }
                        image.YunUrl      = yunUrl;
                        image.ImageStatus = ImageStatus.Yun;
                        if (SyncUtility.SyncImageUrl(image))
                        {
                            MessageLog("sync success,localPath:{0} uploaded yunUrl:{1}", localPath, yunUrl);
                            ImageUrlDao.DeleteRecord(image.Id);
                            successCount++;
                        }
                        else
                        {
                            MessageLog("sync fail,localPath:{0} uploaded yunUrl:{1}", localPath, yunUrl);
                        }
                        Thread.Sleep(15 * 1000);
                    }
                    MessageLog("updated blogImageCount:" + successCount);

                    var coverImageList  = RecommentDao.GetToUploadList();
                    int coverImageCount = coverImageList.Count;
                    MessageLog("updating coverImageCount:" + coverImageCount);
                    successCount = 0;
                    foreach (Recomment image in coverImageList)
                    {
                        if (image.CoverName.Trim().StartsWith("http"))
                        {
                            image.CoverName = CrawlerUtility.GetFileContent(image.CoverName.Trim(),
                                                                            Const.CoverFileDirectory, "");
                            if (string.IsNullOrEmpty(image.CoverName))
                            {
                                continue;
                            }
                        }
                        string localPath = Const.CoverFileDirectory + image.CoverName;
                        string yunUrl    = UploadUtility.UploadLocalFile(localPath);
                        if (yunUrl == "")
                        {
                            //Thread.Sleep(5 * 60 * 1000);
                            continue;
                        }
                        image.YunUrl      = yunUrl;
                        image.ImageStatus = ImageStatus.Yun;
                        if (SyncUtility.SyncRecomment(image))
                        {
                            MessageLog("sync success,localPath:{0} uploaded yunUrl:{1}", localPath, yunUrl);
                            RecommentDao.DeleteRecord(image.Id);
                            successCount++;
                        }
                        else
                        {
                            MessageLog("sync fail,localPath:{0} uploaded yunUrl:{1}", localPath, yunUrl);
                        }
                        Thread.Sleep(15 * 1000);
                    }
                    MessageLog("updated blogImageCount:" + successCount);
                    if (blogImageCount == 0 && coverImageCount == 0)
                    {
                        MessageLog("record empty,sleeping 10 minutes");
                        Thread.Sleep(10 * 60 * 1000);
                    }
                }
                catch (ThreadAbortException threadAbortException)
                {
                    Logger.Error(threadAbortException);
                    break;
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    Thread.Sleep(10 * 60 * 1000);
                }
            }
        }