/// <summary> /// 一次性获取多个章节内容 /// </summary> /// <param name="nodeIdList"></param> public static bool getNodeDetail(List <string> nodeIdList, bool downloadImage = false) { try { string nodeDetails = HttpWorker.HttpGet(Global.NodeDetailApi, "nodeIds=" + string.Join(",", nodeIdList)); NodeDetailResponse nodeDtailResponse = TranslationWorker.ConvertStringToEntity <NodeDetailResponse>(nodeDetails); List <Node> nodes = nodeDtailResponse.ConvertToNodes(); if (downloadImage) { foreach (Node node in nodes)//下载图片到本地,并生成离线内容 { List <string> urls = HtmlCleaner.GetImageUrl(node.content); foreach (string url in urls) { HttpWorker.SaveImg(url, node.lawId); } node.offlineContent = HtmlCleaner.ChangeImageUrlToLocalPath(node.content, node.lawId); } } db.refreshNode(nodes, detailOnly: true); return(true); } catch (Exception) { MessageBox.Show("操作超时"); return(false); } }
/// <summary> /// 获取一个章节的内容 /// </summary> /// <param name="nodeId"></param> public static void getNodeDetail(string nodeId) { string nodeDetails = HttpWorker.HttpGet(Global.NodeDetailApi, "nodeIds=" + nodeId); if (nodeDetails == "error") { return; } NodeDetailResponse nodeDtailResponse = TranslationWorker.ConvertStringToEntity <NodeDetailResponse>(nodeDetails); List <Node> nodes = nodeDtailResponse.ConvertToNodes(); foreach (Node node in nodes)//下载图片到本地,并生成离线内容 { List <string> urls = HtmlCleaner.GetImageUrl(node.content); foreach (string url in urls) { HttpWorker.SaveImg(url, node.lawId); } node.offlineContent = HtmlCleaner.ChangeImageUrlToLocalPath(node.content, node.lawId); } db.refreshNode(nodes, detailOnly: true); }