//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── /// <summary> /// フィールドから値を取得。 /// /// TODO:セルタイプ以外にも対応したい。 /// </summary> /// <param name="RecordSet_toSave">ヌル不可</param> /// <param name="eSelectedFldName">選択フィールド</param> /// <param name="RecordSetSaveTo_or_null"></param> /// <param name="log_Reports"></param> /// <returns>行リスト<列リスト></returns> public List <List <string> > P5_Select_CellType( RecordSet dst_Rs_toSave, Selectstatement selectSt_ToSave, Expressionv_4ASelectRecord ecv_selRec_OrNull, //where Configuration_Node parent_Cf_Query, //this Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_Expr.Name_Library, this, "P5_Select", log_Reports); // // List <List <string> > reslt_sFieldListList = new List <List <string> >(); // // (1)テーブル Table_Humaninput o_Table; { o_Table = this.Owner_MemoryApplication.MemoryTables.GetTable_HumaninputByName( selectSt_ToSave.Expression_From, true, log_Reports); if (null == o_Table) { // エラー。 goto gt_Error_NullTable; } } if (!log_Reports.Successful) { // // エラーが出ていたら、さっさと抜ける。 goto gt_EndMethod; } // // // // // 条件 // // // // Fielddefinition keyFldDefinition = null; string err_SSelectedFldName = null; Exception err_Exception = null; Recordcondition err_Recordcondition = null; foreach (Recordcondition recCond in selectSt_ToSave.List_Recordcondition) { err_Recordcondition = recCond; // // (2)検索のキーフィールドの定義を調べます。 // キーフィールド定義 { List <string> sList_KeyFldName; { // 要素数1個。 sList_KeyFldName = new List <string>(); sList_KeyFldName.Add(recCond.Name_Field); } RecordFielddefinition recordFielddefinition; bool bHit = o_Table.TryGetFieldDefinitionByName( out recordFielddefinition, sList_KeyFldName, false, log_Reports ); if (!log_Reports.Successful || !bHit) { // エラー goto gt_EndMethod; } keyFldDefinition = recordFielddefinition.ValueAt(0); } // // (3)選択対象のフィールドの定義を調べます。 RecordFielddefinition recordFieldDefinition_Selected; { bool bHit = o_Table.TryGetFieldDefinitionByName( out recordFieldDefinition_Selected, selectSt_ToSave.List_SName_SelectField, true, log_Reports ); if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } } // // (4) if (null == keyFldDefinition) { // エラー。 goto gt_Error_NullKeyFldDefinition; } List <string> list_FldImpl3 = new List <string>(); recordFieldDefinition_Selected.ForEach(delegate(Fielddefinition fielddefinition_Selected, ref bool isBreak2, Log_Reports log_Reports2) { string sSelectField = fielddefinition_Selected.Name_Trimupper; // // (5) if (null == fielddefinition_Selected) { // エラー。 isBreak2 = true; goto gt_Error_NullSelectedFldDefinition; } // // (6)欠番 // // (7) if (null == dst_Rs_toSave || dst_Rs_toSave.List_Field.Count < 1) { bool bExpectedValueRequired; { bool parseSuccessful = bool.TryParse(selectSt_ToSave.Required, out bExpectedValueRequired); } // // 条件 // string name_KeyField; Fielddefinition fielddefinition_Key; string value_Expected; P2_ReccondImpl sel2 = new P2_ReccondImpl(); sel2.GetFirstAwhrReccond( out name_KeyField, out fielddefinition_Key, out value_Expected, selectSt_ToSave.List_Recordcondition, o_Table, log_Reports ); List <DataRow> dst_Row = new List <DataRow>(); SelectPerformerImpl sp = new SelectPerformerImpl(); sp.Select( out dst_Row, name_KeyField, value_Expected, bExpectedValueRequired, fielddefinition_Key, o_Table.DataTable, parent_Cf_Query, log_Reports ); dst_Rs_toSave.AddList(dst_Row, log_Reports); if (!log_Reports.Successful) { // 既エラー。 isBreak2 = true; goto gt_EndInnermethod; } if (null == dst_Rs_toSave) { // (7-2) isBreak2 = true; goto gt_Error_UndefinedPrimitiveType; } } else { // レコードセットは、一時記憶から取得済み。 } // (8) if (log_Reports.Successful) { // キー_フィールドの型別に、処理。 switch (keyFldDefinition.Type_Field) { case EnumTypeFielddefinition.String: { // (8-1)キーが string型フィールドなら // この行の、選択対象のフィールドの値。 foreach (Dictionary <string, Value_Humaninput> record in dst_Rs_toSave.List_Field) { // 値。 Value_Humaninput selectedCellData; try { selectedCellData = (Value_Humaninput)record[sSelectField]; } catch (KeyNotFoundException ex) { selectedCellData = null; err_SSelectedFldName = sSelectField; err_Exception = ex; isBreak2 = true; goto gt_Error_NotFoundFld; } Expression_Node_String ec_SelectedValue = this.GetSelectedFieldValue( fielddefinition_Selected, selectedCellData, parent_Cf_Query, log_Reports ); list_FldImpl3.Add(ec_SelectedValue.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports)); } } break; case EnumTypeFielddefinition.Int: { // // (8-2) キー・フィールドが int型の場合。 foreach (Dictionary <string, Value_Humaninput> record in dst_Rs_toSave.List_Field) { // この行の、選択対象のフィールドの値。 if (null != log_Reports && !log_Reports.Successful) //無限ループ防止 { // エラー発生時は無視。 } else { Value_Humaninput selectedCellData; try { selectedCellData = record[sSelectField]; } catch (KeyNotFoundException ex) { selectedCellData = null; err_SSelectedFldName = sSelectField; err_Exception = ex; isBreak2 = true; goto gt_Error_NotFoundFld; } { // 値。 Expression_Node_String ec_SelectedValue = this.GetSelectedFieldValue( fielddefinition_Selected, selectedCellData, parent_Cf_Query, log_Reports ); list_FldImpl3.Add(ec_SelectedValue.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports)); } } } } break; case EnumTypeFielddefinition.Bool: { // (8-3) キーが、bool型フィールド // 値。 foreach (Dictionary <string, Value_Humaninput> record in dst_Rs_toSave.List_Field) { // この行の、選択対象のフィールドの値。 Value_Humaninput selectedCellData; try { selectedCellData = (Value_Humaninput)record[sSelectField]; } catch (KeyNotFoundException ex) { selectedCellData = null; err_SSelectedFldName = sSelectField; err_Exception = ex; isBreak2 = true; goto gt_Error_NotFoundFld; } Expression_Node_String ec_SelectedValue = this.GetSelectedFieldValue( fielddefinition_Selected, selectedCellData, parent_Cf_Query, log_Reports ); list_FldImpl3.Add(ec_SelectedValue.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports)); } } break; default: { // // (8-4) // // 既にエラー対策済み。 if (null != log_Reports) //無限ループ防止 { // // エラー。 isBreak2 = true; goto gt_Error_UndefinedPrimitiveType; } // // 非エラー中断。 isBreak2 = true; goto gt_EndInnermethod; } break; } } goto gt_EndInnermethod; // #region 異常系 //──────────────────────────────────────── gt_Error_NullSelectedFldDefinition: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, o_Table.Name, log_Reports); //テーブル名 tmpl.SetParameter(2, Log_RecordReportsImpl.ToText_Configuration(parent_Cf_Query), log_Reports); //設定位置パンくずリスト this.Owner_MemoryApplication.CreateErrorReport("Er:6026;", tmpl, log_Reports); } goto gt_EndInnermethod; //──────────────────────────────────────── gt_Error_UndefinedPrimitiveType: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, keyFldDefinition.ToString_Type(), log_Reports); //キー・フィールド定義型名 tmpl.SetParameter(2, Log_RecordReportsImpl.ToText_Configuration(parent_Cf_Query), log_Reports); //設定位置パンくずリスト this.Owner_MemoryApplication.CreateErrorReport("Er:6027;", tmpl, log_Reports); } goto gt_EndInnermethod; //──────────────────────────────────────── gt_Error_NotFoundFld: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, err_SSelectedFldName, log_Reports); //選択フィールド名 tmpl.SetParameter(2, Log_RecordReportsImpl.ToText_Configuration(parent_Cf_Query), log_Reports); //設定位置パンくずリスト tmpl.SetParameter(3, Log_RecordReportsImpl.ToText_Exception(err_Exception), log_Reports); //例外メッセージ this.Owner_MemoryApplication.CreateErrorReport("Er:6028;", tmpl, log_Reports); } goto gt_EndInnermethod; //──────────────────────────────────────── #endregion // gt_EndInnermethod: ; }, log_Reports);//select列1つ if (0 < list_FldImpl3.Count) { // フィールドがあれば追加。 reslt_sFieldListList.Add(list_FldImpl3); } } goto gt_EndMethod; // #region 異常系 //──────────────────────────────────────── gt_Error_NullTable: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); this.Owner_MemoryApplication.CreateErrorReport("Er:6024;", tmpl, log_Reports); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_NullKeyFldDefinition: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, Log_RecordReportsImpl.ToText_Configuration(parent_Cf_Query), log_Reports);//設定位置パンくずリスト this.Owner_MemoryApplication.CreateErrorReport("Er:6025;", tmpl, log_Reports); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // gt_EndMethod: log_Method.EndMethod(log_Reports); return(reslt_sFieldListList); }
//──────────────────────────────────────── public void Add(Fielddefinition fielddefinition) { this.List_Fielddefinition.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_Humaninput 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.Cur_Configuration); 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_Humaninput_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 など、フィールドの定義を持つテーブル) // RecordFielddefinition recordFielddefinition = new RecordFielddefinitionImpl(); // // データ・テーブル部 // List <List <string> > rows = new List <List <string> >(); // // まず、0列目、1列目のデータを読み取ります。 // int nRowIndex = 0; foreach (List <string> tokens in lines) { Fielddefinition fieldDefinition = null; int nColumnIndex = 0; foreach (string sToken in tokens) { if (0 == nColumnIndex) { // // 0列目は、フィールド名です。 // string sFieldName = sToken;//.Trim().ToUpper(); // テーブルのフィールドを追加します。フィールドの型は、intに固定です。 fieldDefinition = new FielddefinitionImpl(sFieldName, EnumTypeFielddefinition.Int); recordFielddefinition.Add(fieldDefinition); } else if (1 == nColumnIndex) { // // 1列目は、フィールドのコメントとします。 // nColumnIndex = 1; { fieldDefinition.Comment = sToken; } } else { // // 2列目から右側は、データ・テーブル部。 // if (0 == nRowIndex) { // // 先頭行 // // // 「EOF」というトークンが出てくるまで。 // if (ToCsv_Table_Humaninput_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(recordFielddefinition, log_Reports); if (log_Reports.Successful) { xenonTable.AddRecordList(rows, recordFielddefinition, log_Reports); //essageBox.Show("CSV読取後のテーブル作成終わり", "TableCsvLibデバッグ"); } goto gt_EndMethod; // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(xenonTable); }
//──────────────────────────────────────── #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_Humaninput 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.Cur_Configuration); 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_Humaninput_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 など、フィールドの定義を持つテーブル) // RecordFielddefinition recordFielddefinition = new RecordFielddefinitionImpl(); // // データ・テーブル部 // List <List <string> > rows = new List <List <string> >(); // // まず、0列目、1列目、2列目のデータを読み取ります。 // int nRowIndex = 0; foreach (List <string> tokens in lines) { Fielddefinition fieldDefinition = null; int nColumnIndex = 0; foreach (string sToken in tokens) { if (0 == nColumnIndex) { // // 0列目は、フィールド名です。 // string sFieldName = sToken;//.Trim().ToUpper(); // テーブルのフィールドを追加します。型の既定値は文字列型とします。 fieldDefinition = new FielddefinitionImpl(sFieldName, EnumTypeFielddefinition.String); recordFielddefinition.Add(fieldDefinition); } else if (1 == nColumnIndex) { // // 1列目は、フィールドの型名です。 // nColumnIndex = 1; string sFieldTypeNameLower = sToken.Trim().ToLower(); // テーブルのフィールドを追加します。型の既定値は文字列型とします。 // TODO int型とboolean型にも対応したい。 if (FielddefinitionImpl.S_STRING.Equals(sFieldTypeNameLower)) { fieldDefinition.Type_Field = EnumTypeFielddefinition.String; } else if (FielddefinitionImpl.S_INT.Equals(sFieldTypeNameLower)) { fieldDefinition.Type_Field = EnumTypeFielddefinition.Int; } else if (FielddefinitionImpl.S_BOOL.Equals(sFieldTypeNameLower)) { fieldDefinition.Type_Field = EnumTypeFielddefinition.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 = EnumTypeFielddefinition.String; } } else if (2 == nColumnIndex) { // // 2列目は、フィールドのコメントとします。 // nColumnIndex = 2; { fieldDefinition.Comment = sToken; } } else { // // 3列目から右側は、データ・テーブル部。 // if (0 == nRowIndex) { // // 先頭行 // // // 「EOF」というトークンが出てくるまで。 // if (ToCsv_Table_Humaninput_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(recordFielddefinition, log_Reports); if (log_Reports.Successful) { xenonTable.AddRecordList(rows, recordFielddefinition, log_Reports); //essageBox.Show("CSV読取後のテーブル作成終わり", "TableCsvLibデバッグ"); } goto gt_EndMethod; // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(xenonTable); }
public void Insert(int indexColumn, Fielddefinition fielddefinition) { this.List_Fielddefinition.Insert(indexColumn, fielddefinition); }
//──────────────────────────────────────── /// <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, Fielddefinition fielddefinition_Key, DataTable dataTable, Configuration_Node 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 EnumTypeFielddefinition.String: { // string型フィールドなら judgeS.Judge( out bJudge, name_KeyField, value_Expected, isRequired_ExpectedValue, row, parent_Query, log_Reports ); } break; case EnumTypeFielddefinition.Int: { // int型フィールドなら judgeI.Judge( out bJudge, name_KeyField, value_Expected, isRequired_ExpectedValue, row, parent_Query, log_Reports ); } break; case EnumTypeFielddefinition.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_Configuration(parent_Query)); s.AppendI(0, "</NFuncCellUpdaterImplクラス>"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── /// <summary> /// where句の最初の条件を引っこ抜く。 /// 条件に合うものを一気に集めてくる形になっているが、 /// SelectedRecords に機能を持たせるか? /// </summary> /// <param name="out_Name_KeyField"></param> /// <param name="out_FielddefinitionKey2"></param> /// <param name="out_Value_Expected"></param> /// <param name="childReccondList"></param> /// <param name="tableH"></param> /// <param name="log_Reports"></param> public void GetFirstAwhrReccond( out string out_Name_KeyField, out Fielddefinition out_FielddefinitionKey2, out string out_Value_Expected, List <Recordcondition> list_ChildReccond, Table_Humaninput tableH, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_Expr.Name_Library, this, "GetFirstAwhrReccond", log_Reports); // // Recordcondition err_Recordcondition = null; if (0 < list_ChildReccond.Count) { Recordcondition recCond_First = list_ChildReccond[0]; err_Recordcondition = recCond_First; // // 検索のキーとなるフィールドの定義を調べます。 List <string> list_Name_KeyFld; { // 要素数1個 list_Name_KeyFld = new List <string>(); list_Name_KeyFld.Add(recCond_First.Name_Field); } // 該当なしの場合、ヌルを返す。 RecordFielddefinition recordFielddefinition; bool bHit = tableH.TryGetFieldDefinitionByName( out recordFielddefinition, list_Name_KeyFld, true,// 必須指定。 log_Reports ); if (!log_Reports.Successful || !bHit) { // エラー out_Name_KeyField = ""; out_FielddefinitionKey2 = null; out_Value_Expected = ""; goto gt_EndMethod; } //正常 out_FielddefinitionKey2 = recordFielddefinition.ValueAt(0); out_Name_KeyField = recCond_First.Name_Field; out_Value_Expected = recCond_First.Value; } else { //正常 out_Name_KeyField = ""; out_FielddefinitionKey2 = null; out_Value_Expected = ""; } goto gt_EndMethod; // // // // gt_EndMethod: log_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── /// <summary> /// 選択されているセルに、指定の値を上書きします。 /// </summary> /// <param nFcName="outputValueStr"></param> /// <param nFcName="row"></param> /// <param nFcName="selFldDefinition">選択フィールド</param> /// <param nFcName="log_Reports"></param> public void ToMemory_ToSelectedField( string sValue_Output, Expression_Node_String ec_Fcell, DataRow row, Fielddefinition selFldDefinition,//選択したフィールド定義 Log_Reports log_Reports ) { //essageBox.Show("アップデートデータ【開始】 outputValueStr=[" + outputValueStr + "]\n", "(FormsImpl)" + this.GetType().NFcName ); //.WriteLine(this.GetType().NFcName + "#: 【開始】データのアップデートを始める。"); Log_Method pg_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); pg_Method.BeginMethod(Info_Controls.Name_Library, this, "ToM_ToSelectedField",log_Reports); // // string sName_SelectedFld; { bool bHit = ec_Fcell.TrySelectAttribute( out sName_SelectedFld, PmNames.S_SELECT.Name_Pm, EnumHitcount.One, log_Reports ); } string sConfigStack_StringOfCell = sName_SelectedFld; switch (selFldDefinition.Type_Field) { case EnumTypeFielddefinition.String: { // 空欄も自動処理 String_HumaninputImpl cellData = new String_HumaninputImpl(sConfigStack_StringOfCell); cellData.Text = sValue_Output; row[sName_SelectedFld] = cellData; } break; case EnumTypeFielddefinition.Int: { // 空欄も自動処理 Int_HumaninputImpl cellData = new Int_HumaninputImpl(sConfigStack_StringOfCell); cellData.Text = sValue_Output; row[sName_SelectedFld] = cellData; } break; case EnumTypeFielddefinition.Bool: { // 空欄も自動処理 Bool_HumaninputImpl cellData = new Bool_HumaninputImpl(sConfigStack_StringOfCell); cellData.Text = sValue_Output; row[sName_SelectedFld] = cellData; } break; default: { if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー398!", pg_Method); StringBuilder t = new StringBuilder(); t.Append("予期しない、フィールドの型です。"); t.Append(Environment.NewLine); t.Append("selFldDefinition.Type=["); t.Append(selFldDefinition.ToString_Type()); t.Append("]"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); // ヒント t.Append(r.Message_Configuration( ec_Fcell.Cur_Configuration)); r.Message = t.ToString(); log_Reports.EndCreateReport(); } } break; } // pg_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── public void Add(Fielddefinition fielddefinition) { this.List_Fielddefinition.Add(fielddefinition); }
//──────────────────────────────────────── /// <summary> /// where句の最初の条件を引っこ抜く。 /// 条件に合うものを一気に集めてくる形になっているが、 /// SelectedRecords に機能を持たせるか? /// </summary> /// <param name="out_Name_KeyField"></param> /// <param name="out_FielddefinitionKey2"></param> /// <param name="out_Value_Expected"></param> /// <param name="childReccondList"></param> /// <param name="tableH"></param> /// <param name="log_Reports"></param> public void GetFirstAwhrReccond( out string out_Name_KeyField, out Fielddefinition out_FielddefinitionKey2, out string out_Value_Expected, List<Recordcondition> list_ChildReccond, Table_Humaninput tableH, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_Expr.Name_Library, this, "GetFirstAwhrReccond",log_Reports); // // Recordcondition err_Recordcondition = null; if (0 < list_ChildReccond.Count) { Recordcondition recCond_First = list_ChildReccond[0]; err_Recordcondition = recCond_First; // // 検索のキーとなるフィールドの定義を調べます。 List<string> list_Name_KeyFld; { // 要素数1個 list_Name_KeyFld = new List<string>(); list_Name_KeyFld.Add(recCond_First.Name_Field); } // 該当なしの場合、ヌルを返す。 RecordFielddefinition recordFielddefinition; bool bHit = tableH.TryGetFieldDefinitionByName( out recordFielddefinition, list_Name_KeyFld, true,// 必須指定。 log_Reports ); if (!log_Reports.Successful || !bHit) { // エラー out_Name_KeyField = ""; out_FielddefinitionKey2 = null; out_Value_Expected = ""; goto gt_EndMethod; } //正常 out_FielddefinitionKey2 = recordFielddefinition.ValueAt(0); out_Name_KeyField = recCond_First.Name_Field; out_Value_Expected = recCond_First.Value; } else { //正常 out_Name_KeyField = ""; out_FielddefinitionKey2 = null; out_Value_Expected = ""; } goto gt_EndMethod; // // // // gt_EndMethod: log_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── /// <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, Fielddefinition fielddefinition_Key, DataTable dataTable, Configuration_Node 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 EnumTypeFielddefinition.String: { // string型フィールドなら judgeS.Judge( out bJudge, name_KeyField, value_Expected, isRequired_ExpectedValue, row, parent_Query, log_Reports ); } break; case EnumTypeFielddefinition.Int: { // int型フィールドなら judgeI.Judge( out bJudge, name_KeyField, value_Expected, isRequired_ExpectedValue, row, parent_Query, log_Reports ); } break; case EnumTypeFielddefinition.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_Configuration(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> /// /// </summary> /// <param oVariableName="selectedFldDefinition"></param> /// <param oVariableName="selectedOValue"></param> /// <returns></returns> private Expression_Node_String GetSelectedFieldValue( Fielddefinition selectedFldDefinition, Value_Humaninput valueH_Selected, Configuration_Node parent_Cf_Select, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_Expr.Name_Library, this, "GetSelectedFldValue",log_Reports); // // Expression_Node_String reslt_Expression_SelectedValue; switch (selectedFldDefinition.Type_Field) { case EnumTypeFielddefinition.String: { StringBuilder s = new StringBuilder(); s.Append("StringCellDataフィールド["); s.Append(selectedFldDefinition.Name_Humaninput); s.Append("]から取得"); string sValue = ((Value_Humaninput)valueH_Selected).Text; Expression_Leaf_String ec_Field = new Expression_Leaf_StringImpl(null, parent_Cf_Select); ec_Field.SetString(sValue, log_Reports); reslt_Expression_SelectedValue = ec_Field; } break; case EnumTypeFielddefinition.Int: { StringBuilder s = new StringBuilder(); s.Append("IntCellDataフィールド["); s.Append(selectedFldDefinition.Name_Humaninput); s.Append("]から取得"); string sValue = ((Value_Humaninput)valueH_Selected).Text; Expression_Leaf_String ec_Field = new Expression_Leaf_StringImpl(null, parent_Cf_Select); ec_Field.SetString(sValue, log_Reports); reslt_Expression_SelectedValue = ec_Field; } break; case EnumTypeFielddefinition.Bool: { StringBuilder s = new StringBuilder(); s.Append("Value_Humaninput_Boolフィールド["); s.Append(selectedFldDefinition.Name_Humaninput); s.Append("]から取得"); string sValue = ((Value_Humaninput)valueH_Selected).Text; Expression_Leaf_String ec_Field = new Expression_Leaf_StringImpl(null, parent_Cf_Select); ec_Field.SetString(sValue, log_Reports); reslt_Expression_SelectedValue = ec_Field; } break; default: { reslt_Expression_SelectedValue = null; goto gt_Error_NotSupportedType; } } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_NotSupportedType: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, selectedFldDefinition.ToString_Type(), log_Reports);//選択したフィールド定義の型名 this.Owner_MemoryApplication.CreateErrorReport("Er:6029;", tmpl, log_Reports); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); return reslt_Expression_SelectedValue; }
/// <summary> /// フィールドを追加します。 /// 同名の列が既に追加されている場合は無視されます。 /// </summary> /// <param name="fielddefinition_New"></param> /// <param name="isRequired">追加に失敗したときエラーにするなら真。ただし、既に同名の列が追加されている場合は除く。</param> /// <param name="log_Reports"></param> /// <returns>追加に成功した場合、真を返します。</returns> public bool InsertField(int columnIndex, Fielddefinition fielddefinition_New, bool isRequired, Log_Reports log_Reports) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Table.Name_Library, this, "InsertField", log_Reports); bool isResult = false; if (this.DataTable.Columns.Contains(fielddefinition_New.Name_Trimupper)) { //既に同名の列があれば。 //無視。 goto gt_EndMethod; } // 定義部に挿入します。 this.RecordFielddefinition.Insert(columnIndex, fielddefinition_New); // データ部テーブルの最後尾に、ダミーの列を1個追加します。 this.DataTable.Columns.Add( fielddefinition_New.Name_Humaninput,// "<ADD>",//フィールド名はダミー。被らない名前が好ましい。 fielddefinition_New.ToType_Field() ); this.ForEach_Datapart(delegate(Record_Humaninput recordH, ref bool isBreak2, Log_Reports log_Reports2) { // todo:型もチェンジしてる? recordH.Insert(columnIndex, fielddefinition_New.NewField(log_Method.Fullname,log_Reports2), log_Reports2); },log_Reports); goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── //gt_Error_Exists: // if (log_Reports.CanCreateReport) // { // Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); // r.SetTitle("▲エラー463!", log_Method); // Log_TextIndented s = new Log_TextIndentedImpl(); // s.Append("列定義の個数より フィールド数の少ない入力テーブルが指定されました。"); // s.Newline(); // s.Append("実データのこの行の列数["); // s.Append(err_SList_Column.Count); // s.Append("] 指定した列インデックス=["); // s.Append(err_NCIx); // s.Append("] フィールド定義の個数=["); // s.Append(recordFielddefinition.Count); // s.Append("]"); // s.Newline(); // s.Append("──────────────────────────────テーブルに存在する列名"); // s.Newline(); // foreach (DataColumn col in err_DataRow.Table.Columns) // { // s.Append("実列名=[" + col.ColumnName + "]"); // s.Newline(); // } // s.Append("──────────────────────────────"); // s.Newline(); // s.Append("──────────────────────────────定義に存在する列名"); // s.Newline(); // s.Append("定義列名=[" + recordFielddefinition.ToString_DebugDump() + "]"); // s.Newline(); // s.Append("──────────────────────────────"); // s.Newline(); // // ヒント // r.Message = s.ToString(); // log_Reports.EndCreateReport(); // } // goto gt_EndMethod; //──────────────────────────────────────── #endregion // gt_EndMethod: log_Method.EndMethod(log_Reports); return isResult; }
//──────────────────────────────────────── /// <summary> /// 「END」フィールドの左に、新しいフィールドを追加します。 /// 同名の列が既に追加されている場合は無視されます。 /// </summary> /// <param name="fielddefinition_New"></param> /// <param name="isRequired">追加に失敗したときエラーにするなら真。ただし、既に同名の列が追加されている場合は除く。</param> /// <param name="log_Reports"></param> /// <returns>追加に成功した場合、真を返します。</returns> public bool AddField(Fielddefinition fielddefinition_New, bool isRequired, Log_Reports log_Reports) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Table.Name_Library, this, "AddField", log_Reports); bool isResult = false; if (this.DataTable.Columns.Contains(fielddefinition_New.Name_Trimupper)) { //既に同名の列があれば。 //無視。 goto gt_EndMethod; } //「ENDフィールド」の列index。 int index_FieldEnd = this.RecordFielddefinition.ColumnIndexOf_Trimupper("END"); int index_Insert; if (-1 == index_FieldEnd) { index_Insert = this.RecordFielddefinition.Count; } else { //「END」フィールドがある場合。 index_Insert = index_FieldEnd; } isResult = this.InsertField(index_Insert, fielddefinition_New, isRequired, log_Reports); goto gt_EndMethod; // gt_EndMethod: log_Method.EndMethod(log_Reports); return isResult; }
//──────────────────────────────────────── /// <summary> /// /// </summary> /// <param oVariableName="selectedFldDefinition"></param> /// <param oVariableName="selectedOValue"></param> /// <returns></returns> private Expression_Node_String GetSelectedFieldValue( Fielddefinition selectedFldDefinition, Value_Humaninput valueH_Selected, Configuration_Node parent_Cf_Select, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_Expr.Name_Library, this, "GetSelectedFldValue", log_Reports); // // Expression_Node_String reslt_Expression_SelectedValue; switch (selectedFldDefinition.Type_Field) { case EnumTypeFielddefinition.String: { StringBuilder s = new StringBuilder(); s.Append("StringCellDataフィールド["); s.Append(selectedFldDefinition.Name_Humaninput); s.Append("]から取得"); string sValue = ((Value_Humaninput)valueH_Selected).Text; Expression_Leaf_String ec_Field = new Expression_Leaf_StringImpl(null, parent_Cf_Select); ec_Field.SetString(sValue, log_Reports); reslt_Expression_SelectedValue = ec_Field; } break; case EnumTypeFielddefinition.Int: { StringBuilder s = new StringBuilder(); s.Append("IntCellDataフィールド["); s.Append(selectedFldDefinition.Name_Humaninput); s.Append("]から取得"); string sValue = ((Value_Humaninput)valueH_Selected).Text; Expression_Leaf_String ec_Field = new Expression_Leaf_StringImpl(null, parent_Cf_Select); ec_Field.SetString(sValue, log_Reports); reslt_Expression_SelectedValue = ec_Field; } break; case EnumTypeFielddefinition.Bool: { StringBuilder s = new StringBuilder(); s.Append("Value_Humaninput_Boolフィールド["); s.Append(selectedFldDefinition.Name_Humaninput); s.Append("]から取得"); string sValue = ((Value_Humaninput)valueH_Selected).Text; Expression_Leaf_String ec_Field = new Expression_Leaf_StringImpl(null, parent_Cf_Select); ec_Field.SetString(sValue, log_Reports); reslt_Expression_SelectedValue = ec_Field; } break; default: { reslt_Expression_SelectedValue = null; goto gt_Error_NotSupportedType; } } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_NotSupportedType: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, selectedFldDefinition.ToString_Type(), log_Reports);//選択したフィールド定義の型名 this.Owner_MemoryApplication.CreateErrorReport("Er:6029;", tmpl, log_Reports); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(reslt_Expression_SelectedValue); }
//──────────────────────────────────────── /// <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(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); Fielddefinition o_FldDef = tableH_Source.RecordFielddefinition.ValueAt(nFieldIx); Value_Humaninput o_Value = (Value_Humaninput)srcRow[nFieldIx]; // 型に合わせて値取得。 if (o_Value is Int_HumaninputImpl) { //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.ApplyWhere: intフィールド [" + sLogic + " " + sField + " " + sOpe + " " + sValue + "]"); int nFieldInt; { Int_HumaninputImpl.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(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(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); }
//──────────────────────────────────────── /// <summary> /// 選択されているセルに、指定の値を上書きします。 /// </summary> /// <param nFcName="outputValueStr"></param> /// <param nFcName="row"></param> /// <param nFcName="selFldDefinition">選択フィールド</param> /// <param nFcName="log_Reports"></param> public void ToMemory_ToSelectedField( string sValue_Output, Expression_Node_String ec_Fcell, DataRow row, Fielddefinition selFldDefinition,//選択したフィールド定義 Log_Reports log_Reports ) { //essageBox.Show("アップデートデータ【開始】 outputValueStr=[" + outputValueStr + "]\n", "(FormsImpl)" + this.GetType().NFcName ); //.WriteLine(this.GetType().NFcName + "#: 【開始】データのアップデートを始める。"); Log_Method pg_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); pg_Method.BeginMethod(Info_Controls.Name_Library, this, "ToM_ToSelectedField", log_Reports); // // string sName_SelectedFld; { bool bHit = ec_Fcell.TrySelectAttribute( out sName_SelectedFld, PmNames.S_SELECT.Name_Pm, EnumHitcount.One, log_Reports ); } string sConfigStack_StringOfCell = sName_SelectedFld; switch (selFldDefinition.Type_Field) { case EnumTypeFielddefinition.String: { // 空欄も自動処理 String_HumaninputImpl cellData = new String_HumaninputImpl(sConfigStack_StringOfCell); cellData.Text = sValue_Output; row[sName_SelectedFld] = cellData; } break; case EnumTypeFielddefinition.Int: { // 空欄も自動処理 Int_HumaninputImpl cellData = new Int_HumaninputImpl(sConfigStack_StringOfCell); cellData.Text = sValue_Output; row[sName_SelectedFld] = cellData; } break; case EnumTypeFielddefinition.Bool: { // 空欄も自動処理 Bool_HumaninputImpl cellData = new Bool_HumaninputImpl(sConfigStack_StringOfCell); cellData.Text = sValue_Output; row[sName_SelectedFld] = cellData; } break; default: { if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー398!", pg_Method); StringBuilder t = new StringBuilder(); t.Append("予期しない、フィールドの型です。"); t.Append(Environment.NewLine); t.Append("selFldDefinition.Type=["); t.Append(selFldDefinition.ToString_Type()); t.Append("]"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); // ヒント t.Append(r.Message_Configuration( ec_Fcell.Cur_Configuration)); r.Message = t.ToString(); log_Reports.EndCreateReport(); } } break; } // pg_Method.EndMethod(log_Reports); }