コード例 #1
0
ファイル: SqlTests.cs プロジェクト: codyfinalfight/VN
 public void TestRead()
 {
     using (var ctx = new VNContext("VNConnectionString"))
     {
        var busties = ctx.Characters.Where(w => w.Sizes.Bust > 100).ToList();
        Assert.IsTrue(busties.Any());
     }
 }
コード例 #2
0
ファイル: VndbParser.cs プロジェクト: codyfinalfight/VN
        public void ProcessIndex(int index)
        {
            var novel = new Novel();
            HtmlWeb htmlWeb = new HtmlWeb();

            HtmlDocument htmlDocument = htmlWeb.Load(String.Format(MainUrlPattern, index));

            var mainboxes = htmlDocument.DocumentNode.Descendants("div").Where(w => w.HasClass("mainbox")).ToArray();

            var mainContent = mainboxes[0];
            ParseMainContent(mainContent, novel);

            var releasesNode = htmlDocument.DocumentNode.Descendants("div").FirstOrDefault(w => w.HasClass("releases"));
            if (releasesNode != null)
            {
                ParseReleasesContent(releasesNode, novel);
            }

            var screenshotsNode = htmlDocument.DocumentNode.Descendants("div").FirstOrDefault(w => w.HasId("screenshots"));
            if (screenshotsNode != null)
            {
                ParseImagesContent(screenshotsNode, novel);
            }
            //staff (extract artists)
            htmlDocument = htmlWeb.Load(String.Format(StaffPattern, index));
            var staffNode = htmlDocument.DocumentNode.Descendants("div").FirstOrDefault(w => w.HasClass("staff") && w.NotContainsClass("cast"));
            if (staffNode != null)
            {
                ParseStaffContent(staffNode, novel);
            }
            //characters
            htmlDocument = htmlWeb.Load(String.Format(CharacterPattern, index));
            mainboxes = htmlDocument.DocumentNode.Descendants("div").Where(w => w.HasClass("mainbox")).ToArray();
            if (mainboxes.Length > 1)
            {
                for (int i = 1; i < mainboxes.Length; i++)
                {
                    ParseCharactersContent(mainboxes[i], novel);
                }
            }

            using (var ctx = new VNContext("VNConnectionString"))
            {
                NovelManager.SaveNovel(novel, ctx);
                Logs.Debug($@"Novel {index} finished");
            }

            Console.WriteLine(index + @" finished");
        }
コード例 #3
0
ファイル: GetchuFromInfo.cs プロジェクト: codyfinalfight/VN
        public static void DoWork()
        {
            List<NovelInfo> novelInfos;

            using (var ctx=new VNCommonContext("VNCommonConnectionString"))
            {
                novelInfos = ctx.NovelInfos.Where(w => w.Getchu != null).ToList();
            }

            Assert.IsTrue(novelInfos.Any());

            var parser=new GetchuParser();
            int i = 0;
            foreach (var novelInfo in novelInfos)
            {
                i++;
                string url = null;
                try
                {
                    url = parser.ProvideUrl(novelInfo);
                    var novel = parser.ParsePage(url);
                    novel.JapName = novelInfo.JapName;
                    novel.Site = novelInfo.Site;
                    novel.Source=NovelSource.Getchu;
                    novel.SourceKey = novelInfo.Getchu;
                    using (var ctx = new VNContext("GetchuConnectionString"))
                    {
                        ctx.Novels.Add(novel);
                        ctx.SaveChanges();

                    }
                    System.Console.WriteLine(i +@" finished");
                }
                catch (Exception ex)
                {
                 Logs.Error(String.Format(GetchuParser.ErrorMessagePattern, url,""),ex);
                 System.Console.WriteLine(i + @" failed");
                }

            }
        }