using System; using System.Data; using System.IO; using System.Reflection; using System.Collections.Generic; namespace WCS { /// /// Rf信息配置类 /// public class RfConfig { private const string CONFIG_XML_FILE = "config.xml"; private const string SYSTEM_SET_NODE = "SystemSet"; private static RfConfig _RfConfig; private static string _ServerAddress; private static string _ServiceName; protected RfConfig() { GetConfigInfo(); GetWmsInfo(); } public static RfConfig Create() { if (_RfConfig == null) { _RfConfig = new RfConfig(); } return _RfConfig; } private static string _ScanIp1; private static string _ScanProt1; public string ScanIp1 { get { return _ScanIp1; } } public string ScanProt1 { get { return _ScanProt1; } } private static string _ScanIp2 = "0"; public string ScanIp2 { get { return _ScanIp2; } } private static string _ScanProt2 = "0"; public string ScanProt2 { get { return _ScanProt2; } } /// /// 读配置信息 /// private void GetConfigInfo() { DataSet ds = new DataSet(); string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName); ds.ReadXml(appPath + "\\" + CONFIG_XML_FILE); _ScanIp1 = ds.Tables[SYSTEM_SET_NODE].Rows[0]["scanip1"].ToString(); _ScanProt1 = ds.Tables[SYSTEM_SET_NODE].Rows[0]["prot1"].ToString(); _ScanIp2 = ds.Tables[SYSTEM_SET_NODE].Rows[0]["scanip2"].ToString(); _ScanProt2 = ds.Tables[SYSTEM_SET_NODE].Rows[0]["prot2"].ToString(); } public DataSet plcds = new DataSet(); /// /// 读配置信息 /// private void GetWmsInfo() { string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName); plcds.ReadXml(appPath + "\\" + "PLCData.xml"); } } }