Exemple #1
0
        public static void SaveNovel(Novel novel,VNContext ctx)
        {
            foreach (var company in novel.Companies)
            {
                var existingCompany =  ctx.Companies.FirstOrDefault(w =>(w.EngName!=null && String.Equals(w.EngName,company.EngName)) || (w.JapName != null && String.Equals(w.JapName, company.JapName)));
                if (existingCompany != null)
                {
                    ctx.Entry(existingCompany).State = EntityState.Detached;
                    company.Id = existingCompany.Id;
                    ctx.Entry(company).State = EntityState.Unchanged;
                }
            }

            foreach (var artist in novel.Artists)
            {
                var existingArtist = ctx.Artists.FirstOrDefault(w => (w.EngName != null && String.Equals(w.EngName, artist.EngName)) || (w.JapName != null && String.Equals(w.JapName, artist.JapName)));
                if (existingArtist != null)
                {
                    ctx.Entry(existingArtist).State = EntityState.Detached;
                    artist.Id = existingArtist.Id;
                    ctx.Entry(artist).State = EntityState.Unchanged;
                }
            }

            ctx.Novels.Add(novel);
            ctx.SaveChanges();
        }
Exemple #2
0
    public static void Main()
    {
        Novel nov = new Novel();
        nov.title = "시오리의 비경 발견";
        nov.genre = "판타지";
        nov.writer = "앤크";

        Magazine mag = new Magazine();
        mag.title = "월간 C# 그림책";
        mag.genre = "컴퓨터";
        mag.day = 20;

        nov.printNov();
        Console.WriteLine();
        mag.printMag();
    }
    IEnumerator LoadNovel( Novel novel )
    {
        novelPlace = 0;
        activeNovel = null;

        System.IO.StreamReader streamReader = new System.IO.StreamReader ( novel.location + Path.DirectorySeparatorChar + novel.name + ".xml" );
        string xml = streamReader.ReadToEnd();
        streamReader.Close();

        VisualNovel currentNovel = xml.DeserializeXml<VisualNovel>();
        novel.visualNovel = currentNovel;
        activeNovel = novel;

        int resourcesCount = 0;
        while ( resourcesCount < novel.visualNovel.resources.allResources.Length )
        {

            availableResources.Add ( novel.visualNovel.resources.allResources[resourcesCount].id, novel.visualNovel.resources.allResources[resourcesCount]);

            resourcesCount += 1;
        }

        if ( availableResources.ContainsKey ( "Background" ))
        {

            WWW backgroundWWW = new WWW ( "file://" + novel.location + Path.DirectorySeparatorChar + "Images" + Path.DirectorySeparatorChar + availableResources["Background"].location );
            yield return backgroundWWW;

            backgroundTexture = new Texture2D ( Screen.width, Screen.height );
            backgroundWWW.LoadImageIntoTexture ( backgroundTexture );
        }

        if ( availableResources.ContainsKey ( novel.visualNovel.playerStory.dialogue[0].speakerImage ))
        {

            WWW speakerWWW = new WWW ( "file://" + novel.location + Path.DirectorySeparatorChar + "Images" + Path.DirectorySeparatorChar + availableResources[novel.visualNovel.playerStory.dialogue[0].speakerImage].location );
            yield return speakerWWW;

            speakerTexture = new Texture2D ( Screen.width, Screen.height, TextureFormat.ARGB32, true );
            speakerWWW.LoadImageIntoTexture ( speakerTexture );
        }

        StartNovel ();
    }
Exemple #4
0
        public ActionResult Detail()
        {
            string hideUrl = "";

            if (ChapterContext.VerifyRedirect(NovelId, ChapterCode, ChapterDirection, out hideUrl, SiteSection.Chapter.IsRedirectWeChat))
            {
                return(Redirect(hideUrl));
            }

            SetReadMode();
            Novel novel = _bookService.GetNovel(NovelId);

            if (novel != null && novel.Id > 0)
            {
                InitializeChapterPager();

                Chapter chapter = _chapterService.GetChapter(NovelId, ChapterCode, ChapterDirection, out ChapterCode);
                if (chapter != null && chapter.Id > 0 && IsRead(_orderService))
                {
                    #region

                    bool   isPreChapterCode  = false;
                    bool   isNextChapterCode = false;
                    string url = GetChapterPager("/chapter/detail", ChapterCode, out isPreChapterCode, out isNextChapterCode);

                    #endregion

                    #region 推荐阅读

                    //推荐阅读 - 轮循广告
                    int adClassId           = RecSection.BookChapterDetail.Ad;
                    IEnumerable <AD> adList = GetADList(adClassId, novel.Id, 3);

                    #endregion

                    //阅读记录
                    ReadLog(currentUser.UserName, chapter.NovelId, chapter.Id, chapter.ChapterCode);

                    //最近阅读日志
                    RecentReadContext.Save(novel, chapter.ChapterName, ChapterCode, RouteChannelId, currentUser.UserId);

                    //是否收藏
                    bool isMark = _bookmarkService.Exists(NovelId, currentUser.UserName);

                    //漫画目录
                    IEnumerable <ExtendChapterView> extendChapterList = GetExtendChapterList(novel);

                    //千字价格
                    int chapterWordSizeFee = GetChapterWordSizeFee(novel.ChapterWordSizeFee);

                    //章节正文
                    string chapterContent = GetContent(novel.ContentType, chapter.ChapterName, novel.FilePath, chapter.FileName);

                    ChapterDetailView detailView = new ChapterDetailView()
                    {
                        Novel                    = new SimpleResponse <Novel>(true, novel),
                        Chapter                  = new SimpleResponse <Chapter>(true, chapter),
                        ChapterFee               = GetFee(chapter.WordSize, chapterWordSizeFee),
                        ChapterContent           = chapterContent,
                        IsPreChapterCode         = isPreChapterCode,
                        IsNextChapterCode        = isNextChapterCode,
                        PreChapterUrl            = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.pre, channelId: RouteChannelId),
                        NextChapterUrl           = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.next, channelId: RouteChannelId),
                        AdList                   = new SimpleResponse <IEnumerable <AD> >(!adList.IsNullOrEmpty <AD>(), adList),
                        IsMark                   = isMark,
                        ExtendChapterList        = new SimpleResponse <IEnumerable <ExtendChapterView> >(!extendChapterList.IsNullOrEmpty <ExtendChapterView>(), extendChapterList),
                        ChapterAudioUrl          = GetAudioUrl(novel.ContentType, chapter.FileName),
                        HitUrl                   = GetHitUrl(),
                        ShowQrCodeMinChapterCode = StringHelper.ToInt(UrlParameterHelper.GetParams("qrdx"))
                    };

                    if (novel.ContentType == (int)Constants.Novel.ContentType.漫画)
                    {
                        return(View("/views/cartoonchapter/detail.cshtml", detailView));
                    }
                    else if (novel.ContentType == (int)Constants.Novel.ContentType.听书)
                    {
                        return(View("/views/audiochapter/detail.cshtml", detailView));
                    }
                    else
                    {
                        return(View(detailView));
                    }
                }
                else
                {
                    if (novel.FeeType == (int)Constants.Novel.FeeType.chapter || novel.FeeType == (int)Constants.Novel.FeeType.novelchapter)
                    {
                        return(Redirect(ChapterContext.GetUrl("/preorder/chapter", NovelId, ChapterCode, channelId: RouteChannelId)));
                    }
                    else if (novel.FeeType == (int)Constants.Novel.FeeType.novel)
                    {
                        return(Redirect(ChapterContext.GetUrl("/preorder/novel", NovelId, ChapterCode, channelId: RouteChannelId)));
                    }
                }
            }

            return(Redirect(DataContext.GetErrorUrl(ErrorMessage.小说不存在, channelId: RouteChannelId)));
        }
        private void CheckUpdate(Novel novel)
        {
            if (Downloader == null)
            {
                Debug.Assert(false);
                return;
            }

            if (novel == null)
            {
                return;
            }

            string filePath = Config.NovelPath + novel.Name;

            if (!Directory.Exists(filePath))
            {
                novel.UpdateCount = novel.Episodes.Count;
                return;
            }

            var myDirectory = new DirectoryInfo(filePath);
            var files       = myDirectory.GetFiles("*.txt");

            if (novel.Episodes.Count == 0)
            {
                var Episodes = Downloader.DownloadList(novel);

                if (Episodes != null)
                {
                    novel.Episodes.Clear();
                    novel.Episodes.AddAll(Episodes);

                    App.Current?.Dispatcher?.InvokeAsync(() =>
                    {
                        novel.UIEpisodes.Clear();
                        novel.UIEpisodes.AddAll(novel.Episodes);
                    });
                }
            }

            novel.EpisodeStartIndex = 0;
            novel.EpisodeEndIndex   = novel.Episodes.Count - 1;

            if (novel.Episodes.Count == 0)
            {
                novel.UpdateCount = 0;
                return;
            }

            int lastNumber = novel.Episodes[novel.Episodes.Count - 1].Number;
            int max        = 0;

            for (int i = 0; i < files.Length; i++)
            {
                var fileName = Path.GetFileNameWithoutExtension(files[i].FullName);

                int  number;
                bool isSuccess;

                if (fileName.Contains("~"))
                {
                    var splitStrings = fileName.Split('~');

                    isSuccess = int.TryParse(splitStrings[splitStrings.Length - 1], out number);
                    if (isSuccess && lastNumber == number)
                    {
                        max = lastNumber;
                        break;
                    }

                    if (isSuccess && max < number)
                    {
                        max = number;
                    }
                }

                isSuccess = int.TryParse(fileName, out number);
                if (!isSuccess)
                {
                    continue;
                }

                if (lastNumber == number)
                {
                    max = lastNumber;
                    break;
                }

                if (max < number)
                {
                    max = number;
                }
            }

            novel.UpdateCount = lastNumber - max;

            if (novel.UpdateCount > 0)
            {
                novel.EpisodeStartIndex = novel.EpisodeEndIndex - (novel.UpdateCount - 1);
            }
        }
Exemple #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("  Pilihan Jenis Buku");
            Console.WriteLine("======================");
            Console.WriteLine("1. Buku Non Fiksi");
            Console.WriteLine("2. Buku Fiksi");
            Console.WriteLine("======================");
            Console.Write("Pilih Buku [1/2] : ");
            int pil = Convert.ToInt32(Console.ReadLine());

            if (pil == 1)
            {
                Console.WriteLine();
                Console.WriteLine("Pilihan Buku Non Fiksi");
                Console.WriteLine("======================");
                Console.WriteLine("1. Biografi");
                Console.WriteLine("2. Ensiklopedi");
                Console.WriteLine("3. Literatur");
                Console.WriteLine("======================");
                Console.Write("Pilih Buku [1/2/3] : ");
                int pilBuku = Convert.ToInt32(Console.ReadLine());

                BukuNonFiksi bukuNF;

                if (pilBuku == 1)
                {
                    bukuNF = new Biografi();
                }
                else if (pilBuku == 2)
                {
                    bukuNF = new Ensiklopedi();
                }
                else
                {
                    bukuNF = new Literatur();
                }

                Console.WriteLine();
                bukuNF.Title();
                bukuNF.Data();

                Console.ReadKey();
            }

            else if (pil == 2)
            {
                Console.WriteLine();
                Console.WriteLine("  Pilihan Buku Fiksi");
                Console.WriteLine("======================");
                Console.WriteLine("1. Dongeng");
                Console.WriteLine("2. Komik");
                Console.WriteLine("3. Novel");
                Console.WriteLine("======================");
                Console.Write("Pilih Buku [1/2/3] : ");
                int pilBook = Convert.ToInt32(Console.ReadLine());

                IBukuFiksi bukufiksi;

                if (pilBook == 1)
                {
                    bukufiksi = new Dongeng();
                }
                else if (pilBook == 2)
                {
                    bukufiksi = new Komik();
                }
                else
                {
                    bukufiksi = new Novel();
                }

                Console.WriteLine();
                Console.WriteLine("=====================================");
                Console.WriteLine("| Berikut Data Buku Yang Anda Pilih |");
                Console.WriteLine("=====================================");

                Console.WriteLine();
                bukufiksi.info();

                Console.ReadKey();
            }

            else
            {
                Console.WriteLine("Pilihan Anda tidak tersedia.");
            }
        }
Exemple #7
0
 public Novel Save(Novel novel)
 {
     throw new NotImplementedException();
 }
Exemple #8
0
 public async void AddNovel(Novel input)
 {
     await _novelRepository.InsertAsync(input);
 }
Exemple #9
0
        /// <summary>
        /// Generate the novel JSON data file
        /// </summary>
        /// <param name="novel">The instance of the Novel class containing the metadata of the novel</param>
        static public void GenNovelJSON(Novel novel)
        {
            string path = novelsDir + FormatName(novel.Name);

            WriteJSONData(path, novel);
        }
 public static BookDetailView ToBookDetailView(this Novel model)
 {
     return(model != null?Mapper.Map <BookDetailView>(model) : null);
 }
Exemple #11
0
        public async Task Seed()
        {
            await _dbContext.Database.EnsureDeletedAsync();

            await _dbContext.Database.EnsureCreatedAsync();

            var tag1 = new Tag {
                Name = "tag1", Hint = "This is tag1"
            };
            var tag2 = new Tag {
                Name = "tag2", Hint = "This is tag2"
            };

            var genre1 = new Genre {
                Name = "genre1", Hint = "This is genre1"
            };
            var genre2 = new Genre {
                Name = "genre2", Hint = "This is genre2"
            };
            var genre3 = new Genre {
                Name = "genre3", Hint = "This is genre3"
            };

            var type1 = new NovelType {
                Name = "Type1"
            };
            var type2 = new NovelType {
                Name = "Type2"
            };

            var novel1 = new Novel
            {
                Title = "Novel1Title",
                AltTitlesCollection = (new [] { "Novel1AltTitle1", "Novel1AltTitle2" }).ToImmutableArray(),
                Type   = type1,
                Genres = new List <NovelGenre> {
                    new NovelGenre {
                        Genre = genre1
                    }, new NovelGenre {
                        Genre = genre2
                    }
                },
                Tags = new List <NovelTag> {
                    new NovelTag {
                        Tag = tag1
                    }, new NovelTag {
                        Tag = tag2
                    }
                }
            };

            var novel2 = new Novel
            {
                Title = "Novel2Title",
                AltTitlesCollection = (new[] { "Novel2AltTitle1", "Novel2AltTitle2" }).ToImmutableArray(),
                Type   = type2,
                Genres = new List <NovelGenre> {
                    new NovelGenre {
                        Genre = genre3
                    }, new NovelGenre {
                        Genre = genre2
                    }
                },
                Tags = new List <NovelTag> {
                    new NovelTag {
                        Tag = tag2
                    }
                }
            };

            await _dbContext.Novels.AddRangeAsync(novel1, novel2);

            await _dbContext.SaveChangesAsync();
        }
Exemple #12
0
 protected override void newText()
 {
     txtText = new Novel();
 }
Exemple #13
0
        public int Execute(string input)
        {
            if (input.All(x => x == ' ') || input == "")
            {
                return(0);
            }

            Object[] fields = CParser.Parse(input);

            string command = (string)fields[0];

            if (!cmds.Keys.Contains(command))
            {
                Console.WriteLine("command not found");
                return(-1);
            }

            List <string> flags   = (List <string>)fields[1];
            List <string> paramss = (List <string>)fields[2];

            /* -------------------
             * READ command
             * -------------------*/
            if (command == READ)
            {
                if (paramss == null)
                {
                    dictManger.read("../../input1.txt");
                }
                else if (paramss.Count == 1)
                {
                    dictManger.read(paramss[0]);
                }
                else
                {
                    Console.WriteLine("error: too many params");
                }

                return(0);
            }

            /* -------------------
             * SAVE command
             * -------------------*/
            if (command == SAVE)
            {
                if (paramss == null)
                {
                    dictManger.save("../../input1.txt");
                }
                else if (paramss.Count == 1)
                {
                    dictManger.save(paramss[0]);
                }
                else
                {
                    Console.WriteLine("error: too many params");
                }
                return(0);
            }

            /* -------------------
             * ADD command
             * -------------------*/
            if (command == ADD)
            {
                if (flags.Count == 0)
                {
                    Console.WriteLine("error: choose -w / -d / -n / -e");
                    return(0);
                }

                if (flags[0] == "-z")
                {
                    if (paramss == null || paramss.Count != 2)
                    {
                        Console.WriteLine("ERROR USAGE: add -dct DICT_NAME LANG");
                        return(-1);
                    }

                    dictManger.addDict(
                        DictBuilder.dictBuilder().
                        setName(paramss[0]).
                        setLanguage(paramss[1]).
                        build()
                        );
                    return(0);
                }



                /* -------------------
                 * ADD DEFINITION command
                 * -------------------*/
                if (flags[0] == "-d")
                {
                    if (paramss == null || paramss.Count == 1)
                    {
                        Console.WriteLine("USAGE: add -w WORD DEFINITION");
                        return(0);
                    }

                    Word wrd = dictManger.CurDict().findWord(paramss[0]);

                    if (wrd == null)
                    {
                        Console.WriteLine("Error: Word not found");
                        return(-1);
                    }

                    wrd.addDefinition(new Definition(paramss[1].Replace("\'", "").Replace("\"", "")));
                    return(0);
                }

                /*-----------------------
                 * ADD SYNONYM OR CONTRARY
                 * ------------------------*/

                if (flags[0] == "-s")
                {
                    if (paramss == null || (paramss.Count != 3 && paramss.Count != 2))
                    {
                        Console.WriteLine("USAGE: add -s WORD SYNONYM [N.DEFINITION]");
                        return(0);
                    }


                    Word wrd = dictManger.CurDict().findWord(paramss[0]);
                    if (wrd == null)
                    {
                        Console.WriteLine("Error: Word not found");
                        return(-1);
                    }

                    Definition def;
                    def = wrd.getDefinition(paramss.Count == 3 ? Int32.Parse(paramss[2]) : 0);
                    def.addSynonym(dictManger.CurDict().findWord(paramss[1]));
                }

                if (flags[0] == "-c")
                {
                    if (paramss == null || (paramss.Count != 3 && paramss.Count != 2))
                    {
                        Console.WriteLine("USAGE: add -s WORD CONTRARY [N.DEFINITION]");
                        return(0);
                    }


                    Word wrd = dictManger.CurDict().findWord(paramss[0]);
                    if (wrd == null)
                    {
                        Console.WriteLine("Error: Word not found");
                        return(-1);
                    }

                    Definition def;
                    def = wrd.getDefinition(paramss.Count == 3 ? Int32.Parse(paramss[2]) : 0);
                    def.addContrary(dictManger.CurDict().findWord(paramss[1]));
                }

                /*-----------------------
                 * ADD TRANSLATION  need to be re-thought
                 * ------------------------*/
                if (flags[0] == "-t")
                {
                    if (paramss == null || paramss.Count > 4 || paramss.Count < 2)
                    {
                        Console.WriteLine("USAGE: add -t WORD TRANSLATED LANG [N.DEFINITION]");
                        return(0);
                    }

                    Word wrd = dictManger.CurDict().findWord(paramss[0]);
                    if (wrd == null)
                    {
                        Console.WriteLine("Error: Word not found");
                        return(-1);
                    }

                    // Texts found , List of indexes of dictionaries
                    Tuple <List <Text>, List <int> > tuple = dictManger.find(paramss[1], Dictionary.FLAG_W);
                    int idx = tuple.Item2[0];

                    if (tuple.Item1.Count != 1)
                    {
                        for (int i = 0; i < tuple.Item2.Count; i++)
                        {
                            if (dictManger.getDict(tuple.Item2[i]).Language == paramss[2])
                            {
                                idx = i;
                                break;
                            }
                        }
                    }

                    Word       translated = (Word)tuple.Item1[idx];
                    Definition def        = wrd.getDefinition(paramss.Count == 4 ? Int32.Parse(paramss[3]) : 0);
                    wrd.addTranslation(new Translation(paramss[2], translated), wrd.indexOfDef(def));
                }

                Text   txt    = null;
                string title  = "";
                string origin = "";
                string note   = "";

                /* -------------------
                 * ADD WORD command
                 * -------------------*/
                if (flags[0] == "-w")
                {
                    string type = "";

                    if (paramss == null)
                    {
                        title  = DShell.input("word:");
                        type   = DShell.input("tipo:");
                        origin = DShell.multiline("origin:");
                        note   = DShell.multiline("note:");
                    }

                    if (paramss != null && paramss.Count == 2)
                    {
                        title = paramss[0];
                        type  = paramss[1];
                    }
                    else if (paramss.Count == 1)
                    {
                        title = paramss[0];
                    }
                    else
                    {
                        return(-1);
                    }

                    wrdBuilder.setTitle(title);
                    wrdBuilder.setOrigin(origin);
                    wrdBuilder.setNote(note);
                    wrdBuilder.setType(type);
                    txt = wrdBuilder.build();
                }


                /* -------------------
                 * ADD EXPRESSION command
                 * -------------------*/
                if (flags[0] == "-e")
                {
                    string text        = "";
                    string explanation = "";



                    title = DShell.input("title:");
                    text  = DShell.multiline("text:");

                    txt = new Expression(title, origin, note, text, explanation);
                }

                /* -------------------
                 * ADD NOVEL command
                 * -------------------*/
                if (flags[0] == "-n")
                {
                    string text   = "";
                    string author = "";


                    title  = DShell.input("title:");
                    author = DShell.input("author:");
                    text   = DShell.multiline("text:");


                    txt = new Novel(title, origin, note, text, author);
                }

                if (txt == null)
                {
                    Console.WriteLine("Invalid flag");
                }

                dictManger.CurDict().add(txt);
                return(0);
            }

            /* -------------------
             * CLEAR command
             * -------------------*/
            if (command == CLEAR)
            {
                Console.Clear();
                Console.WriteLine(HEAD);
                return(0);
            }

            /* -------------------
             * EXIT command
             * -------------------*/

            if (command == EXIT)
            {
                return(0);
            }

            /* -------------------
             * HELP command
             * -------------------*/

            if (command == HELP)
            {
                Console.WriteLine("commands:");
                foreach (var var in cmds)
                {
                    Console.WriteLine("   " + var.Key + ":" + "\t" + var.Value);
                }
                return(0);
            }


            /* -------------------
             * LIST command
             * -------------------*/

            if (command == LIST)
            {
                var dict = dictManger.CurDict();

                /* -------------------
                 * LIST all TEXT command
                 * -------------------*/
                if (flags == null)
                {
                    Console.WriteLine(dict.list());
                    return(0);
                }

                /* ----------------------------
                 * LIST DICTIONARIES command
                 * --------------------------*/

                if (flags[0] == "-z")
                {
                    Console.WriteLine(dictManger.listDicts());
                    return(0);
                }

                /* -------------------
                 * LIST WORDS command
                 * -------------------*/
                //show flag
                int sFLAG = 0;

                if (flags[0] == "-w")
                {
                    sFLAG = sFLAG | Dictionary.FLAG_W;
                }

                /* -------------------
                 * LIST EXPRESSIONS command
                 * -------------------*/
                if (flags[0] == "-e")
                {
                    sFLAG = sFLAG | Dictionary.FLAG_E;
                }

                /* -------------------
                 * LIST NOVELS command
                 * -------------------*/
                if (flags[0] == "-n")
                {
                    sFLAG = sFLAG | Dictionary.FLAG_N;
                }

                Console.WriteLine(dict.list(sFLAG));
                return(0);
            }


            /* -------------------
             * DELETE command
             * -------------------*/
            if (command == REMOVE)
            {
                if (paramss == null)
                {
                    Console.WriteLine("ERROR: params missing");
                    return(-1);
                }
                else if ((paramss.Count != 2 && paramss.Count != 1))
                {
                    Console.WriteLine("USAGE: remove -d WORD N*DEFINITION");
                    return(-1);
                }


                Text txt = dictManger.CurDict().find(paramss[0]);


                if (flags.Count != 0 && flags[0] == "-d")
                {
                    if (((Word)txt).removeDefinition(Int32.Parse(paramss[1]) - 1) == null)
                    {
                        Console.WriteLine("ERROR: index of definition out of bound");
                        return(-1);
                    }
                    return(0);
                }

                if (flags.Count == 0 && dictManger.CurDict().remove(txt))
                {
                    Console.WriteLine("ERROR: word/expression/novel not found");
                    return(-1);
                }



                return(0);
            }

            /*----------------------
             * FIND
             * -------------------*/
            if (command == FIND)
            {
                if (flags.Count == 0)
                {
                    Text txt = dictManger.CurDict().find(paramss[0]);
                    if (txt != null)
                    {
                        Console.WriteLine("found:" + txt.title);
                    }
                    else
                    {
                        Console.WriteLine("not found :" + paramss[0]);
                    }
                    return(0);
                }

                if (flags[0] == "-w")
                {
                    if (paramss == null)
                    {
                        Console.WriteLine("ERROR: params missing");
                        return(-1);
                    }

                    Word wrd = dictManger.CurDict().findWord(paramss[0]);
                    if (wrd != null)
                    {
                        Console.WriteLine("found word:" + wrd.title);
                    }
                    else
                    {
                        Console.WriteLine("not found word:" + paramss[0]);
                    }
                    return(0);
                }

                if (flags[0] == "-e")
                {
                    if (paramss == null)
                    {
                        Console.WriteLine("ERROR: params missing");
                        return(-1);
                    }

                    Expression exp = dictManger.CurDict().findExp(paramss[0]);
                    if (exp != null)
                    {
                        Console.WriteLine("found word:" + exp.title);
                    }
                    else
                    {
                        Console.WriteLine("not found word:" + paramss[0]);
                    }
                    return(0);
                }

                if (flags[0] == "-n")
                {
                    if (paramss == null)
                    {
                        Console.WriteLine("ERROR: params missing");
                        return(-1);
                    }

                    Novel nvl = dictManger.CurDict().findNovel(paramss[0]);
                    if (nvl != null)
                    {
                        Console.WriteLine("found novel:" + nvl.title);
                    }
                    else
                    {
                        Console.WriteLine("not found word:" + paramss[0]);
                    }
                    return(0);
                }

                if (flags[0] == "-p")
                {
                    if (paramss == null)
                    {
                        Console.WriteLine("ERROR: params missing");
                        return(-1);
                    }

                    List <Text> texts = dictManger.CurDict().PBS(paramss[0]);
                    foreach (Text text in texts)
                    {
                        if (text != null)
                        {
                            Console.WriteLine("found text:" + text.title);
                        }
                        else
                        {
                            Console.WriteLine("not found word:" + paramss[0]);
                        }
                    }
                    return(0);
                }
            }

            /*----------------------
             * REMIND
             * -------------------*/

            if (command == REMIND)
            {
                int n = 5;
                if (paramss != null)
                {
                    n = int.Parse(paramss[0]);
                }

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

                List <Word> words = dictManger.CurDict().wrdRemind(n);
                foreach (Word w in words)
                {
                    list_wrd.Add(w.title);
                }
                Console.WriteLine(list_wrd);
                return(0);
            }

            /*----------------------
             * SHOW
             * -------------------*/
            if (command == SHOW)
            {
                if (paramss == null || paramss.Count != 1)
                {
                    Console.WriteLine("USAGE: show -w WORD");
                    return(0);
                }
                int find_flags = 0;

                if (flags.Count != 0)
                {
                    if (flags[0] == "-w")
                    {
                        find_flags |= Dictionary.FLAG_W;
                    }
                    else if (flags[0] == "-n")
                    {
                        find_flags |= Dictionary.FLAG_N;
                    }
                    else if (flags[0] == "-e")
                    {
                        find_flags |= Dictionary.FLAG_E;
                    }
                }

                Text txtFound = dictManger.CurDict().find(paramss[0], find_flags);

                if (txtFound == null)
                {
                    Console.WriteLine("error: word/expression/novel not found");
                    return(-1);
                }
                else
                {
                    Console.WriteLine(txtFound.toString());
                }

                return(0);
            }


            /*----------------------
             * CHANGE
             * -------------------*/
            if (command == CHANGE)
            {
                if (paramss == null || paramss.Count != 1)
                {
                    Console.WriteLine("ERROR, USAGE: change INDEX");
                    return(-1);
                }

                dictManger.setCurDict(Int32.Parse(paramss[0]));
            }


            Console.WriteLine($"{input} not found");
            return(1);
        }
        public List <Episode> DownloadList(Novel novel)
        {
            if (novel == null)
            {
                throw new ArgumentNullException(nameof(novel), "Parameter cannot be null");
            }

            try
            {
                if (novel.Type == NovelType.Normal || novel.Type == NovelType.R18)
                {
                    using (var client = new CookieAwareWebClient())
                    {
                        client.Headers.Add("User-Agent: Other");
                        client.UseDefaultCredentials = true;

                        string URL = (novel.Type == NovelType.Normal ? NCodeURL : NCode18URL) + novel.Code + "/";

                        if (novel.Type == NovelType.R18)
                        {
                            var Values = new Dictionary <string, string>
                            {
                                { "over18", "yes" },
                                { "ks2", "f6argh6akx2" },
                                { "sasieno", "0" },
                                { "lineheight", "0" },
                                { "fontsize", "0" },
                                { "novellayout", "0" },
                                { "fix_menu_bar", "1" }
                            };

                            var cookieString = new StringBuilder();
                            foreach (var Value in Values)
                            {
                                cookieString.Append(Value.Key);
                                cookieString.Append("=");
                                cookieString.Append(Value.Value);
                                cookieString.Append(";");
                                cookieString.Append(" ");
                            }

                            cookieString = cookieString.Remove(cookieString.Length - 1, 1);

                            client.CookieContainer.SetCookies(new Uri(URL), cookieString.ToString());
                        }

                        var bytes            = client.DownloadData(URL);
                        var downloadedString = Encoding.UTF8.GetString(bytes);
                        var collection       = new Regex("<a href=\"/" + novel.Code + "/([0-9]*)/\">(.*)</a>", RegexOptions.IgnoreCase).Matches(downloadedString);

                        var document = new HtmlDocument();
                        document.LoadHtml(downloadedString);

                        if (string.IsNullOrWhiteSpace(novel.Name))
                        {
                            novel.Name = document.DocumentNode.Descendants("title").FirstOrDefault().InnerText;
                        }

                        if (string.IsNullOrWhiteSpace(novel.Desc))
                        {
                            var desc = document.GetElementbyId("novel_ex").InnerText;
                            if (Translator != null)
                            {
                                desc = Translator.Translate(desc).Result;
                            }

                            novel.Desc = desc;
                        }

                        if (novel.LastUpdateTime == default)
                        {
                            var datetimeString = document.DocumentNode.SelectNodes("//dt[@class='long_update']").Last().InnerText;
                            datetimeString = datetimeString.Replace("\n", "");
                            datetimeString = datetimeString.Replace("(改)", "");

                            bool isSuccess = DateTime.TryParseExact(
                                datetimeString, "yyyy'/'MM'/'dd' 'HH':'mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out var dateTime);

                            if (isSuccess)
                            {
                                novel.LastUpdateTime = dateTime;
                            }
                        }

                        var episodes = new List <Episode>();
                        for (int i = 0; i < collection.Count; i++)
                        {
                            var episode = new Episode
                            {
                                Number    = i + 1,
                                URLNumber = (i + 1).ToString(),
                                Title     = collection[i].Value.Split('>')[1].Split('<')[0]
                            };

                            episodes.Add(episode);
                        }

                        return(episodes);
                    }
                }
                else if (novel.Type == NovelType.Kakuyomu)
                {
                    using (var client = new WebClient())
                    {
                        client.Headers.Add("User-Agent: Other");
                        client.UseDefaultCredentials = true;

                        string URL = KakuyomuURL + novel.Code;

                        var bytes            = client.DownloadData(URL);
                        var downloadedString = Encoding.UTF8.GetString(bytes);
                        var regex1           = new Regex("\"widget-toc-episode-titleLabel js-vertical-composition-item\">");
                        var regex2           = new Regex("/episodes/");

                        var document = new HtmlDocument();
                        document.LoadHtml(downloadedString);

                        if (string.IsNullOrWhiteSpace(novel.Name))
                        {
                            novel.Name = document.GetElementbyId("workTitle").InnerText;
                        }

                        if (string.IsNullOrWhiteSpace(novel.Desc))
                        {
                            var desc = document.GetElementbyId("introduction").InnerText;
                            if (Translator != null)
                            {
                                desc = Translator.Translate(desc).Result;
                            }

                            novel.Desc = desc;
                        }

                        var matches1 = regex1.Matches(downloadedString);
                        var matches2 = regex2.Matches(downloadedString);

                        var episodes = new List <Episode>();
                        var dict     = new Dictionary <string, Episode>();

                        int Count = 0;
                        for (int i = 0, j = 0; i < matches1.Count && j < matches2.Count; i++, j++)
                        {
                            int startIndex1 = matches1[i].Index + matches1[i].Length;
                            int endIndex1   = downloadedString.IndexOf("</span>", startIndex1, StringComparison.InvariantCulture) - 1;

                            if (startIndex1 < 0 || endIndex1 < 0)
                            {
                                continue;
                            }

                            int startIndex2 = matches2[j].Index + matches2[j].Length;
                            int endIndex2   = downloadedString.IndexOf("\"", startIndex2, StringComparison.InvariantCulture) - 1;

                            if (startIndex2 < 0 || endIndex2 < 0)
                            {
                                i--;
                                continue;
                            }

                            string title        = downloadedString.Substring(startIndex1, endIndex1 - startIndex1 + 1);
                            string stringNumber = downloadedString.Substring(startIndex2, endIndex2 - startIndex2 + 1);

                            if (stringNumber == novel.Code)
                            {
                                i--;
                                continue;
                            }

                            bool isSuccess = long.TryParse(stringNumber, out long Number);
                            if (!isSuccess)
                            {
                                i--;
                                continue;
                            }

                            if (dict.ContainsKey(stringNumber))
                            {
                                i--;
                                continue;
                            }

                            var episode = new Episode
                            {
                                Number    = ++Count,
                                URLNumber = stringNumber,
                                Title     = title
                            };

                            episodes.Add(episode);
                            dict.Add(episode.URLNumber, episode);
                        }

                        return(episodes);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
            }

            return(null);
        }
        private async Task DownloadNovel(Novel novel, Episode episode, bool createFile, bool translate, bool isPrologue, bool loadOnly)
        {
            if (novel.Type == NovelType.Normal || novel.Type == NovelType.R18)
            {
                using (var client = new CookieAwareWebClient())
                {
                    client.Headers.Add("User-Agent: Other");
                    client.UseDefaultCredentials = true;

                    string nCodeURL = novel.Type == NovelType.Normal ? NCodeURL : NCode18URL;
                    string url      = $"{nCodeURL}{novel.Code}/{episode.URLNumber}";

                    if (novel.Type == NovelType.R18)
                    {
                        var Values = new Dictionary <string, string>
                        {
                            { "over18", "yes" },
                            { "ks2", "f6argh6akx2" },
                            { "sasieno", "0" },
                            { "lineheight", "0" },
                            { "fontsize", "0" },
                            { "novellayout", "0" },
                            { "fix_menu_bar", "1" }
                        };

                        var cookieString = new StringBuilder();
                        foreach (var Value in Values)
                        {
                            cookieString.Append(Value.Key);
                            cookieString.Append("=");
                            cookieString.Append(Value.Value);
                            cookieString.Append(";");
                            cookieString.Append(" ");
                        }

                        cookieString = cookieString.Remove(cookieString.Length - 1, 1);

                        client.CookieContainer.SetCookies(new Uri(url), cookieString.ToString());
                    }

                    var bytes = await client.DownloadDataTaskAsync(url).ConfigureAwait(false);

                    string input = Encoding.UTF8.GetString(bytes);

                    var document = new HtmlDocument();
                    document.LoadHtml(input);

                    var result = document.GetElementbyId("novel_color").InnerText;
                    if (!result.Contains(Environment.NewLine))
                    {
                        result = result.Replace("\n", Environment.NewLine);
                    }

                    result = result.Replace("&nbsp;", "");
                    result = result.Replace("<ruby>", "");
                    result = result.Replace("</ruby>", "");
                    result = result.Replace("<rp>", "");
                    result = result.Replace("</rp>", "");
                    result = result.Replace("<rb>", "");
                    result = result.Replace("</rb>", "");
                    result = result.Replace("<rt>", "");
                    result = result.Replace("</rt>", "");
                    result = result.Replace("<br />", Environment.NewLine + Environment.NewLine);
                    result = result.Replace("&quot;", "\"");
                    result = result.Replace("&lt;", "<");
                    result = result.Replace("&gt;", ">");
                    result = result.Replace("&quot", "\"");
                    result = result.Replace("&lt", "<");
                    result = result.Replace("&gt", ">");

                    episode.SourceText = result;
                }
            }
            else
            {
                using (var client = new HttpClient())
                {
                    client.DefaultRequestHeaders.Add("User-Agent", "Other");

                    string URL   = $"{KakuyomuURL}{novel.Code}/episodes/{episode.URLNumber}";
                    string input = await client.GetStringAsync(new Uri(URL)).ConfigureAwait(false);

                    var document = new HtmlDocument();
                    document.LoadHtml(input);

                    var result = document.GetElementbyId("contentMain-inner").InnerText;
                    if (!result.Contains(Environment.NewLine))
                    {
                        result = result.Replace("\n", Environment.NewLine);
                    }

                    result = result.Replace("&nbsp;", "");
                    result = result.Replace("<em class=\"emphasisDots\">", "");
                    result = result.Replace("</em>", "");
                    result = result.Replace("<span>", "");
                    result = result.Replace("</span>", "");
                    result = result.Replace("<ruby>", "");
                    result = result.Replace("</ruby>", "");
                    result = result.Replace("<rp>", "");
                    result = result.Replace("</rp>", "");
                    result = result.Replace("<rb>", "");
                    result = result.Replace("</rb>", "");
                    result = result.Replace("<rt>", "");
                    result = result.Replace("</rt>", "");
                    result = result.Replace("<br />", Environment.NewLine);

                    episode.SourceText = result;
                }
            }

            if (isPrologue)
            {
                PrologueChanged?.Invoke(novel, new EventArgs());
            }

            if (!loadOnly)
            {
                novel.ProgressValue++;
            }

            if (translate && Translator != null)
            {
                if (!string.IsNullOrWhiteSpace(episode.SourceText))
                {
                    episode.TranslatedText = await Translator.Translate(episode.SourceText).ConfigureAwait(false);

                    if (isPrologue)
                    {
                        PrologueChanged?.Invoke(novel, new EventArgs());
                    }
                }
            }
            else
            {
                episode.TranslatedText = null;
            }

            if (createFile)
            {
                string novelPath = Config.NovelPath + novel.Name;

                if (!Directory.Exists(novelPath))
                {
                    Directory.CreateDirectory(novelPath);
                }

                var filePath = string.Format(CultureInfo.InvariantCulture, "{0}\\{1:D4}.txt", novelPath, episode.Number);
                File.WriteAllText(filePath, episode.TranslatedText ?? episode.SourceText, Encoding.UTF8);

                novel.ProgressValue++;
            }
        }
 private void GetSectionLinks(Novel novel)
 {
     novel.Sections = HtmlAnalysis.AnalysisDirectory(HtmlCrawler.GetHtmlContent(new System.Uri(novel.DirectoryUri)));
 }
Exemple #17
0
        public ActionResult Detail()
        {
            #region

            string absoluteUrl = "";
            if (EnvSettings.Domain.IsInvalid(out absoluteUrl))
            {
                return(Redirect(absoluteUrl));
            }

            #endregion

            SetReadMode();
            Novel novel = _bookService.GetNovel(NovelId);
            if (novel != null && novel.Id > 0)
            {
                InitializeChapterPager();

                Chapter chapter = _chapterService.GetChapter(NovelId, ChapterCode, ChapterDirection, out ChapterCode);
                if (chapter != null && chapter.Id > 0 && IsRead(_orderService))
                {
                    #region

                    bool   isPreChapterCode  = false;
                    bool   isNextChapterCode = false;
                    string url = GetChapterPager("/chapter/detail", ChapterCode, out isPreChapterCode, out isNextChapterCode);

                    #endregion

                    #region 推荐阅读

                    //推荐阅读 - 轮循广告
                    int adClassId           = RecSection.BookChapterDetail.Ad;
                    IEnumerable <AD> adList = GetADList(adClassId, novel.Id, 3);

                    #endregion

                    //阅读记录
                    ReadLog(currentUser.UserName, chapter.NovelId, chapter.Id, chapter.ChapterCode);

                    //最近阅读日志
                    RecentReadContext.Save(novel, chapter.ChapterName, ChapterCode, RouteChannelId, currentUser.UserId);

                    //是否收藏
                    bool isMark = _bookmarkService.Exists(NovelId, currentUser.UserName);

                    //漫画目录
                    IEnumerable <ExtendChapterView> extendChapterList = GetExtendChapterList(novel);

                    // 千字价格
                    int chapterWordSizeFee = GetChapterWordSizeFee(novel.ChapterWordSizeFee);
                    //正文中插入用户信息
                    string encryptInfo = string.IsNullOrEmpty(currentUser.UserName) ? null : string.Concat("16", ";", currentUser.UserName.Substring(1));

                    ChapterDetailView detailView = new ChapterDetailView()
                    {
                        Novel                    = new SimpleResponse <Novel>(true, novel),
                        Chapter                  = new SimpleResponse <Chapter>(true, chapter),
                        ChapterFee               = GetFee(chapter.WordSize, chapterWordSizeFee),
                        ChapterContent           = StringHelper.ConvertAndSignTxt((novel.ContentType == (int)Constants.Novel.ContentType.小说) ? FileHelper.ReadFile(FileHelper.MergePath("\\", new string[] { novel.FilePath, chapter.FileName }), chapter.ChapterName) : "", Constants.SecurityKey.userAESId.ToLower(), encryptInfo),
                        IsPreChapterCode         = isPreChapterCode,
                        IsNextChapterCode        = isNextChapterCode,
                        PreChapterUrl            = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.pre, channelId: RouteChannelId),
                        NextChapterUrl           = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.next, channelId: RouteChannelId),
                        AdList                   = new SimpleResponse <IEnumerable <AD> >(!adList.IsNullOrEmpty <AD>(), adList),
                        IsMark                   = isMark,
                        ExtendChapterList        = new SimpleResponse <IEnumerable <ExtendChapterView> >(!extendChapterList.IsNullOrEmpty <ExtendChapterView>(), extendChapterList),
                        ChapterAudioUrl          = GetAudioUrl(novel.ContentType, chapter.FileName),
                        HitUrl                   = GetHitUrl(),
                        ShowQrCodeMinChapterCode = StringHelper.ToInt(UrlParameterHelper.GetParams("qrdx"))
                    };

                    if (novel.ContentType == (int)Constants.Novel.ContentType.漫画)
                    {
                        return(View("/views/cartoonchapter/detail.cshtml", detailView));
                    }
                    else if (novel.ContentType == (int)Constants.Novel.ContentType.听书)
                    {
                        return(View("/views/audiochapter/detail.cshtml", detailView));
                    }
                    else
                    {
                        return(View(detailView));
                    }
                }
                else
                {
                    if (novel.FeeType == (int)Constants.Novel.FeeType.chapter || novel.FeeType == (int)Constants.Novel.FeeType.novelchapter)
                    {
                        return(Redirect(ChapterContext.GetUrl("/preorder/chapter", NovelId, ChapterCode, channelId: RouteChannelId)));
                    }
                    else if (novel.FeeType == (int)Constants.Novel.FeeType.novel)
                    {
                        return(Redirect(ChapterContext.GetUrl("/preorder/novel", NovelId, ChapterCode, channelId: RouteChannelId)));
                    }
                }
            }

            return(Redirect(DataContext.GetErrorUrl(ErrorMessage.小说不存在, channelId: RouteChannelId)));
        }
 public void UpdateNovelDateAccessed(Novel novel)
 {
     novel.DateAccessed    = DateTime.Now;
     db.Entry(novel).State = EntityState.Modified;
     db.SaveChanges();
 }
        private void lvHomePage_ItemClick(object sender, ItemClickEventArgs e)
        {
            Novel pass = (Novel)e.ClickedItem;

            ((Frame)Window.Current.Content).Navigate(typeof(DetailPage), pass);
        }
Exemple #20
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(int id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            // Fetch data from DB to get OwnerID.
            Novel novelToUpdate = await Context
                                  .Novels.AsNoTracking()
                                  .FirstOrDefaultAsync(n => n.NovelID == id);

            if (novelToUpdate == null)
            {
                return(NotFound());
            }

            var isAuthorized = await AuthorizationService.AuthorizeAsync(
                User, novelToUpdate,
                NovelOperations.Update);

            if (!isAuthorized.Succeeded)
            {
                return(Forbid());
            }

            using (var memoryStream = new MemoryStream())
            {
                if (FileUpload.FormFile != null)
                {
                    await FileUpload.FormFile.CopyToAsync(memoryStream);
                }

                // Upload the file if less than 260 KB
                if (memoryStream.Length < 262144)
                {
                    //Protect from overposting attacks
                    if (await TryUpdateModelAsync <Novel>(
                            novelToUpdate,
                            "Novel", // Prefix for form value.
                            n => n.Introduction, n => n.Type, n => n.PrimeRead, n => n.End))
                    {
                        if (memoryStream.Length != 0)
                        {
                            novelToUpdate.Image = memoryStream.ToArray();
                        }
                        novelToUpdate.UpdateTime = DateTime.Now;

                        Context.Attach(novelToUpdate).State = EntityState.Modified;

                        try
                        {
                            await Context.SaveChangesAsync();
                        }
                        catch (DbUpdateConcurrencyException)
                        {
                            if (!NovelExists(Novel.NovelID))
                            {
                                return(NotFound());
                            }
                            else
                            {
                                throw;
                            }
                        }

                        return(RedirectToPage("./Index"));
                    }
                }
                else
                {
                    ModelState.AddModelError("FileUpload", "圖片檔案必須小於260KB");
                    ErrorMessage = "圖片檔案必須小於260KB";
                }
            }

            return(Page());
        }
Exemple #21
0
 public Novel UpdateNovel(Novel novel)
 {
     throw new NotImplementedException();
 }
Exemple #22
0
        public ActionResult Yorum(int id)
        {
            Novel novel = StatikVeritaban.DetayNovel(id);

            return(PartialView(novel));
        }
Exemple #23
0
        public static void Initialize(MchneContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Novels.Any())
            {
                return;   // DB has been seeded
            }

            var novels = new Novel[]
            {
                new Novel {
                    Title      = "Tempest of the Stellar War",
                    CoverImage = "https://cdn.novelupdates.com/images/2016/04/Tempest-of-the-Stellar.jpg",
                    Synopsis   = "In a distant future, the empires of mankind span the galaxy, and glorious Earth has devolved into a peripheral backwater." + "\r\n" + "\r\n" +
                                 "In Shanjing city in the Asian region, Wang Zheng’s dreams of becoming a mech pilot are crushed when his college entrance exam genetic score turns out a pathetic twenty eight, barely above an animal." + "\r\n" + "\r\n" +
                                 "To make things worse, people get the impression he attempted suicide after being rejected by the campus beauty." + "\r\n" + "\r\n" +
                                 "Then the closest thing to a family he has, the old man in the book store across the road, goes missing, leaving him only a mysterious birthday present.",
                    Genres = new string[5]
                },
                new Novel {
                    Title      = "Galactic Dark Net",
                    CoverImage = "https://cdn.novelupdates.com/images/2017/03/Galactic-Dark-Net.jpg",
                    Synopsis   = "When the last prodigy level esper on Earth disappeared, Earth was in deep trouble of becoming another species' colony. The ordinary Han, with his intelligence and hardworking character, was able to make a fortune after “accidentally” stepping into the world of dark net, later purchasing an esper power crystal that brought him the ultimate power that changed the fate of the universe." + "\r\n" + "\r\n" +
                                 "Dark net is a subset of the Deep Web that is not only not indexed by traditional search engines, but that also requires special tools like specific proxy or authentication to gain access. Dark net is not restricted by any law or morals, so the dark net market has everything that is prohibited by the law. Drugs, slaves, firearms, uranium, bioweapons, rare animals, human testing, assassination, and the list goes on. During the year of 2075 on Earth, Han Lang logged into the largest hyperspace dark net market, and our story begins.",
                    Genres = new string[4]
                },
                new Novel {
                    Title      = "Rebirth of the Thief Who Roamed The World",
                    CoverImage = "https://cdn.novelupdates.com/images/2015/08/chongshengzhi.jpg",
                    Synopsis   = "The world’s largest VRMMO, Conviction, was almost like a second world for humanity. It had integrated itself into the real world’s economy, with both corporations and individuals seeking their fortunes through the game." + "\r\n" + "\r\n" +
                                 "In this game, Nie Yan prided himself in his Level 180 Thief. He could barely be considered among the top experts in the game. Though, that was the only thing he could take pride in. He was penniless and unable to advance in life; a situation he was forced into by the enemy of his father. If it weren’t for the little money he made by selling off items in Conviction, he would’ve barely been able to eat. In the end, he chose to settle his matters once and for all. He assassinated his father’s enemy. He lay dying shortly after being shot in the pursuit." + "\r\n" + "\r\n" +
                                 "However, that wasn’t the end of his story. Instead, he awoke moments later to find that he had reincarnated into his past self. Armed with his experience and knowledge of future events, he sets out to live his life anew.",
                    Genres = new string[5]
                }
            };

            novels[0].Genres[0] = "Science Fiction";
            novels[0].Genres[1] = "School Life";
            novels[0].Genres[2] = "Martial Arts";
            novels[0].Genres[3] = "Comedy";
            novels[0].Genres[4] = "Romance";

            novels[1].Genres[0] = "Science Fiction";
            novels[1].Genres[1] = "Romance";
            novels[1].Genres[2] = "Martial Arts";
            novels[1].Genres[3] = "Comedy";

            novels[2].Genres[0] = "Science Fiction";
            novels[2].Genres[1] = "School Life";
            novels[2].Genres[2] = "Martial Arts";
            novels[2].Genres[3] = "Comedy";
            novels[2].Genres[4] = "Romance";
            foreach (Novel n in novels)
            {
                context.Novels.Add(n);
            }
            context.SaveChanges();

            var chapters = new Chapter[]
            {
                new Chapter {
                    ChapterNumber = 1, ContentUrl = "Chemistry", NovelID = 1
                },
                new Chapter {
                    ChapterNumber = 2, ContentUrl = "Microeconomics", NovelID = 1
                },
                new Chapter {
                    ChapterNumber = 1, ContentUrl = "Chemistry", NovelID = 2
                },
                new Chapter {
                    ChapterNumber = 2, ContentUrl = "Microeconomics", NovelID = 2
                }
            };

            foreach (Chapter c in chapters)
            {
                context.Chapters.Add(c);
            }
            context.SaveChanges();
        }
Exemple #24
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(string from, int fromID)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            await SetOtherEpisodesNotLast(fromID);

            Episode.OwnerID = UserManager.GetUserId(User);

            Novel = Context.Novels.Where(n => n.NovelID == fromID).FirstOrDefault();

            var isAuthorized = await AuthorizationService.AuthorizeAsync(
                User, Novel,
                NovelOperations.Create);

            if (!isAuthorized.Succeeded)
            {
                return(Forbid());
            }

            if (from != "Novels")
            {
                ErrorMessage = "沒有指定的評論頁面";
                return(Page());
            }

            Episode emptyEpisode = new Episode
            {
                Votings = new List <Voting>
                {
                    new Voting
                    {
                        Title     = "anchor",
                        EpisodeID = Episode.EpisodeID,
                        OwnerID   = Episode.OwnerID
                    }
                },
                Title    = "temp title",
                Content  = "temp content",
                Comments = new List <Comment>
                {
                    //防止Comment找不到所屬的Episode
                    new Comment
                    {
                        ProfileID = Episode.OwnerID,
                        EpisodeID = Episode.EpisodeID,
                        Block     = true,
                        Content   = "anchor"
                    }
                }
            };

            //Protect from overposting attacks
            if (await TryUpdateModelAsync <Episode>(
                    emptyEpisode,
                    "Episode", // Prefix for form value.
                    e => e.Title, e => e.Content))
            {
                emptyEpisode.UpdateTime = DateTime.Now;
                if (from == "Novels")
                {
                    emptyEpisode.NovelID = fromID;
                }
                var tempUser = await Context.Profiles.FirstOrDefaultAsync(u => u.ProfileID == emptyEpisode.OwnerID);

                emptyEpisode.OwnerID   = Episode.OwnerID;
                emptyEpisode.IsLast    = true;
                emptyEpisode.Views     = 0;
                emptyEpisode.HasVoting = true;
                Context.Episodes.Add(emptyEpisode);
                Novel.UpdateTime            = DateTime.Now;
                Context.Attach(Novel).State = EntityState.Modified;
                await Context.SaveChangesAsync();

                if (from != null)
                {
                    return(RedirectToPage("/" + from + "/Details", "OnGet", new { id = fromID }, "EpisodeHead"));
                }
            }
            return(Page());
        }
Exemple #25
0
 public bool Delete(Novel novel)
 {
     throw new NotImplementedException();
 }
Exemple #26
0
        public ActionResult Novel()
        {
            string url = "";

            Novel novelInfo = _bookService.GetNovel(NovelId, (int)Constants.Status.yes);

            if (!novelInfo.IsNullOrEmpty <Novel>() && novelInfo.Id > 0)
            {
                ErrorMessage errorMessage = ErrorMessage.失败;
                switch (novelInfo.FeeType)
                {
                case (int)Constants.Novel.FeeType.novel:
                case (int)Constants.Novel.FeeType.novelchapter:
                    int result = Novel(novelInfo);
                    if (EnumHelper.TryParsebyValue <ErrorMessage>(result, out errorMessage))
                    {
                        switch (errorMessage)
                        {
                        case ErrorMessage.成功:
                            url = ChapterContext.GetUrl("/chapter/detail", NovelId, ChapterCode, channelId: RouteChannelId);
                            break;

                        case ErrorMessage.余额不足:
                            url = StringHelper.GetReturnUrl("/order/recharge", UrlParameterHelper.GetParams("returnUrl"), channelId: RouteChannelId);
                            break;

                        case ErrorMessage.已购买过该小说:
                            url = ChapterContext.GetUrl("/chapter/detail", NovelId, ChapterCode, channelId: RouteChannelId);
                            break;

                        case ErrorMessage.用户不存在:
                            url = DataContext.GetErrorUrl(ErrorMessage.用户不存在, channelId: RouteChannelId);
                            break;

                        case ErrorMessage.小说不存在:
                            url = DataContext.GetErrorUrl(ErrorMessage.小说不存在, channelId: RouteChannelId);
                            break;

                        case ErrorMessage.小说章节不存在:
                            url = DataContext.GetErrorUrl(ErrorMessage.小说章节不存在, channelId: RouteChannelId);
                            break;

                        case ErrorMessage.该小说标价有误无法购买:
                            url = DataContext.GetErrorUrl(ErrorMessage.该小说标价有误无法购买, channelId: RouteChannelId);
                            break;

                        case ErrorMessage.该小说无法按本计费:
                            url = DataContext.GetErrorUrl(ErrorMessage.该小说无法按本计费, channelId: RouteChannelId);
                            break;

                        default:
                            url = DataContext.GetErrorUrl(ErrorMessage.未知错误, channelId: RouteChannelId);
                            break;
                        }
                    }
                    break;

                case (int)Constants.Novel.FeeType.chapter:
                    url = ChapterContext.GetUrl("/preorder/chapter", NovelId, ChapterCode, channelId: RouteChannelId);
                    break;
                }
            }

            return(Redirect(url));
        }
Exemple #27
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var user = await UserManager.GetUserAsync(User);

            if (user.Banned)
            {
                return(Forbid());
            }

            Novel.ProfileID = UserManager.GetUserId(User);

            var isAuthorized = await AuthorizationService.AuthorizeAsync(
                User, Novel,
                NovelOperations.Create);

            if (!isAuthorized.Succeeded)
            {
                return(Forbid());
            }

            Novel emptyNovel =
                new Novel
            {
                Title        = "temp title",
                Introduction = "temp introduction",
                ProfileID    = Novel.ProfileID,
                Comments     = new List <Comment>
                {
                    //防止Comment找不到所屬的Feedback
                    new Comment
                    {
                        ProfileID = Novel.ProfileID,
                        NovelID   = Novel.NovelID,
                        Block     = true,
                        Content   = "anchor"
                    }
                },
                //    Episodes = new List<Episode>
                //{
                //    new Episode
                //    {
                //        Title = "anchor",
                //        NovelID = Novel.NovelID,
                //        Content = "anchor"
                //    }
                //}
            };

            using (var memoryStream = new MemoryStream())
            {
                if (FileUpload.FormFile != null)
                {
                    await FileUpload.FormFile.CopyToAsync(memoryStream);
                }

                // Upload the file if less than 260 KB
                if (memoryStream.Length < 262144)
                {
                    //Protect from overposting attacks
                    if (await TryUpdateModelAsync <Novel>(
                            emptyNovel,
                            "Novel", // Prefix for form value.
                            n => n.Title, n => n.Introduction, n => n.Type, n => n.PrimeRead, n => n.Block, n => n.ProfileID))
                    {
                        if (memoryStream.Length != 0)
                        {
                            emptyNovel.Image = memoryStream.ToArray();
                        }
                        emptyNovel.UpdateTime = DateTime.Now;
                        emptyNovel.CreateTime = DateTime.Now;
                        //var tempUser = await Context.Profiles.FirstOrDefaultAsync(u => u.ProfileID == Novel.ProfileID);
                        //emptyNovel.ProfileID = Novel.ProfileID;
                        Context.Novels.Add(emptyNovel);
                        await Context.SaveChangesAsync();

                        return(RedirectToPage("./Index"));
                    }
                }
                else
                {
                    ModelState.AddModelError("FileUpload", "這個檔案太大了");
                }
            }

            return(Page());
        }
    void Start()
    {
        startupManager = GameObject.FindGameObjectWithTag ( "StartupManager" ).GetComponent<StartupManager> ();
        guiManager = GameObject.FindGameObjectWithTag ( "GUIManager" ).GetComponent<GUIManager> ();

        if ( !Directory.Exists(startupManager.parentFolder + Path.DirectorySeparatorChar + "Novels"))
        {

            Directory.CreateDirectory(startupManager.parentFolder + Path.DirectorySeparatorChar + "Novels");
            UnityEngine.Debug.Log("Directory does not exist!");
        }

        if (Directory.Exists(startupManager.parentFolder + Path.DirectorySeparatorChar + "Novels"))
        {

            foreach (string directory in Directory.GetDirectories(startupManager.parentFolder + Path.DirectorySeparatorChar + "Novels"))
            {

                if (File.Exists(directory + Path.DirectorySeparatorChar + "Info.txt"))
                {

                    Novel tempNovel = new Novel();
                    tempNovel.location = directory.ToString();
                    using (StreamReader reader = new StreamReader(directory + Path.DirectorySeparatorChar + "Info.txt"))
                    {

                        tempNovel.name = reader.ReadLine();
                        tempNovel.author = reader.ReadLine();
                        tempNovel.version = reader.ReadLine();
                    }

                    if (tempNovel.name != null && tempNovel.author != null && tempNovel.version != null && File.Exists(directory + Path.DirectorySeparatorChar + tempNovel.name + ".xml"))
                        availableNovels.Add(tempNovel);
                    else
                        UnityEngine.Debug.Log("Folder not added");
                }
            }
        }
    }
Exemple #29
0
        static void Main(string[] args)
        {
            var jericho = new Snake("Jericho", "Boa Constrictor");

            jericho.FeedReptile();
            jericho.Speak();
            jericho.Slither();

            var rogue = new Iguana("Rogue", "Green Iguana");

            rogue.FeedReptile();
            rogue.Speak();
            rogue.Dislike();

            var snuggles = new Alligator("Snuggles", "American Alligator");

            snuggles.FeedReptile();
            snuggles.Speak();
            snuggles.DeathRoll();

            var fgfc820 = new Industrial("FGFC820", "Aggrotech")
            {
                AlbumNumber = 10
            };

            fgfc820.RockOut("Bridgestone Arena");
            fgfc820.CheckAlbums();
            fgfc820.Bringit();

            var vnvNation = new Industrial("VNV Nation", "EBM")
            {
                AlbumNumber = 20
            };

            vnvNation.RockOut("Exit/In");
            vnvNation.CheckAlbums();
            vnvNation.Bringit();

            var bach = new Classical("Johan Sebestian Bach", "Baroque");

            bach.Encore();

            var theGrapesOfWrath = new Novel("The Grapes of Wrath", 525, "John Steinbeck")
            {
                HaveRead = true
            };

            theGrapesOfWrath.Open();
            theGrapesOfWrath.Read();

            var braveNewWorld = new Novel("Brave New World", 452, "Aldous Huxley")
            {
                HaveRead = false
            };

            braveNewWorld.Read();

            var verdi = new PictureBook("Verdi", 15, "Janell Cannon");

            verdi.Read();

            var worldOfWarcraft = new VideoGames("World of Warcraft", new DateTime(2004, 11, 24))
            {
                Developer = "Blizzard",
                GameGenre = GameGenre.MMO
            };

            worldOfWarcraft.Play();
            worldOfWarcraft.Return();

            var doom = new VideoGames("Doom", new DateTime(1993, 12, 10))
            {
                Developer = "id Software",
                GameGenre = GameGenre.Shooter
            };

            doom.Play();
            doom.Return();

            Console.ReadKey();
        }
Exemple #30
0
        public ActionResult Chapter()
        {
            SetReadMode();
            Novel novel = _bookService.GetNovel(NovelId);

            if (novel != null && novel.Id > 0)
            {
                if (novel.FeeType == (int)Constants.Novel.FeeType.novel)
                {
                    return(Redirect(DataContext.GetErrorUrl(ErrorMessage.该小说无法按章计费, channelId: RouteChannelId)));
                }

                InitializeChapterPager();

                Chapter chapter = _chapterService.GetChapter(NovelId, ChapterCode, ChapterDirection, out ChapterCode);
                if (chapter != null && chapter.Id > 0 && IsRead(_orderService))
                {
                    return(Redirect(ChapterContext.GetUrl("/chapter/detail", chapter.NovelId, chapter.ChapterCode, channelId: RouteChannelId)));
                }

                if (chapter != null && chapter.Id > 0)
                {
                    int i = 0;
                    if (int.TryParse(StringHelper.ToString(SessionHelper.Get("ancp")), out i) && i == NovelId)
                    {
                        return(Redirect(ChapterContext.GetUrl("/order/chapter", chapter.NovelId, chapter.ChapterCode, channelId: RouteChannelId)));
                    }

                    #region

                    bool   isPreChapterCode  = false;
                    bool   isNextChapterCode = false;
                    string url = GetChapterPager("/chapter/detail", ChapterCode, out isPreChapterCode, out isNextChapterCode);

                    #endregion

                    bool isMark = _bookmarkService.Exists(NovelId, currentUser.UserName);

                    // 千字价格
                    int chapterWordSizeFee       = GetChapterWordSizeFee(novel.ChapterWordSizeFee);
                    ChapterDetailView detailView = new ChapterDetailView()
                    {
                        Novel              = new SimpleResponse <Novel>(true, novel),
                        Chapter            = new SimpleResponse <Chapter>(true, chapter),
                        ChapterWordSizeFee = chapterWordSizeFee,
                        ChapterFee         = GetFee(chapter.WordSize, chapterWordSizeFee),
                        NovelFee           = GetFee((decimal)(novel.WordSize * 0.95f), chapterWordSizeFee),
                        ChapterContent     = (novel.ContentType == (int)Constants.Novel.ContentType.小说) ? StringHelper.CutString(FileHelper.ReadFile(FileHelper.MergePath("\\", new string[] { novel.FilePath, chapter.FileName }), chapter.ChapterName), 100, true) : "",
                        IsPreChapterCode   = isPreChapterCode,
                        IsNextChapterCode  = isNextChapterCode,
                        PreChapterUrl      = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.pre, channelId: RouteChannelId),
                        NextChapterUrl     = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.next, channelId: RouteChannelId),
                        UserBalance        = GetUserBalance(),
                        IsMark             = isMark
                    };

                    if (novel.ContentType == (int)Constants.Novel.ContentType.漫画)
                    {
                        return(View("/views/cartoonchapter/order.cshtml", detailView));
                    }
                    else if (novel.ContentType == (int)Constants.Novel.ContentType.听书)
                    {
                        return(View("/views/audiochapter/order.cshtml", detailView));
                    }
                    else
                    {
                        return(View("/views/chapter/order.cshtml", detailView));
                    }
                }
                else
                {
                    //章节不存在
                    return(Redirect(DataContext.GetErrorUrl(ErrorMessage.小说章节不存在, channelId: RouteChannelId)));
                }
            }
            else
            {
                //小说不存在
                return(Redirect(DataContext.GetErrorUrl(ErrorMessage.小说不存在, channelId: RouteChannelId)));
            }
        }
Exemple #31
0
        private void lvHomePage_ItemClick(object sender, ItemClickEventArgs e)
        {
            Novel pass = (Novel)e.ClickedItem;

            Frame.Navigate(typeof(DetailPage), pass);
        }
Exemple #32
0
 public int AddNovel(Novel novelInfo)
 {
     return(_dal.AddNovel(novelInfo));
 }
Exemple #33
0
        /// <summary>
        /// 书籍详情
        /// </summary>
        /// <param name="nid"></param>
        /// <returns></returns>
        public async Task <ActionResult> Detail(int novelId = 0)
        {
            string loginUserName = currentUser.UserName;
            Novel  novel         = null;

            if (novelId > 0)
            {
                novel = _bookService.GetNovel(novelId);
            }

            if (novel == null || novel.Id <= 0)
            {
                return(Redirect(DataContext.GetErrorUrl(ErrorMessage.小说不存在, channelId: RouteChannelId)));
            }

            BookDetailView view = novel.ToBookDetailView();
            //活动截止时间
            var packageInfo = await Task.Run(() => _packageService.GetNovelPackage(Constants.PackageType.LimitFree, novelId));

            if (packageInfo != null)
            {
                view.PackageEndTime = packageInfo.EndTime;
            }
            else
            {
                view.PackageEndTime = null;
            }

            //是否收藏
            bool isAddMark = await Task.Run(() => _bookmarkService.Exists(novelId, loginUserName));

            view.IsAddMark = isAddMark;
            //是否全本优惠
            view.IsOrder = await Task.Run(() => IsOrder(_orderService));

            //阅读记录
            ILogService         logService = DataContext.ResolveService <ILogService>();
            NovelReadRecordInfo readRecord = await Task.Run(() => logService.GetRecentChapter(loginUserName, novelId));

            if (readRecord != null)
            {
                view.RecentReadChapterCode = readRecord.ChapterCode;
            }

            //作者的话
            string column = "Message";

            string where = "and novelId = @novelId and authorId = @authorId ";
            string orderby      = " order by id desc";
            var    authorNotice = await Task.Run(() => _bookService.GetAuthorNotice(column, where, orderby, new { novelId = novelId, authorId = novel.UserId }));

            view.AuthorNotice = authorNotice == null ? null : authorNotice.Message;

            //章节信息
            var lastChapter = await Task.Run(() => _chapterService.GetLatestChapter(novelId));

            view.RecentChapterName       = lastChapter == null ? null : lastChapter.ChapterName;
            view.RecentChapterUpdateTime = lastChapter == null ? default(DateTime) : lastChapter.OnlineTime;
            view.RecentChapterCode       = lastChapter == null ? 0 : lastChapter.ChapterCode;
            int rowCount    = 0;
            var chapterList = await Task.Run(() => GetChapterList(out rowCount, novelId, novel.ContentType));

            view.TotalChapterCount = rowCount;
            view.ChapterList       = new SimpleResponse <IEnumerable <ChapterView> >(!chapterList.IsNullOrEmpty(), chapterList);

            //评论信息
            int commentCount = 0;
            var commentList  = await Task.Run(() => GetCommentList(out commentCount, novel.Id));

            view.CommentCount = commentCount;
            view.CommentList  = new SimpleResponse <IEnumerable <CommentView> >(!commentList.IsNullOrEmpty(), commentList);

            //猜你喜欢
            bool IsCartoonType = novel.ContentType == (int)Constants.Novel.ContentType.漫画;

            view.RecClassId = IsCartoonType ? RecSection.CartoonDetail.GuessRec : RecSection.BookDetail.GuessRec;
            if (IsCartoonType)
            {
                //漫画详情-来源
                var cp = await Task.Run(() => _bookService.GetCP("CnName", "and Id = @cpId and status = @status", "order by id ", new { cpId = novel.CPId, status = 1 }));

                view.CPName = cp == null ? null : cp.CnName;
            }

            //记录日志

            NovelLogInfo log = new NovelLogInfo();

            log          = GetLogInfo(log) as NovelLogInfo;
            log.CookieId = GetCookieId();
            log.NovelId  = novelId;
            log.AddTime  = DateTime.Now;
            var service = DataContext.ResolveService <ILogService>();
            await Task.Run(() => service.NovelReadLog(log));

            var model = new SimpleResponse <BookDetailView>(view != null, view);

            if (IsCartoonType)
            {
                return(View("/Views/Cartoon/Detail.cshtml", model));
            }
            else
            {
                return(View(model));
            }
        }
 public Library AddNovel(Novel novel)
 {
     novels.Add(novel);
     return(this);
 }