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/ConfigXml.cs |  164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 164 insertions(+), 0 deletions(-)

diff --git a/HotelPms.Share/Xml/ConfigXml.cs b/HotelPms.Share/Xml/ConfigXml.cs
new file mode 100644
index 0000000..972e8dd
--- /dev/null
+++ b/HotelPms.Share/Xml/ConfigXml.cs
@@ -0,0 +1,164 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HotelPms.Share.Util;
+using System.Xml;
+using System.IO;
+
+namespace HotelPms.Share.Xml
+{
+    /// ****************************** Description *******************************
+    /// ���V�X�e������
+    /// �@�ėp�N���X
+    /// ���T�v
+    /// �@Config.xml��Ǎ�
+    /// ������
+    /// �@20070803  ���؁@����    �V�K�쐬
+    /// ****************************** Declarations ******************************
+    public class ConfigXml
+    {
+        private static string configXmlPath = System.AppDomain.CurrentDomain.BaseDirectory + @"Config.xml";
+        private static string dBServer = string.Empty;
+        private static string dBName = string.Empty;
+        private static string dBUser = string.Empty;
+        private static string dBPassWord = string.Empty;
+
+        public static string DBName
+        {
+            get { return dBName; }
+            set { dBName = value; }
+        }
+
+        public static string DBServer
+        {
+            get { return dBServer; }
+            set { dBServer = value; }
+        }
+
+        public static string DBUser
+        {
+            get { return dBUser; }
+            set { dBUser = value; }
+        }
+
+        public static string DBPassWord
+        {
+            get { return dBPassWord; }
+            set { dBPassWord = value; }
+        }
+
+        public static string ConfigXmlPath
+        {
+            get { return configXmlPath; }
+            set { configXmlPath = value; }
+        }
+
+        /// <summary>
+        /// �[���ݒ�̓ǂݍ���
+        /// </summary>
+        public static void GetConfigXml()
+        {
+            try
+            {
+                if (!File.Exists(configXmlPath))
+                {
+                    try
+                    {
+                        string[] connectInfo = new string[4];
+                        //�Ȃ���ΐ�������
+                        StringBuilder fileBuilder = new StringBuilder();
+                        fileBuilder.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+                        fileBuilder.AppendLine("<environment>");
+                        fileBuilder.AppendLine("  <param>");
+                        fileBuilder.AppendLine("	<name>DataSource</name>");
+                        fileBuilder.AppendLine(string.Format("    <value>{0}</value>", connectInfo[0]));
+                        fileBuilder.AppendLine("  </param>");
+                        fileBuilder.AppendLine("  <param>");
+                        fileBuilder.AppendLine("    <name>InitialCatalog</name>");
+                        fileBuilder.AppendLine(string.Format("	  <value>{0}</value>", connectInfo[1]));
+                        fileBuilder.AppendLine("  </param>");
+                        fileBuilder.AppendLine("  <param>");
+                        fileBuilder.AppendLine("    <name>UserID</name>");
+                        fileBuilder.AppendLine(string.Format("    <value>{0}</value>", connectInfo[2]));
+                        fileBuilder.AppendLine("  </param>");
+                        fileBuilder.AppendLine("  <param>");
+                        fileBuilder.AppendLine("    <name>Password</name>");
+                        fileBuilder.AppendLine(string.Format("    <value>{0}</value>", connectInfo[3]));
+                        fileBuilder.AppendLine("  </param>");
+                        fileBuilder.AppendLine("</environment>");
+                        File.WriteAllText(configXmlPath, fileBuilder.ToString(), Encoding.UTF8);
+                    }
+                    catch
+                    {
+                        return;
+                    }
+                }
+
+                Dictionary<string, string> dic = SysXmlMgr.GetNormalXml(configXmlPath);
+                dBServer = dic["DataSource"];
+                dBName = dic["InitialCatalog"];
+                dBUser = dic["UserID"];
+                dBPassWord = dic["Password"];
+                dic.Clear();
+            }
+            catch { }
+        }
+
+        /// <summary>
+        ///   ���ѕW���̂w�l�k��ǂ�
+        /// </summary>
+        /// <param name="hvConfigXml">̧���߽</param>
+        /// <param name="hsKeyName">SystemStorage�̃L�[</param>
+        /// <returns>bool</returns>
+        public static bool GetNormalXml(object hvConfigXml, string hsKeyName)
+        {
+            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);
+                        }
+                    }
+                }
+                SystemStorage.Instance().SetItem(hsKeyName, config);
+                return true;
+            }
+            catch
+            {
+                return false;
+            }
+        } 
+
+    }
+}

--
Gitblit v1.10.0