public List <IEtlSessionListener> GetSessionListeners(IEtlSession session)
        {
            var result = new List <IEtlSessionListener>();

            var listenersSection = _configuration.GetSection(_section + ":SessionListeners");

            if (listenersSection == null)
            {
                return(result);
            }

            var children = listenersSection.GetChildren();

            foreach (var childSection in children)
            {
                if (!ConfigurationReader.GetCurrentValue(childSection, "Enabled", false))
                {
                    continue;
                }

                var type = Type.GetType(childSection.Key);
                if (type != null && typeof(IEtlSessionListener).IsAssignableFrom(type))
                {
                    try
                    {
                        var instance = (IEtlSessionListener)Activator.CreateInstance(type);
                        var ok       = instance.Init(session, childSection, SecretProtector);
                        if (ok)
                        {
                            result.Add(instance);
                        }
                    }
                    catch (Exception ex)
                    {
                        var exception = new Exception("Can't initialize session listener.", ex);
                        exception.Data.Add("FullyQualifiedTypeName", childSection.Key);
                        throw exception;
                    }
                }
                else
                {
                    var exception = new Exception("Session listener type not found.");
                    exception.Data.Add("FullyQualifiedTypeName", childSection.Key);
                    throw exception;
                }
            }

            return(result);
        }
Esempio n. 2
0
 public void Start(IEtlSession session)
 {
     Session = session;
     OnStart();
 }