Ejemplo n.º 1
0
        public static ServiceStatusSettings GetConfig()
        {
            ServiceStatusSettings result = (ServiceStatusSettings)ConfigurationBroker.GetSection(ServiceStatusConfigName);

            if (result == null)
            {
                result = new ServiceStatusSettings();
            }

            return(result);
        }
Ejemplo n.º 2
0
        private bool InitStatusService()
        {
            this.statusService = null;

            try
            {
                //string uri = ServiceStatusSettings.GetConfig().Servers["defaultService"].Description;

                string uri;

                if (ServiceStatusSettings.GetConfig().Servers["defaultService"] == null)
                {
                    if (missingLogged == false)
                    {
                        string failMessage = "未能找到名为 defaultService 的状态服务配置,因此可能无法查看状态服务";
                        EventLog.WriteEntry(ServiceMainSettings.SERVICE_NAME, failMessage, EventLogEntryType.Warning);
                        if (this.InvokeRequired)
                        {
                            this.Invoke(new Action <string>(this.ShowMessageBox), failMessage);
                        }
                        else
                        {
                            this.ShowMessageBox(failMessage);
                        }

                        missingLogged = true;
                    }
                }
                else
                {
                    uri = ServiceStatusSettings.GetConfig().Servers["defaultService"].Description;

                    try
                    {
                        //尝试获取当前应用注册的服务地址
                        uri = GetServiceStatusUri();
                    }
                    catch (Exception ex)
                    {
                        EventLog.WriteEntry(ServiceMainSettings.SERVICE_NAME, ex.Message, EventLogEntryType.Warning);
                    }

                    this.statusService = (IStatusService)Activator.GetObject(typeof(IStatusService), uri);
                }
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry(ServiceMainSettings.SERVICE_NAME, ex.Message, EventLogEntryType.Warning);
            }

            return(this.statusService != null);
        }