/// <summary> /// 検索結果の表示メインメソッド /// </summary> private void AddSearchValue(List <Dictionary <string, string> > list, Class_SearchResult seachResult) { for (int i = 0; i < list.Count; i++) { SetColumnValue(seachResult, list[i], i); } }
/// <summary> /// 検索結果の列設定 /// </summary> private void SetResultColumn(Class_SearchResult se) { for (int i = 3; i < Dgv_InspectionResult.ColumnCount; i++) { string header = Dgv_InspectionResult.Columns[i].Name; if (!se.columnValue.Contains(header)) { Dgv_InspectionResult.Columns[i].Visible = false; } } }
/// <summary> /// 行の作成と値の追加を行う /// </summary> private void SetColumnValue(Class_SearchResult se, Dictionary <string, string> dc, int rowPos) { Dgv_InspectionResult.Rows.Add(); foreach (string columnName in se.columnValue) { Dgv_InspectionResult.Rows[rowPos].Cells[GetColumnIndex(columnName)].Value = dc[columnName]; } if (!se.columnValue.Contains("Payment")) { Dgv_InspectionResult.Rows[rowPos].Cells[GetColumnIndex("Payment")].Value = 0; } if (!se.columnValue.Contains("Claim")) { Dgv_InspectionResult.Rows[rowPos].Cells[GetColumnIndex("Claim")].Value = 0; } }
/// <summary> /// 配列をDictionaryに変換する /// </summary> private Dictionary <string, string> ToDictionary(string[] values, out Class_SearchResult se) { Dictionary <string, string> dv = new Dictionary <string, string>(); se = new Class_SearchResult(); foreach (string value in values) { if (string.IsNullOrEmpty(value)) { continue; } string dicKey = value.Substring(0, value.IndexOf(":")); string dicValue = value.Substring(value.IndexOf(":") + 1); dv.Add(dicKey, dicValue); se.AddColumnValue(dicKey); } return(dv); }
/// <summary> /// テキスト読み取りのメインメソッド /// </summary> public List <Dictionary <string, string> > ReadText(Class_SearchParam searchParam, out Class_SearchResult se) { string line = ""; List <Dictionary <string, string> > addList = new List <Dictionary <string, string> >(); se = new Class_SearchResult(); //ストリームライターでテキストファイルを読み取り using (StreamReader sr = new StreamReader(setting.readFilePath, Encoding.GetEncoding("shift_jis"))) { //読み取ったテキストの行数だけ処理 while ((line = sr.ReadLine()) != null) { //列をスプリットして配列に保存 string[] value = line.Split(','); addList.Add(ToDictionary(value, out se)); } //ストリームライターをクローズ sr.Close(); } return(GetSearchValue(addList, searchParam)); }