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> /// NGWordに必要な条件を設定して初期化します /// </summary> /// <param name="word">設定するNGWord</param> /// <param name="url">利用先のURL</param> /// <param name="setTime">設定した時間</param> /// <param name="releaseTime">設定を解除する時間</param> /// <param name="ab">設定するNGWordのあぼーんタイプ</param> public NGWord(string word, AboneType ab, string url, DateTime setTime, TimeSpan releaseTime) { this.word = word; this.url = url; this.setTime = setTime; this.releaseTime = releaseTime; this.isRegex = false; this.regexWord = null; this.ab = ab; }
/// <summary> /// 全板共通のNGWordを正規表現を用いて初期化します /// </summary> /// <param name="re">設定するNGWordの正規表現パターン</param> /// <param name="ab">設定するNGWordのあぼーんタイプ</param> public NGWord(Regex re, AboneType ab) { this.regexWord = re; this.url = String.Empty; this.setTime = DateTime.MinValue; this.releaseTime = TimeSpan.Zero; this.isRegex = true; this.word = null; this.ab = ab; }
/// <summary> /// NGWordを時間を設定せずに初期化します /// </summary> /// <param name="url">利用先のURL</param> /// <param name="word">設定するNGWord</param> /// <param name="ab">設定するNGWordのあぼーんタイプ</param> public NGWord(string word, AboneType ab, string url) { this.word = word; this.url = url; this.setTime = DateTime.MinValue; this.releaseTime = TimeSpan.Zero; this.regexWord = null; this.isRegex = false; this.ab = ab; }
/// <summary> /// NGWordに必要な条件を正規表現を用いて初期化します /// </summary> /// <param name="re">設定するNGWordの正規表現パターン</param> /// <param name="url">利用先のURL</param> /// <param name="setTime">設定した時間</param> /// <param name="releaseTime">設定を解除する時間</param> /// <param name="ab">設定するNGWordのあぼーんタイプ</param> public NGWord(Regex re, AboneType ab, string url, DateTime setTime, TimeSpan releaseTime) { this.regexWord = re; this.url = url; this.setTime = setTime; this.releaseTime = releaseTime; this.isRegex = true; this.word = null; this.ab = ab; }
/// <summary> /// NGワードを読み込みします /// </summary> /// <returns>読み込んだNGWord</returns> static public async Task <HashSet <string> > Load(AboneType aboneType) { string ngData = String.Empty; using (FileStream fs = new FileStream(gs.OtherFolderPath + "\\ng.dat", FileMode.Create, FileAccess.ReadWrite)) { StreamReader sr = new StreamReader(fs); ngData = await sr.ReadToEndAsync(); sr.Dispose(); } string[] ngLines = ngData.Split(new string[] { "\r\n" }, StringSplitOptions.None); HashSet <string> ngList = new HashSet <string>(); foreach (string item in ngLines) { if (item.IndexOf(aboneType.ToString()) == 0) { ngList.Add(item.Replace(aboneType.ToString() + ":", "")); } } return(ngList); }
public void SetAbone(int Index, AboneType Value) { base.InvokeMethod("SetAbone", Index, (int)Value); }
public bool AddNgId(string Item, AboneType AboneType, int LifeSpan) { return (bool)base.InvokeMethod("AddNgId", Item, (int)AboneType, LifeSpan); }
/// <summary> /// NGWordを読み込みます /// </summary> /// <returns>読み込まれたNGWordの配列</returns> /// <remarks>ネストが深くなりすぎてすまん</remarks> public static NGWord[] ReadAboneFiles() { string data = Utility.TextUtility.Read(gs.OtherFolderPath + "\\ng.dat"); if (data == null) { return(new NGWord[0]); } string[] lines = data.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); NGWord[] words = new NGWord[lines.Length]; int i = 0; foreach (string item in lines) { string[] splitData = item.Split('\\'); NGWord nw; AboneType at = (AboneType)Enum.Parse(typeof(AboneType), splitData[1]); if (splitData[0] == "False") { if (splitData[3] != "Null") { if (splitData[4] != "Null" && splitData[5] != "Null") { nw = new NGWord(splitData[2], at, splitData[3], DateTime.Parse(splitData[4]), TimeSpan.Parse(splitData[5])); } else { nw = new NGWord(splitData[2], at, splitData[3]); } } else { if (splitData[4] != "Null" && splitData[5] != "Null") { nw = new NGWord(splitData[2], at, String.Empty, DateTime.Parse(splitData[4]), TimeSpan.Parse(splitData[5])); } else { nw = new NGWord(splitData[2], at); } } } else { if (splitData[3] != "Null") { if (splitData[4] != "Null" && splitData[5] != "Null") { nw = new NGWord(new Regex(splitData[2], RegexOptions.Compiled), at, splitData[3], DateTime.Parse(splitData[4]), TimeSpan.Parse(splitData[5])); } else { nw = new NGWord(new Regex(splitData[2], RegexOptions.Compiled), at, splitData[3]); } } else { if (splitData[4] != "Null" && splitData[5] != "Null") { nw = new NGWord(new Regex(splitData[2], RegexOptions.Compiled), at, String.Empty, DateTime.Parse(splitData[4]), TimeSpan.Parse(splitData[5])); } else { nw = new NGWord(new Regex(splitData[2], RegexOptions.Compiled), at); } } } words[i] = nw; i++; } return(words); }