From 1a1c8e71fcd14858f595029f089b2d4a00202b32 Mon Sep 17 00:00:00 2001
From: ogi <Administrator@S-OGI-PC>
Date: Fri, 05 Dec 2025 09:24:16 +0900
Subject: [PATCH] プロジェクトファイルを追加。

---
 HotelPms.Share/Xml/SysXmlMgr.cs |  223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 223 insertions(+), 0 deletions(-)

diff --git a/HotelPms.Share/Xml/SysXmlMgr.cs b/HotelPms.Share/Xml/SysXmlMgr.cs
new file mode 100644
index 0000000..f58c220
--- /dev/null
+++ b/HotelPms.Share/Xml/SysXmlMgr.cs
@@ -0,0 +1,223 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+using System.Xml;
+using HotelPms.Share.IO;
+using HotelPms.Share.Util;
+
+namespace HotelPms.Share.Xml
+{
+    public class SysXmlMgr :IDisposable
+    {
+        /// ****************************** Description *******************************
+        /// ���V�X�e������
+        /// �@�ėp�N���X
+        /// ���T�v
+        /// �@XML�̑���F�lj��A�C���A�폜�A�����Ȃ�
+        /// <>�g�p���@
+        /// ������
+        /// �@2007/11/10  ���؁@����    �V�K�쐬
+        /// ****************************** Declarations ******************************
+        #region  �����������@Declartions�@����������
+
+        private string fileName;
+        private Dictionary<string, string>? fileInfo;
+
+        #endregion
+
+        #region  �����������@Property�@����������
+
+        public string FileName
+        {
+            get { return fileName; }
+            set { fileName = value; }
+        }
+
+        public Dictionary<string, string> FileInfo
+        {
+            get { return fileInfo; }
+            set { fileInfo = value; }
+        }
+	        
+        #endregion
+
+        #region  �����������@Class Event�@����������
+
+        public SysXmlMgr()
+            : this("")
+        {
+        }
+
+        public SysXmlMgr(string fileName)
+        {
+            if (!fileName.Equals(""))
+            {
+                this.fileName = fileName;
+            }
+            if (!File.Exists(this.fileName))
+            {
+                fileInfo = new Dictionary<string, string>();
+            }
+            else
+            {
+                fileInfo = GetNormalXml(this.fileName);
+            }
+            
+        }
+
+        #endregion
+
+        #region  �����������@Private Function�@����������
+        #endregion
+
+        #region  �����������@Public  Function�@����������
+
+        public static Dictionary<string, string> GetNormalXml(object hvConfigXml)
+        {
+            Dictionary<string, string> config = new Dictionary<string, string>();
+            XmlDocument doc = new XmlDocument();
+            string itemName = string.Empty;
+            string itemValue = string.Empty;
+            try
+            {
+                if (hvConfigXml is Stream)
+                {
+                    doc.Load((hvConfigXml as Stream));
+                }
+                else
+                {
+                    doc.Load((hvConfigXml as string));
+                }
+                XmlNode rootnode = doc.DocumentElement;
+                foreach (XmlNode child in rootnode.ChildNodes)
+                {
+                    if (child.NodeType == XmlNodeType.Element)
+                    {
+                        if (child.HasChildNodes)
+                        {
+                            foreach (XmlNode woItem in child.ChildNodes)
+                            {
+                                if (woItem.NodeType == XmlNodeType.Element)
+                                {
+                                    if (woItem.Name == "name")
+                                    {
+                                        itemName = woItem.InnerText;
+                                    }
+                                    else if (woItem.Name == "value")
+                                    {
+                                        itemValue = woItem.InnerText;
+                                    }
+                                }
+                            }
+                            config.Add(itemName, itemValue);
+                        }
+                    }
+                }
+                return config;
+            }
+            catch
+            {
+                return null;
+            }
+        }
+
+        public int GetInt(string name)
+        {
+            return CConvert.ToInt(GetItem(name));
+        }
+
+        public bool GetBool(string name)
+        {
+            return CConvert.ToBool(GetItem(name));
+        }
+
+        public string GetItem(string name)
+        {
+            if (fileInfo.ContainsKey(name))
+            {
+                return fileInfo[name];
+            }
+            else
+            {
+                return string.Empty;
+            }
+        }
+
+        public bool SetItem(string name, string value)
+        {
+            return SetItem(name, value, false);
+        }
+
+        public bool SetItem(string name, string value, bool forceAdd)
+        {
+            if (fileInfo.ContainsKey(name))
+            {
+                fileInfo[name] = value;
+                return true;
+            }
+            else
+            {
+                if (forceAdd)
+                {
+                    Add(name, value);
+                    return true;
+                }
+                else
+                {
+                    return false;
+                }
+            }
+        }
+
+        public void Remove(string name)
+        {
+            fileInfo.Remove(name);
+        }
+
+        public void Add(string name,string value)
+        {
+            fileInfo.Add(name, value);
+        }
+
+        /// <summary>
+        /// �ۑ�����
+        /// </summary>
+        /// <returns></returns>
+        public bool Save()
+        {
+            try
+            {             
+                StringBuilder fileBuilder = new StringBuilder();
+                fileBuilder.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+                fileBuilder.AppendLine("<environment>");
+                foreach (string item in fileInfo.Keys)
+                {
+                    fileBuilder.AppendLine("  <param>");
+                    fileBuilder.AppendLine("    <name>" + item + "</name>");
+                    fileBuilder.AppendLine("    <value>" + fileInfo[item] + "</value>");
+                    fileBuilder.AppendLine("  </param>");
+                }
+                fileBuilder.AppendLine("</environment>");
+                FileOperation.Delete(fileName);
+                File.WriteAllText(fileName, fileBuilder.ToString(), Encoding.UTF8);
+                return true;
+            }
+            catch
+            {
+                return false;
+            }
+        }
+
+        public void ReLoad()
+        {
+            this.fileInfo = GetNormalXml(this.fileName);
+        }
+
+        public void Dispose()
+        {
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.10.0