Ejemplo n.º 1
0
        //────────────────────────────────────────

        /// <summary>
        /// O_TableImpl#AddRecordListで使います。
        /// </summary>
        /// <param name="columnIndex"></param>
        /// <param name="value"></param>
        /// <param name="oTable"></param>
        /// <param name="log_Reports"></param>
        /// <returns></returns>
        public static Cell ConfigurationTo_Field(
            int index_Column,
            string value,
            RecordFielddef recordFielddef,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl();

            log_Method.BeginMethod(Info_Table.Name_Library, "Utility_Row", "ConfigurationTo_Field", log_Reports);
            //

            //
            // セルのソースヒント名
            string nodeConfigtree;

            try
            {
                nodeConfigtree = recordFielddef.ValueAt(index_Column).Name_Humaninput;
            }
            catch (ArgumentOutOfRangeException)
            {
                // エラー
                goto gt_Error_Index;
            }

            Cell result;

            // 型毎に処理を分けます。
            switch (recordFielddef.ValueAt(index_Column).Type_Field)
            {
            case EnumTypeFielddef.Int:
            {
                // 空白データも自動処理
                IntCellImpl cellData = new IntCellImpl(nodeConfigtree);
                cellData.Text = value;
                result        = cellData;
            }
            break;

            case EnumTypeFielddef.Bool:
            {
                // 空白データも自動処理
                BoolCellImpl cellData = new BoolCellImpl(nodeConfigtree);
                cellData.Text = value;
                result        = cellData;
            }
            break;

            default:
            {
                StringCellImpl cellData = new StringCellImpl(nodeConfigtree);
                cellData.Text = value;
                result        = cellData;
            }
            break;
            }

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

                Log_TextIndented t = new Log_TextIndentedImpl();

                t.Append("列インデックス[" + index_Column + "](0スタート)が指定されましたが、");
                t.Newline();
                t.Append("列は[" + recordFielddef.Count + "]個しかありません。(列定義リストは、絞りこまれている場合もあります)");
                t.Newline();

                // ヒント

                r.Message = t.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return(result);
        }
Ejemplo n.º 2
0
        //────────────────────────────────────────

        /// <summary>
        ///
        /// </summary>
        /// <param name="out_sFieldListList"></param>
        /// <param name="out_O_NewFldDefList"></param>
        /// <param name="src_sNewFieldNameList"></param>
        /// <param name="e_Where"></param>
        /// <param name="tableH_Source"></param>
        /// <param name="log_Reports"></param>
        public static void SelectFieldListList(
            out List <List <string> > listList_SField_Out,
            out RecordFielddef out_RecordFielddef_New,
            EnumLogic enumWhereLogic,
            List <string> list_SName_NewField_Src,
            List <Recordcondition> list_Reccond,
            Table_Humaninput tableH_Source,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl();

            log_Method.BeginMethod(Info_Table.Name_Library, "Util_Table", "SelectFieldListList", log_Reports);

            //

            RecordFielddef recordFielddef_New = new RecordFielddefImpl();
            List <int>     list_indexField    = new List <int>();

            //
            // 新しい、列定義リストを作成します。
            //
            {
                // 最初の列は「NO」とします。
                list_SName_NewField_Src.Insert(0, Utility_Table.S_FIELD_NO);

                //fieldIndex
                int nFIx = 0;
                tableH_Source.RecordFielddef.ForEach(delegate(Fielddef fielddefinition, ref bool isBreak, Log_Reports log_Reports2)
                {
                    if (list_SName_NewField_Src.Contains(fielddefinition.Name_Humaninput))
                    {
                        // 選出されたフィールドだけでリストを作ります。
                        recordFielddef_New.Add(fielddefinition);
                        list_indexField.Add(nFIx);
                    }

                    nFIx++;
                }, log_Reports);
            }



            //
            // テーブルに列定義を設定した後で。
            // 移し替えたいデータ値の配列を作ります。
            listList_SField_Out = new List <List <string> >();
            //
            {
                int nEndover = list_indexField.Count;
                foreach (DataRow srcRow in tableH_Source.DataTable.Rows)
                {
                    List <string> sList_NewField = new List <string>();


                    //
                    // 「E■@where」属性を解析します。
                    //
                    // 該当しないレコードは除去していきます。
                    //
                    // 「E■@where」に logic属性が無い場合は logic="and" とします。
                    if (EnumLogic.None == enumWhereLogic)
                    {
                        enumWhereLogic = EnumLogic.And;
                    }
                    bool bHit = Utility_Table.ApplyReccond(srcRow, tableH_Source, enumWhereLogic, list_Reccond, 0, log_Reports);
                    //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":Util_Table.SelectFieldListList: (結果) [" + bHit + "]");

                    if (bHit)
                    {
                        for (int nA = 0; nA < nEndover; nA++)
                        {
                            // TODO:指定のフィールド・インデックスだけをピックアップしたい。
                            int  nB      = list_indexField[nA];
                            Cell o_Value = (Cell)srcRow[nB];

                            sList_NewField.Add(o_Value.Text);
                        }

                        listList_SField_Out.Add(sList_NewField);
                    }
                    //hit
                }
            }


            goto gt_EndMethod;

            //
            //
            //
            //
gt_EndMethod:
            out_RecordFielddef_New = recordFielddef_New;
            log_Method.EndMethod(log_Reports);
        }