public static EDataSection newModelInstance(string secCode, string itemCode) { return(new EDataSection { BatchNo = GenCodeHelper.DataSection_BatchNo(secCode), ItemCode = itemCode, SectionCode = secCode, CreateDateTime = DateTime.Now, }); }
private void InitData(string entryUrl) { _entryUrl = entryUrl; int sp = _entryUrl.IndexOf("subject") + "subject/".Length; int ep = _entryUrl.IndexOf("/", sp + 1); if (ep == -1) { ep = _entryUrl.Length; } _DouBanBookId = _entryUrl.Substring(sp, ep - sp); _bookDetailData = NewDetailMiddle(); _bookDetailData.DouBanBookInfo.SourceBookId = _DouBanBookId; _bookDetailData.DouBanBookInfo.Code = GenCodeHelper.Book_Code(DouBanAbbr, _DouBanBookId); //$"{DouBanAbbr}_{_DouBanBookId}"; }
/// <summary> /// 处理 Span嵌套Span /// </summary> /// <param name="node"></param> /// <param name="bi"></param> private void AnalyInfo_SpanChild(HtmlNode node) { EBookInfo bi = _bookDetailData.DouBanBookInfo; EPerson author = _bookDetailData.Author; string name = node.InnerText.Trim(); HtmlNode ci = node.NextSibling.NextSibling;; string url = ci.Attributes["href"].Value; if (!url.StartsWith(DouBanBookPrefix)) { url = DouBanBookPrefix + url; } switch (name) { case "作者:": case "作者": var authorName = ci.InnerText.Trim(); if (authorName.StartsWith("[")) { var ep = authorName.IndexOf("]"); author.Country = authorName.Substring(1, ep - 1); author.Name = authorName.Substring(ep + 1); } if (authorName.StartsWith("<")) { var ep = authorName.IndexOf(">"); author.Country = authorName.Substring(1, ep - 1); author.Name = authorName.Substring(ep + 1); } else if (authorName.StartsWith("(")) { var ep = authorName.IndexOf(")"); author.Country = authorName.Substring(1, ep - 1); author.Name = authorName.Substring(ep + 1); } else if (authorName.StartsWith("【")) { var ep = authorName.IndexOf("】"); author.Country = authorName.Substring(1, ep - 1); author.Name = authorName.Substring(ep + 1); } else { author.Name = authorName; author.Country = "中国"; } author.Code = GenCodeHelper.Person_Code(author.Name.Trim()); bi.AuthorCode = author.Code; author.SourceUrl = url; break; case "译者:": case "译者": bi.Translater = ci.InnerText; bi.TranslaterUrl = url; break; case "丛书": case "丛书:": bi.Series = ci.InnerText; bi.SeriesUrl = url; break; case "出品方": case "出品方:": bi.Producer = ci.InnerText; bi.ProducerUrl = url; break; } }