Пример #1
0
        //────────────────────────────────────────

        /// <summary>
        /// 警告メッセージの定型文を作ります。
        /// </summary>
        /// <returns></returns>
        public static string ToText_Configuration(
            Configuration_Node parent_Conf
            )
        {
            Log_TextIndented s = new Log_TextIndentedImpl();

            if (null == parent_Conf)
            {
                s.Append("  親要素が指定されていません。");
            }
            else
            {
                s.Append("  設定位置パンくずリスト(問題個所ヒント):");
                s.Newline();
                s.Newline();
                parent_Conf.ToText_Locationbreadcrumbs(s);
                s.Newline();
                s.Newline();

                parent_Conf.ToText_Content(s);
                s.Newline();
                s.Newline();

                s.Append(Log_RecordReportsImpl.ToText_Separator());

                s.Append("  問題を報告したオブジェクトの型: ");
                s.Append(parent_Conf.GetType());
                s.Append(" (これはラッパークラスということもあるかも知れません)");
                s.Newline();
                s.Newline();
            }


            return(s.ToString());
        }
Пример #2
0
        //────────────────────────────────────────

        /// <summary>
        /// 「ディレクトリー」と「入力値」の2つを入力すると、「絶対パス」を返します。
        ///
        /// ──────────
        ///
        /// 未設定の場合は、空文字列を返します。
        /// ※bug:フォルダーパスの場合も空文字列になる??
        ///
        /// ・ファイルパスとして利用できない文字や、予約語が含まれていると例外を投げます。
        /// ・絶対パスの文字列の長さが、ファイルシステムで使える制限を越えると例外を投げます。
        ///
        /// もし、設定されたパスが相対パスだった場合に、ベース・パスが設定されていなければ、
        /// 起動「.exe」のあったパスが頭に付く。
        /// </summary>
        /// <param name="baseDirectory"></param>
        /// <param name="humanInputText"></param>
        /// <param name="flagCheckPathTooLong">絶対パスの文字列の長さが、ファイルシステムで使える上限を超えていた場合に真、そうでない場合 偽にセットされます。</param>
        /// <param name="okPathTooLong">絶対パスの文字列の長さが、ファイルシステムで使える上限を超えていた場合に、「正常扱いにするなら」真、「エラー扱いにするなら」偽。</param>
        /// <param name="cur_Conf">デバッグ用情報。人間オペレーターが修正するべき箇所などの情報。</param>
        /// <returns></returns>
        public static string ToFilepathabsolute(
            string directory_Base,
            string humaninput,
            ref bool ref_IsTooLong_Path,
            bool isSafe_TooLong_Path,
            Log_Reports log_Reports,
            Configuration_Node cur_Conf
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0);

            log_Method.BeginMethod(Info_Syntax.Name_Library, "Utility_Configurationtree_Filepath", "ToFilepathabsolute②", log_Reports);
            //
            //

            //
            // 修正履歴(2009-12-02)
            //
            // ・カレント・ディレクトリの移動を使ったコードを書いてはいけない。
            //   MS-DOSの名残り?
            //
            // ・起動「.exe」のディレクトリは Application.StartupPath で取得できる。
            //
            // ・備考:
            // System.IO.Directory.GetCurrentDirectory()は、
            // 「プロセスが開始されたディレクトリ」を返すので、
            // openFileDialogで開いたディレクトリを返すこともある。
            //
            // System.IO.Path.GetFullPath(path)も同じ。

            Exception err_Excp;

            string result_Filepath;//ファイルパス

            // フラグのクリアー。
            ref_IsTooLong_Path = false;

            //
            // 人間がCSVファイルに記述しているファイル・パス。
            //
            // 「絶対パス」「相対パス」のどちらでも指定されます。
            //
            string filepath_Source = humaninput.Trim();

            if ("" == filepath_Source)
            {
                // 未設定の場合。
                result_Filepath = "";//ファイルパスとしては使えない文字列。
                goto gt_EndMethod;
            }

            // 「絶対パス」か、「相対パス」かを判断します。
            bool isRooted_Path = Utility_Configurationtree_Filepath.IsRooted_Path(
                filepath_Source,
                log_Reports
                );

            if (!log_Reports.Successful)
            {
                // 既エラー。
                result_Filepath = "";//ファイルパスとしては使えない文字列。
                goto gt_EndMethod;
            }

            if (!isRooted_Path)
            {
                // 相対パスの場合

                // 「相対パス」に「ベース・ディレクトリー文字列」を連結して、「絶対パス」に変換します。

                if ("" != directory_Base)
                {
                    // 相対パスの相対元となるディレクトリーが設定されていれば。

                    if (!directory_Base.EndsWith(Path.DirectorySeparatorChar.ToString()))
                    {
                        filepath_Source = directory_Base + Path.DirectorySeparatorChar + filepath_Source;
                    }
                    else
                    {
                        filepath_Source = directory_Base + filepath_Source;
                    }
                }
                else
                {
                    // 起動「.exe」のあったパスを、相対の元となるディレクトリーとします。

                    if (!directory_Base.EndsWith(Path.DirectorySeparatorChar.ToString()))
                    {
                        filepath_Source = Application.StartupPath + Path.DirectorySeparatorChar + filepath_Source;
                    }
                    else
                    {
                        filepath_Source = Application.StartupPath + filepath_Source;
                    }
                }
            }

            // ここで、パスは 絶対パスに変換されています。

            try
            {
                // カレントディレクトリは使わない。

                // 絶対パスの場合、GetFullPathを通す必要はないが、
                // ファイルパスに使えない文字列を判定するために、
                // 例外を返すメソッドを使っています。
                result_Filepath = System.IO.Path.GetFullPath(filepath_Source);
            }
            catch (ArgumentException e)
            {
                // 指定のファイルパスに「*」など、ファイルパスとして使えない文字列が含まれていた場合など。

                result_Filepath = "";//ファイルパスとしては使えない文字列。

                err_Excp = e;
                goto gt_Error_ArgumentException;
            }
            catch (PathTooLongException e)
            {
                // ディレクトリーの文字数が、制限数を超えた場合などのエラー。

                result_Filepath = "";//ファイルパスとしては使えない文字列。

                if (isSafe_TooLong_Path)
                {
                    // 正常処理扱いとします。
                }
                else
                {
                    // 異常扱いとします。

                    err_Excp = e;
                    goto gt_Error_PathTooLongException;
                }


                ref_IsTooLong_Path = true;
            }
            catch (NotSupportedException e)
            {
                //パスのフォーマットが間違っているなどのエラー。
                result_Filepath = "";//ファイルパスとしては使えない文字列。
                err_Excp        = e;
                goto gt_Error_NotSupportedException;
            }
            catch (Exception e)
            {
                // それ以外のエラー。
                result_Filepath = "";//ファイルパスとしては使えない文字列。
                err_Excp        = e;
                goto gt_Error_Exception;
            }

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append(Environment.NewLine);
                s.Append("使えないファイルパスです。[");
                s.Append(filepath_Source);
                s.Append("] :");

                s.Append(err_Excp.Message);
                cur_Conf.ToText_Locationbreadcrumbs(s);

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append(Environment.NewLine);
                s.Append("エラー 入力パス=[" + filepath_Source + "]:(" + err_Excp.GetType().Name + ") ");

                s.Append(err_Excp.Message);
                cur_Conf.ToText_Locationbreadcrumbs(s);

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append(Environment.NewLine);
                s.Append("ファイルパスが間違っているかもしれません。");
                s.Newline();
                s.AppendI(1, "入力パス=[" + filepath_Source + "]");
                s.Newline();

                // ヒント
                s.Append(r.Message_SException(err_Excp));
                cur_Conf.ToText_Locationbreadcrumbs(s);

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append(Environment.NewLine);
                s.Append("エラー 入力パス=[" + filepath_Source + "]");
                s.Newline();

                // ヒント
                s.Append(r.Message_SException(err_Excp));
                cur_Conf.ToText_Locationbreadcrumbs(s);

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return(result_Filepath);
        }
Пример #3
0
        //────────────────────────────────────────
        public void Judge(
            out bool isJudge,
            string name_KeyField,
            string value_Expected,
            bool isRequired_ExpectedValue,
            DataRow row,
            Configuration_Node 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
            {
                Value_Humaninput valueH = (Value_Humaninput)row[name_KeyField];

                // (5)キーが空欄で、検索ヒット必須でなければ、無視します。【bool型フィールドの場合】
                if (Bool_HumaninputImpl.IsSpaces(valueH))
                {
                    isJudge = false;
                    goto gt_EndMethod;
                }

                //
                // (6)この行の、キー_フィールドの値を取得。
                //
                bool isKeyValue;

                bool isParsedSuccessful = Bool_HumaninputImpl.TryParse(
                    valueH,
                    out isKeyValue,
                    EnumOperationIfErrorvalue.Error,
                    null,
                    log_Reports
                    );
                if (log_Reports.Successful)
                {
                    if (!isParsedSuccessful)
                    {
                        // エラー。
                        isJudge = false;
                        if (log_Reports.CanCreateReport)
                        {
                            Log_RecordReports d_Report = log_Reports.BeginCreateReport(EnumReport.Error);
                            d_Report.SetTitle("▲エラー699!", log_Method);
                            d_Report.Message = "bool型パース失敗。";
                            log_Reports.EndCreateReport();
                        }
                        goto gt_EndMethod;
                    }
                }

                bool isExpectedValue;
                if (log_Reports.Successful)
                {
                    // (8)キー値をbool型に変換します。
                    bool isParseSuccessful2 = bool.TryParse(value_Expected, out isExpectedValue);
                    if (!isParseSuccessful2)
                    {
                        isJudge = false;
                        if (isRequired_ExpectedValue)
                        {
                            // 空値ではダメという設定の場合。
                            goto gt_Error_Parse;
                        }
                        goto gt_EndMethod;
                    }
                }
                else
                {
                    isExpectedValue = false;
                }

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

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

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

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.AppendI(0, "<Select_KeyBoolImplクラス>");
                s.Append(Environment.NewLine);

                s.AppendI(1, "これはbool型値のプログラムです。他の型のプログラムを使ってください。");
                s.Append(Environment.NewLine);

                s.AppendI(1, "sExpectedValue=[");
                s.Append(value_Expected);
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                // ヒント
                parent_Query.ToText_Locationbreadcrumbs(s);

                s.AppendI(0, "</Select_KeyBoolImplクラス>");

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
            gt_EndMethod:
            log_Method.EndMethod(log_Reports);
        }
        //────────────────────────────────────────
        /// <summary>
        /// 「ディレクトリー」と「入力値」の2つを入力すると、「絶対パス」を返します。
        /// 
        /// ──────────
        /// 
        /// 未設定の場合は、空文字列を返します。
        /// ※bug:フォルダーパスの場合も空文字列になる??
        /// 
        /// ・ファイルパスとして利用できない文字や、予約語が含まれていると例外を投げます。
        /// ・絶対パスの文字列の長さが、ファイルシステムで使える制限を越えると例外を投げます。
        /// 
        /// もし、設定されたパスが相対パスだった場合に、ベース・パスが設定されていなければ、
        /// 起動「.exe」のあったパスが頭に付く。
        /// </summary>
        /// <param name="baseDirectory"></param>
        /// <param name="humanInputText"></param>
        /// <param name="flagCheckPathTooLong">絶対パスの文字列の長さが、ファイルシステムで使える上限を超えていた場合に真、そうでない場合 偽にセットされます。</param>
        /// <param name="okPathTooLong">絶対パスの文字列の長さが、ファイルシステムで使える上限を超えていた場合に、「正常扱いにするなら」真、「エラー扱いにするなら」偽。</param>
        /// <param name="cur_Conf">デバッグ用情報。人間オペレーターが修正するべき箇所などの情報。</param>
        /// <returns></returns>
        public static string ToFilepathabsolute(
            string directory_Base,
            string humaninput,
            ref bool ref_IsTooLong_Path,
            bool isSafe_TooLong_Path,
            Log_Reports log_Reports,
            Configuration_Node cur_Conf
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0);
            log_Method.BeginMethod(Info_Syntax.Name_Library, "Utility_Configurationtree_Filepath", "ToFilepathabsolute②", log_Reports);
            //
            //

            //
            // 修正履歴(2009-12-02)
            //
            // ・カレント・ディレクトリの移動を使ったコードを書いてはいけない。
            //   MS-DOSの名残り?
            //
            // ・起動「.exe」のディレクトリは Application.StartupPath で取得できる。
            //
            // ・備考:
            // System.IO.Directory.GetCurrentDirectory()は、
            // 「プロセスが開始されたディレクトリ」を返すので、
            // openFileDialogで開いたディレクトリを返すこともある。
            //
            // System.IO.Path.GetFullPath(path)も同じ。

            Exception err_Excp;

            string result_Filepath;//ファイルパス

            // フラグのクリアー。
            ref_IsTooLong_Path = false;

            //
            // 人間がCSVファイルに記述しているファイル・パス。
            //
            // 「絶対パス」「相対パス」のどちらでも指定されます。
            //
            string filepath_Source = humaninput.Trim();

            if ("" == filepath_Source)
            {
                // 未設定の場合。
                result_Filepath = "";//ファイルパスとしては使えない文字列。
                goto gt_EndMethod;
            }

            // 「絶対パス」か、「相対パス」かを判断します。
            bool isRooted_Path = Utility_Configurationtree_Filepath.IsRooted_Path(
                filepath_Source,
                log_Reports
                );

            if (!log_Reports.Successful)
            {
                // 既エラー。
                result_Filepath = "";//ファイルパスとしては使えない文字列。
                goto gt_EndMethod;
            }

            if (!isRooted_Path)
            {
                // 相対パスの場合

                // 「相対パス」に「ベース・ディレクトリー文字列」を連結して、「絶対パス」に変換します。

                if ("" != directory_Base)
                {
                    // 相対パスの相対元となるディレクトリーが設定されていれば。

                    if (!directory_Base.EndsWith(Path.DirectorySeparatorChar.ToString()))
                    {
                        filepath_Source = directory_Base + Path.DirectorySeparatorChar + filepath_Source;
                    }
                    else
                    {
                        filepath_Source = directory_Base + filepath_Source;
                    }
                }
                else
                {
                    // 起動「.exe」のあったパスを、相対の元となるディレクトリーとします。

                    if (!directory_Base.EndsWith(Path.DirectorySeparatorChar.ToString()))
                    {
                        filepath_Source = Application.StartupPath + Path.DirectorySeparatorChar + filepath_Source;
                    }
                    else
                    {
                        filepath_Source = Application.StartupPath + filepath_Source;
                    }
                }
            }

            // ここで、パスは 絶対パスに変換されています。

            try
            {
                // カレントディレクトリは使わない。

                // 絶対パスの場合、GetFullPathを通す必要はないが、
                // ファイルパスに使えない文字列を判定するために、
                // 例外を返すメソッドを使っています。
                result_Filepath = System.IO.Path.GetFullPath(filepath_Source);
            }
            catch (ArgumentException e)
            {
                // 指定のファイルパスに「*」など、ファイルパスとして使えない文字列が含まれていた場合など。

                result_Filepath = "";//ファイルパスとしては使えない文字列。

                err_Excp = e;
                goto gt_Error_ArgumentException;
            }
            catch (PathTooLongException e)
            {
                // ディレクトリーの文字数が、制限数を超えた場合などのエラー。

                result_Filepath = "";//ファイルパスとしては使えない文字列。

                if (isSafe_TooLong_Path)
                {
                    // 正常処理扱いとします。

                }
                else
                {
                    // 異常扱いとします。

                    err_Excp = e;
                    goto gt_Error_PathTooLongException;
                }

                ref_IsTooLong_Path = true;
            }
            catch (NotSupportedException e)
            {
                //パスのフォーマットが間違っているなどのエラー。
                result_Filepath = "";//ファイルパスとしては使えない文字列。
                err_Excp = e;
                goto gt_Error_NotSupportedException;
            }
            catch (Exception e)
            {
                // それ以外のエラー。
                result_Filepath = "";//ファイルパスとしては使えない文字列。
                err_Excp = e;
                goto gt_Error_Exception;
            }

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append(Environment.NewLine);
                s.Append("使えないファイルパスです。[");
                s.Append(filepath_Source);
                s.Append("] :");

                s.Append(err_Excp.Message);
                cur_Conf.ToText_Locationbreadcrumbs(s);

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append(Environment.NewLine);
                s.Append("エラー 入力パス=[" + filepath_Source + "]:(" + err_Excp.GetType().Name + ") ");

                s.Append(err_Excp.Message);
                cur_Conf.ToText_Locationbreadcrumbs(s);

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append(Environment.NewLine);
                s.Append("ファイルパスが間違っているかもしれません。");
                s.Newline();
                s.AppendI(1,"入力パス=[" + filepath_Source + "]");
                s.Newline();

                // ヒント
                s.Append(r.Message_SException(err_Excp));
                cur_Conf.ToText_Locationbreadcrumbs(s);

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append(Environment.NewLine);
                s.Append("エラー 入力パス=[" + filepath_Source + "]");
                s.Newline();

                // ヒント
                s.Append(r.Message_SException(err_Excp));
                cur_Conf.ToText_Locationbreadcrumbs(s);

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return result_Filepath;
        }
Пример #5
0
        //────────────────────────────────────────
        public void Judge(
            out bool isJudge,
            string name_KeyField,
            string value_Expected,
            bool isRequired_ExpectedValue,
            DataRow row,
            Configuration_Node 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
            {
                object obj = row[name_KeyField];

                if (obj is DBNull)
                {
                    isJudge = false;
                    goto gt_Error_DBNull;
                }

                Value_Humaninput valueH = (Value_Humaninput)obj;

                // (5)キーが空欄で、検索ヒット必須でなければ、無視します。【int型フィールドの場合】
                if (Int_HumaninputImpl.IsSpaces(valueH))
                {
                    isJudge = false;
                    goto gt_EndMethod;
                }

                // (6)この行の、キー_フィールドの値を取得。
                int keyValue;

                bool bParsedSuccessful = Int_HumaninputImpl.TryParse(
                    valueH,
                    out keyValue,
                    EnumOperationIfErrorvalue.Error,
                    null,
                    log_Reports
                    );

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

                // (7)キー値をint型に変換します。
                int expectedValue;
                if (log_Reports.Successful)
                {
                    bool bParseSuccessful2 = int.TryParse(value_Expected, out expectedValue);
                    if (!bParseSuccessful2)
                    {
                        isJudge = false;
                        if (isRequired_ExpectedValue)
                        {
                            goto gt_Error_Parse;
                        }

                        goto gt_EndMethod;
                    }
                }
                else
                {
                    expectedValue = 0;
                }

                if (log_Reports.Successful)
                {
                    // (8)該当行をレコードセットに追加。
                    if (keyValue == expectedValue)
                    {
                        //
                        // 該当行なら。
                        isJudge = true;
                    }
                    else
                    {
                        isJudge = false;
                    }
                }
                else
                {
                    isJudge = false;
                }

            }
            catch (RowNotInTableException)
            {
                // (9)指定行がなかった場合は、スルー。
                isJudge = false;

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

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

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append("検索キーに指定した[");
                s.Append(name_KeyField);
                s.Append("]というフィールドは無いです。");
                s.Newline();

                // ヒント
                parent_Query.ToText_Locationbreadcrumbs(s);

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            gt_Error_Parse:
            // 空値ではダメという設定の場合。
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー287!", log_Method);

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.AppendI(0, "<Select_KeyIntImplクラス>");
                s.Newline();

                s.AppendI(1, "これはint型値のプログラムです。他の型のプログラムを使ってください。");
                s.Newline();

                s.AppendI(1, "・ヒント:変数が見つからなかった場合もここに来ます。例えば、変数名「$aaa」を書こうとして、「aaa」と書いていませんか?");
                s.Newline();

                s.AppendI(1, "・ヒント:数値が大きすぎた場合もここに来ます。");
                s.Newline();

                s.AppendI(1, "sExpectedValue=[");
                s.Append(value_Expected);
                s.Append("]");
                s.Newline();
                s.Newline();

                //
                // ヒント
                parent_Query.ToText_Locationbreadcrumbs(s);

                s.AppendI(0, "</Select_KeyIntImplクラス>");
                s.Newline();

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
            gt_EndMethod:
            log_Method.EndMethod(log_Reports);
        }
Пример #6
0
        //────────────────────────────────────────

        public void Judge(
            out bool isJudge,
            string name_KeyField,
            string value_Expected,
            bool isRequired_ExpectedValue,
            DataRow row,
            Configuration_Node 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
            {
                Value_Humaninput valueH = (Value_Humaninput)row[name_KeyField];

                // (5)キーが空欄で、検索ヒット必須でなければ、無視します。【bool型フィールドの場合】
                if (Bool_HumaninputImpl.IsSpaces(valueH))
                {
                    isJudge = false;
                    goto gt_EndMethod;
                }



                //
                // (6)この行の、キー_フィールドの値を取得。
                //
                bool isKeyValue;

                bool isParsedSuccessful = Bool_HumaninputImpl.TryParse(
                    valueH,
                    out isKeyValue,
                    EnumOperationIfErrorvalue.Error,
                    null,
                    log_Reports
                    );
                if (log_Reports.Successful)
                {
                    if (!isParsedSuccessful)
                    {
                        // エラー。
                        isJudge = false;
                        if (log_Reports.CanCreateReport)
                        {
                            Log_RecordReports d_Report = log_Reports.BeginCreateReport(EnumReport.Error);
                            d_Report.SetTitle("▲エラー699!", log_Method);
                            d_Report.Message = "bool型パース失敗。";
                            log_Reports.EndCreateReport();
                        }
                        goto gt_EndMethod;
                    }
                }


                bool isExpectedValue;
                if (log_Reports.Successful)
                {
                    // (8)キー値をbool型に変換します。
                    bool isParseSuccessful2 = bool.TryParse(value_Expected, out isExpectedValue);
                    if (!isParseSuccessful2)
                    {
                        isJudge = false;
                        if (isRequired_ExpectedValue)
                        {
                            // 空値ではダメという設定の場合。
                            goto gt_Error_Parse;
                        }
                        goto gt_EndMethod;
                    }
                }
                else
                {
                    isExpectedValue = false;
                }



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

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

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

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.AppendI(0, "<Select_KeyBoolImplクラス>");
                s.Append(Environment.NewLine);

                s.AppendI(1, "これはbool型値のプログラムです。他の型のプログラムを使ってください。");
                s.Append(Environment.NewLine);

                s.AppendI(1, "sExpectedValue=[");
                s.Append(value_Expected);
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                // ヒント
                parent_Query.ToText_Locationbreadcrumbs(s);

                s.AppendI(0, "</Select_KeyBoolImplクラス>");

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
        }
Пример #7
0
        //────────────────────────────────────────
        /// <summary>
        /// 警告メッセージの定型文を作ります。
        /// </summary>
        /// <returns></returns>
        public static string ToText_Configuration(
            Configuration_Node parent_Conf
            )
        {
            Log_TextIndented s = new Log_TextIndentedImpl();

            if (null == parent_Conf)
            {
                s.Append("  親要素が指定されていません。");
            }
            else
            {
                s.Append("  設定位置パンくずリスト(問題個所ヒント):");
                s.Newline();
                s.Newline();
                parent_Conf.ToText_Locationbreadcrumbs(s);
                s.Newline();
                s.Newline();

                parent_Conf.ToText_Content(s);
                s.Newline();
                s.Newline();

                s.Append(Log_RecordReportsImpl.ToText_Separator());

                s.Append("  問題を報告したオブジェクトの型: ");
                s.Append(parent_Conf.GetType());
                s.Append(" (これはラッパークラスということもあるかも知れません)");
                s.Newline();
                s.Newline();
            }

            return s.ToString();
        }
Пример #8
0
        //────────────────────────────────────────

        public void Judge(
            out bool isJudge,
            string name_KeyField,
            string value_Expected,
            bool isRequired_ExpectedValue,
            DataRow row,
            Configuration_Node 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
            {
                object obj = row[name_KeyField];

                if (obj is DBNull)
                {
                    isJudge = false;
                    goto gt_Error_DBNull;
                }

                Value_Humaninput valueH = (Value_Humaninput)obj;

                // (5)キーが空欄で、検索ヒット必須でなければ、無視します。【int型フィールドの場合】
                if (Int_HumaninputImpl.IsSpaces(valueH))
                {
                    isJudge = false;
                    goto gt_EndMethod;
                }


                // (6)この行の、キー_フィールドの値を取得。
                int keyValue;

                bool bParsedSuccessful = Int_HumaninputImpl.TryParse(
                    valueH,
                    out keyValue,
                    EnumOperationIfErrorvalue.Error,
                    null,
                    log_Reports
                    );

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



                // (7)キー値をint型に変換します。
                int expectedValue;
                if (log_Reports.Successful)
                {
                    bool bParseSuccessful2 = int.TryParse(value_Expected, out expectedValue);
                    if (!bParseSuccessful2)
                    {
                        isJudge = false;
                        if (isRequired_ExpectedValue)
                        {
                            goto gt_Error_Parse;
                        }

                        goto gt_EndMethod;
                    }
                }
                else
                {
                    expectedValue = 0;
                }



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

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

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

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append("検索キーに指定した[");
                s.Append(name_KeyField);
                s.Append("]というフィールドは無いです。");
                s.Newline();

                // ヒント
                parent_Query.ToText_Locationbreadcrumbs(s);

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
gt_Error_Parse:
            // 空値ではダメという設定の場合。
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー287!", log_Method);

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.AppendI(0, "<Select_KeyIntImplクラス>");
                s.Newline();

                s.AppendI(1, "これはint型値のプログラムです。他の型のプログラムを使ってください。");
                s.Newline();

                s.AppendI(1, "・ヒント:変数が見つからなかった場合もここに来ます。例えば、変数名「$aaa」を書こうとして、「aaa」と書いていませんか?");
                s.Newline();

                s.AppendI(1, "・ヒント:数値が大きすぎた場合もここに来ます。");
                s.Newline();

                s.AppendI(1, "sExpectedValue=[");
                s.Append(value_Expected);
                s.Append("]");
                s.Newline();
                s.Newline();

                //
                // ヒント
                parent_Query.ToText_Locationbreadcrumbs(s);

                s.AppendI(0, "</Select_KeyIntImplクラス>");
                s.Newline();

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