Exemplo n.º 1
0
        public static RabbitMQConfig_Root GetRabbitMQConfig()
        {
            RabbitMQConfig_Root config = null;
            FileStream          stream = null;

            try
            {
                string strXmlFile = Path.Combine(Application.StartupPath, "RabbitMQConfig.xml");
                if (File.Exists(strXmlFile) == false)
                {
                    strXmlFile = Path.Combine(ConfigurationManager.AppSettings["RootPath"], "RabbitMQConfig.xml");
                }

                _logService.Write("RabbitMQConfig.xml", strXmlFile, TraceEventType.Verbose);

                XmlSerializer _xmlSerializer = new XmlSerializer(typeof(RabbitMQConfig_Root));
                stream = new FileStream(strXmlFile, FileMode.Open);
                config = _xmlSerializer.Deserialize(stream) as RabbitMQConfig_Root;
            }
            catch (Exception ex)
            {
                _logService.Write("RabbitMQConfig.xml 加载失败", ex.Message, TraceEventType.Error);
                Debug.Assert(false, ex.Message);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                    stream.Dispose();
                }
            }

            return(config);
        }
Exemplo n.º 2
0
 private RabbitMQService()
 {
     try
     {
         _rabbitMQConfig = RabbitMQConfig.GetRabbitMQConfig();
     }
     catch (Exception ex)
     {
         Debug.Assert(false, ex.Message);
         _logService.Write("加载 RabbitMQ 配置失败", ex.Message, TraceEventType.Error);
     }
 }