Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
0
        //────────────────────────────────────────
        public void CreateErrorReport(
            string errorSymbol,
            Builder_TexttemplateP1p texttemplateBuilder_ParameterSetted,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static);
            log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "CreateErrorReport", log_Reports);
            //

            int errorNumber;
            {
                string tempErrorSymbol = errorSymbol;
                if (tempErrorSymbol.StartsWith("Er:"))
                {
                    tempErrorSymbol = tempErrorSymbol.Substring(3);
                    if (tempErrorSymbol.EndsWith(";"))
                    {
                        tempErrorSymbol = tempErrorSymbol.Substring(0, tempErrorSymbol.Length - 1);
                        if (int.TryParse(tempErrorSymbol, out errorNumber))
                        {
                        }
                        else
                        {
                            goto gt_Error_Symbol;
                        }
                    }
                    else
                    {
                        goto gt_Error_Symbol;
                    }
                }
                else
                {
                    goto gt_Error_Symbol;
                }
            }

            if (log_Reports.CanCreateReport)
            {
                string strTypedata = ValuesTypeData.S_TABLE_ERRORMESSAGES;
                Configurationtree_Node cur_Ct = new Configurationtree_NodeImpl(log_Method.Fullname, null);
                List<Table_Humaninput> tables = this.MemoryTables.GetTable_HumaninputByTypedata(
                    new Expression_Leaf_StringImpl(strTypedata, null, cur_Ct), true, log_Reports);

                bool hit = false;
                foreach (Table_Humaninput table in tables)
                {
                    foreach (DataRow dataRow in table.DataTable.Rows)
                    {
                        Int_HumaninputImpl xenonValue_Int = (Int_HumaninputImpl)dataRow["ID"];

                        int valueInt;
                        xenonValue_Int.TryGet(out valueInt);

                        if (valueInt == errorNumber)
                        {
                            //ヒット
                            hit = true;

                            Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                            r.SetTitle("Er:" + errorNumber + ";", log_Method);

                            String_HumaninputImpl xenonValue_String = (String_HumaninputImpl)dataRow["MESSAGE"];

                            string valueStr;
                            xenonValue_String.TryGet(out valueStr);

                            texttemplateBuilder_ParameterSetted.Text = valueStr;
                            r.Message = texttemplateBuilder_ParameterSetted.Compile(log_Reports).Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports);
                            //log_Method.WriteDebug_ToConsole(texttemplateBuilder_ParameterSetted.Compile(log_Reports).Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports));

                            goto gt_EndLoop1;
                        }
                    }
                }
            gt_EndLoop1:

                if (!hit)
                {
                    //エラーメッセージの登録がない。

                    Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                    r.SetTitle("Er:0;", log_Method);

                    Log_TextIndented s = new Log_TextIndentedImpl();
                    s.Append("エラーメッセージテーブルに、エラーメッセージの登録がありませんでした。\n%1%=[%2%]\nテーブル数=[%3%]");

                    Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(s.ToString());
                    tmpl.SetParameter(1, NamesFld.S_TYPE_DATA,log_Reports);
                    tmpl.SetParameter(2, strTypedata,log_Reports);
                    tmpl.SetParameter(3, tables.Count.ToString(),log_Reports);

                    r.Message = tmpl.Compile(log_Reports).Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports);
                }

                log_Reports.EndCreateReport();
            }

            goto gt_EndMethod;
            //
            #region 異常系
            //────────────────────────────────────────
            gt_Error_Symbol:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー204!", log_Method);

                StringBuilder s = new StringBuilder();
                s.Append("エラーシンボルがおかしい。[" + errorSymbol + "]。プログラムのミス?");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            gt_EndMethod:
            log_Method.EndMethod(log_Reports);
        }