Beispiel #1
0
        //────────────────────────────────────────

        /// <summary>
        /// 『ツール設定ファイル』へ書き出します。
        /// </summary>
        /// <param name="toolConfigXmlFileAbsPath"></param>
        /// <param name="applicationName"></param>
        /// <param name="inputs"></param>
        /// <param name="runningHintName"></param>
        public void Write(
            string sFpatha_Config_Tool,
            string sName_Application,
            Dictionary_AatoolxmlEditor dic_AatoolxmlEditor,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0);

            log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "Write", log_Reports);

            XmlDocument xDoc = new XmlDocument();

            // UTF-8 エンコーディングで書くものとします。
            XmlProcessingInstruction xPi = xDoc.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");

            xDoc.AppendChild(xPi);

            // 説明文の記述
            {
                StringBuilder sbText1 = new StringBuilder();
                sbText1.Append("このファイルは、UTF-8(BOM無し) エンコーディングで記述してください。");

                xDoc.AppendChild(xDoc.CreateComment(sbText1.ToString()));
            }


            Exception err_Excp;

            try
            {
                // ルート要素を作成
                System.Xml.XmlElement xRoot = xDoc.CreateElement(NamesNode.S_CODEFILE_TOOL);

                //
                // これは書出しなので、スクリプトファイルのバージョンチェックを省略。
                //

                xRoot.SetAttribute("application", sName_Application);
                xDoc.AppendChild(xRoot);

                // 説明文の記述
                {
                    StringBuilder sb1 = new StringBuilder();
                    sb1.Append("このファイルは、恐らく『");
                    sb1.Append(sName_Application);
                    sb1.Append("』によって読書きされるかと思います。");

                    xRoot.AppendChild(xDoc.CreateComment(sb1.ToString()));
                }

                // エディター要素:
                foreach (MemoryAatoolxml_Editor aatool_Editor in dic_AatoolxmlEditor.Dictionary_Item.Values)
                {
                    XmlElement xEditor = xDoc.CreateElement(NamesNode.S_EDITOR);

                    // input要素:
                    aatool_Editor.Dictionary_Fsetvar_Configurationtree.List_Child.ForEach(delegate(Configurationtree_Node s_Fsetvar, ref bool bBreak)
                    {
                        XmlElement x_Input = xDoc.CreateElement(NamesNode.S_F_SET_VAR);

                        //name-var属性
                        string sNamevar;
                        s_Fsetvar.Dictionary_Attribute.TryGetValue(PmNames.S_NAME_VAR, out sNamevar, true, log_Reports);

                        //folder属性
                        string sFolder;
                        s_Fsetvar.Dictionary_Attribute.TryGetValue(PmNames.S_FOLDER, out sFolder, true, log_Reports);

                        //value属性
                        string sValue;
                        s_Fsetvar.Dictionary_Attribute.TryGetValue(PmNames.S_VALUE, out sValue, true, log_Reports);

                        //description属性
                        string sDescription;
                        s_Fsetvar.Dictionary_Attribute.TryGetValue(PmNames.S_DESCRIPTION, out sDescription, true, log_Reports);

                        x_Input.SetAttribute(PmNames.S_NAME.Name_Attribute, sNamevar);
                        x_Input.SetAttribute(PmNames.S_FOLDER.Name_Attribute, sFolder);
                        x_Input.SetAttribute(PmNames.S_VALUE.Name_Attribute, sValue);
                        x_Input.SetAttribute(PmNames.S_DESCRIPTION.Name_Attribute, sDescription);

                        xEditor.AppendChild(x_Input);
                    });

                    xRoot.AppendChild(xEditor);
                }



                // .xmlファイルの中身全文を保存。
                xDoc.Save(sFpatha_Config_Tool);
            }
            catch (Exception ex)
            {
                // エラー
                err_Excp = ex;
                goto gt_Error_Exception;
            }

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

                StringBuilder s = new StringBuilder();
                s.Append("『ツール設定ファイル』への書き出しに失敗しました。");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

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

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

        /// <summary>
        /// 『AaEditor.xml』ファイルへ書き出します。
        /// </summary>
        /// <param name="sFpatha_Pcnf"></param>
        /// <param name="applicationName"></param>
        /// <param name="inputs"></param>
        public void Write(
            string sFpatha_Pcnf,
            string sName_Editor,
            Dictionary_Fsetvar_Configurationtree stDic_Fsetvar,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0);

            log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "Write", log_Reports);

            XmlDocument xDoc = new XmlDocument();

            // UTF-8 エンコーディングで書くものとします。
            XmlProcessingInstruction xPi = xDoc.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");

            xDoc.AppendChild(xPi);

            Exception err_Excp;

            try
            {
                // ルート要素を作成
                System.Xml.XmlElement xRoot = xDoc.CreateElement(NamesNode.S_EDITOR);

                //
                // これは書出しなので、スクリプトファイルのバージョンチェックを省略。
                //

                //xRoot.SetAttribute(PmNames.S_NAME_EDITOR.Name_Attribute, sName_Editor);

                xDoc.AppendChild(xRoot);

                // 説明文の記述
                {
                    StringBuilder sbText1 = new StringBuilder();
                    sbText1.Append("このファイルは、『");
                    sbText1.Append(sName_Editor);
                    sbText1.Append("』によって読書きされます");

                    xRoot.AppendChild(xDoc.CreateComment(sbText1.ToString()));
                }

                // <f-set-var>要素:
                stDic_Fsetvar.List_Child.ForEach(delegate(Configurationtree_Node cf_Fsetvar, ref bool bBreak)
                {
                    XmlElement x_Fsetvar = xDoc.CreateElement(NamesNode.S_F_SET_VAR);

                    //name-var属性
                    string sNamevar;
                    cf_Fsetvar.Dictionary_Attribute.TryGetValue(PmNames.S_NAME_VAR, out sNamevar, true, log_Reports);

                    //folder属性
                    string sFolder;
                    cf_Fsetvar.Dictionary_Attribute.TryGetValue(PmNames.S_FOLDER, out sFolder, true, log_Reports);

                    //value属性
                    string sValue;
                    cf_Fsetvar.Dictionary_Attribute.TryGetValue(PmNames.S_VALUE, out sValue, true, log_Reports);

                    //description属性
                    string sDescription;
                    cf_Fsetvar.Dictionary_Attribute.TryGetValue(PmNames.S_DESCRIPTION, out sDescription, true, log_Reports);

                    x_Fsetvar.SetAttribute(PmNames.S_NAME.Name_Attribute, sNamevar);
                    x_Fsetvar.SetAttribute(PmNames.S_FOLDER.Name_Attribute, sFolder);
                    x_Fsetvar.SetAttribute(PmNames.S_VALUE.Name_Attribute, sValue);
                    x_Fsetvar.SetAttribute(PmNames.S_DESCRIPTION.Name_Attribute, sDescription);
                    xRoot.AppendChild(x_Fsetvar);
                });

                // .xmlファイルの中身全文を保存。
                xDoc.Save(sFpatha_Pcnf);
            }
            catch (Exception ex)
            {
                // エラー
                err_Excp = ex;
                goto gt_Error_Exception;
            }

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

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append("エディター設定ファイルへの書き出しに失敗しました。");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                s.Append("エラーの種類:");
                s.Append(err_Excp.GetType().Name);
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);
                s.Append("エラーメッセージ:");
                s.Append(err_Excp.Message);
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

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