/// <summary> /// オフラインでスレッドを取得します /// </summary> /// <returns>取得したデータ</returns> public string OfflineGetResponse() { string fileDirectory = gs.DatFilePath + "\\" + datFolder; if (!System.IO.Directory.Exists(fileDirectory)) { System.IO.Directory.CreateDirectory(fileDirectory); } string filePath = fileDirectory + "\\" + datKey; Regex re = new Regex(@"(?<name>.*)<>(?<mail>.*)<>(?<date>.*?)((?<ID>ID:.*?|発信元:.*?|HOST:.*?|))(?<BE>BE:.*?)?<>(?<sentence>.*)<>(?<threadName>.*)\n", RegexOptions.Compiled); string data = Utility.TextUtility.Read(filePath + ".dat"); //System.IO.FileInfo fi = new System.IO.FileInfo(filePath + ".dat"); long size = Encoding.GetEncoding("Shift-JIS").GetByteCount(data); string byteCount = Chron.Calture.DatSizeFormat(size, 1); var result = base.GetResponse(data, re, readCgiUrl); this.resSets = base.ResSets; Chron.ThreadOrResData.ThreadData td = new Chron.ThreadOrResData.ThreadData(); td.ThisBBS = VIPBrowserLibrary.Common.BBSType._2ch; if (System.IO.File.Exists(filePath + ".xml")) { td = Chron.ThreadOrResData.ThreadDataWriterAndReader.Read(filePath + ".xml"); td.ThreadKey = datKey; td.ThreadAddress = GetUrl; td.DatSize = byteCount; td.ThreadName = threadName = base.ThreadName; td.GetRescount = base.ResCount; td.ThisFilePath = filePath; td.DatByte = (int)size; this.threadInfo = td; } else { td.ThreadKey = datKey; td.ThreadAddress = GetUrl; td.DatSize = byteCount; td.ThreadName = threadName = base.ThreadName; td.GetRescount = base.ResCount; td.ThisFilePath = filePath; this.threadInfo = td; td.DatByte = (int)size; } return(result); }
/// <summary> /// オフラインでスレを取得します /// </summary> /// <returns>取得したデータ</returns> public string OfflineGetResponse() { string fileDirectory = gs.DatFilePath + "\\" + datFolder; if (!System.IO.Directory.Exists(fileDirectory)) { System.IO.Directory.CreateDirectory(fileDirectory); } string filePath = fileDirectory + "\\" + datKey; string data = Utility.TextUtility.Read(filePath + ".cgi"); long size = Encoding.GetEncoding("EUC-JP").GetByteCount(data); string byteCount = Chron.Calture.DatSizeFormat(size, 1); var result = base.GetResponse(data, new Regex(@"\d{1,6}<>(?<name>.*)<>(?<mail>.*)<>(?<date>.*)<>(?<sentence>.+)<>(?<threadName>.*)<>(?<ID>.*)\n", RegexOptions.Compiled), readCgiUrl); this.resSets = base.ResSets; Chron.ThreadOrResData.ThreadData td = new Chron.ThreadOrResData.ThreadData(); td.ThisBBS = VIPBrowserLibrary.Common.BBSType.jbbs; if (System.IO.File.Exists(filePath + ".xml")) { td = Chron.ThreadOrResData.ThreadDataWriterAndReader.Read(filePath + ".xml"); td.ThreadKey = datKey; td.ThreadAddress = GetUrl; td.DatSize = byteCount; td.ThreadName = threadName = base.ThreadName; td.GetRescount = base.ResCount; td.ThisFilePath = filePath; this.threadInfo = td; } else { td.ThreadKey = datKey; td.ThreadAddress = GetUrl; td.DatSize = byteCount; td.ThreadName = threadName = base.ThreadName; td.GetRescount = base.ResCount; td.ThisFilePath = filePath; this.threadInfo = td; } return(result); }
/// <summary> /// スレッドのデータをダウンロードしてをHTML形式に変換します /// </summary> /// <returns>変換されたスレッドのHTML</returns> public async Task <string> GetResponse() { string fileDirectory = gs.DatFilePath + "\\" + datFolder; if (!System.IO.Directory.Exists(fileDirectory)) { System.IO.Directory.CreateDirectory(fileDirectory); } string filePath = fileDirectory + "\\" + datKey; string data = String.Empty; if (!GetUrl.Contains(gs.DatFilePath)) { Common.HttpClient hc = new Common.HttpClient(GetUrl); hc.Encoding = "EUC-JP"; data = await hc.GetStringAsync(); Utility.TextUtility.Write(filePath + ".cgi", data, false); //System.IO.FileInfo fi = new System.IO.FileInfo(filePath + ".cgi"); } else { data = System.IO.File.ReadAllText(GetUrl, Encoding.GetEncoding("Shift-JIS")); } long size = Encoding.GetEncoding("EUC-JP").GetByteCount(data); string byteCount = Chron.Calture.DatSizeFormat(size, 1); var result = await AwaitSet.Awaitable <string> .Run(() => { return(base.GetResponse(data, new Regex(@"\d{1,6}<>(?<name>.*)<>(?<mail>.*)<>(?<date>.*)<>(?<sentence>.+)<>(?<threadName>.*)<>(?<ID>.*)\n", RegexOptions.Compiled), readCgiUrl, this.IsOutHtml)); }); this.resSets = base.ResSets; Chron.ThreadOrResData.ThreadData td = new Chron.ThreadOrResData.ThreadData(); td.ThisBBS = VIPBrowserLibrary.Common.BBSType.jbbs; if (System.IO.File.Exists(filePath + ".xml")) { td = Chron.ThreadOrResData.ThreadDataWriterAndReader.Read(filePath + ".xml"); td.ThreadKey = datKey; td.ThreadAddress = GetUrl; td.DatSize = byteCount; td.ThreadName = threadName = base.ThreadName; td.GetRescount = base.ResCount; td.ThisFilePath = filePath; this.threadInfo = td; } else { td.ThreadKey = datKey; td.ThreadAddress = GetUrl; td.DatSize = byteCount; td.ThreadName = threadName = base.ThreadName; td.GetRescount = base.ResCount; td.ThisFilePath = filePath; this.threadInfo = td; } Chron.ThreadOrResData.ThreadDataWriterAndReader.Write(td, filePath + ".xml"); return(result); }
/// <summary> /// このスレッドを取得して変換します /// </summary> /// <returns>変換したスレッドのUrl</returns> public async Task <string> GetResponse() { int range = 0; string fileDirectory = gs.DatFilePath + "\\" + datFolder; if (!System.IO.Directory.Exists(fileDirectory)) { System.IO.Directory.CreateDirectory(fileDirectory); } string filePath = fileDirectory + "\\" + datKey; bool isRefresh = System.IO.File.Exists(filePath + ".dat"); if (isRefresh) { Chron.ThreadOrResData.ThreadData tdd = Chron.ThreadOrResData.ThreadDataWriterAndReader.Read(filePath + ".xml"); if (!tdd.IsNullObject()) { range = tdd.DatByte; } } Common.HttpClient hc = null; long size = 0; string data = String.Empty; string etag = String.Empty; if (!GetUrl.Contains(gs.DatFilePath)) { hc = new Common.HttpClient(GetUrl); hc.UserAgent = "Monazilla/1.00(VIPBrowser ver 0.0.0.3)"; if (!isRefresh) { data = await hc.GetStringAsync(); } else { data = Utility.TextUtility.Read(filePath + ".dat", Encoding.GetEncoding("Shift-JIS")); hc.Range = range - 1; size = range; string get = await hc.GetStringAsync(); System.Net.HttpStatusCode hsc = hc.RequestStatusCode; switch (hsc) { case System.Net.HttpStatusCode.PartialContent: data += get; isRefresh = false; break; case System.Net.HttpStatusCode.NotModified: //size += 10; break; case System.Net.HttpStatusCode.RequestedRangeNotSatisfiable: hc.Range = 0; size = 0; data = await hc.GetStringAsync(); isRefresh = false; break; default: break; } etag = hc.Headers["ETag"]; } } else { data = System.IO.File.ReadAllText(GetUrl, Encoding.GetEncoding("Shift-JIS")); } Regex re = new Regex(@"(?<name>.*)<>(?<mail>.*)<>(?<date>.*?)((?<ID>ID:.*?|発信元:.*?|HOST:.*?|))(?<BE>BE:.*?)?<>(?<sentence>.*)<>(?<threadName>.*)\n", RegexOptions.Compiled); Utility.TextUtility.Write(filePath + ".dat", data, false); //System.IO.FileInfo fi = new System.IO.FileInfo(filePath + ".dat"); if (!isRefresh) { size = Encoding.GetEncoding("Shift-JIS").GetByteCount(data); } string byteCount = Chron.Calture.DatSizeFormat(size, 1); var result = await AwaitSet.Awaitable <string> .Run(() => { return(base.GetResponse(data, re, readCgiUrl, this.IsOutHtml)); }); if (result == null && (GetUrl.Contains(".2ch.net") || GetUrl.Contains(".bbspink.com")) && !GetUrl.Contains(gs.DatFilePath)) { //offlaw2.soによる過去ログスレ取得予定 hc = new Common.HttpClient(VIPBrowserLibrary.Common.URLParse.ReadcgiToOfflaw2(readCgiUrl)); hc.Referer = readCgiUrl; data = await hc.GetStringAsync(); result = await AwaitSet.Awaitable <string> .Run(() => { return(base.GetResponse(data, re, readCgiUrl)); }); result += "<br><center>---このスレは過去ログ化されています---</center>"; } this.resSets = base.ResSets; Chron.ThreadOrResData.ThreadData td = new Chron.ThreadOrResData.ThreadData(); td.ThisBBS = VIPBrowserLibrary.Common.BBSType._2ch; if (System.IO.File.Exists(filePath + ".xml")) { td = Chron.ThreadOrResData.ThreadDataWriterAndReader.Read(filePath + ".xml"); td.ThreadKey = datKey; td.ThreadAddress = GetUrl; td.DatSize = byteCount; td.ThreadName = threadName = base.ThreadName; td.GetRescount = base.ResCount; td.ThisFilePath = filePath; td.DatByte = (int)size; this.threadInfo = td; } else { td.ThreadKey = datKey; td.ThreadAddress = GetUrl; td.DatSize = byteCount; td.ThreadName = threadName = base.ThreadName; td.GetRescount = base.ResCount; td.ThisFilePath = filePath; this.threadInfo = td; td.DatByte = (int)size; } td.ETag = etag; Chron.ThreadOrResData.ThreadDataWriterAndReader.Write(td, filePath + ".xml"); return(result); }
/// <summary> /// 指定したホストに向けてデータを送信します /// </summary> /// <param name="post">送信するデータ</param> /// <param name="isThread">スレ立てかどうか</param> /// <returns>成功したらtrue,失敗したらfalse</returns> /// <param name="td">送信するスレッドのデータ</param> public async Task <bool> Post2ch(Dictionary <string, string> post, bool isThread, Chron.ThreadOrResData.ThreadData td) { // SambaCheck var v = await base.CheckSamba(hostAddress.Replace("test/bbs.cgi", "") + post["bbs"] + "/"); if (!((bool)v[0])) { System.Windows.Forms.MessageBox.Show("Please wait " + (((TimeSpan)(v[1])).TotalSeconds.ToString()) + " seconds.", "Samba24 warning"); return(false); } //ここっていらないよね System.Text.RegularExpressions.Match m = new System.Text.RegularExpressions.Regex("http://(?<host>.+)/.+/bbs.cgi", System.Text.RegularExpressions.RegexOptions.Compiled).Match(hostAddress); hostAddress = String.Format("http://{0}/test/bbs.cgi", m.Groups["host"].Value); bool isCan = false; StringBuilder postStringBuilder = new StringBuilder().Clear(); foreach (var item in post) { postStringBuilder.Append(item.Key).Append("=").Append(item.Value).Append("&"); } string poststr = postStringBuilder.ToString(); bool firstPost = false; while (true) { hc = new HttpClient(hostAddress); hc.Host = hostAddress.Trim('/').Replace("http://", "").Replace("bbs.cgi", ""); hc.IsReadCookieFromHost = true; if (!isThread) { hc.Referer = String.Format("{0}read.cgi/{1}/{2}", hostAddress.Replace("bbs.cgi", ""), post["bbs"], post["key"]); } else { hc.Referer = String.Format("{0}/{1}", hostAddress.Replace("test/bbs.cgi", ""), post["bbs"]); } if (!isThread) { poststr = firstPost ? poststr + "submit=上記全てを承諾して書き込む" : poststr + "submit=書き込む"; } else { poststr = firstPost ? poststr + "submit=上記全てを承諾して書き込む" : poststr + "submit=新規スレッド作成"; } poststr = this.RoninProcesing(poststr); string res = await hc.PostStringAsync(poststr); string hidden = String.Empty; if (res.IndexOf("<!-- 2ch_X:cookie -->") != -1) { if (hostAddress.IndexOf("2ch.net") != -1 || hostAddress.IndexOf("bbspink.com") != -1) { ResponseParse(res, out hidden); firstPost = true; string[] hiddencookie = hidden.Split('='); System.Net.CookieCollection cc = new System.Net.CookieCollection(); cc.Add(new System.Net.Cookie(hiddencookie[0], hiddencookie[1], "/", hostAddress.Replace("/test/bbs.cgi", "").Replace("http://", ""))); HttpClient.CookieManagement.WriteCookieToDisk(cc); } if (System.Windows.Forms.DialogResult.No == System.Windows.Forms.MessageBox.Show(WarningText, "投稿確認", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Information)) { isCan = false; break; } } else if (res.IndexOf("書きこみました。") != -1) { isCan = true; base.WriteRecords(post, td); base.WriteSamba(hostAddress.Replace("test/bbs.cgi", "") + post["bbs"] + "/"); break; } else { System.Windows.Forms.Form f = new System.Windows.Forms.Form(); System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser(); wb.Dock = System.Windows.Forms.DockStyle.Fill; wb.DocumentText = res; f.Controls.Add(wb); f.Width = 250; f.Show(); isCan = false; break; } hc = null; poststr = poststr.Replace("submit=書き込む", "").Replace("submit=上記全てを承諾して書き込む", "").Replace("submit=新規スレッド作成", ""); } return(isCan); }
/// <summary> /// レスをしたらばに送信します /// </summary> /// <param name="postData">送信するデータを収めたDictionary<string,string></param> /// <param name="isThread">スレッドである場合はtrue,レスである場合はfalse</param> /// <param name="td">スレッドの情報</param> /// <returns>成功の可否</returns> public async Task <bool> PostJbbs(Dictionary <string, string> postData, bool isThread, Chron.ThreadOrResData.ThreadData td) { hc = new Common.HttpClient(hostAddress); bool isCan = false; hc.Encoding = "EUC-JP"; hc.Host = "jbbs.livedoor.jp"; hc.IsReadCookieFromHost = true; if (!isThread) { hc.Referer = "http://jbbs.shitaraba.net/bbs/read.cgi/" + postData["DIR"] + "/" + postData["BBS"] + "/" + postData["KEY"] + "/"; } else { hc.Referer = "http://jbbs.shitaraba.net/" + postData["DIR"] + "/" + postData["BBS"] + "/"; } StringBuilder sb = new StringBuilder(); foreach (KeyValuePair <string, string> item in postData) { sb.Append(item.Key); sb.Append("="); sb.Append(item.Value); sb.Append("&"); } if (isThread) { sb.Append("submit=新規スレッド作成"); } else { sb.Append("submit=書き込む"); } string postString = sb.ToString().TrimEnd('&'); string data = await hc.PostStringAsync(postString); if (data.Contains("書きこみました。")) { base.WriteRecords(postData, td); return(isCan = true); } return(isCan); }
/// <summary> /// オフラインでスレッド一覧を取得し、listViewItem[]形式に変換します /// </summary> /// <param name="re">変換に用いるRegex</param> /// <param name="url">取得先のURL</param> /// <returns>スレッド一覧を格納したListViewItem</returns> protected virtual async Task <ListViewItem[]> ParseThreadList(Regex re, string url) { VIPBrowserLibrary.Common.BBSType bt; string datNameBase = String.Empty; bt = VIPBrowserLibrary.Common.TypeJudgment.BBSTypeJudg(url); Encoding enc; Setting.GeneralSetting gs = new Setting.GeneralSetting(); ListViewItem[] liCollection = null; try { string folder = String.Empty; string address = url.Replace("http://", "").TrimEnd('/'); if (address.IndexOf("jbbs.livedoor.jp") == -1 && address.IndexOf("jbbs.shitaraba.net") == -1) { string[] filePath = address.Split('/'); folder = gs.DatFilePath + "\\" + filePath[0] + "-" + filePath[1]; enc = Encoding.GetEncoding("Shift-JIS"); bt = VIPBrowserLibrary.Common.BBSType._2ch; datNameBase = url + "dat/"; } else { address = address.Replace("jbbs.livedoor.jp", "").Replace("jbbs.shitaraba.net", "").TrimStart('/').Replace('/', '-'); folder = gs.DatFilePath + "\\jbbs-" + address; enc = Encoding.GetEncoding("EUC-JP"); bt = VIPBrowserLibrary.Common.BBSType.jbbs; Match m = new Regex(@"http://jbbs.(shitaraba.net|livedoor.jp)/(?<category>.+)/(?<number>\d+)/?").Match(url); datNameBase = String.Concat("http://jbbs.shitaraba.net/bbs/rawmode.cgi/", m.Groups["category"].Value, "/", m.Groups["number"].Value, "/"); } string getData = Utility.TextUtility.Read(folder + "\\subject.txt", enc); MatchCollection mc = re.Matches(getData); liCollection = new ListViewItem[mc.Count]; int i = 1; foreach (Match item in mc) { Chron.ThreadOrResData.ThreadData td = Chron.ThreadOrResData.ThreadDataWriterAndReader.Read(folder + "\\" + item.Groups["datName"].Value + ".xml"); //Console.WriteLine(item.Groups["threadTitle"].Value); Console.WriteLine(item.Groups["datName"].Value); Console.WriteLine(item.Groups["resCount"].Value); ListViewItem li = null; DateTime dt = Chron.Calture.UnixTimeToDateTime(item.Groups["datName"].Value); //if (!dt.IsNullObject()) //{ // li = new ListViewItem(new string[] //{ // (i++).ToString(), // Utility.StringUtility.HTMLDecode(item.Groups["threadTitle"].Value), // item.Groups["resCount"].Value, // dt.ToString(), // Chron.Calture.ThreadAuthority(dt,item.Groups["resCount"].Value).ToString(), // td.DatSize //}); //} //else //{ // li = new ListViewItem(new string[] //{ // (i++).ToString(), // Utility.StringUtility.HTMLDecode(item.Groups["threadTitle"].Value), // item.Groups["resCount"].Value, // dt.ToString(), // Chron.Calture.ThreadAuthority(dt,item.Groups["resCount"].Value).ToString(), // td.DatSize //}); //} Chron.ThreadOrResData.ThreadListItemColorRing cl = new Chron.ThreadOrResData.ThreadListItemColorRing(folder + "\\subject.txt"); bool isColorring = cl.IsNull; Chron.ThreadOrResData.Abone.ThreadListAbone tla = new Chron.ThreadOrResData.Abone.ThreadListAbone(); tla.InstLoad(); string resCount = item.Groups["resCount"].Value; if (td == null) { //li = new ListViewItem(new string[] //{ // " ", // (i++).ToString(), // Utility.StringUtility.HTMLDecode(item.Groups["threadTitle"].Value), // resCount, // dt.ToString(), // Chron.Calture.ThreadAuthority(dt,resCount).ToString(), // "0", // "0", // "0" //}); #region やっつけで書いた、後悔はしていない Sub read = new Sub(); read.Text = " "; read.Name = "IsRead"; Sub count = new Sub(); count.Text = i.ToString(); count.Name = "Count"; Sub name = new Sub(); name.Text = Utility.StringUtility.HTMLDecode(item.Groups["threadTitle"].Value); name.Name = "Name"; Sub res = new Sub(); res.Text = resCount.ToString(); res.Name = "ResCount"; Sub time = new Sub(); time.Text = dt.ToString(); time.Name = "Time"; Sub speed = new Sub(); speed.Text = Chron.Calture.ThreadAuthority(dt, resCount).ToString(); speed.Name = "Speed"; Sub size = new Sub(); size.Text = ""; size.Name = "Size"; Sub oldRes = new Sub(); oldRes.Text = ""; oldRes.Name = "OldResCount"; Sub newRes = new Sub(); newRes.Text = ""; newRes.Name = "NewResCount"; li = new ListViewItem(new Sub[] { read, count, name, res, time, speed, size, oldRes, newRes }, ""); #endregion } else { int newRes = (resCount.Parse() - (td.GetRescount - 1)); string isNewState = String.Empty; if (newRes == 0) { isNewState = "○"; } else { isNewState = "●"; } //li = new ListViewItem(new string[] //{ // isNewState, // (i++).ToString(), // Utility.StringUtility.HTMLDecode(item.Groups["threadTitle"].Value), // resCount, // dt.ToString(), // Chron.Calture.ThreadAuthority(dt,resCount).ToString(), // td.DatSize, // (td.GetRescount - 1).ToString(), // newRes.ToString() //}); #region やっつけで書いた、後悔はしていない Sub read = new Sub(); read.Text = isNewState; read.Name = "IsRead"; Sub count = new Sub(); count.Text = i.ToString(); count.Name = "Count"; Sub name = new Sub(); name.Text = Utility.StringUtility.HTMLDecode(item.Groups["threadTitle"].Value); name.Name = "Name"; Sub res = new Sub(); res.Text = resCount.ToString(); res.Name = "ResCount"; Sub time = new Sub(); time.Text = dt.ToString(); time.Name = "Time"; Sub speed = new Sub(); speed.Text = Chron.Calture.ThreadAuthority(dt, resCount).ToString(); speed.Name = "Speed"; Sub size = new Sub(); size.Text = td.DatSize; size.Name = "Size"; Sub oldRes = new Sub(); oldRes.Text = (td.GetRescount - 1).ToString(); oldRes.Name = "OldResCount"; Sub newRess = new Sub(); newRess.Text = newRes.ToString(); newRess.Name = "NewResCount"; li = new ListViewItem(new Sub[] { read, count, name, res, time, speed, size, oldRes, newRess }, ""); #endregion } if (!isColorring) { li = cl.ChangeColor(li); } if (tla.IsVisible(li.SubItems["Name"].Text)) { string datName = item.Groups["datName"].Value; li = cl.ChangeAlreadyListColor(li, datName); liCollection[i - 1] = li; if (bt == VIPBrowserLibrary.Common.BBSType._2ch) { liCollection[i - 1].ImageKey = datNameBase + datName + ".dat"; } else { liCollection[i - 1].ImageKey = datNameBase + datName; } } //liCollection[i - 2] = li; //if (bt == VIPBrowserLibrary.Common.BBSType._2ch) // liCollection[i - 2].ImageKey = datNameBase + item.Groups["datName"].Value + ".dat"; //else // liCollection[i - 2].ImageKey = datNameBase + item.Groups["datName"].Value; i++; } Chron.ThreadColumn tc = new Chron.ThreadColumn(); tc.ReadColumnData(gs.NotNecessarySettingDataPath + "\\column.dat"); return(tc.ConvertToColumnBaseItem(liCollection)); } catch { throw; } }
/// <summary> /// スレッド一覧を取得し、ListViewItem[]形式に変換します。 /// </summary> /// <param name="re">変換に用いるRegex</param> /// <param name="url">取得先のURL</param> /// <param name="hc">取得に用いる、HttpClientクラス</param> /// <returns>スレッド一覧を格納したListViewItem[]</returns> protected virtual async Task <System.Windows.Forms.ListViewItem[]> ParseThreadList(Regex re, string url, Common.HttpClient hc) { VIPBrowserLibrary.Common.BBSType bt; string datNameBase = String.Empty; Chron.ThreadOrResData.Abone.ThreadListAbone tla = new Chron.ThreadOrResData.Abone.ThreadListAbone(); tla.InstLoad(); Encoding enc; Setting.GeneralSetting gs = new Setting.GeneralSetting(); ListViewItem[] liCollection = null; try { string folder = String.Empty; string address = url.Replace("http://", "").TrimEnd('/'); if (address.IndexOf("jbbs.livedoor.jp") == -1 && address.IndexOf("jbbs.shitaraba.net") == -1) { string[] filePath = address.Split('/'); folder = gs.DatFilePath + "\\" + filePath[0] + "-" + filePath[1]; enc = Encoding.GetEncoding("Shift-JIS"); if (!address.Contains("machi.to")) { bt = VIPBrowserLibrary.Common.BBSType._2ch; datNameBase = url + "dat/"; } else { bt = VIPBrowserLibrary.Common.BBSType.machibbs; Match m = Regex.Match(url, @"http://(?<host>\w+)[.]machi[.]to/(?<folder>\w+)/?", RegexOptions.Compiled); datNameBase = "http://" + m.Groups["host"].Value + ".machi.to/bbs/offlaw.cgi/" + m.Groups["folder"].Value + "/"; hc.Host = m.Groups["host"].Value + ".machi.to"; } } else { address = address.Replace("jbbs.livedoor.jp", "").Replace("jbbs.shitaraba.net", "").TrimStart('/').Replace('/', '-'); folder = gs.DatFilePath + "\\" + "jbbs-" + address; enc = Encoding.GetEncoding("EUC-JP"); bt = VIPBrowserLibrary.Common.BBSType.jbbs; Match m = new Regex(@"http://jbbs.(shitaraba.net|livedoor.jp)/(?<category>.+)/(?<number>\d+)/").Match(url); datNameBase = String.Concat("http://jbbs.shitaraba.net/bbs/rawmode.cgi/", m.Groups["category"].Value, "/", m.Groups["number"].Value, "/"); } string getData = await hc.GetStringAsync(); if (!System.IO.Directory.Exists(folder)) { System.IO.Directory.CreateDirectory(folder); } MatchCollection mc = re.Matches(getData); liCollection = new ListViewItem[mc.Count]; int i = 1; Chron.ThreadOrResData.ThreadListItemColorRing cl = new Chron.ThreadOrResData.ThreadListItemColorRing(folder + "\\subject.txt"); bool isColorring = cl.IsNull; foreach (Match item in mc) { Chron.ThreadOrResData.ThreadData td = Chron.ThreadOrResData.ThreadDataWriterAndReader.Read(folder + "\\" + item.Groups["datName"].Value + ".xml"); //Console.WriteLine(item.Groups["threadTitle"].Value); Console.WriteLine(item.Groups["datName"].Value); Console.WriteLine(item.Groups["resCount"].Value); ListViewItem li = null; DateTime dt = Chron.Calture.UnixTimeToDateTime(item.Groups["datName"].Value); string resCount = item.Groups["resCount"].Value; if (td == null) { //li = new ListViewItem(new string[] //{ // " ", // (i++).ToString(), // Utility.StringUtility.HTMLDecode(item.Groups["threadTitle"].Value), // resCount, // dt.ToString(), // Chron.Calture.ThreadAuthority(dt,resCount).ToString(), // "0", // "0", // "0" //}); #region やっつけで書いた、後悔はしていない Sub read = new Sub(); read.Text = " "; read.Name = "IsRead"; Sub count = new Sub(); count.Text = i.ToString(); count.Name = "Count"; Sub name = new Sub(); name.Text = Utility.StringUtility.HTMLDecode(item.Groups["threadTitle"].Value); name.Name = "Name"; Sub res = new Sub(); res.Text = resCount.ToString(); res.Name = "ResCount"; Sub time = new Sub(); time.Text = dt.ToString(); time.Name = "Time"; Sub speed = new Sub(); speed.Text = Chron.Calture.ThreadAuthority(dt, resCount).ToString(); speed.Name = "Speed"; Sub size = new Sub(); size.Text = ""; size.Name = "Size"; Sub oldRes = new Sub(); oldRes.Text = ""; oldRes.Name = "OldResCount"; Sub newRes = new Sub(); newRes.Text = ""; newRes.Name = "NewResCount"; li = new ListViewItem(new Sub[] { read, count, name, res, time, speed, size, oldRes, newRes }, ""); #endregion } else { int newRes = (resCount.Parse() - (td.GetRescount - 1)); string isNewState = String.Empty; if (newRes == 0) { isNewState = "○"; } else { isNewState = "●"; } //li = new ListViewItem(new string[] //{ // isNewState, // (i++).ToString(), // Utility.StringUtility.HTMLDecode(item.Groups["threadTitle"].Value), // resCount, // dt.ToString(), // Chron.Calture.ThreadAuthority(dt,resCount).ToString(), // td.DatSize, // (td.GetRescount - 1).ToString(), // newRes.ToString() //}); #region やっつけで書いた、後悔はしていない Sub read = new Sub(); read.Text = isNewState; read.Name = "IsRead"; Sub count = new Sub(); count.Text = i.ToString(); count.Name = "Count"; Sub name = new Sub(); name.Text = Utility.StringUtility.HTMLDecode(item.Groups["threadTitle"].Value); name.Name = "Name"; Sub res = new Sub(); res.Text = resCount.ToString(); res.Name = "ResCount"; Sub time = new Sub(); time.Text = dt.ToString(); time.Name = "Time"; Sub speed = new Sub(); speed.Text = Chron.Calture.ThreadAuthority(dt, resCount).ToString(); speed.Name = "Speed"; Sub size = new Sub(); size.Text = td.DatSize; size.Name = "Size"; Sub oldRes = new Sub(); oldRes.Text = (td.GetRescount - 1).ToString(); oldRes.Name = "OldResCount"; Sub newRess = new Sub(); newRess.Text = newRes.ToString(); newRess.Name = "NewResCount"; li = new ListViewItem(new Sub[] { read, count, name, res, time, speed, size, oldRes, newRess }, ""); #endregion } if (!isColorring) { li = cl.ChangeColor(li); } if (tla.IsVisible(li.SubItems["Name"].Text)) { string datName = item.Groups["datName"].Value; li = cl.ChangeAlreadyListColor(li, datName); liCollection[i - 1] = li; if (bt == VIPBrowserLibrary.Common.BBSType._2ch) { liCollection[i - 1].ImageKey = datNameBase + datName + ".dat"; } else { liCollection[i - 1].ImageKey = datNameBase + datName; } } i++; } await Utility.TextUtility.WriteAsync(folder + "\\subject.txt", getData, enc, false); Chron.ThreadColumn tc = new Chron.ThreadColumn(); tc.ReadColumnData(gs.NotNecessarySettingDataPath + "\\column.dat"); return(tc.ConvertToColumnBaseItem(liCollection)); //return liCollection; } catch (ArgumentNullException) { return(null); } catch (IndexOutOfRangeException e) { throw new System.Net.WebException("配列の対象外:CommonThreadReader行231", e); } catch (Exception) { throw; } }