static public int addNovelList(string ncode, string html, SQLiteConnection aConnection) { using (var aConText = new DataContext(aConnection)) { var htmlDoc = new HtmlAgilityPack.HtmlDocument(); htmlDoc.LoadHtml(html); var title = htmlDoc.DocumentNode .SelectNodes(@"//p[@class=""novel_title""]") .Select(a => a.InnerText.Trim()) .ToList().FirstOrDefault(); var writername = htmlDoc.DocumentNode .SelectNodes(@"//div[@class=""novel_writername""]") .Select(a => a.InnerText.Trim()) .ToList().FirstOrDefault().Substring(3); var novellists = aConText.GetTable <Novellist>(); var rec = new Novellist { Ncode = ncode, Html = html, Title = title, Writername = writername, Regdate = DateTime.Today.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(), }; novellists.InsertOnSubmit(rec); aConText.SubmitChanges(); return(getNovelId(ncode, aConText)); } }
static public int addNovelList(Novellist novellst, DataContext aConText) { var novellists = aConText.GetTable <Novellist>(); novellst.Regdate = DateTime.Today.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); novellists.InsertOnSubmit(novellst); aConText.SubmitChanges(); return(getNovelId(novellst.Ncode, aConText)); }