private void LoadData() { AboneManagement am = new AboneManagement(); am.InstLoad(); foreach (NGWord n in am.NGCollection) { string word = String.Empty; if (n.IsRegex) { word = n.RegexWord.ToString(); } else { word = n.Word; } ListViewItem lvi = new ListViewItem(new string[] { n.AboneTypes.ToString(), word, n.IsRegex.ToString(), n.Url, n.SetTime.ToString(), n.ReleaseTime.ToString() }); lvi.Tag = n; listView1.Items.Add(lvi); } }
private async void SaveData() { AboneManagement am = new AboneManagement(); List <NGWord> ngs = new List <NGWord>(); foreach (ListViewItem i in listView1.Items) { NGWord nw; bool isReg = false; AboneType type = (AboneType)Enum.Parse(typeof(AboneType), i.SubItems[0].Text); if (i.SubItems[2].Text == "True") { isReg = true; } if (isReg) { nw = new NGWord(new Regex(i.SubItems[1].Text, RegexOptions.Compiled), type, i.SubItems[3].Text, DateTime.Parse(i.SubItems[4].Text), TimeSpan.Parse(i.SubItems[5].Text)); } else { nw = new NGWord(i.SubItems[1].Text, type, i.SubItems[3].Text, DateTime.Parse(i.SubItems[4].Text), TimeSpan.Parse(i.SubItems[5].Text)); } ngs.Add(nw); } am.NGCollection = ngs; await am.InstSave(); }
/// <summary> /// 指定された正規表現を用いてdatを変換します /// </summary> /// <param name="dat">変換するdat</param> /// <param name="re">使用する正規表現</param> /// <returns>変換後のHTMLデータ</returns> /// <param name="url">読み込み先のアドレス</param> /// <param name="isOutHtml">Htmlを出力する表します</param> protected string GetResponse(string dat, Regex re, string url, bool isOutHtml = true) { try { //SimpleAbone sa = new SimpleAbone(); //sa.InstLoad(); AboneManagement am = new AboneManagement(); am.InstLoad(); var settingData = new Setting.Serializer().Deserilize(); base.LoadSkin(settingData.UsingSkinPath); int resCount = 1; int count = 0; MatchCollection mc = re.Matches(dat); int mcount = mc.Count; Dictionary <string, int[]> IDCollection = new Dictionary <string, int[]>(); Res[] r = new Res[mcount]; if (mc.Count <= 0) { return(null); } threadName = mc[0].Groups["threadName"].Value; StringBuilder resData = new StringBuilder().Append(base.AddHeader(threadName)); //foreach (Match m in mc) //{ // string id = m.Groups["ID"].Value; // if (IDCollection.ContainsKey(id)) // { // IDCollection[id][1]++; // } // else // { // IDCollection.Add(id, new int[] { 0, 1 }); // } //} for (int i = 0; i < mcount; i++) { string id = mc[i].Groups["ID"].Value; if (IDCollection.ContainsKey(id)) { IDCollection[id][1]++; } else { IDCollection.Add(id, new int[] { 0, 1 }); } } foreach (Match m in mc) { r[count] = new Res(resCount, m.Groups["name"].Value, m.Groups["mail"].Value, m.Groups["sentence"].Value, m.Groups["ID"].Value, m.Groups["date"].Value, m.Groups["BE"].Value, true); count++; resCount++; } if (isOutHtml) { if (settingData.IsMultiThreading) { SortedDictionary <int, string> str = new SortedDictionary <int, string>(); Parallel.For(0, r.Length, (d) => { string id = r[d].ID; IDCollection[id][0] = IDCollection[id][0] + 1; r[d].Visible = am.IsVisible(r[d], url); Res rs = new Res(); string datra = base.SimpleConvertCore(r[d], IDCollection, out rs); lock (this) { str.Add(r[d].Index, datra); } r[d] = rs; }); foreach (var item in str) { resData.Append(item.Value); } } else { for (int i = 0; i < r.Length; i++) { string id = r[i].ID; IDCollection[id][0] = IDCollection[id][0] + 1; //r[i].Visible = sa.IsVisible(r[i]); r[i].Visible = am.IsVisible(r[i], url); Res rs = new Res(); resData.Append(base.SimpleConvertCore(r[i], IDCollection, out rs)); r[i] = rs; } } } else { for (int i = 0; i < r.Length; i++) { string id = r[i].ID; IDCollection[id][0] = IDCollection[id][0] + 1; r[i].Visible = am.IsVisible(r[i], url); } } this.IdCollection = IDCollection; this.resCount = resCount; this.resSets = r; return(resData.ToString()); } catch (ArgumentOutOfRangeException) { return(null); } }