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



        #region 判定
        //────────────────────────────────────────

        public override bool Equals(System.Object obj)
        {
            // 引数がヌルの場合は、偽です。
            if (obj == null)
            {
                return(false);
            }

            // 型が違えば偽です。
            StringCellImpl stringH = obj as StringCellImpl;

            if (null != stringH)
            {
                // 文字列の比較。
                return(this.Text == stringH.Text);
            }

            string str = obj as string;

            if (null != str)
            {
                // 文字列の比較。
                return(this.Text == str);
            }

            return(false);
        }
Ejemplo n.º 2
0
        //────────────────────────────────────────

        public Cell NewField(string nodeConfigtree, Log_Reports log_Reports)
        {
            Log_Method log_Method = new Log_MethodImpl(0);

            log_Method.BeginMethod(Info_Table.Name_Library, this, "NewField", log_Reports);

            Cell result;

            switch (this.Type_Field)
            {
            case EnumTypeFielddef.String:
            {
                result = new StringCellImpl(nodeConfigtree);
            }
            break;

            case EnumTypeFielddef.Int:
            {
                result = new IntCellImpl(nodeConfigtree);
            }
            break;

            case EnumTypeFielddef.Bool:
            {
                result = new BoolCellImpl(nodeConfigtree);
            }
            break;

            default:
            {
                // 未該当
                result = null;
                goto gt_Error_Unspported;
            }
            }

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

                Log_TextIndented s = new Log_TextIndentedImpl();

                s.Append("フィールド定義を元にして、フィールド値を用意しようとしましたが、未定義のフィールド型でした。");
                s.Newline();

                s.Append("this.Type.ToString()=[");
                s.Append(this.ToString_Type());
                s.Append("]");
                s.Newline();

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return(result);
        }
Ejemplo n.º 3
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.º 4
0
        //────────────────────────────────────────
        #endregion



        #region アクション
        //────────────────────────────────────────

        /// <summary>
        /// DataRow → Dictionary
        /// </summary>
        /// <param name="row"></param>
        /// <param name="log_Reports"></param>
        public void Add(DataRow row, Log_Reports log_Reports)
        {
            Log_Method log_Method = new Log_MethodImpl(0);

            log_Method.BeginMethod(Info_Table.Name_Library, this, "Add", log_Reports);

            Dictionary <string, Cell> record = new Dictionary <string, Cell>();

            int nFieldCount = row.ItemArray.Length;

            for (int nFieldIndex = 0; nFieldIndex < nFieldCount; nFieldIndex++)
            {
                // フィールド名
                string sFieldName = xTable.RecordFielddef.ValueAt(nFieldIndex).Name_Trimupper;

                // 値
                Cell oValue;
                if (row[nFieldIndex] is DBNull)
                {
                    //// デバッグ
                    //if (true)
                    //{
                    //Log_TextIndented txt = new Log_TextIndentedImpl();

                    //    txt.Append(InfxenonTable.LibraryName + ":" + this.GetType().Name + "#Add:【ヌル】");
                    //    txt.Append(" field=[" + sFieldName + "]");

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

                    String sConfigStack = xTable.Expr_Filepath_ConfigStack.Lv4Execute_OnImplement(
                        EnumHitcount.Unconstraint, log_Reports);
                    if (!log_Reports.Successful)
                    {
                        // 既エラー。
                        goto gt_EndMethod;
                    }

                    EnumTypeFielddef typeField = xTable.RecordFielddef.ValueAt(nFieldIndex).Type_Field;
                    switch (typeField)
                    {
                    case EnumTypeFielddef.String:
                        oValue = new StringCellImpl(sConfigStack);
                        break;

                    case EnumTypeFielddef.Int:
                        oValue = new IntCellImpl(sConfigStack);
                        break;

                    case EnumTypeFielddef.Bool:
                        oValue = new BoolCellImpl(sConfigStack);
                        break;

                    default:
                        // エラー。
                        goto gt_Error_UndefinedType;
                    }
                }
                else
                {
                    oValue = (Cell)row[nFieldIndex];

                    //// デバッグ
                    //if (true)
                    //{
                    //Log_TextIndented txt = new Log_TextIndentedImpl();

                    //    txt.Append(InfxenonTable.LibraryName + ":" + this.GetType().Name + "#Add:【○】");
                    //    txt.Append(" 値=[" + oValue.HumanInputString + "]");

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

                record.Add(sFieldName, oValue);
            }

            this.List_Field.Add(record);

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append(" 未定義の型です。プログラムのミスの可能性があります。");
                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);
            return;
        }
Ejemplo n.º 5
0
        //────────────────────────────────────────

        public void Judge(
            out bool isJudge,
            string name_KeyField,
            string value_Expected,
            bool isRequired_ExpectedValue,//使ってない。
            DataRow row,
            Conf_String parent_Query,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl();

            log_Method.BeginMethod(Info_Table.Name_Library, this, "Judge", log_Reports);

            //

            try
            {
                // 無い列名を指定した場合。
                if (!row.Table.Columns.Contains(name_KeyField))
                {
                    // エラー
                    isJudge = false;
                    goto gt_Error_NothingKeyField;
                }

                Cell valueH = (Cell)row[name_KeyField];


                //
                // (5)キーが空欄なら、無視します。【文字列型フィールドのみ】
                //
                if (StringCellImpl.IsSpaces(valueH))
                {
                    isJudge = false;
                    goto gt_EndMethod;
                }


                //
                // (6)この行の、キー_フィールドの値を取得。
                //
                string keyValue;
                bool   isParsedSuccessful = StringCellImpl.TryParse(
                    valueH,
                    out keyValue,
                    parent_Query.ToString(),//TODO:本当はテーブル名がいい。 xenonTable.SName,
                    name_KeyField,
                    log_Method,
                    log_Reports);
                if (!log_Reports.Successful)
                {
                    // 既エラー
                    isJudge = false;
                    goto gt_EndMethod;
                }

                if (!isParsedSuccessful)
                {
                    // エラー
                    isJudge = false;
                    if (log_Reports.CanCreateReport)
                    {
                        Log_RecordReports d_Report = log_Reports.BeginCreateReport(EnumReport.Error);
                        d_Report.SetTitle("▲エラー697!", log_Method);
                        d_Report.Message = "string型パース失敗。";
                        log_Reports.EndCreateReport();
                    }
                    goto gt_EndMethod;
                }



                // (8)該当行をレコードセットに追加。
                if (keyValue == value_Expected)
                {
                    isJudge = true;
                }
                else
                {
                    isJudge = false;
                }
            }
            catch (RowNotInTableException)
            {
                // (9)指定行がなかった場合は、スルー。
                isJudge = false;

                //
                // 指定の行は、テーブルの中にありませんでした。
                // 再描画と、行の削除が被ったのかもしれません。
                // いわゆる「処理中」です。
                //

                //.WriteLine(this.GetType().Name+"#GetValueStringList: ["+refTable.Name+"]テーブルには、["+ttbwIndex+"]行が存在しませんでした。もしかすると、削除されたのかもしれません。エラー:"+e.Message);
            }

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

                StringBuilder s = new StringBuilder();
                s.Append("無い列名が指定されました。 sKeyFieldName=[" + name_KeyField + "]");
                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
        }
Ejemplo n.º 6
0
        //────────────────────────────────────────

        public static Cell NewInstance(
            object value,
            bool isRequired,
            string conf_Node,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0);

            log_Method.BeginMethod(Info_Table.Name_Library, "Utility_HumaninputValue", "NewInstance", log_Reports);

            Cell result;

            if (value is StringCellImpl)
            {
                result = new StringCellImpl(conf_Node);
            }
            else if (value is IntCellImpl)
            {
                result = new IntCellImpl(conf_Node);
            }
            else if (value is BoolCellImpl)
            {
                result = new BoolCellImpl(conf_Node);
            }
            else
            {
                result = null;

                if (isRequired)
                {
                    //エラー
                    goto gt_Error_AnotherType;
                }
            }

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append("▲エラー201!(" + Info_Table.Name_Library + ")");
                s.Newline();
                s.Append("string,int,boolセルデータクラス以外のオブジェクトが指定されました。");
                s.Newline();

                s.Append("指定された値のクラス=[");
                s.Append(value.GetType().Name);
                s.Append("]");

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