/* public static void Insert(string threadUrl, List<ResInfo> resList) { foreach (ResInfo res in resList) { Insert(threadUrl, res); } } */ public static void Insert(string threadUrl, ResInfo resList) { StringBuilder sb = new StringBuilder(); sb.AppendLine("INSERT "); sb.AppendLine("INTO `PecaTsuBBS`.`BBSResponse` ( "); sb.AppendLine(" `ThreadUrl`"); sb.AppendLine(" , `ResNo`"); sb.AppendLine(" , `WriterName`"); sb.AppendLine(" , `WriterMail`"); sb.AppendLine(" , `WriteTime`"); sb.AppendLine(" , `WriterId`"); sb.AppendLine(" , `Message`"); sb.AppendLine(") "); sb.AppendLine("VALUES ( "); sb.AppendLine(" @ThreadUrl"); sb.AppendLine(" , @ResNo"); sb.AppendLine(" , @WriterName"); sb.AppendLine(" , @WriterMail"); sb.AppendLine(" , @WriteTime"); sb.AppendLine(" , @WriterId"); sb.AppendLine(" , @Message"); sb.AppendLine(") "); sb.AppendLine("ON DUPLICATE KEY UPDATE Message = @Message"); Dictionary<string, string> paramDic = new Dictionary<string, string>(); paramDic["ThreadUrl"] = threadUrl; paramDic["ResNo"] = resList.ResNo; paramDic["WriterName"] = resList.Name; paramDic["WriterMail"] = resList.Mail; paramDic["WriteTime"] = resList.Date; paramDic["WriterId"] = resList.Id; paramDic["Message"] = resList.Message; DBUtil.Update(sb.ToString(), paramDic); }
public static void Insert(string threadUrl, string channelName, string imageUrl, ResInfo res) { StringBuilder sb = new StringBuilder(); sb.AppendLine("INSERT "); sb.AppendLine("INTO `PecaTsuBBS`.`ImageLink` ( "); sb.AppendLine(" `ThreadUrl`"); sb.AppendLine(" , `ResNo`"); sb.AppendLine(" , `ImageUrl`"); sb.AppendLine(" , `ChannelName`"); sb.AppendLine(" , `WriterName`"); sb.AppendLine(" , `WriterMail`"); sb.AppendLine(" , `WriteTime`"); sb.AppendLine(" , `WriterId`"); sb.AppendLine(" , `Message`"); sb.AppendLine(") "); sb.AppendLine("VALUES ( "); sb.AppendLine(" @ThreadUrl"); sb.AppendLine(" , @ResNo"); sb.AppendLine(" , @ImageUrl"); sb.AppendLine(" , @ChannelName"); sb.AppendLine(" , @WriterName"); sb.AppendLine(" , @WriterMail"); sb.AppendLine(" , @WriteTime"); sb.AppendLine(" , @WriterId"); sb.AppendLine(" , @Message"); sb.AppendLine(") "); sb.AppendLine("ON DUPLICATE KEY UPDATE ImageUrl = @ImageUrl"); Dictionary<string, string> paramDic = new Dictionary<string, string>(); paramDic["ThreadUrl"] = threadUrl; paramDic["ResNo"] = res.ResNo; paramDic["ImageUrl"] = imageUrl; paramDic["ChannelName"] = channelName; paramDic["WriterName"] = res.Name; paramDic["WriterMail"] = res.Mail; paramDic["WriteTime"] = res.Date; paramDic["WriterId"] = res.Id; paramDic["Message"] = res.Message; DBUtil.Update(sb.ToString(), paramDic); }
//------------------------------------------------------------- // 概要:スレッドデータ解析 // 詳細:datからレス一覧情報を作成する //------------------------------------------------------------- protected override List<ResInfo> AnalyzeDatText(string[] lines, bool isHtmlDecode) { Logger.Instance.DebugFormat("AnalyzeDatText(isHtmlDecode:{0})", isHtmlDecode); List<ResInfo> resList = new List<ResInfo>(); foreach (var line in lines.Select((v, i) => new { v, i })) { if (String.IsNullOrEmpty(line.v)) continue; String[] data = line.v.Split(new[] { "<>" }, StringSplitOptions.None); string mail = data[(int)DatIndex.Mail]; string message = data[(int)DatIndex.Message]; string name = data[(int)DatIndex.Name]; ResInfo resInfo = new ResInfo { ResNo = (line.i + 1).ToString(), Date = data[(int)DatIndex.DateAndId], Id = "", // TODO IDを取得する Mail = isHtmlDecode ? HttpUtility.HtmlDecode(mail) : mail, Message = isHtmlDecode ? HttpUtility.HtmlDecode(message) : message, Name = isHtmlDecode ? HttpUtility.HtmlDecode(name) : name, }; resList.Add(resInfo); } return resList; }
/// <summary> /// レスHTMLの作成 /// </summary> /// <param name="res"></param> /// <returns></returns> private string CreateResHtml(ResInfo res) { string html = ""; // 折り返し if (!ViewerSettings.NoBR) { html += "<nobr>"; } // レス番号 html += "<b><u><font color=#0000FF>" + ResNum + "</font></u></b>"; html += "<font color=#999999>"; html += " : "; // 名前 [ html += "<font color=#228B22>" + res.Name + "</font> "; // メール欄 if (res.Mail == "") { html += "[] "; } else if (res.Mail == "sage") { html += "[sage] "; } else if (res.Mail == "age") { html += "<font color = red>[age]</font> "; } else { html += "<font color = blue>[" + res.Mail + "]</font> "; } // ]日付 html += res.Date; // ID if (res.Id != "") { html += @" <font color=""blue"">ID:"; // 折り返し if (!ViewerSettings.NoBR) { html += "<nobr>"; } html += "</font><ID>" + res.Id + "</ID></nobr>"; } html += "</font><br><ul>"; // 本文 html += res.Message; // ドキュメントに追加 DocumentText += html + "</ul><hr></nobr>\n"; html = html.Replace(">", ">"); html = html.Replace("<br>", "\n"); // タグ除去 Regex regex = new Regex("<.*?>", RegexOptions.Singleline); html = regex.Replace(html, ""); return html; }