Exemplo n.º 1
0
        /// <summary>
        /// セレクト文を指定することで、レコードセットを取得。
        /// </summary>
        /// <param name="log_Reports"></param>
        /// <returns>該当がなければヌル。</returns>
        private RecordSet E_Execute_P2_Select(
            bool isExists_Awhr,
            Selectstatement selectSt,
            Configuration_Node parent_Conf_Query,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static);
            log_Method.BeginMethod(Info_Expr.Name_Library, this, "E_Execute_P2_Select",log_Reports);
            //
            //

            RecordSet reslt_Rs;

            bool bLoad = false;

            // 一時記憶から、レコードセットのロードをするか否か。
            {
                {
                    Expression_Node_String ec_Awhr_RecordSetLoadFrom;//ソース情報利用
                    bool bHit = this.TrySelectAttribute(
                         out ec_Awhr_RecordSetLoadFrom,
                        NamesNode.S_RECORD_SET_LOAD_FROM,
                        EnumHitcount.One_Or_Zero,
                        log_Reports //null
                        );

                    selectSt.Expression_Where_RecordSetLoadFrom = ec_Awhr_RecordSetLoadFrom;
                }

                if ("" != selectSt.Expression_Where_RecordSetLoadFrom.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports).Trim())
                {
                    bLoad = true;
                }
            }

            // レコードセットの取得。
            if (bLoad)
            {
                // 一時記憶からロード。
                P1_RecordSetLoader sel1 = new P1_RecordSetLoader(this.Owner_MemoryApplication);
                reslt_Rs = sel1.P1_Load(
                    selectSt.Expression_Where_RecordSetLoadFrom,
                    this.Cur_Configuration,
                    log_Reports
                    );

                // ★空になってる。一時記憶から取り出したい。★★★★★★★★★★★★★★★★★★★★
                //p3_Selectstatement = recordSet.Selectstatement;
                // new SelectStateImpl(s_ParentNode);

                //
                // データベースからレコード検索。
                //p3_Selectstatement = this.E_Execute_P0(
                //    nWhere_recordSetLoadFrom,
                //    s_ParentNode,
                //    log_Reports
                //    );

                // debug: 一時記憶から読み取った、レコードセットの内容。
                //if (false)
                //{
                //    StringBuilder txt = new StringBuilder();

                //    txt.Append(Info_E.LibraryName + ":" + this.GetType().Name + "#E_Execute: (30_<f-cell>)【一時記憶から読み取った、レコードセットの内容(A)】");
                //    txt.Append(" fld=[" + recordSet.Selectstatement.E_Field.E_Execute( log_Reports) + "]");
                //    txt.Append(" lookup-value=[" + recordSet.Selectstatement.E_Value.E_Execute( log_Reports) + "]");
                //    txt.Append(" required=[" + recordSet.Selectstatement.E_Required.E_Execute( log_Reports) + "]");
                //    txt.Append(" from=[" + recordSet.Selectstatement.Expression_From.E_Execute( log_Reports) + "]");
                //    txt.Append(" description=[" + recordSet.Selectstatement.Expression_Description.E_Execute( log_Reports) + "]");
                //    txt.Append(" Storage=[" + recordSet.Selectstatement.Expression_Storage.E_Execute( log_Reports) + "]");
                //    txt.Append(" ヒット件数=[" + recordSet.O_Items.Count + "]");

                //    // レコードの内容
                //    foreach (Dictionary<string, Value_Humaninput> oRecord in recordSet.O_Items)
                //    {
                //        txt.Append(" フィールド数=[" + oRecord.Count + "]");
                //        foreach (string sKey in oRecord.Keys)
                //        {
                //            Value_Humaninput oValue = oRecord[sKey];
                //            txt.Append(" 要素=[" + sKey + ":"+ oValue.Humaninput + "]");
                //        }
                //    }

                //    //ystem.Console.WriteLine( txt.ToString() );
                //}

            }
            else
            {
                Table_Humaninput tableH = this.Owner_MemoryApplication.MemoryTables.GetTable_HumaninputByName(selectSt.Expression_From, true, log_Reports);
                if (null == tableH)
                {
                    // エラー。
                    reslt_Rs = null;
                    goto gt_Error_NullTable;
                }
                // レコードセットを用意。
                reslt_Rs = new RecordSetImpl(tableH);

                bool isRequired_ExpectedValue;
                {
                    bool parseSuccessful = bool.TryParse(selectSt.Required, out isRequired_ExpectedValue);
                }

                //
                // 検索実行。
                {
                    List<DataRow> dst_Row = new List<DataRow>();

                    //
                    // 条件
                    //
                    if (0 < selectSt.List_Recordcondition.Count)
                    {
                        // 条件が指定されている場合。

                        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.List_Recordcondition,
                            tableH,
                            log_Reports
                            );

                        if (log_Reports.Successful)
                        {
                            // TODO:セル型でない場合、キーフィールド名がないこともある。

                            SelectPerformerImpl sp = new SelectPerformerImpl();
                            sp.Select(
                                out dst_Row,
                                name_KeyField,
                                value_Expected,
                                isRequired_ExpectedValue,
                                fielddefinition_Key,
                                tableH.DataTable,
                                parent_Conf_Query,
                                log_Reports
                                );
                        }
                    }
                    else
                    {
                        // 条件が指定されていない場合。

                        SelectPerformerImpl sp = new SelectPerformerImpl();
                        sp.Select(
                            out dst_Row,
                            isRequired_ExpectedValue,
                            tableH.DataTable,
                            parent_Conf_Query,
                            log_Reports
                            );
                    }

                    if (log_Reports.Successful)
                    {
                        reslt_Rs.AddList(dst_Row, log_Reports);
                    }

                    if (!log_Reports.Successful)
                    {
                        // 既エラー。
                        goto gt_EndMethod;
                    }

                }
            }

            goto gt_EndMethod;
            //
            //
            #region 異常系
            //────────────────────────────────────────
            gt_Error_NullTable:
            {
                Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl();
                tmpl.SetParameter(1, Log_RecordReportsImpl.ToText_Configuration(parent_Conf_Query), log_Reports);//設定位置パンくずリスト

                this.Owner_MemoryApplication.CreateErrorReport("Er:6019;", tmpl, log_Reports);
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
            gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return reslt_Rs;
        }
        //────────────────────────────────────────
        /// <summary>
        /// レコードセットを、名前を付けて一時記憶します。
        /// </summary>
        public void Execute_SaveRecordset(Log_Reports log_Reports)
        {
            Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static);
            log_Method.BeginMethod(Info_Expr.Name_Library, this, "Execute_SaveRecordset", log_Reports);
            //
            //

            //
            // 既に、一時記憶に同名のレコードセットがないか検索。

            string sStorage = this.Expression_Storage.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports);
            if (!this.Owner_MemoryApplication.MemoryRecordset.RecordsetStorage.Contains(this.Expression_Storage, log_Reports))
            {
                RecordSet dst_Rs_ToSave;
                Selectstatement selectSt_ToSave;
                {
                    if ("" == this.Expression_From.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports).Trim())
                    {
                        //
                        // エラー。
                        goto gt_Error_EmptyTableName;
                    }

                    Table_Humaninput oTable = this.Owner_MemoryApplication.MemoryTables.GetTable_HumaninputByName(
                        this.Expression_From,//これが空文字列の場合がある??
                        true,
                        log_Reports
                        );
                    dst_Rs_ToSave = new RecordSetImpl(oTable);

                    //
                    // 要求の作成。
                    {
                        // <startup-special-rule>の中で使う子要素。
                        selectSt_ToSave = new SelectstatementImpl(this, this.Cur_Configuration);
                        {
                            Recordcondition recCond1;// = new RecordconditionImpl(s_ParentNode);

                            // TODO: logic要素がある版も要るはず。
                            bool bSuccessful = RecordconditionImpl.TryBuild(
                                out recCond1,
                                EnumLogic.None,
                                this.Expression_Field.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports),
                                this.Cur_Configuration.Parent,
                                log_Reports
                                );
                            recCond1.Value = this.Expression_LookupVal.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports);
                            selectSt_ToSave.List_Recordcondition.Add(recCond1);
                        }
                        selectSt_ToSave.Required = this.Expression_Required.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports);
                        selectSt_ToSave.Expression_From = this.Expression_From;
                        selectSt_ToSave.Storage = this.Expression_Storage.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports);
                    }
                }

                //
                // レコードの検索。
                {
                    //Configurationtree_Node
                    Configuration_Node parent_Cf_Query = this.Cur_Configuration.Parent;

                    // テーブル名。
                    if ("" == selectSt_ToSave.Expression_From.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports).Trim())
                    {
                        //
                        // エラー。
                        goto gt_Error_EmptyTableName;
                    }

                    Table_Humaninput o_Table = this.Owner_MemoryApplication.MemoryTables.GetTable_HumaninputByName(selectSt_ToSave.Expression_From, true, log_Reports);

                    if (null == o_Table)
                    {
                        goto gt_Error_NullTable;
                    }

                    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)
                    {
                        // 既エラー。
                        goto gt_EndMethod;
                    }

                    //P2_SelectCellImpl sel2 = new P2_SelectCellImpl(this.MoOpyopyo);
                    //sel2.P2_Select(
                    //    ref dst_Rs_ToSave,
                    //    selectSt_ToSave,
                    //    this.Parent,
                    //    log_Reports
                    //    );
                }

                // debug:
                //if (false)
                //{
                //    StringBuilder txt = new StringBuilder();

                //    txt.Append(Info_E.LibraryName + ":" + this.GetType().Name + "#SaveRecordSet: 【検索してきたレコードセット】ここで内容消えてない?(2)?");
                //    txt.Append(" fld=[" + recordSet_toSave.Selectstatement.E_Field.E_Execute(log_Reports) + "]");
                //    txt.Append(" lookup-value=[" + recordSet_toSave.Selectstatement.E_Value.E_Execute( log_Reports) + "]");
                //    txt.Append(" description=[" + recordSet_toSave.Selectstatement.Expression_Description.E_Execute( log_Reports) + "]");
                //    txt.Append(" from=[" + recordSet_toSave.Selectstatement.Expression_From.E_Execute( log_Reports) + "]");
                //    txt.Append(" required=[" + recordSet_toSave.Selectstatement.E_Required.E_Execute( log_Reports) + "]");
                //    txt.Append(" Storage=[" + recordSet_toSave.Selectstatement.Expression_Storage.E_Execute( log_Reports) + "]");

                //    //txt.Append(" this.NFld=[" + RecordSet_toSave.NField.E_Execute(EnumHitcount.Unconstraint, log_Reports) + "]");
                //    //txt.Append(" this.NLookupValue=[" + RecordSet_toSave.NLookupValue.E_Execute(EnumHitcount.Unconstraint, log_Reports) + "]");
                //    //txt.Append(" this.NRequired=[" + RecordSet_toSave.NRequired.E_Execute(EnumHitcount.Unconstraint, log_Reports) + "]");
                //    //txt.Append(" this.NFrom=[" + RecordSet_toSave.NFrom.E_Execute(EnumHitcount.Unconstraint, log_Reports) + "]");

                //    //txt.Append(" ヒット件数=[" + RecordSet_toSave.O_Items.Count + "]");
                //    txt.Append(" ヒット件数=[" + recordSet.Count + "]");

                //    // レコードの内容
                //    //foreach (Dictionary<string, OValue> oRecord in RecordSet_toSave.O_Items)
                //    //{
                //    //    txt.Append(" フィールド数=[" + oRecord.Count + "]");
                //    //    foreach (string sKey in oRecord.Keys)
                //    //    {
                //    //        OValue oValue = oRecord[sKey];
                //    //        txt.Append(" 要素=[" + sKey + ":" + oValue.HumanInputString + "]");
                //    //    }
                //    //}
                //    foreach (DataRow record in recordSet)
                //    {
                //        txt.Append(" フィールド数=[" + record.Table.Columns.Count + "]");
                //        foreach (DataColumn column in record.Table.Columns)
                //        {

                //            Value_Humaninput oValue = (Value_Humaninput)record[column.ColumnName];

                //            txt.Append(" ★" + column.ColumnName + "=[" + oValue.Humaninput + "]");
                //        }
                //    }

                //    //ystem.Console.WriteLine(txt.ToString());
                //}

                // debug:
                //if (false)
                //{
                //    StringBuilder txt = new StringBuilder();

                //    txt.Append(Info_E.LibraryName + ":" + this.GetType().Name + "#SaveRecordSet:  【検索してきたレコードセット】内容入っていますか(3)?");

                //    txt.Append(" ヒット件数=[" + recordSet_toSave.O_Items.Count + "]←検索後");

                //    // レコードの内容
                //    foreach (Dictionary<string, Value_Humaninput> oRecord in recordSet_toSave.O_Items)
                //    {
                //        txt.Append(" フィールド数=[" + oRecord.Count + "]");
                //        foreach (string sKey in oRecord.Keys)
                //        {
                //            Value_Humaninput oValue = oRecord[sKey];
                //            txt.Append(" ■" + sKey + "=[" + oValue.Humaninput + "]");
                //        }
                //    }

                //    //ystem.Console.WriteLine(txt.ToString());
                //}

                //
                // レコードの一時保存。
                P4_RecordSetSaverImpl sel4 = new P4_RecordSetSaverImpl(this.Owner_MemoryApplication);
                sel4.P4_Save(
                    dst_Rs_ToSave,
                    this,
                    log_Reports
                    );
            }
            else
            {
                //ystem.Console.WriteLine(this.GetType().Name + "#SaveRecordSet: レコードセットは既に登録済みです。");
            }

            goto gt_EndMethod;
            //
            //
            #region 異常系
            //────────────────────────────────────────
            gt_Error_EmptyTableName:
            {
                Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl();
                tmpl.SetParameter(1, Log_RecordReportsImpl.ToText_Configuration(this.Cur_Configuration.Parent), log_Reports);//設定位置パンくずリスト

                this.Owner_MemoryApplication.CreateErrorReport("Er:6030;", tmpl, log_Reports);
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            gt_Error_NullTable:
            {
                Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl();
                tmpl.SetParameter(1, Log_RecordReportsImpl.ToText_Configuration(this.Cur_Configuration.Parent), log_Reports);//設定位置パンくずリスト

                this.Owner_MemoryApplication.CreateErrorReport("Er:6031;", tmpl, log_Reports);
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
            gt_EndMethod:
            log_Method.EndMethod(log_Reports);
        }
Exemplo n.º 3
0
        //────────────────────────────────────────
        /// <summary>
        /// ユーザー定義プログラムの実行。
        /// </summary>
        /// <returns></returns>
        public override string Execute5_Main(
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static);
            log_Method.BeginMethod(Info_Expr.Name_Library, this, "Execute5_Main", log_Reports);
            //
            //

            Configuration_Node parent_Configurationtree_Node_Query = this.Cur_Configuration;

            StringBuilder sb_Result = new StringBuilder();

            //
            // 外観
            //
            // <f-text-template table="Ut:条件テーブル" lookup-id="100">
            //
            // ・lookup-id は、lookup-value という名前の方が良かった。
            //

            //
            // 指定のテーブルの ID列を指定して、TEXT列の内容を取得。
            Builder_TexttemplateP1pImpl p1pText = new Builder_TexttemplateP1pImpl();
            {
                // <f-text-template>要素。
                Selectstatement selectSt = new SelectstatementImpl(this, this.Cur_Configuration);

                // TODO: logic属性がある版も要るはず。
                Recordcondition recCond1;
                bool bSuccessful = RecordconditionImpl.TryBuild(out recCond1, EnumLogic.None, Expression_SftextTemplate.S_FIELD_ID, parent_Configurationtree_Node_Query, log_Reports);
                selectSt.List_Recordcondition.Add(recCond1);

                ////
                //// (1)キー_フィールド名
                //{
                //    recCond1.Name_Field = "ID";
                //}

                //
                // (2)探したいキー値
                {
                    //
                    // thisは、<f-text-template>。
                    //

                    string sLookupId;
                    bool bHit = this.TrySelectAttribute(out sLookupId, PmNames.S_LOOKUP_ID.Name_Pm, EnumHitcount.One, log_Reports);
                    if (bHit)
                    {
                        recCond1.Value = sLookupId;
                    }

                    string sLookupValue;
                    if (log_Reports.Successful)
                    {
                        sLookupValue = recCond1.Value;
                    }
                    else
                    {
                        // エラー
                        goto gt_Error_NotFoundVariable;
                    }

                    // bug:
                    if ("" == sLookupValue.Trim())
                    {
                        //
                        // 検索キーが空欄の場合。
                        sb_Result.Length = 0; //空文字列にする。
                        goto gt_EndMethod;
                    }
                }

                //
                // (3)検索ヒットの必須の有無
                {
                    // 必須指定。
                    selectSt.Required = Expression_SftextTemplate.S_TRUE;
                }

                //
                // (4)テーブル名
                {
                    Expression_Node_String ec_Result;//ソース情報利用
                    bool bHit = this.TrySelectAttribute(out ec_Result, PmNames.S_TABLE.Name_Pm, EnumHitcount.One, log_Reports);
                    selectSt.Expression_From = ec_Result;
                }

                //
                // (5)欲しいデータのあるフィールド名
                selectSt.List_SName_SelectField.Add(Expression_SftextTemplate.S_FIELD_TEXT);

                //
                // (1)レコードセットの絞り込み。
                RecordSet dst_Rs;
                {
                    Table_Humaninput o_Tbl = this.Owner_MemoryApplication.MemoryTables.GetTable_HumaninputByName(
                        selectSt.Expression_From,//これが空文字列の場合がある??
                        true,
                        log_Reports
                        );
                    dst_Rs = new RecordSetImpl(o_Tbl);
                }
                //dst_Rs.Selectstatement = selectSt;//★

                {

                    // テーブル名。
                    if ("" == selectSt.Expression_From.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports).Trim())
                    {
                        //
                        // エラー。
                        goto gt_Error_EmptyTableName;
                    }

                    Table_Humaninput o_Table = this.Owner_MemoryApplication.MemoryTables.GetTable_HumaninputByName(selectSt.Expression_From, true, log_Reports);

                    if (null == o_Table)
                    {
                        goto gt_Error_NullTable;
                    }

                    bool isRequired_ExpectedValue;
                    {
                        bool parseSuccessful = bool.TryParse(selectSt.Required, out isRequired_ExpectedValue);
                    }

                    //
                    //
                    //
                    // 条件
                    //
                    //
                    //
                    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.List_Recordcondition,
                        o_Table,
                        log_Reports
                        );

                    List<DataRow> dst_Row = new List<DataRow>();

                    if (log_Reports.Successful)
                    {
                        SelectPerformerImpl sp = new SelectPerformerImpl();
                        sp.Select(
                            out dst_Row,
                            name_KeyField,
                            value_Expected,
                            isRequired_ExpectedValue,
                            fielddefinition_Key,
                            o_Table.DataTable,
                            parent_Configurationtree_Node_Query,
                            log_Reports
                            );
                    }

                    if (log_Reports.Successful)
                    {
                        dst_Rs.AddList(dst_Row, log_Reports);
                    }

                    if (!log_Reports.Successful)
                    {
                        // 既エラー。
                        goto gt_EndMethod;
                    }
                }

                if (!log_Reports.Successful)
                {
                    //
                    // エラーが出ていたら、さっさと抜ける。
                    //sResult = "";
                    goto gt_EndMethod;
                }

                //
                // フィールド値の取得。
                P5_CellsSelecterImpl sel5 = new P5_CellsSelecterImpl(this.Owner_MemoryApplication);
                List<List<string>> sListList_reslt = sel5.P5_Select_CellType(
                    dst_Rs,
                    selectSt,
                    null,//nwhere_recordSetSaveTo,
                    this.Cur_Configuration,
                    log_Reports
                    );

                if (0 < sListList_reslt.Count)
                {
                    // 先頭行の、
                    List<string> sList_Fld = sListList_reslt[0];
                    // 先頭フィールドの値。
                    string sString = sList_Fld[0];

                    //e_string.SetValidation(...);
                    p1pText.Text = sString;
                }
                else
                {
                    // エラー

                    Log_TextIndented txt = new Log_TextIndentedImpl();
                    txt.Append(this.GetType().Name);
                    txt.Append("#GetString:(" + Info_Expr.Name_Library + ") エラー。該当なし。");

                    txt.Append(" 選択フィールド=[");

                    txt.Append(selectSt.ToSelectFieldNameListCsv());

                    txt.Append("]");

                    txt.Append(" テーブル=[");

                    txt.Append(selectSt.Expression_From.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports));
                    txt.Append("]");

                    // キーフィールド
                    txt.Append(" [");

                    txt.Append(recCond1.Name_Field);

                    txt.Append("]が");

                    // 探す値。
                    txt.Append("[");
                    txt.Append(recCond1.Value);
                    txt.Append("]のとき");

                    p1pText.Text = txt.ToString();
                }

            }

            List<int> nList_P1p = p1pText.ExistsP1pNumbers(
                this.Dictionary_Expression_Attribute,
                log_Reports
                );

            foreach (int n_P1p in nList_P1p)
            {
                string p1pValue;
                {
                    bool bHit = this.TrySelectAttribute(
                        out p1pValue,
                        "p" + n_P1p+"p",
                        EnumHitcount.One,
                        log_Reports
                        );

                    if (log_Reports.Successful)
                    {
                    }
                    else
                    {
                        p1pValue = null;
                    }

                    p1pText.Dictionary_NumberAndValue_Parameter.Add(n_P1p, p1pValue);
                }
            }

            Expression_Node_String ec_TextTemplate = p1pText.Compile(
                log_Reports
                );

            sb_Result.Append(ec_TextTemplate.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports));

            //
            //
            //
            // TODO: 制約の判定
            //
            //
            //

            goto gt_EndMethod;
            //
            //
            #region 異常系
            //────────────────────────────────────────
            gt_Error_NotFoundVariable:
            {
                Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl();
                tmpl.SetParameter(1, Log_RecordReportsImpl.ToText_Configuration(parent_Configurationtree_Node_Query), log_Reports);//設定位置パンくずリスト

                this.Owner_MemoryApplication.CreateErrorReport("Er:6009;", tmpl, log_Reports);
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            gt_Error_EmptyTableName:
            {
                Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl();
                tmpl.SetParameter(1, Log_RecordReportsImpl.ToText_Configuration(parent_Configurationtree_Node_Query), log_Reports);//設定位置パンくずリスト

                this.Owner_MemoryApplication.CreateErrorReport("Er:6010;", tmpl, log_Reports);
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            gt_Error_NullTable:
            {
                Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl();
                tmpl.SetParameter(1, Log_RecordReportsImpl.ToText_Configuration(parent_Configurationtree_Node_Query), log_Reports);//設定位置パンくずリスト

                this.Owner_MemoryApplication.CreateErrorReport("Er:6011;", tmpl, log_Reports);
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
            gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return sb_Result.ToString();
        }
        //────────────────────────────────────────
        /// <summary>
        /// <f-cell>→M
        /// </summary>
        /// <param name="outputValueStr"></param>
        /// <param name="nKeyExpected"></param>
        /// <param name="nFcell"></param>
        /// <param name="moApplication"></param>
        /// <param name="log_Reports"></param>
        public void Translate(
            string sOutputValue,
            Expression_Node_String ec_KeyExpected,
            Expression_Node_String ec_SfCell,//Sf:cell;相当と想定。
            MemoryApplication moApplication,
            Log_Reports log_Reports
            )
        {
            Log_Method pg_Method = new Log_MethodImpl(0);
            pg_Method.BeginMethod(Info_Controls.Name_Library, this, "EToM2",log_Reports);
            //
            //

            string sName_Fnc;
            ec_SfCell.TrySelectAttribute(out sName_Fnc, PmNames.S_NAME.Name_Pm, EnumHitcount.One, log_Reports);
            if (NamesFnc.S_CELL != sName_Fnc)
            {
                // エラー。
                goto gt_Error_NotSfcell;
            }

            string sSelectedFldName;
            if (log_Reports.Successful)
            {
                bool bHit = ec_SfCell.TrySelectAttribute(
                    out sSelectedFldName,
                    PmNames.S_SELECT.Name_Pm,
                    EnumHitcount.One_Or_Zero,
                    log_Reports
                    );

                //if (!bHit)
                //{
                //    // 【追加 2012-07-10】
                //    // Sf:cell; の子要素arg1 には、name="select" のものがある。本来これは属性連結しておいて欲しい。
                //    List<Expression_Node_String> list_Arg1 = e_SfCell.SelectDirectchildByNodename(NamesNode.S_ARG1, false, EnumHitcount.Unconstraint, log_Reports);

                //    d_InMethod.WriteDebug_ToConsole(1, "sSelectedFldNameが属性になかった。子要素arg1(" + list_Arg1 .Count+ "個)から探す。");
                //    if (0<d_InMethod.NDebugLevel && list_Arg1.Count<=0)
                //    {
                //        Log_TextIndented s = new Log_TextIndentedImpl();
                //        e_SfCell.ToText_Snapshot(s);
                //        d_InMethod.WriteDebug_ToConsole(1, s.ToString());
                //    }

                //    EUtil_NodeImpl.SelectItemsByAttrAsCsv(list_Arg1, PmNames.NAME.SAttrName, ValuesAttr.S_SELECT, false, EnumHitcount.First_Exist, log_Reports);

                //    if (log_Reports.Successful)
                //    {
                //        sSelectedFldName = list_Arg1[0].Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports);
                //    }
                //}
            }
            else
            {
                sSelectedFldName = "";
            }

            Expression_Node_String ec_KeyFldName1 = null;
            if (log_Reports.Successful)
            {
                Expression_Node_String ec_Where = null;

                //
                // 「E■where」は子要素。
                //

                // 再検索。
                ec_SfCell.List_Expression_Child.ForEach(delegate(Expression_Node_String ec_Child, ref bool bRemove, ref bool bBreak)
                {
                    string sValue;
                    ec_Child.TrySelectAttribute(out sValue, PmNames.S_NAME.Name_Pm, EnumHitcount.One, log_Reports);

                    if (NamesNode.S_FNC == ec_Child.Cur_Configuration.Name &&
                        NamesFnc.S_WHERE == sValue)
                    {
                        ec_Where = ec_Child;

                        if (pg_Method.CanDebug(2))
                        {
                            pg_Method.WriteDebug_ToConsole("子「E■[" + ec_Child.Cur_Configuration.Name + "]」。子要素数=[" + ec_Where.List_Expression_Child.Count + "]");
                        }

                        ec_Where.List_Expression_Child.ForEach(delegate(Expression_Node_String e_Item, ref bool bRemove2, ref bool bBreak2)
                        {
                            if (NamesNode.S_FNC == e_Item.Cur_Configuration.Name)
                            {
                                Expression_Node_String ec_Field;
                                bool bHit3 = e_Item.TrySelectAttribute(out ec_Field, PmNames.S_FIELD.Name_Pm, EnumHitcount.One_Or_Zero, log_Reports);
                                if (bHit3)
                                {
                                    //「E■f-cell」/「E■@where」/「E■fnc field=”★”」。
                                    ec_KeyFldName1 = ec_Field;

                                    if (pg_Method.CanDebug(2))
                                    {
                                        pg_Method.WriteDebug_ToConsole( "「E■f-cell」/「E■a-where」/「E■fnc field=”[" + ec_KeyFldName1.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]”」。");
                                    }
                                }
                                else
                                {
                                    throw new Exception("ここは通らない?");
                                }
                            }
                            else
                            {
                                // #エラー
                                System.Console.WriteLine(Info_Controls.Name_Library + ":" + this.GetType().Name + "#EToM: 「E■fnc」がありませんでした。");
                            }

                        });
                    }
                    else
                    {
                        if (pg_Method.CanDebug(2))
                        {
                            pg_Method.WriteDebug_ToConsole( "(無視)  子「E■[" + ec_Child.Cur_Configuration.Name + "]」。");
                        }
                    }
                });

                if (null == ec_Where)
                {
                    // #エラー
                    System.Console.WriteLine(Info_Controls.Name_Library + ":" + this.GetType().Name + "#EToM: 「E■f-cell」に、子「E■where」が無かった? そういう場合(無条件)もある。");
                }
            }
            else
            {
                ec_KeyFldName1 = null;
            }

            //
            // from
            //
            Expression_Node_String ec_TableName1;//ソース情報利用
            if (log_Reports.Successful)
            {
                // Sf:cell; に from が指定されていない?
                bool bHit = ec_SfCell.TrySelectAttribute(
                    out ec_TableName1,
                    PmNames.S_FROM.Name_Pm,
                    EnumHitcount.One,
                    log_Reports
                    );

                //if (null == e_TableName1)
                //{
                //    d_InMethod.WriteDebug_ToConsole(1, "e_TableName1が属性になかった。子要素arg1から探す。");
                //    // 【追加 2012-07-10】
                //    // Sf:cell; の子要素arg1 には、name=”from” のものがある。本来これは属性連結しておいて欲しい。
                //    List<Expression_Node_String> list_Arg1 = e_SfCell.SelectDirectchildByNodename(NamesNode.S_ARG1, false, EnumHitcount.Unconstraint, log_Reports);
                //    EUtil_NodeImpl.SelectItemsByAttrAsCsv(list_Arg1, PmNames.NAME.SAttrName, ValuesAttr.S_FROM, false, EnumHitcount.First_Exist, log_Reports);

                //    if (log_Reports.Successful)
                //    {
                //        e_TableName1 = list_Arg1[0];
                //    }
                //}
            }
            else
            {
                ec_TableName1 = null;
            }

            //
            // required
            //
            bool bExpectedValueRequired = false;
            if (log_Reports.Successful)
            {
                string sRequired1;
                bool bHit = ec_SfCell.TrySelectAttribute(out sRequired1, PmNames.S_REQUIRED.Name_Pm, EnumHitcount.One_Or_Zero, log_Reports);
                if (bHit)
                {
                    // 【旧仕様】
                    bool bParseSuccessful = bool.TryParse(sRequired1, out bExpectedValueRequired);
                }
                else
                {
                    // 【新仕様】

                    //
                    // 新仕様では、「E■f-cell/@E■where/E■prm name=”required”」。
                    //
                    {
                        Expression_Node_String ec_Where;
                        bool bHit1 = ec_SfCell.TrySelectAttribute(out ec_Where, PmNames.S_WHERE.Name_Pm, EnumHitcount.One_Or_Zero, log_Reports);
                        if (bHit1)
                        {
                            throw new Exception("こーこは通らない?");
                        }
                    }

                }
            }
            else
            {
            }

            // e_TableName を取得してから引数エラーチェック。
            if (null == ec_KeyExpected)
            {
                // エラー
                goto gt_Error_NullKeyExpected;
            }

            // ──────────

            Table_Humaninput o_Table;
            if (log_Reports.Successful)
            {
                o_Table = moApplication.MemoryTables.GetTable_HumaninputByName(ec_TableName1, true, log_Reports);
                // エラー時には、エラーメッセージを出させます。

                if (null == o_Table)
                {
                    //
                    // エラー中断。
                    goto gt_Error_NotFoundTable;
                }
                else
                {
                    //
                    // 正常時
                    //
                    //.WriteLine("(" + Info_Forms .LibraryName+ ")" + this.GetType().NFcName + "#...: (1)テーブル検索終了 refOTable=[" + refOTable.SourceFilePath + "]");
                }
            }
            else
            {
                o_Table = null;
            }

            string err_SKeyFldName;
            string err_SSelectedFldName;

            // field=""。
            Fielddefinition o_KeyFldDef;
            if (log_Reports.Successful)
            {
                //
                // 検索のキーとなるフィールドの定義を調べます。
                //

                List<string> sList_KeyFldName;
                {
                    sList_KeyFldName = new List<string>();

                    string sKeyFldName = ec_KeyFldName1.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports);
                    if ("" == sKeyFldName.Trim())
                    {
                        // エラー
                        err_SKeyFldName = sKeyFldName;
                        goto gt_Error_EmptyKeyField;
                    }
                    sList_KeyFldName.Add(sKeyFldName);
                    if (sList_KeyFldName.Count < 1)
                    {
                        // エラー
                        err_SKeyFldName = sKeyFldName;
                        goto gt_Error_ZeroKeyField;
                    }
                }

                RecordFielddefinition recordFielddefinition;
                bool bHit = o_Table.TryGetFieldDefinitionByName(
                    out recordFielddefinition,
                    sList_KeyFldName,
                    true,
                    log_Reports
                    );
                if (!log_Reports.Successful || !bHit)
                {
                    goto gt_EndMethod;
                }

                o_KeyFldDef = recordFielddefinition.ValueAt(0);
            }
            else
            {
                o_KeyFldDef = null;
            }

            RecordFielddefinition recordFielddefinition_Selected;
            if (log_Reports.Successful)
            {
                // 選択対象のフィールドの定義を調べます。

                List<string> sList_SelectedFldName;
                {
                    sList_SelectedFldName = new CsvTo_ListImpl().Read(sSelectedFldName);
                    foreach (string sName in sList_SelectedFldName)
                    {
                        if ("" == sName.Trim())
                        {
                            // エラー
                            err_SSelectedFldName = sSelectedFldName;
                            goto gt_Error_EmptySelectField;
                        }
                    }

                    if (sList_SelectedFldName.Count < 1)
                    {
                        // エラー
                        err_SSelectedFldName = sSelectedFldName;
                        goto gt_Error_ZeroSelectField;
                    }
                }

                bool bHit = o_Table.TryGetFieldDefinitionByName(
                    out recordFielddefinition_Selected,
                    sList_SelectedFldName,
                    false,
                    log_Reports
                    );
                if (!log_Reports.Successful || !bHit)
                {
                    goto gt_EndMethod;
                }
            }
            else
            {
                recordFielddefinition_Selected = null;
            }

            if (log_Reports.Successful)
            {
                if (null == o_KeyFldDef)
                {
                    //
                    // エラー中断。
                    goto gt_Error_NotFoundKeyFldDefinition;
                }
            }

            if (log_Reports.Successful)
            {
                if (recordFielddefinition_Selected.Count < 1)
                {
                    //
                    // エラー中断。
                    goto gt_Error_NotFoundSelectFldDefinition;
                }
            }

            if (log_Reports.Successful)
            {

                List<DataRow> dst_Row = new List<DataRow>();

                string sKeyFieldName = ec_KeyFldName1.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports);
                string sExpectedValue = ec_KeyExpected.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports);
                Configuration_Node cf_WrittenPlace_Query = ec_SfCell.Cur_Configuration;

                SelectPerformerImpl sp = new SelectPerformerImpl();
                sp.Select(
                    out dst_Row,
                    sKeyFieldName,
                    sExpectedValue,
                    bExpectedValueRequired,
                    o_KeyFldDef,
                    o_Table.DataTable,
                    cf_WrittenPlace_Query,
                    log_Reports
                    );

                if (0 < dst_Row.Count)
                {
                    //.WriteLine("(" + Info_Forms .LibraryName+ ")" + this.GetType().NFcName + "#...: (6a)該当 recordSet.Count=[" + recordSet.Count + "]");

                    foreach (DataRow row in dst_Row)
                    {
                        ToMemory_CellImpl updater = new ToMemory_CellImpl();

                        recordFielddefinition_Selected.ForEach(delegate(Fielddefinition fielddefinition_Selected, ref bool isBreak2, Log_Reports log_Reports2)
                        {
                            updater.ToMemory_ToSelectedField(
                                sOutputValue,
                                ec_SfCell,
                                row,
                                fielddefinition_Selected,
                                log_Reports
                                );
                        }, log_Reports);
                    }
                }
                else
                {
                    // エラー。
                    goto gt_Error_NotFoundRecord;
                }
            }

            goto gt_EndMethod;
            //
            //
            gt_Error_NotSfcell:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー909!", pg_Method);

                Log_TextIndented s = new Log_TextIndentedImpl();

                s.Append("Sf:cell;でないExpression_Node_Stringが指定されました。");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                // ヒント
                s.Append(r.Message_Configuration(ec_SfCell.Cur_Configuration));
                if (null != ec_SfCell)
                {
                    ec_SfCell.ToText_Snapshot(s);
                }

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //
            //
            gt_Error_NullKeyExpected:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー906!", pg_Method);

                StringBuilder s = new StringBuilder();

                s.Append("引数e_KeyExpectedにヌルが指定されました。 e_KeyExpected=[");
                s.Append(ec_KeyExpected);
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                s.Append("  this.TableName=[");
                s.Append(ec_TableName1.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports));
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                // ヒント
                s.Append(r.Message_Configuration(ec_SfCell.Cur_Configuration));

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;

            gt_Error_EmptyKeyField:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー903!", pg_Method);

                StringBuilder s = new StringBuilder();

                s.Append("fieldで指定されたキーフィールドの名前が空文字列でした。 err_SKeyFldName=[");
                s.Append(err_SKeyFldName);
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                s.Append("  this.TableName=[");
                s.Append(ec_TableName1.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports));
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                // ヒント
                s.Append(r.Message_Configuration(ec_SfCell.Cur_Configuration));

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;

            gt_Error_ZeroKeyField:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー902!", pg_Method);

                StringBuilder s = new StringBuilder();

                s.Append("fieldで指定されたキーフィールドの個数が0個でした。 err_SKeyFldName=[");
                s.Append(err_SKeyFldName);
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                s.Append("  this.TableName=[");
                s.Append(ec_TableName1.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports));
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                // ヒント
                s.Append(r.Message_Configuration(ec_SfCell.Cur_Configuration));

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;

            gt_Error_EmptySelectField:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー904!", pg_Method);

                StringBuilder s = new StringBuilder();

                s.Append("selectで指定されたフィールドの名前に空文字列がありました。 err_SSelectedFldName=[");
                s.Append(err_SSelectedFldName);
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                s.Append("  this.TableName=[");
                s.Append(ec_TableName1.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports));
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                // ヒント
                s.Append(r.Message_Configuration(ec_SfCell.Cur_Configuration));

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;

            gt_Error_ZeroSelectField:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー901!", pg_Method);

                StringBuilder s = new StringBuilder();

                s.Append("selectで指定されたフィールドの個数が0個でした。 err_SSelectedFldName=[");
                s.Append(err_SSelectedFldName);
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                s.Append("  this.TableName=[");
                s.Append(ec_TableName1.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports));
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                // ヒント
                s.Append(r.Message_Configuration(ec_SfCell.Cur_Configuration));

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;

            // エラー。
            gt_Error_NotFoundTable:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー1011!", pg_Method);

                StringBuilder s = new StringBuilder();

                s.Append(" ヌル=refTable");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                s.Append("  this.TableName=[");
                s.Append(ec_TableName1.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports));
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                // ヒント
                s.Append(r.Message_Configuration(ec_SfCell.Cur_Configuration));

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;

            gt_Error_NotFoundKeyFldDefinition:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー478!", pg_Method);

                StringBuilder t = new StringBuilder();

                t.Append(" キーフィールドの定義を取得できませんでした。");
                t.Append(Environment.NewLine);

                t.Append("「E■[");
                t.Append(ec_KeyFldName1.Cur_Configuration.Name);
                t.Append("]」、キーフィールド名=[");
                t.Append(ec_KeyFldName1.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports));
                t.Append("]");
                t.Append(Environment.NewLine);
                t.Append(Environment.NewLine);

                // ヒント
                t.Append(r.Message_Configuration(ec_SfCell.Cur_Configuration));

                r.Message = t.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;

            gt_Error_NotFoundSelectFldDefinition:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー479!", pg_Method);

                StringBuilder t = new StringBuilder();

                t.Append(" 取得データが入っているはずのフィールドの定義を取得できませんでした。");
                t.Append(Environment.NewLine);
                t.Append("  指定されたフィールド名=[");
                t.Append(sSelectedFldName);
                t.Append("]");
                t.Append(Environment.NewLine);
                t.Append(Environment.NewLine);

                // ヒント
                t.Append(r.Message_Configuration(ec_SfCell.Cur_Configuration));

                r.Message = t.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;

            gt_Error_NotFoundRecord:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー344!", pg_Method);

                string sDebugExceptedKey = ec_KeyExpected.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports);

                Log_TextIndented s = new Log_TextIndentedImpl();

                s.Append("【失敗】");
                s.Newline();
                s.Newline();

                s.Append("[");
                s.Append(o_Table.Name);
                s.Append("](テーブル)には、");
                s.Append(Environment.NewLine);

                s.Append("[");
                s.Append(ec_KeyFldName1.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports));
                s.Append("]フィールドに");

                s.Append("[");
                s.Append(sDebugExceptedKey);
                s.Append("]が入っているレコードは、見つかりませんでした。");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);
                s.Append("この入力したデータは、入力が確定されず、無視されています。");
                s.Append(Environment.NewLine);

                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);
                s.Append("もしかして?");
                s.Append(Environment.NewLine);
                s.Append(" ・ツールの不便さにより、手入力で");
                s.Append(Environment.NewLine);
                s.Append("  指定のテーブルに ID付きのレコードの空欄を");
                s.Append(Environment.NewLine);
                s.Append("  予め 作っておかなければならなかった、といった決まりごとはありませんか?");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);
                s.Append(" ・それとも、それ以外の理由?");
                s.Append(Environment.NewLine);

                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);
                s.Append("────────以下はプログラマー用の情報。");
                s.Append(Environment.NewLine);

                // ヒント
                s.Append(r.Message_Configuration(ec_SfCell.Cur_Configuration));

                r.Message = s.ToString();

                //essageBox.Show(r.SMsg(log_Reports), Info_Forms.LibraryName + ":" + this.GetType().Name );
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //
            //
            gt_EndMethod:
            pg_Method.EndMethod(log_Reports);
        }
Exemplo n.º 5
0
        //────────────────────────────────────────
        /// <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;
        }