Пример #1
0
        //获取当前用户所有浏览历史

        public static List <ChapterModel> GetAllChapter()
        {
            if (IsCreate())
            {
                XmlDocument doc = new XmlDocument(); //加载xml文件
                doc.Load(HistoryXmlPath);
                List <ChapterModel> list = new List <ChapterModel>();
                XmlNodeList         dt   = doc.SelectNodes("/dt/td");
                foreach (XmlNode item in dt)
                {
                    ChapterModel cp = new ChapterModel
                    {
                        Title      = item.FirstChild.InnerText,
                        Path       = item.FirstChild.NextSibling.InnerText,
                        History    = item.FirstChild.NextSibling.NextSibling.InnerText,
                        Historyurl = item.FirstChild.NextSibling.NextSibling.NextSibling.InnerText
                    };
                    list.Add(cp);
                }
                return(list);
            }
            else
            {
                return(new List <ChapterModel>());
            }
        }
    // Use this for initialization
    void Start()
    {
        chapters = new List <ChapterModel>();
        for (int i = 0; i < 2; i++)
        {
            var cm = new ChapterModel();
            cm.pages = new List <PageModel>();
            cm.id    = i;
            for (int j = 0; j < 2; j++)
            {
                var pm = new PageModel();
                pm.BackgroundArt = j.ToString();
                cm.pages.Add(pm);
            }
            chapters.Add(cm);
        }
        string json = JsonWriter.Serialize(chapters);
        //Will end up in in invalid cast:
        //var deserialized = JsonReader.Deserialize<List<ChapterModel>(json);
        //Will be casted to object[] on deserialization:
        //var deserialized = JsonReader.Deserialize(json, typeof (List<ChapterModel>));
        //Will evaluate just fine:
        var deserialized         = JsonReader.Deserialize(json, typeof(List <ChapterModel>)) as object[];
        List <ChapterModel> list = deserialized.Select(item => item as ChapterModel).ToList();

        Debug.Log(list.Count);
    }
Пример #3
0
        public async Task <Chapter> Create(ChapterModel chapterModel)
        {
            var chapter = _mapper.Map <Chapter>(chapterModel);
            await _chapters.InsertOneAsync(chapter);

            return(chapter);
        }
 public static Domain.Models.Chapter Map(ChapterModel model)
 {
     return(new Domain.Models.Chapter {
         ID = model.ID,
         Title = model.Title,
         EpicID = model.EpicID,
         Text = model.Text,
         Date = model.Date
     });
 }
Пример #5
0
        public void ParseChapter()
        {
            ChapterModel _parseChapterResult = new ChapterModel();

            _parseChapterResult.ImageUrl = "http://testsite.com";
            _parseChapterResult.NextUrl  = "mailto:[email protected]";

            var result = _objParse.GetChapterLinks(_html.ToString());

            Assert.AreEqual(_parseChapterResult, result);
        }
Пример #6
0
        public StageModel GetFirstStage(ChapterModel chapter)
        {
            if (null == chapter)
            {
                return(null);
            }

            int firstStageId = chapter.Stages.First();

            return(StageListData[firstStageId].Stage);
        }
        public async Task <IActionResult> Post(ChapterModel chapter)
        {
            var domain_chapter = Mappers.ChapterModelMapper.Map(chapter);
            var completed      = await Task.FromResult(_chapterRepository.AddChapter(domain_chapter));

            if (completed)
            {
                return(CreatedAtAction(nameof(GetById), new { id = chapter.ID }, chapter));
            }

            return(BadRequest());
        }
Пример #8
0
        public DbBookModel Get(int bookId)
        {
            DbBookModel      bookModel    = new DbBookModel();
            ChapterModel     chapterModel = null;
            BookSectionModel sectionModel = null;

            using (var db = new BookDbContext())
            {
                var dbBook = db.Books.Where(b => b.Id == bookId).FirstOrDefault();
                bookModel.Id           = dbBook.Id;
                bookModel.BookTitle    = dbBook.BookTitle;
                bookModel.Introduction = dbBook.Introduction;
                bookModel.Preface      = dbBook.Preface;

                var bookChapters = dbBook.Chapters.OrderBy(c => c.ChapterOrder).ToList();

                foreach (BookChapter dbChapter in bookChapters)
                {
                    chapterModel              = new ChapterModel();
                    chapterModel.Id           = dbChapter.Id;
                    chapterModel.ChapterTitle = dbChapter.ChapterTitle;
                    chapterModel.ChapterOrder = dbChapter.ChapterOrder;
                    chapterModel.Preface      = dbChapter.Preface;

                    var chapterSections = dbChapter.Sections.OrderBy(s => s.SectionOrder).ToList();

                    foreach (BookSection dbSection in chapterSections)
                    {
                        sectionModel              = new BookSectionModel();
                        sectionModel.Id           = dbSection.Id;
                        sectionModel.SectionTitle = dbSection.SectionTitle;
                        sectionModel.SectionOrder = dbSection.SectionOrder;
                        //sectionModel.SectionContents = dbSection.SectionContents;
                        var subSections = dbSection.SubSections.OrderBy(ss => ss.SubSectionOrder).ToList();
                        foreach (SubSection dbSubSection in subSections)
                        {
                            sectionModel.SubSections.Add(new SubSectionModel()
                            {
                                Id = dbSubSection.Id,
                                SubSectionContents = dbSubSection.SubSectionContents,
                                SubSectionTitle    = dbSubSection.SubSectionTitle,
                                SubSectionOrder    = dbSubSection.SubSectionOrder
                            });
                        }
                        chapterModel.Sections.Add(sectionModel);
                    }
                    bookModel.Chapters.Add(chapterModel);
                }
                bookModel.success = "ok";
            }
            return(bookModel);
        }
Пример #9
0
    public void Bind(ChapterModel chapterModel, ChapterScrollList heroScrollList)
    {
        model      = chapterModel;
        scrollList = heroScrollList;

        chapterNumText.text = "第" + ConvertHelper.convertNumToStr(model.chapterId) + "章";

        char[]   delimiterChars = { ' ' };
        string[] words          = model.chapterTitle.Split(delimiterChars);
        descOneText.text = words[0];
        descTwoText.text = words[1];
        statusText.text  = PrefDefine.CHAPTER_STATUS[model.status];
    }
Пример #10
0
        protected async void EntrySelected(TimelineEntryModel entry)
        {
            var model = new EntryStoryUpdateModel(Model.Id);

            if (entrySelectionChapter != null)
            {
                model.ChapterId = entrySelectionChapter.Id;
            }

            entrySelectionChapter = null;
            await Api.UpdateEntryStoryAsync(entry.Id, model);

            await EventDispatcher.PublishAsync(new StoryEntriesChanged(model.StoryId, model.ChapterId, entry.Id));
        }
Пример #11
0
        public void Setup()
        {
            chapter = DataManager.Get().ChapterData[1];
            GameManager.Get().CurrentChapter = chapter;
            var stageJsonText = Resources.Load <TextAsset>("Data/Stage/Stage01");

            stage = JObject.Parse(stageJsonText.text).ToObject <StageModel>();
            var mapJsonText = Resources.Load <TextAsset>($"Data/Map/{stage.MapName}");

            map = JObject.Parse(mapJsonText.text).ToObject <MapModel>();
            GameManager.Get().CurrentStage = stage;
            GameManager.Get().GameRoom     = GameRoomModel.GetSoloPlay();
            SceneManager.LoadScene("GameScene");
        }
Пример #12
0
        private void LoadChapterVerses(ChapterModel chapter)
        {
            int verseCount = this.chapterVerseCount[chapter.ChapterKey];

            for (int x = 1; x <= verseCount; ++x)
            {
                chapter.Verses.Add(x,
                                   new  VerseModel
                {
                    VerseKey    = this.BuildVerseKey(chapter.ChapterKey, x),
                    VerseNumber = x
                });
            }
        }
Пример #13
0
        public void CreateMap(MapInfo map)
        {
            //设置当前配置信息
            if (map.type == ConfigType.PVEChapter)
            {
                ChapterModel chatperModel = Core.Data.getIModelConfig <ChapterModel>();
                curChapConfig = chatperModel.get(map.ID);
            }
            else
            {
                PVPBattleModel pvpModel = Core.Data.getIModelConfig <PVPBattleModel>();
                curChapConfig = pvpModel.get(map.ID);
            }

            //加载配表
            reader.loadSceneConfig(map.ID);

            //TODO : According to the type of map, we should make up the right path
            StringBuilder strBld = new StringBuilder("Scenes/Stage_");

            strBld.Append(map.ID.ToString());
            GameObject go = Maploader.loadFromUnPack(strBld.ToString(), false);

            UnityUtils.AddChild_Reverse(go, ScenePoint);

            MapInSceneData[] mapdata = reader.GetSceneEditorElementData <MapInSceneData>();
            if (mapdata != null && mapdata.Length > 0)
            {
                go.transform.localPosition    = new Vector3(mapdata [0].pos [0], mapdata [0].pos [1], mapdata [0].pos [2]);
                go.transform.localScale       = new Vector3(mapdata [0].scale [0], mapdata [0].scale [1], mapdata [0].scale [2]);
                go.transform.localEulerAngles = new Vector3(mapdata [0].rotation [0], mapdata [0].rotation [1], mapdata [0].rotation [2]);
            }

            strBld.Append("Graph");
            string    strPath = System.IO.Path.Combine(ResourceSetting.UNPACKROOT, strBld.ToString());
            TextAsset mapTxt  = UnityEngine.Resources.Load(strPath) as TextAsset;

            if (mapTxt == null)
            {
                Debug.LogError("scene textAsseet data is null ::  " + strPath);
            }

            AstarPath.active.astarData.DeserializeGraphs(mapTxt.bytes);

            CreateUnVision();

            GameObject helper = new GameObject("helper");

            helper.AddComponent <TileHandlerHelper>();
        }
Пример #14
0
        public Task BindModelAsync(ModelBindingContext bindingContext)
        {
            ChapterModel model;

            if (bindingContext.HttpContext.Request.Form.Files.GetFile(nameof(ComicChapterModel.Pages)) != null)
            {
                var comicChapterModel = new ComicChapterModel
                {
                    Pages = bindingContext.HttpContext.Request.Form.Files.FirstOrDefault()
                };
                model = comicChapterModel;
            }
            else if (bindingContext.HttpContext.Request.Form.ContainsKey(nameof(NovelChapterModel.Content)))
            {
                model = new NovelChapterModel();
            }
            else
            {
                model = new ChapterModel();
            }

            model.TitleId = Guid.Parse(bindingContext.ValueProvider.GetValue(nameof(ChapterModel.TitleId)).FirstValue !);

            foreach (var(key, value) in bindingContext.HttpContext.Request.Form)
            {
                var property = model.GetType().GetProperties().SingleOrDefault(info => string.Equals(info.Name, key, StringComparison.CurrentCultureIgnoreCase));

                if (property == null)
                {
                    continue;
                }

                if (property.PropertyType.IsEnum)
                {
                    property.SetValue(model, Enum.Parse(property.PropertyType, value.First()));
                }
                else if (property.PropertyType == typeof(Guid?) || property.PropertyType == typeof(Guid))
                {
                    property.SetValue(model, property.PropertyType == typeof(Guid?) && string.IsNullOrWhiteSpace(value.FirstOrDefault()) ? null : Guid.Parse(value.First()));
                }
                else
                {
                    property.SetValue(model, string.IsNullOrEmpty(value.FirstOrDefault()) ? null : Convert.ChangeType(value.FirstOrDefault(), Nullable.GetUnderlyingType(property.PropertyType) is var underlyingType && underlyingType != null ? underlyingType : property.PropertyType));
                }
            }

            bindingContext.Result = ModelBindingResult.Success(model);
            return(Task.CompletedTask);
        }
Пример #15
0
 public static ChapterView Map(this ChapterModel source)
 => new ChapterView
 {
     Id                      = source.Id,
     Title                   = source.Title,
     ChapterNumber           = source.ChapterNumber,
     BookId                  = source.BookId,
     Status                  = source.Status.ToDescription(),
     WriterAccountId         = source.WriterAccountId,
     WriterAccountName       = source.WriterAccountName,
     WriterAssignTimeStamp   = source.WriterAssignTimeStamp,
     ReviewerAccountId       = source.ReviewerAccountId,
     ReviewerAccountName     = source.ReviewerAccountName,
     ReviewerAssignTimeStamp = source.ReviewerAssignTimeStamp
 };
Пример #16
0
        public void WriteChapterToStorage(ChapterModel model)
        {
            var path    = $"{Directory.GetCurrentDirectory()}\\Articles\\Chapters.txt";
            var pathDir = $"{Directory.GetCurrentDirectory()}\\Articles\\{model.Chapter}";

            using (var writer = File.AppendText(path))
            {
                writer.Write(model.Chapter + Environment.NewLine);
            }

            if (!Directory.Exists(pathDir))
            {
                Directory.CreateDirectory(pathDir);
            }
        }
Пример #17
0
        private void LoadBookChapters(BookModel book)
        {
            int chapterCount = this.bookChapterCount[book.BookKey];

            for (int x = 1; x <= chapterCount; ++x)
            {
                ChapterModel chapter = new ChapterModel
                {
                    ChapterNumber = x,
                    ChapterKey    = this.BuildChapterKey(book.BookKey, x)
                };

                this.LoadChapterVerses(chapter);

                book.Chapters.Add(x, chapter);
            }
        }
Пример #18
0
        public async Task <ChapterModel> AddChapter(int libraryId, int bookId, ChapterModel chapter, CancellationToken cancellationToken)
        {
            int id;

            using (var connection = _connectionProvider.GetConnection())
            {
                var sql     = "Insert Into Chapter (Title, BookId, ChapterNumber) Output Inserted.Id Values (@Title, @BookId, @ChapterNumber)";
                var command = new CommandDefinition(sql, new { Title = chapter.Title, BookId = bookId, ChapterNumber = chapter.ChapterNumber }, cancellationToken: cancellationToken);
                id = await connection.ExecuteScalarAsync <int>(command);
            }

            var retVal = await GetChapterById(libraryId, bookId, chapter.ChapterNumber, cancellationToken);

            await ReorderChapters(libraryId, bookId, cancellationToken);

            return(retVal);
        }
Пример #19
0
        public ActionResult ChangeChapter()
        {
            ChapterModel model;

            if (Request.Form.IsValid(typeof(ChapterModel)))
            {
                model = new ChapterModel(Request.Form);
            }
            else
            {
                throw new ArgumentNullException("Форма не валидна");
            }

            var wrapper = new StorageManager();

            wrapper.MoveChapterByTitle(model.ChapterSelect, model.Chapter);

            return(RedirectToAction("Index", "Admin", new { page = 0 }));
        }
Пример #20
0
        public async Task <ChapterModel> GetChapterBy(string chapterId, CancellationToken token)
        {
            string sql = @"SELECT ChapterName, Id FROM Chapters WHERE Id = @ChapterId";

            var parameters = new
            {
                ChapterId = chapterId
            };

            IEnumerable <ChapterModel> matches = await _client.LoadData <ChapterModel, dynamic>(sql, parameters, token);

            ChapterModel output = matches.SingleOrDefault();

            List <PictureModel> pictures = await _imagesRepo.FindPicturesFor(chapterId, token);

            output.Pictures = pictures;

            return(output);
        }
Пример #21
0
        public int Post(ChapterModel chapterModel)
        {
            int success = 0;

            using (var db = new BookDbContext())
            {
                var chapter = new BookChapter()
                {
                    BookId       = chapterModel.BookId,
                    ChapterTitle = chapterModel.ChapterTitle,
                    ChapterOrder = chapterModel.ChapterOrder,
                    Preface      = chapterModel.Preface
                };
                db.Chapters.Add(chapter);
                db.SaveChanges();
                success = chapter.Id;
            }
            return(success);
        }
Пример #22
0
        public ChapterModel Patch(int chapterId)
        {
            var chapter = new ChapterModel();

            using (var db = new BookDbContext())
            {
                var dbChapter = db.Chapters.Where(c => c.Id == chapterId).FirstOrDefault();
                if (dbChapter != null)
                {
                    chapter.Id           = dbChapter.Id;
                    chapter.ChapterTitle = dbChapter.ChapterTitle;
                    chapter.ChapterOrder = dbChapter.ChapterOrder;
                    chapter.Preface      = dbChapter.Preface;
                    chapter.BookTitle    = dbChapter.Book.BookTitle;
                    chapter.BookId       = dbChapter.BookId.Value;
                    chapter.success      = "ok";
                }
            }
            return(chapter);
        }
        public async Task <IActionResult> Put([FromRoute] int chapterID, [FromBody] ChapterModel newChapter)
        {
            var domain_chapter = Mappers.ChapterModelMapper.Map(newChapter);

            if (_chapterRepository.GetChaptersByEpicID(newChapter.EpicID) is IEnumerable <Chapter> )
            {
                var completed = await Task.FromResult(_chapterRepository.UpdateChapter(domain_chapter));

                if (completed)
                {
                    return(NoContent());
                }
                else
                {
                    return(BadRequest());
                }
            }

            return(NotFound());
        }
Пример #24
0
        /// <summary>
        /// 创建地图
        /// </summary>
        public void CreateMap()
        {
            Charactors = WarSMgr.realServer.monitor.CharactorPool;

            MapInfo map = WarSMgr.realServer.mWar.Map;

            //将数据发给客户端
            WarSMgr.realServer.proxyCli.CtorEnv(map);

            if (map.type == ConfigType.PVEChapter)
            {
                ChapterModel chatperModel = Core.Data.getIModelConfig <ChapterModel>();
                curChapConfig = chatperModel.get(map.ID);
            }
            else
            {
                PVPBattleModel pvpModel = Core.Data.getIModelConfig <PVPBattleModel>();
                curChapConfig = pvpModel.get(map.ID);
            }
        }
Пример #25
0
        public void Parse_Chapter(ChapterModel chapterModel)
        {
            Random r = new Random();
            var    delayTimeSpance = r.Next(1, 10);

            Thread.Sleep(delayTimeSpance * 1000);

            try
            {
                var connection  = NSoupClient.Connect(chapterModel.Url);
                var document    = connection.Get();
                var element     = document.GetElementById("content");
                var contentHtml = element.Html();
                var lines       = Regex.Replace(contentHtml, "<br.*?/>", "");
                lines = Regex.Replace(lines, "&nbsp;", " ");

                if (lines.Length <= 0)
                {
                    return;
                }

                using (var uow = new NovelUnitOfWork())
                {
                    var chapterService = new ChapterDomainService(uow);
                    chapterService.Update(chapterModel.Id, x =>
                    {
                        x.Content         = lines;
                        x.LastUpdatedTime = DateTime.Now;
                    });
                }
            }
            catch (Exception e)
            {
                //InvokeScriptFunction("show_message", e.Message);

                InvokeScriptFunction(() =>
                {
                    Document.InvokeScript("show_message", new[] { e.Message, "danger" });
                });
            }
        }
Пример #26
0
        public void SetVerse(string bibleVerseKey)
        {
            try
            {
                if (bibleVerseKey.IsNullEmptyOrWhiteSpace())
                {
                    bibleVerseKey = "01O||1||1";
                }

                string bookKey = $"{Formatters.GetBookFromKey(bibleVerseKey)}||";

                string chapterKey = $"{bookKey}{Formatters.GetChapterFromKey(bibleVerseKey)}||";

                string verseKey = $"{chapterKey}{Formatters.GetVerseFromKey(bibleVerseKey)}||";

                if (Formatters.IsOldTestament(bibleVerseKey))
                {
                    BookModel book = this.OldTestamentBooks.FirstOrDefault(b => b.BookKey == bookKey);

                    this.SelectedOldTestamentBook = book;
                }
                else
                {
                    BookModel book = this.NewTestamentBooks.FirstOrDefault(b => b.BookKey == bookKey);

                    this.SelectedNewTestamentBook = book;
                }

                ChapterModel chapter = this.bookChapters.FirstOrDefault(c => c.ChapterKey == chapterKey);

                this.SelectedChapter = chapter;

                VerseModel verse = this.ChapterVerses.FirstOrDefault(v => v.VerseKey == verseKey);

                this.SelectedVerse = verse;
            }
            catch
            {
                // DO NOTHING, We would not like to have things fall over
            }
        }
Пример #27
0
        private string GetChapterContent(List <ChapterModel> list, HtmlNode chapterQuery, string link)
        {
            var model = new ChapterModel();

            model.Link = link;

            var linkNextChapter = string.Empty;

            var titleQuery = chapterQuery.QuerySelectorAll("div.header h2.title").FirstOrDefault();

            if (titleQuery != null)
            {
                model.Title = titleQuery.InnerText;
            }

            var linkNextQuery = chapterQuery.QuerySelector("div.truyencv-read-navigation a[title='Chương sau']");

            if (linkNextQuery != null)
            {
                linkNextChapter = linkNextQuery.Attributes["href"].Value;
            }

            var contentQuery = chapterQuery.QuerySelector("div#js-truyencv-content");

            if (contentQuery != null)
            {
                model.Content = contentQuery.InnerHtml;
            }

            if (!string.IsNullOrEmpty(model.Content))
            {
                list.Add(model);
            }
            else
            {
                linkNextChapter = string.Empty;
            }

            return(linkNextChapter);
        }
Пример #28
0
        private string GetChapterContent(List <ChapterModel> list, string link)
        {
            HtmlWeb htmlWeb = new HtmlWeb()
            {
                AutoDetectEncoding = false,
                OverrideEncoding   = Encoding.UTF8 //Set UTF8 để hiển thị tiếng Việt
            };

            HtmlDocument document = htmlWeb.Load(link);

            try
            {
                var headers = document.DocumentNode.QuerySelectorAll("div#bookContent p").ToArray();

                var chapterTitle = headers[1].InnerText;

                var thread  = document.DocumentNode.QuerySelectorAll("div#bookContentBody").FirstOrDefault();
                var content = thread.InnerHtml;

                var nextChapter     = document.DocumentNode.QuerySelectorAll("a#btnNextChapter").FirstOrDefault();
                var linkNextChapter = nextChapter.Attributes["href"].Value;

                var item = new ChapterModel();
                item.Title   = chapterTitle;
                item.Content = content;

                list.Add(item);

                if (!string.IsNullOrEmpty(linkNextChapter))
                {
                    return(Constants.UrlWiki + linkNextChapter);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
            }

            return(string.Empty);
        }
Пример #29
0
    void AddButtons()
    {
        for (int i = 0; i < chapters.Count; i++)
        {
            Button bt = Instantiate(btn);
            bt.transform.SetParent(transform, true);
            //bt.GetComponent<RectTransform> ().SetPositionAndRotation (new Vector3(0, -i*150, 0), Quaternion.identity);
            bt.GetComponent <RectTransform> ().localPosition = new Vector3(0, -i * 150, 0);
            RectTransform rt = bt.GetComponent <RectTransform> ();
            //			rt.SetInsetAndSizeFromParentEdge (RectTransform.Edge.Left, 0, 750);
            rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, i * 150, 150);

            ChapterItem  item  = bt.GetComponent <ChapterItem> ();
            ChapterModel model = chapters[i];
            item.Bind(model, this);
        }

        RectTransform rootRt = GetComponent <RectTransform> ();

        rootRt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, screenW);
        rootRt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, chapters.Count * 150);
    }
Пример #30
0
        public string Put(ChapterModel chapterModel)
        {
            string success = "";

            using (var db = new BookDbContext())
            {
                var chapter = db.Chapters.Where(c => c.Id == chapterModel.Id).FirstOrDefault();
                if (chapter == null)
                {
                    success = "not found";
                }
                else
                {
                    chapter.ChapterTitle = chapterModel.ChapterTitle;
                    chapter.ChapterOrder = chapterModel.ChapterOrder;
                    chapter.Preface      = chapterModel.Preface;
                    db.SaveChanges();
                    success = "ok";
                }
            }
            return(success);
        }