Example #1
0
        public void RefreshEventListenersList()
        {
            if (_environmentListeners == null)
            {
                _environmentListeners = new Dictionary <ServiceEnvironmentEventType, List <ServiceEnvironmentEventListenerInfo> >();
            }
            else
            {
                foreach (var list in _environmentListeners.Values)
                {
                    list.Clear();
                }
            }

            var env = EnvironmentConfiguration;

            using (var connection = new SqlConnection(env.ConnectionString))
            {
                var command = new SqlCommand(env.SP_EnvironmentEventListenerListGet, connection);
                command.CommandType = CommandType.StoredProcedure;
                connection.Open();
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var info = new ServiceEnvironmentEventListenerInfo
                        {
                            ListenerID = SqlUtility.ClrValue <string, Guid>(
                                reader["ListenerID"],
                                guidRaw => Guid.Parse(guidRaw),
                                Guid.Empty
                                ),
                            EventType = SqlUtility.ClrValue <string, ServiceEnvironmentEventType>(
                                reader["EventType"],
                                ev => (ServiceEnvironmentEventType)Enum.Parse(typeof(ServiceEnvironmentEventType), ev, false),
                                (ServiceEnvironmentEventType)0
                                ),
                            EndpointName    = SqlUtility.ClrValue <string>(reader["EndpointName"]),
                            EndpointAddress = SqlUtility.ClrValue <string>(reader["EndpointAddress"])
                        };
                        List <ServiceEnvironmentEventListenerInfo> list;
                        if (!_environmentListeners.TryGetValue(info.EventType, out list))
                        {
                            _environmentListeners.Add(info.EventType, list = new List <ServiceEnvironmentEventListenerInfo>());
                        }

                        list.Add(info);
                    }
                }
            }
        }
        public void RefreshEventListenersList()
        {
            if (_environmentListeners == null)
            {
                _environmentListeners = new Dictionary <ServiceEnvironmentEventType, ServiceEnvironmentEventListenerInfo>();
            }
            else
            {
                _environmentListeners.Clear();
            }

            var env = this.EnvironmentConfiguration;

            using (var connection = new SqlConnection(env.ConnectionString))
            {
                var command = new SqlCommand(env.SP_EnvironmentEventList, connection);
                command.CommandType = CommandType.StoredProcedure;
                connection.Open();
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var info = new ServiceEnvironmentEventListenerInfo()
                        {
                            EventType = SqlUtility.ClrValue <string, ServiceEnvironmentEventType>(
                                reader["EventType"],
                                ev => (ServiceEnvironmentEventType)Enum.Parse(typeof(ServiceEnvironmentEventType), ev, false),
                                (ServiceEnvironmentEventType)0
                                ),
                            EndpointName    = SqlUtility.ClrValue <string>(reader["EndpointName"]),
                            EndpointAddress = SqlUtility.ClrValue <string>(reader["EndpointAddress"])
                        };
                        _environmentListeners.Add(info.EventType, info);
                    }
                }
            }
        }