//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── /// <summary> /// TODO:「,」「"」に対応したい。 /// /// /// 縦と横が逆のテーブル。 /// /// CSVを読取り、テーブルにして返します。 /// /// /// SRS仕様の実装状況 /// ここでは、先頭行を[0]行目と数えるものとします。 /// (1)CSVの[0]行目は列名です。 /// (2)CSVの[1]行目は型名です。 /// (3)CSVの[2]行目はコメントです。 /// /// (4)データ・テーブル部で、0列目に「EOF」と入っていれば終了。大文字・小文字は区別せず。 /// それ以降に、コメントのようなデータが入力されていることがあるが、フィールドの型に一致しないことがあるので無視。 /// TODO EOF以降の行も、コメントとして残したい。 /// /// (5)列名にENDがある場合、その手前までの列が有効データです。 /// END以降の列は無視します。 /// TODO END以降の行も、コメントとして残したい。 /// /// (6)int型として指定されているフィールドのデータ・テーブル部に空欄があった場合、DBNull(データベース用のヌル)とします。 /// </summary> /// <param name="csvText"></param> /// <returns>列名情報も含むテーブル。列の型は文字列型とします。</returns> public Table_Humaninput Read( string string_Csv, Request_ReadsTable forTable_Request, Format_Table forTable_Format, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Table.Name_Library, this, "Read", log_Reports); // // // // CsvLineParserImpl csvParser = new CsvLineParserImpl(); Table_Humaninput xenonTable = new Table_HumaninputImpl( forTable_Request.Name_PutToTable, forTable_Request.Expression_Filepath, forTable_Request.Expression_Filepath.Conf); xenonTable.Tableunit = forTable_Request.Tableunit; xenonTable.Typedata = forTable_Request.Typedata; xenonTable.IsDatebackupActivated = forTable_Request.IsDatebackupActivated; xenonTable.Format_Table_Humaninput = forTable_Format; // // 一旦、テーブルを全て読み込みます。 // List <List <string> > lines = new List <List <string> >(); { // CSVテキストを読み込み、型とデータのバッファーを作成します。 System.IO.StringReader reader = new System.IO.StringReader(string_Csv); while (-1 < reader.Peek()) { string sLine = reader.ReadLine(); List <string> tokens = new List <string>(); string[] sFields; sFields = csvParser.UnescapeLineToFieldList(sLine, this.charSeparator).ToArray(); int nColumnIndex = 0; foreach (string sToken in sFields) { if (nColumnIndex == 0 && ( ToCsv_Table_RowColRegularImpl_.S_EOL == sToken.Trim().ToUpper() || ToCsv_Table_RowColRegularImpl_.S_END == sToken.Trim().ToUpper() ) ) { // 1列目にENDがある場合、その手前までの列が有効データです。 // END以降の行は無視します。 goto row_end; } tokens.Add(sToken); nColumnIndex++; } lines.Add(tokens); } row_end: // ストリームを閉じます。 reader.Close(); } // // 型定義部 // // (※NO,ID,EXPL,NAME など、フィールドの定義を持つテーブル) // RecordFielddef recordFielddef = new RecordFielddefImpl(); // // データ・テーブル部 // List <List <string> > rows = new List <List <string> >(); // // まず、0列目、1列目、2列目のデータを読み取ります。 // int nRowIndex = 0; foreach (List <string> tokens in lines) { Fielddef fieldDefinition = null; int nColumnIndex = 0; foreach (string sToken in tokens) { if (0 == nColumnIndex) { // // 0列目は、フィールド名です。 // string sFieldName = sToken;//.Trim().ToUpper(); // テーブルのフィールドを追加します。型の既定値は文字列型とします。 fieldDefinition = new FielddefImpl(sFieldName, EnumTypeFielddef.String); recordFielddef.Add(fieldDefinition); } else if (1 == nColumnIndex) { // // 1列目は、フィールドの型名です。 // nColumnIndex = 1; string sFieldTypeNameLower = sToken.Trim().ToLower(); // テーブルのフィールドを追加します。型の既定値は文字列型とします。 // TODO int型とboolean型にも対応したい。 if (FielddefImpl.S_STRING.Equals(sFieldTypeNameLower)) { fieldDefinition.Type_Field = EnumTypeFielddef.String; } else if (FielddefImpl.S_INT.Equals(sFieldTypeNameLower)) { fieldDefinition.Type_Field = EnumTypeFielddef.Int; } else if (FielddefImpl.S_BOOL.Equals(sFieldTypeNameLower)) { fieldDefinition.Type_Field = EnumTypeFielddef.Bool; } else { // 型が未定義の列は、文字列型として読み取ります。 // TODO: 警告。(エラーではない) Log_TextIndented t = new Log_TextIndentedImpl(); t.Append("▲エラー45!(" + Info_Table.Name_Library + ")"); t.Newline(); t.Append("型の名前を記入してください。"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); t.Append("※縦と横がひっくり返っているテーブルと指定されています。"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); t.Append("1列目(先頭を0とする)に、型の名前は必須です。"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); t.Append("["); t.Append(fieldDefinition.Name_Humaninput); t.Append("]フィールド (["); t.Append(nRowIndex); t.Append("]行目)に、"); t.Append(Environment.NewLine); t.Append("型名が["); t.Append(sFieldTypeNameLower); t.Append("]と入っています。この名前には、未対応です。"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); t.Append("文字列型として続行します。"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); t.Append("テーブル名=["); t.Append(forTable_Request.Name_PutToTable); t.Append("]"); t.Append(Environment.NewLine); t.Append("ファイル・パス=["); t.Append(forTable_Request.Expression_Filepath.Humaninput); t.Append("]"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); string sWarning = t.ToString(); MessageBox.Show(sWarning, "▲警告!(L02)"); fieldDefinition.Type_Field = EnumTypeFielddef.String; } } else if (2 == nColumnIndex) { // // 2列目は、フィールドのコメントとします。 // nColumnIndex = 2; { fieldDefinition.Comment = sToken; } } else { // // 3列目から右側は、データ・テーブル部。 // if (0 == nRowIndex) { // // 先頭行 // // // 「EOF」というトークンが出てくるまで。 // if (ToCsv_Table_RowColRegularImpl_.S_EOF == sToken.Trim().ToUpper()) { goto column_end; } List <string> record = new List <string>(); // 1番目のフィールド_データを追加。 record.Add(sToken); rows.Add(record); } else { // // 2番目以降のフィールド_データを追加。 // // // 先頭の3つのレコード分、切り詰めます。 // int nDataIndex = nColumnIndex - 3; if (nDataIndex < rows.Count) { List <string> record = rows[nDataIndex]; record.Add(sToken); } else { // 無視 } } } nColumnIndex++; }//c column_end: nRowIndex++; } //essageBox.Show("CSV読取終わり1 rows.Count=[" + rows.Count + "]", "TableCsvLibデバッグ"); // テーブル作成。テーブルのフィールド型定義と、データ本体をセットします。 xenonTable.CreateTable(recordFielddef, log_Reports); if (log_Reports.Successful) { xenonTable.AddRecordList(rows, recordFielddef, log_Reports); //essageBox.Show("CSV読取後のテーブル作成終わり", "TableCsvLibデバッグ"); } goto gt_EndMethod; // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(xenonTable); }
//──────────────────────────────────────── /// <summary> /// 「フィールド名=値」という条件1つで検索。該当するレコード0~N件を返す。 /// </summary> /// <param name="dst_Row"></param> /// <param name="name_KeyField"></param> /// <param name="value_Expected"></param> /// <param name="isRequired_ExpectedValue"></param> /// <param name="fielddefinition_Key"></param> /// <param name="dataTable"></param> /// <param name="s_ParentNode_query"></param> /// <param name="log_Reports"></param> public void Select( out List <DataRow> out_List_DstRow, string name_KeyField, string value_Expected, bool isRequired_ExpectedValue, Fielddef fielddefinition_Key, DataTable dataTable, Conf_String parent_Query, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Table.Name_Library, this, "Select", log_Reports); // // // // out_List_DstRow = new List <DataRow>(); Judge_FieldBoolImpl judgeB = new Judge_FieldBoolImpl(); Judge_FieldIntImpl judgeI = new Judge_FieldIntImpl(); Judge_FieldStringImpl judgeS = new Judge_FieldStringImpl(); foreach (DataRow row in dataTable.Rows) { bool bJudge; switch (fielddefinition_Key.Type_Field) { case EnumTypeFielddef.String: { // string型フィールドなら judgeS.Judge( out bJudge, name_KeyField, value_Expected, isRequired_ExpectedValue, row, parent_Query, log_Reports ); } break; case EnumTypeFielddef.Int: { // int型フィールドなら judgeI.Judge( out bJudge, name_KeyField, value_Expected, isRequired_ExpectedValue, row, parent_Query, log_Reports ); } break; case EnumTypeFielddef.Bool: { // bool型フィールドなら judgeB.Judge( out bJudge, name_KeyField, value_Expected, isRequired_ExpectedValue, row, parent_Query, log_Reports ); } break; default: { // エラー。 goto gt_Error_UndefinedClass; } break; } if (!log_Reports.Successful) { // 既エラー。 goto gt_EndMethod; } if (bJudge) { out_List_DstRow.Add(row); } } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_UndefinedClass: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー899", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.AppendI(0, "<NFuncCellUpdaterImplクラス>"); s.Append(Environment.NewLine); s.AppendI(1, "予期しない型です。"); s.Append(Environment.NewLine); s.AppendI(1, "keyFldDefinition.Type=["); s.Append(fielddefinition_Key.ToString_Type()); s.Append("]"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); // ヒント s.AppendI(1, r.Message_Conf(parent_Query)); s.AppendI(0, "</NFuncCellUpdaterImplクラス>"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── /// <summary> /// 「E■@where」属性を解析します。 /// /// 該当しないレコードは除去していきます。 /// </summary> /// <param name="srcRow"></param> /// <param name="tableH_Source"></param> /// <param name="groupLogic"></param> /// <param name="reccondList"></param> /// <param name="log_Reports"></param> /// <returns>ロジックの真偽。</returns> private static bool ApplyReccond( DataRow srcRow, Table_Humaninput tableH_Source, EnumLogic parent_EnumLogic, List <Recordcondition> list_Reccond,//「E■@where」または「E■rec-cond」。子要素を持たないか、子要素に「E■rec-cond」を持つものとする。 int nCount_Recursive_Debug, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Table.Name_Library, "Util_Table", "ApplyReccond", log_Reports); // // // // bool bResult; string err_SField; int nDebug_ChildIndex = 0; if (EnumLogic.Or == parent_EnumLogic) { // 1つも真がなければ、偽。 bResult = false; } else if (EnumLogic.And == parent_EnumLogic) { // 1つも偽がなければ、真。 bResult = true; } else { // 条件による。条件が1つもなければ真。 bResult = true; } foreach (Recordcondition childReccond in list_Reccond) { // // "and" と有れば、条件に合わなかった場合 false。 // "or" と有れば、 // if (EnumLogic.None != childReccond.EnumLogic) { // andグループ、orグループなら。 bool bChildHit = Utility_Table.ApplyReccond(srcRow, tableH_Source, childReccond.EnumLogic, childReccond.List_Child, nCount_Recursive_Debug + 1, log_Reports); if (EnumLogic.And == parent_EnumLogic) { if (bChildHit) { // そのまま。 //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件内のグループで真 [" + bChildHit + "→真なのでそのまま " + bResult + "=True] Reccond=[" + childReccond.ToString() + "] 子が真なので変化なし。"); } else { // 1つでも偽があれば、偽。 //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件内のグループで偽 [" + bChildHit + "→偽なので確定偽に " + bResult + "=False] Reccond=[" + childReccond.ToString() + "] 子に偽があるので偽。"); bResult = false; goto gt_EndMethod; } } else if (EnumLogic.Or == parent_EnumLogic) { if (bChildHit) { // 1つでも真があれば、真。 //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件内のグループで真 [" + bChildHit + "→真なので確定真に " + bResult + "=True] Reccond=[" + childReccond.ToString() + "] 子に真があるので真。"); bResult = true; goto gt_EndMethod; } else { // そのまま。 //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件内のグループで偽 [" + bChildHit + "→偽なのでそのまま "+ bResult + "=False] Reccond=[" + childReccond.ToString() + "] 子が偽なので変化なし。"); } } else { // #TODO:エラー System.Console.WriteLine("L02:" + Info_Table.Name_Library + ":Util_Table.ApplyWhere: 不明ロジック[" + parent_EnumLogic + "]"); } } else { // 条件なら。 // このレコードについて判定。 if (!tableH_Source.DataTable.Columns.Contains(childReccond.Name_Field)) { // エラー err_SField = childReccond.Name_Field; goto gt_Error_MissField; } int nFieldIx = tableH_Source.DataTable.Columns.IndexOf(childReccond.Name_Field); Fielddef o_FldDef = tableH_Source.RecordFielddef.ValueAt(nFieldIx); Cell o_Value = (Cell)srcRow[nFieldIx]; // 型に合わせて値取得。 if (o_Value is IntCellImpl) { //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyWhere: intフィールド [" + sLogic + " " + sField + " " + sOpe + " " + sValue + "]"); int nFieldInt; { IntCellImpl.TryParse( o_Value, out nFieldInt, EnumOperationIfErrorvalue.Spaces_To_Alt_Value, -1, log_Reports ); } int nExpectedInt; { bool bHit2 = int.TryParse(childReccond.Value, out nExpectedInt); if (!bHit2 && log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー502!", log_Method); r.Message = "int型に変換できませんでした。sValue=[" + childReccond.Value + "]"; log_Reports.EndCreateReport(); } } if (EnumLogic.Or == parent_EnumLogic) { switch (childReccond.EnumOpe) { case EnumOpe.Gteq: // 「>=」 if (nFieldInt >= nExpectedInt) { // セーフ // 1つでも真が確定なら、真。 bResult = true; //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件[" + bResult + "=True] Reccond=[" + childReccond.ToString() + "] 1つでも真なら真。"); goto gt_EndMethod; } else { // アウト //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件[" + bResult + "=False] Reccond=[" + childReccond.ToString() + "]"); } break; case EnumOpe.Gt: // 「>」 if (nFieldInt > nExpectedInt) { // セーフ // 1つでも真が確定なら、真。 bResult = true; //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件[" + bResult + "=True] Reccond=[" + childReccond.ToString() + "] 1つでも真なら真。"); goto gt_EndMethod; } else { //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件[" + bResult + "=False] Reccond=[" + childReccond.ToString() + "]"); } break; case EnumOpe.Lteq: // 「<=」 if (nFieldInt <= nExpectedInt) { // セーフ // 1つでも真が確定なら、真。 bResult = true; //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件[" + bResult + "=True] Reccond=[" + childReccond.ToString() + "] 1つでも真なら真。"); goto gt_EndMethod; } else { // アウト //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件[" + bResult + "=False] Reccond=[" + childReccond.ToString() + "]"); } break; case EnumOpe.Lt: // 「<」 if (nFieldInt < nExpectedInt) { // セーフ // 1つでも真が確定なら、真。 bResult = true; //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件[" + bResult + "=True] Reccond=[" + childReccond.ToString() + "] 1つでも真なら真。"); goto gt_EndMethod; } else { // アウト //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件[" + bResult + "=False] Reccond=[" + childReccond.ToString() + "]"); } break; case EnumOpe.Neq: // 「!=」 if (nFieldInt != nExpectedInt) { // セーフ // 1つでも真が確定なら、真。 bResult = true; //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件[" + bResult + "=True] Reccond=[" + childReccond.ToString() + "] 1つでも真なら真。"); goto gt_EndMethod; } else { // アウト //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件[" + bResult + "=False] Reccond=[" + childReccond.ToString() + "]"); } break; case EnumOpe.Eq: // ""、"eq"、は eq扱い。 // 「=」 if (nFieldInt == nExpectedInt) { // セーフ // 1つでも真が確定なら、真。 bResult = true; //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件[" + bResult + "=True] Reccond=[" + childReccond.ToString() + "] 1つでも真なら真。"); goto gt_EndMethod; } else { // アウト //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") OR条件[" + bResult + "=False] Reccond=[" + childReccond.ToString() + "]"); } break; } } else if (EnumLogic.And == parent_EnumLogic) { switch (childReccond.EnumOpe) { case EnumOpe.Gteq: // 「>=」 if (nFieldInt >= nExpectedInt) { // セーフ //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件[" + bResult + "=True] Reccond=[" + childReccond.ToString() + "]"); } else { // アウト // 1つでも偽が確定なら、偽。 bResult = false; //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件[" + bResult + "=False] Reccond=[" + childReccond.ToString() + "] 1つでも偽なら偽。"); goto gt_EndMethod; } break; case EnumOpe.Gt: // 「>」 if (nFieldInt > nExpectedInt) { // セーフ //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件[" + bResult + "=True] Reccond=[" + childReccond.ToString() + "]"); } else { // アウト // 1つでも偽が確定なら、偽。 bResult = false; //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件[" + bResult + "=False] Reccond=[" + childReccond.ToString() + "] 1つでも偽なら偽。"); goto gt_EndMethod; } break; case EnumOpe.Lteq: // 「<=」 if (nFieldInt <= nExpectedInt) { // セーフ //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件[" + bResult + "=True] Reccond=[" + childReccond.ToString() + "]"); } else { // アウト // 1つでも偽が確定なら、偽。 bResult = false; //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件[" + bResult + "=False] Reccond=[" + childReccond.ToString() + "] 1つでも偽なら偽。"); goto gt_EndMethod; } break; case EnumOpe.Lt: // 「<」 if (nFieldInt < nExpectedInt) { // セーフ //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件[" + bResult + "=True] Reccond=[" + childReccond.ToString() + "]"); } else { // アウト // 1つでも偽が確定なら、偽。 bResult = false; //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件[" + bResult + "=False] Reccond=[" + childReccond.ToString() + "] 1つでも偽なら偽。"); goto gt_EndMethod; } break; case EnumOpe.Neq: // 「!=」 if (nFieldInt != nExpectedInt) { // セーフ //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件[" + bResult + "=True] Reccond=[" + childReccond.ToString() + "]"); } else { // アウト // 1つでも偽が確定なら、偽。 bResult = false; //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件[" + bResult + "=False] Reccond=[" + childReccond.ToString() + "] 1つでも偽なら偽。"); goto gt_EndMethod; } break; case EnumOpe.Eq: // ""、"eq"、は eq扱い。 // 「=」 if (nFieldInt == nExpectedInt) { // セーフ //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件[" + bResult + "=True] Reccond=[" + childReccond.ToString() + "]"); } else { // アウト // 1つでも偽が確定なら、偽。 bResult = false; //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyRecord: (" + debug_RecursiveCount + "." + debug_ChildIndex + ") AND条件[" + bResult + "=False] Reccond=[" + childReccond.ToString() + "] 1つでも偽なら偽。"); goto gt_EndMethod; } break; } } else { // #TODO:エラー System.Console.WriteLine("L02:" + Info_Table.Name_Library + ":Util_Table.ApplyWhere: 不明ロジック[" + parent_EnumLogic + "] nFieldIx=[" + nFieldIx + "] フィールド名=[" + o_FldDef.Name_Humaninput + "] [" + parent_EnumLogic + "][" + childReccond.Name_Field + " " + childReccond.EnumOpe + " " + childReccond.Value + "] objValueの型=[" + o_Value.GetType().Name + "]"); } } else { // #TODO:エラー System.Console.WriteLine("L02:" + Info_Table.Name_Library + ":Util_Table.ApplyWhere: 不明フィールド nFieldIx=[" + nFieldIx + "] フィールド名=[" + o_FldDef.Name_Humaninput + "] [" + parent_EnumLogic + "][" + childReccond.Name_Field + " " + childReccond.EnumOpe + " " + childReccond.Value + "] objValueの型=[" + o_Value.GetType().Name + "]"); } }//or,and,条件 nDebug_ChildIndex++; }//for goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_MissField: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー501!", log_Method); StringBuilder s = new StringBuilder(); s.Append("<rec-cond>要素のfield属性エラー"); s.Append(Environment.NewLine); s.Append("field=["); s.Append(err_SField); s.Append("]"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(bResult); }
public void Insert(int indexColumn, Fielddef fielddefinition) { this.List_Fielddef.Insert(indexColumn, fielddefinition); }
//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── public void Add(Fielddef fielddefinition) { this.List_Fielddef.Add(fielddefinition); }
//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── /// <summary> /// TODO:「,」「"」に対応したい。 /// /// /// 縦、横がひっくり返っていて、 /// 型定義レコードがないCSVテーブルの読取。 /// </summary> /// <param name="csvText"></param> /// <returns>列名情報も含むテーブル。</returns> public Table_Humaninput Read( string string_Csv, Request_ReadsTable forTable_Request, Format_Table forTable_Format, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Table.Name_Library, this, "Read", log_Reports); // // // // CsvLineParserImpl csvParser = new CsvLineParserImpl(); Table_Humaninput xenonTable = new Table_HumaninputImpl( forTable_Request.Name_PutToTable, forTable_Request.Expression_Filepath, forTable_Request.Expression_Filepath.Conf); xenonTable.Tableunit = forTable_Request.Tableunit; xenonTable.Typedata = forTable_Request.Typedata; xenonTable.IsDatebackupActivated = forTable_Request.IsDatebackupActivated; xenonTable.Format_Table_Humaninput = forTable_Format; // // 一旦、テーブルを全て読み込みます。 // List <List <string> > lines = new List <List <string> >(); { // CSVテキストを読み込み、型とデータのバッファーを作成します。 System.IO.StringReader reader = new System.IO.StringReader(string_Csv); string[] sFields; while (-1 < reader.Peek()) { string sLine = reader.ReadLine(); List <string> tokens = new List <string>(); sFields = csvParser.UnescapeLineToFieldList(sLine, this.charSeparator).ToArray(); int nColumnIndex = 0; foreach (string sToken in sFields) { if (nColumnIndex == 0 && ( ToCsv_Table_RowColRegularImpl_.S_EOL == sToken.Trim().ToUpper() || ToCsv_Table_RowColRegularImpl_.S_END == sToken.Trim().ToUpper() ) ) { // 1列目にENDがある場合、その手前までの列が有効データです。 // END以降の行は無視します。 goto row_end; } tokens.Add(sToken); nColumnIndex++; } lines.Add(tokens); } row_end: // ストリームを閉じます。 reader.Close(); } // // 型定義部 // // (※NO,ID,EXPL,NAME など、フィールドの定義を持つテーブル) // RecordFielddef recordFielddef = new RecordFielddefImpl(); // // データ・テーブル部 // List <List <string> > rows = new List <List <string> >(); // // まず、0列目、1列目のデータを読み取ります。 // int nRowIndex = 0; foreach (List <string> tokens in lines) { Fielddef fieldDefinition = null; int nColumnIndex = 0; foreach (string sToken in tokens) { if (0 == nColumnIndex) { // // 0列目は、フィールド名です。 // string sFieldName = sToken;//.Trim().ToUpper(); // テーブルのフィールドを追加します。フィールドの型は、intに固定です。 fieldDefinition = new FielddefImpl(sFieldName, EnumTypeFielddef.Int); recordFielddef.Add(fieldDefinition); } else if (1 == nColumnIndex) { // // 1列目は、フィールドのコメントとします。 // nColumnIndex = 1; { fieldDefinition.Comment = sToken; } } else { // // 2列目から右側は、データ・テーブル部。 // if (0 == nRowIndex) { // // 先頭行 // // // 「EOF」というトークンが出てくるまで。 // if (ToCsv_Table_RowColRegularImpl_.S_EOF == sToken.Trim().ToUpper()) { goto column_end; } List <string> record = new List <string>(); // 1番目のフィールド_データを追加。 record.Add(sToken); rows.Add(record); } else { // // 2番目以降のフィールド_データを追加。 // // // 先頭の2つのレコード分、切り詰めます。 // int nDataIndex = nColumnIndex - 2; if (nDataIndex < rows.Count) { List <string> record = rows[nDataIndex]; record.Add(sToken); } else { // 無視 } } } nColumnIndex++; }//c column_end: nRowIndex++; } //essageBox.Show("CSV読取終わり1 rows.Count=[" + rows.Count + "]", "TableCsvLibデバッグ"); // テーブル作成。テーブルのフィールド型定義と、データ本体をセットします。 xenonTable.CreateTable(recordFielddef, log_Reports); if (log_Reports.Successful) { xenonTable.AddRecordList(rows, recordFielddef, log_Reports); //essageBox.Show("CSV読取後のテーブル作成終わり", "TableCsvLibデバッグ"); } goto gt_EndMethod; // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(xenonTable); }