public string AddLocalNovelInMyNovel(string novelId) { try { User user = _authUtil.GetCurrentUser().User; Novel novel = _app.GetNovel(novelId); _app.AddLocalNovelInMyNovel(user, novel); } catch (Exception ex) { Result.Code = 500; Result.Message = ex.ToString(); } return(JsonHelper.Instance.Serialize(Result)); }
/// <summary> /// 获取章节到本地 /// </summary> /// <param name="novelId"></param> /// <param name="ids"></param> /// <returns></returns> public string GetChapterToLocal(string novelId, string id) { try { var novel = _novelManagerApp.GetNovel(novelId); var sqlStr = string.Format("Select * From [{0}] Where Id= '{1}' and state <> 2 ", novelId, id); var listChapter = _app.Repository.ChapterQueryFromSql(sqlStr).ToList(); if (listChapter.Count() > 0) { ThreadPool.QueueUserWorkItem(x => { var _chapterManagerApp = AutofacExt.GetFromFac <ChapterManagerApp>(); foreach (var chapter in listChapter) { _chapterManagerApp.UpdateChapterState(novel.Id, chapter.Id, 1); var tmpChapterContent = _chapterManagerApp.GetWebChapterContent(chapter); _chapterManagerApp.SaveToLocal(_hostingEnvironment.ContentRootPath, novel, chapter, tmpChapterContent); _chapterManagerApp.UpdateChapterState(novel.Id, chapter.Id, 2); } if (_chapterManagerApp.IsAllChapterToLocal(novel.Id)) { novel.State = 2; var _novelManagerApp = AutofacExt.GetFromFac <NovelManagerApp>(); _novelManagerApp.Update(novel); } }); } else { Result.Code = 500; Result.Message = "未找到要获取的章节或者章节全部获取完成!"; } } catch (Exception ex) { Result.Code = 500; Result.Message = ex.ToString(); } return(JsonHelper.Instance.Serialize(Result)); }