123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml.Serialization;
- namespace Pms.WebHandle
- {
- public class UriData
- {
- public string Uri = "http://127.0.0.1:8804/taiguang";
- public string MESUri = "http://127.0.0.1:8804/taiguang";
- public string WMSUri = "http://127.0.0.1:8804/taiguang";
- }
- public class UriSetting
- {
- private static UriData g_DBSetting = new UriData();
- private static string m_ServiceUri = "";
- private static string m_MESUri = "";
- private static string m_WMSUri = "";
- public static string g_ServiceUri
- {
- get
- {
- if (m_ServiceUri == "")
- {
- InitDBSetting();
- try
- {
- XmlSerializer serializer1 = new XmlSerializer(UriSetting.g_DBSetting.GetType());
- string strPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins\\PMS\\Config";
- string strFileName = strPath + "\\UriSetting.xml";
- DirectoryInfo dir = new DirectoryInfo(strPath);
- if (!dir.Exists)
- {
- dir.Create();
- }
- using (TextWriter tw = new StreamWriter(strFileName))
- {
- serializer1.Serialize(tw, UriSetting.g_DBSetting);
- }
- }
- catch
- { }
- }
- return m_ServiceUri;
- }
- }
- public static string g_MESUri
- {
- get
- {
- if (m_MESUri == "")
- {
- InitDBSetting();
- try
- {
- XmlSerializer serializer1 = new XmlSerializer(UriSetting.g_DBSetting.GetType());
- string strPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins\\PMS\\Config";
- string strFileName = strPath + "\\UriSetting.xml";
- DirectoryInfo dir = new DirectoryInfo(strPath);
- if (!dir.Exists)
- {
- dir.Create();
- }
- using (TextWriter tw = new StreamWriter(strFileName))
- {
- serializer1.Serialize(tw, UriSetting.g_DBSetting);
- }
- }
- catch
- { }
- }
- return m_MESUri;
- }
- }
- public static string g_WMSUri
- {
- get
- {
- if (m_WMSUri == "")
- {
- InitDBSetting();
- try
- {
- XmlSerializer serializer1 = new XmlSerializer(UriSetting.g_DBSetting.GetType());
- string strPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins\\PMS\\Config";
- string strFileName = strPath + "\\UriSetting.xml";
- DirectoryInfo dir = new DirectoryInfo(strPath);
- if (!dir.Exists)
- {
- dir.Create();
- }
- using (TextWriter tw = new StreamWriter(strFileName))
- {
- serializer1.Serialize(tw, UriSetting.g_DBSetting);
- }
- }
- catch
- { }
- }
- return m_WMSUri;
- }
- }
- private static void InitDBSetting()
- {
- //反序列化
- XmlSerializer serializer = new XmlSerializer(UriSetting.g_DBSetting.GetType());
- try
- {
- string path = AppDomain.CurrentDomain.BaseDirectory + "Plugins\\PMS\\Config\\UriSetting.xml";
- using (TextReader tr = new StreamReader(path))
- {
- UriSetting.g_DBSetting = (UriData)serializer.Deserialize(tr);
- }
- }
- catch (Exception)
- { }
- m_ServiceUri = g_DBSetting.Uri;
- m_MESUri = g_DBSetting.MESUri;
- m_WMSUri = g_DBSetting.WMSUri;
- }
- }
- }
|