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

        /// <summary>
        /// 無条件で、全てのレコードを返す。
        /// </summary>
        /// <param name="dst_Row"></param>
        /// <param name="isRequired_ExpectedValue"></param>
        /// <param name="dataTable"></param>
        /// <param name="s_ParentNode_query"></param>
        /// <param name="log_Reports"></param>
        public void Select(
            out List <DataRow> out_List_DstRow,
            bool isRequired_ExpectedValue,
            DataTable dataTable,
            Conf_String parent_Conf,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl();

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

            //
            //
            //
            //

            out_List_DstRow = new List <DataRow>();


            foreach (DataRow row in dataTable.Rows)
            {
                out_List_DstRow.Add(row);
            }

            goto gt_EndMethod;

            //
            //
            //
            //

gt_EndMethod:
            log_Method.EndMethod(log_Reports);
        }
Ejemplo n.º 2
0
        //────────────────────────────────────────

        /// <summary>
        /// パスを設定します。
        /// </summary>
        /// <param name="folderRel_New">フォルダーのパス。</param>
        /// <param name="fileBoth_Newhumaninput">ファイルの相対パス、または絶対パス。</param>
        public static Expr_Filepath Init2(
            string folderRel_New,
            string fileBoth_Newhumaninput,
            string confName,
            Conf_String cParent_OrNull,
            Log_Reports log_Reports
            )
        {
            // ツール設定ファイルへのパスは固定とします。
            Expr_Filepath eFileRel = null;

            {
                Conf_Filepath cFileRel = new Conf_FilepathImpl(confName, cParent_OrNull);
                // #コンフィグ作成
                cFileRel.Init1(
                    folderRel_New,
                    fileBoth_Newhumaninput,
                    log_Reports);

                if (log_Reports.Successful)
                {
                    eFileRel = new Expr_FilepathImpl(cFileRel);
                }
            }

            return(eFileRel);
        }
Ejemplo n.º 3
0
        //────────────────────────────────────────

        /// <summary>
        ///
        /// </summary>
        /// <param name="name">引数名</param>
        /// <param name="value">その値</param>
        /// <param name="cElm">引数のコンフィグ</param>
        /// <param name="eParent">親Expr</param>
        /// <param name="isRequired"></param>
        /// <param name="log_Reports"></param>
        /// <returns></returns>
        public bool TryGetValue2(
            PmName name,
            out Expr_String value,
            Conf_String cElm,
            Expr_String eParent,
            bool isRequired,
            Log_Reports log_Reports
            )
        {
            bool isHit = false;

            string s;//コントロール名

            this.TryGetValue(name, out s, isRequired, log_Reports);

            if (log_Reports.Successful)
            {
                value = new Expr_LeafStringImpl(s, eParent, cElm);
                isHit = true;
            }
            else
            {
                value = null;
            }

            return(isHit);
        }
Ejemplo n.º 4
0
        //────────────────────────────────────────

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

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

                cParent.ToText_Content(s);
                s.Newline();
                s.Newline();

                s.Append(Log_RecordReportsImpl.ToText_Separator());

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


            return(s.ToString());
        }
Ejemplo n.º 5
0
        //────────────────────────────────────────

        /// <summary>
        /// 新しいインスタンスを作ります。
        /// </summary>
        /// <param name="log_Reports"></param>
        /// <returns></returns>
        public Expr_LeafString NewInstance(
            Conf_String parent_Expression,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl();

            log_Method.BeginMethod(Info_Syntax.Name_Library, this, "NewInstance", log_Reports);

            //
            //
            //
            //

            Expr_LeafStringImpl result = new Expr_LeafStringImpl(null, parent_Expression);

            result.SetString(
                this.sHumanInput,
                log_Reports
                );

            //
            //
            log_Method.EndMethod(log_Reports);
            return(result);
        }
Ejemplo n.º 6
0
        //────────────────────────────────────────

        /// <summary>
        /// 絶対パスが、ファイルシステムで使えるファイルパスの文字列の長さの制限を越えていれば真。
        /// </summary>
        /// <param name="newDirectoryPath">指定するものがない場合は、System.Windows.Forms.StartupPath を入れてください。</param>
        /// <param name="newHumanInputFilePath"></param>
        /// <param name="cElm"></param>
        public static bool IsTooLong(
            string folderRel_New,
            string fileRel_Humaninput_New,
            Log_Reports log_Reports,
            Conf_String cElm
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0);

            log_Method.BeginMethod(Info_Syntax.Name_Library, "Util_Filepath", "IsTooLong", log_Reports);

            // フラグ。
            bool bFlagCheckPathTooLong = false;

            if (log_Reports.Successful)
            {
                // チェック。絶対パスにすることができればOK。
                Util_Filepath.ToAbsolute(
                    folderRel_New,
                    fileRel_Humaninput_New,
                    ref bFlagCheckPathTooLong,
                    true,        //ファイル名の長さが上限超過でも、正常処理扱いとします。
                    log_Reports, // out sErrorMsg,
                    cElm
                    );
            }

            goto gt_EndMethod;
            //
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return(bFlagCheckPathTooLong);
        }
Ejemplo n.º 7
0
        //────────────────────────────────────────

        /// <summary>
        /// 追加。
        /// </summary>
        public void Add(
            Conf_String cElm,
            Log_Reports log_Reports
            )
        {
            this.items.Add(cElm);
        }
Ejemplo n.º 8
0
        //────────────────────────────────────────

        public Conf_StringImpl(string name, Conf_String cParent_OrNull)
        {
            this.childNodes = new ConfStringListImpl(this);
            this.attributes = new ConfStringMapImpl(this);

            this.name   = name;
            this.parent = cParent_OrNull;
        }
Ejemplo n.º 9
0
        //────────────────────────────────────────

        /// <summary>
        /// 文字列を、子要素として追加。
        /// </summary>
        /// <param name="sHumaninput"></param>
        /// <param name="parent_Conf"></param>
        /// <param name="log_Reports"></param>
        public void AppendTextNode(
            string sHumaninput,
            Conf_String parent_Conf,
            Log_Reports log_Reports
            )
        {
            throw new Exception(Info_Syntax.Name_Library + ":" + this.GetType().Name + "#AppendTextElement:このクラスでは、このメソッドを使わないでください。");
        }
Ejemplo n.º 10
0
        //────────────────────────────────────────

        /// <summary>
        /// new された直後の内容に戻します。
        /// </summary>
        public void Clear(string name, Conf_String cParent_OrNull, Log_Reports log_Reports)
        {
            Log_Method log_Method = new Log_MethodImpl(0);

            log_Method.BeginMethod(Info_Syntax.Name_Library, this, "Clear", log_Reports);

            //
            //
            //
            // 親
            //
            //
            //
            this.Parent = cParent_OrNull;


            //
            //
            //
            // 自
            //
            //
            //
            this.Name = name;


            //
            //
            //
            // 属性
            //
            //
            //
            this.Attributes.Clear(this, log_Reports);


            //
            //
            //
            // 子
            //
            //
            //
            this.childNodes.Clear(log_Reports);


            //
            //
            //
            // 親への連結は維持。
            //
            //
            //

            //
            //
            log_Method.EndMethod(log_Reports);
        }
Ejemplo n.º 11
0
        //────────────────────────────────────────

        /// <summary>
        /// コンストラクター。
        /// </summary>
        /// <param name="parent_Expr"></param>
        /// <param name="cur_Conf">生成時に指定できないものもある。</param>
        public Expr_StringImpl(Expr_String parent_Expr, Conf_String cur_Conf)
        {
            this.parent_Expression = parent_Expr;
            this.conf_             = cur_Conf;

            enumHitcount     = EnumHitcount.Unconstraint;
            this.eChildNodes = new Expr_StringListImpl(this);
            this.attributes  = new ExprStringMapImpl(this.Conf);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// コンストラクター。
        /// </summary>
        public Expr_LeafStringImpl(string sHumanInput, Expr_String parent_Expr, Conf_String cur_Conf)
        {
            this.sHumanInput       = sHumanInput;
            this.parent_Expression = parent_Expr;
            this.conf_             = cur_Conf;

            this.enumHitcount = EnumHitcount.Unconstraint;
            this.dictionary_Expression_Attribute = new ExprStringMapImpl(this.Conf);
        }
Ejemplo n.º 13
0
        //────────────────────────────────────────

        /// <summary>
        /// コンストラクター。
        /// </summary>
        /// <param name="s_ParentNode"></param>
        private RecordconditionImpl(Conf_String parent_Conf)
        {
            this.parent = parent_Conf;

            this.list_Child = new List <Recordcondition>();
            this.enumLogic  = EnumLogic.None;
            this.sField     = "(▲未初期化102!)";
            this.enumOpe    = EnumOpe.Eq;
            this.sValue     = "";
        }
Ejemplo n.º 14
0
        //────────────────────────────────────────

        /// <summary>
        /// コンストラクター。
        /// </summary>
        public Expr_TexttemplateP1pImpl(Expr_String eParent, Conf_String cElm)
        {
            this.parent_Expression = eParent;
            this.conf = cElm;

            this.requestItems = EnumHitcount.Unconstraint;

            this.dictionary_P1p                  = new Dictionary <int, string>();
            this.list_Expression_Child           = new Expr_StringListImpl(this);//使いません。
            this.dictionary_Expression_Attribute = new ExprStringMapImpl(this.Conf);
        }
Ejemplo n.º 15
0
        //────────────────────────────────────────

        /// <summary>
        /// 文字列を、子要素として追加。
        /// </summary>
        /// <param name="contents"></param>
        /// <param name="s_ParentNode"></param>
        /// <param name="log_Reports"></param>
        public void AppendTextNode(
            string contents,
            Conf_String parent_Conf,
            Log_Reports log_Reports
            )
        {
            Expr_LeafStringImpl eChild = new Expr_LeafStringImpl(null, parent_Conf);

            eChild.SetString(contents, log_Reports);

            this.ChildNodes.Add(eChild, log_Reports);
        }
Ejemplo n.º 16
0
        //────────────────────────────────────────

        public SelectstatementImpl(Expr_String parent_Expr, Conf_String parent_Conf)
        {
            this.parent = parent_Conf;
            this.List_SName_SelectField             = new List <string>();
            this.Expression_From                    = new Expr_StringImpl(parent_Expr, parent_Conf);
            this.Expression_Into                    = new Expr_StringImpl(parent_Expr, parent_Conf);
            this.Expression_Where_RecordSetLoadFrom = new Expr_StringImpl(parent_Expr, parent_Conf);
            this.EnumWherelogic       = EnumLogic.And;//whereのlogic属性のデフォルト。
            this.list_Recordcondition = new List <Recordcondition>();
            this.Required             = "";
            this.Storage     = "";
            this.Description = "";
        }
Ejemplo n.º 17
0
        //────────────────────────────────────────

        public static bool IsTooLong(
            string fileRel_Humaninput_New,
            Log_Reports log_Reports,
            Conf_String cElm
            )
        {
            return(Util_Filepath.IsTooLong(
                       "",
                       fileRel_Humaninput_New,
                       log_Reports,// out sErrorMsg,
                       cElm
                       ));
        }
Ejemplo n.º 18
0
        //────────────────────────────────────────

        /// <summary>
        /// new された直後の内容に戻します。
        /// </summary>
        public void Clear(Conf_String cOwner, Log_Reports log_Reports)
        {
            Log_Method log_Method = new Log_MethodImpl(0);

            log_Method.BeginMethod(Info_Syntax.Name_Library, this, "Clear", log_Reports);

            //
            //

            this.owner = null;
            this.map.Clear();

            //
            //
            log_Method.EndMethod(log_Reports);
        }
Ejemplo n.º 19
0
        //────────────────────────────────────────

        /// <summary>
        /// 文字列を、子要素として追加。
        /// </summary>
        /// <param name="humaninput"></param>
        /// <param name="cParent"></param>
        /// <param name="log_Reports"></param>
        public void AppendTextNode(
            string humaninput,
            Conf_String cParent,
            Log_Reports log_Reports
            )
        {
            Expr_LeafStringImpl eAtom = new Expr_LeafStringImpl(null, cParent);

            eAtom.SetString(
                humaninput,
                log_Reports
                );

            this.ChildNodes.Add(
                eAtom,
                log_Reports
                );
        }
Ejemplo n.º 20
0
        //────────────────────────────────────────

        /// <summary>
        /// 未実装の場合。
        /// </summary>
        /// <param name="parent_Conf"></param>
        /// <param name="log_Reports"></param>
        static public void NoImpl_Expression_AddChild(
            Conf_String parent_Conf,
            Log_Reports log_Reports
            )
        {
            //
            // エラー。

            Log_Method log_Method = new Log_MethodImpl();

            log_Method.BeginMethod(Info_Syntax.Name_Library, "Util_Expression_Node_String", "NoImpl_Expression_AddChild", log_Reports);

            //
            //
            //
            //

            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー361!", log_Method);

                StringBuilder sb = new StringBuilder();

                sb.Append("Expression_AddChild メソッドは、未実装です。");
                sb.Append(Environment.NewLine);
                sb.Append(Environment.NewLine);

                // ヒント
                sb.Append(r.Message_Conf(parent_Conf));

                r.Message = sb.ToString();
                log_Reports.EndCreateReport();
            }

            //
            //
            //
            //
            log_Method.EndMethod(log_Reports);
        }
Ejemplo n.º 21
0
        //────────────────────────────────────────

        /// <summary>
        /// ファイルパスを、絶対ファイルパスに変換します。
        /// </summary>
        /// <param name="humaninput"></param>
        /// <param name="isTooLong"></param>
        /// <param name="isSafe_TooLong"></param>
        /// <param name="log_Reports"></param>
        /// <param name="cElm"></param>
        /// <returns></returns>
        public static string ToAbsolute(
            string humaninput,
            ref bool isTooLong,
            bool isSafe_TooLong,
            Log_Reports log_Reports,
            Conf_String cElm
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0);

            log_Method.BeginMethod(Info_Syntax.Name_Library, "Util_Filepath", "ToAbsolute③", log_Reports);

            string sResult;

            if (log_Reports.Successful)
            {
                sResult = Util_Filepath.ToAbsolute(
                    "",
                    humaninput,
                    ref isTooLong,
                    isSafe_TooLong,
                    log_Reports,//out sErrorMsg,
                    cElm
                    );
            }
            else
            {
                sResult = "";
            }

            goto gt_EndMethod;
            //
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return(sResult);
        }
Ejemplo n.º 22
0
        //────────────────────────────────────────

        /// <summary>
        /// コンストラクター。
        /// </summary>
        public Expr_LeafStringImpl(Expr_String parent_Expr, Conf_String cur_Conf)
            : this("", parent_Expr, cur_Conf)
        {
        }
Ejemplo n.º 23
0
 /// <summary>
 /// 警告メッセージの定型文を作ります。
 /// </summary>
 /// <returns></returns>
 public string Message_Conf(
     Conf_String parent_Cnf
     )
 {
     return(Log_RecordReportsImpl.ToText_Conf(parent_Cnf));
 }
Ejemplo n.º 24
0
        //────────────────────────────────────────

        /// <summary>
        /// コンストラクター。
        /// </summary>
        public ConfStringListImpl(Conf_String cOwner)
        {
            this.owner = cOwner;
            this.items = new List <Conf_String>();
        }
Ejemplo n.º 25
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
            {
                Cell valueH = (Cell)row[name_KeyField];

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



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

                bool isParsedSuccessful = BoolCellImpl.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);
        }
Ejemplo n.º 26
0
        //────────────────────────────────────────

        /// <summary>
        /// 「フィールド名=値」という条件1つで検索。該当するレコード0~N件を返す。
        /// </summary>
        /// <param name="dst_Row"></param>
        /// <param name="name_KeyField"></param>
        /// <param name="value_Expected"></param>
        /// <param name="isRequired_ExpectedValue"></param>
        /// <param name="fielddefinition_Key"></param>
        /// <param name="dataTable"></param>
        /// <param name="s_ParentNode_query"></param>
        /// <param name="log_Reports"></param>
        public void Select(
            out List <DataRow> out_List_DstRow,
            string name_KeyField,
            string value_Expected,
            bool isRequired_ExpectedValue,
            Fielddef fielddefinition_Key,
            DataTable dataTable,
            Conf_String parent_Query,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl();

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

            //
            //
            //
            //

            out_List_DstRow = new List <DataRow>();

            Judge_FieldBoolImpl   judgeB = new Judge_FieldBoolImpl();
            Judge_FieldIntImpl    judgeI = new Judge_FieldIntImpl();
            Judge_FieldStringImpl judgeS = new Judge_FieldStringImpl();


            foreach (DataRow row in dataTable.Rows)
            {
                bool bJudge;

                switch (fielddefinition_Key.Type_Field)
                {
                case EnumTypeFielddef.String:
                {
                    // string型フィールドなら
                    judgeS.Judge(
                        out bJudge,
                        name_KeyField,
                        value_Expected,
                        isRequired_ExpectedValue,
                        row,
                        parent_Query,
                        log_Reports
                        );
                }
                break;

                case EnumTypeFielddef.Int:
                {
                    // int型フィールドなら
                    judgeI.Judge(
                        out bJudge,
                        name_KeyField,
                        value_Expected,
                        isRequired_ExpectedValue,
                        row,
                        parent_Query,
                        log_Reports
                        );
                }
                break;

                case EnumTypeFielddef.Bool:
                {
                    // bool型フィールドなら
                    judgeB.Judge(
                        out bJudge,
                        name_KeyField,
                        value_Expected,
                        isRequired_ExpectedValue,
                        row,
                        parent_Query,
                        log_Reports
                        );
                }
                break;

                default:
                {
                    // エラー。
                    goto gt_Error_UndefinedClass;
                }
                break;
                }

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

                if (bJudge)
                {
                    out_List_DstRow.Add(row);
                }
            }

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

                Log_TextIndented s = new Log_TextIndentedImpl();

                s.AppendI(0, "<NFuncCellUpdaterImplクラス>");
                s.Append(Environment.NewLine);

                s.AppendI(1, "予期しない型です。");
                s.Append(Environment.NewLine);

                s.AppendI(1, "keyFldDefinition.Type=[");
                s.Append(fielddefinition_Key.ToString_Type());
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                // ヒント
                s.AppendI(1, r.Message_Conf(parent_Query));

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

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



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

        /// <summary>
        /// attr系要素の追加。
        ///
        /// 既に追加されている要素は、追加できない。
        /// </summary>
        public void Add(
            string key,
            string value,
            Conf_String cValue,
            bool isRequired,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0);

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

            //
            //

            if (!this.map.ContainsKey(key))
            {
                this.map.Add(key, value);
            }
            else
            {
                if (isRequired)
                {
                    // エラー
                    goto gt_Error_Duplicate;
                }
            }

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

                Log_TextIndented s = new Log_TextIndentedImpl();

                s.Append("要素<");
                s.Append(this.owner.Name);
                s.Append(">に、同じ名前の属性が重複していました。");
                s.Newline();

                s.Append("入れようとした要素の名前=[");
                s.Append(key);
                s.Append("]");
                s.Newline();

                // ヒント
                s.Append(r.Message_Conf(cValue));

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

        public Record_HumaninputImpl(string config, DataRow dataRow, Conf_String cParent)
            : base(config, cParent)
        {
            this.dataRow = dataRow;
            //this.configuration_Node = configuration_Node;
        }
Ejemplo n.º 29
0
        //────────────────────────────────────────

        public ConfStringMapImpl(Conf_String cOwner)
        {
            this.owner = cOwner;
            this.map   = new Dictionary <string, string>();
        }
Ejemplo n.º 30
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 ToAbsolute(
            string directory_Base,
            string humaninput,
            ref bool isTooLong,
            bool isSafe_TooLong,
            Log_Reports log_Reports,
            Conf_String cur_Conf
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0);

            log_Method.BeginMethod(Info_Syntax.Name_Library, "Util_Filepath", "ToAbsolute②", 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;//ファイルパス

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

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

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

            // 「絶対パス」か、「相対パス」かを判断します。
            bool isRooted_Path = Util_Filepath.IsRooted(
                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)
                {
                    // 正常処理扱いとします。
                }
                else
                {
                    // 異常扱いとします。

                    err_Excp = e;
                    goto gt_Error_PathTooLongException;
                }


                isTooLong = 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);
        }