コード例 #1
0
        private static void LoadUrlsFromXML()
        {
            UrlTable = new Hashtable();
            if (ConfigFilePath == null)
            {
                ConfigFilePath = ConstConfig.GetConfigFilePath("RemoteConfig.xml");
            }
            if (!File.Exists(ConfigFilePath))
            {
                throw new PLMException("客户端配置文件" + ConfigFilePath + "没有找到!无法与应用服务器通信!");
            }
            StreamReader  input  = new StreamReader(ConfigFilePath);
            XmlTextReader reader = new XmlTextReader(input)
            {
                WhitespaceHandling = WhitespaceHandling.None
            };

            while (reader.Read())
            {
                if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "RemotingObject"))
                {
                    ProcessXml(reader, Server, Port);
                }
            }
            input.Close();
        }
コード例 #2
0
ファイル: RemoteProxy.cs プロジェクト: funtomi/MyNewCode
 private static string GetURL(string objType)
 {
     lock (typeof(Hashtable))
     {
         if (UrlTable == null)
         {
             RetriveConfigInfo();
             UrlTable = new Hashtable();
             if (ConfigFilePath == null)
             {
                 ConfigFilePath = ConstConfig.GetConfigFilePath("RemoteConfig.xml");
             }
             if (!File.Exists(ConfigFilePath))
             {
                 throw new PLMException("客户端配置文件" + ConfigFilePath + "没有找到!无法与应用服务器通信!");
             }
             StreamReader  input  = new StreamReader(ConfigFilePath);
             XmlTextReader reader = new XmlTextReader(input)
             {
                 WhitespaceHandling = WhitespaceHandling.None
             };
             while (reader.Read())
             {
                 if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "RemotingObject"))
                 {
                     ProcessXml(reader);
                 }
             }
             input.Close();
             string path = Path.Combine(Path.GetDirectoryName(ConstConfig.GetConfigFilePath("RemoteConfig.xml")), "RemoteConfig.config");
             try
             {
                 if (isfirst && File.Exists(path))
                 {
                     RemotingConfiguration.Configure(path, false);
                     isfirst = false;
                 }
             }
             catch (Exception exception)
             {
                 EventLog.WriteEntry("TiPLM", exception.Message);
             }
         }
         if (UrlTable[objType] != null)
         {
             return(UrlTable[objType].ToString());
         }
         return(null);
     }
 }