示例#1
0
        private void InitProvider()
        {
            Guid _providerId            = MailingUtilities.GetActiveProviderId(UserConnection);
            SysMailingProvider provider = GetProvider(_providerId);

            if (provider == null)
            {
                string msg = string.Format("Could not load provider data from DB. Provider UId: {0}", _providerId);
                throw new Exception(msg);
            }
            Type providerType = Type.GetType(provider.ClassName);

            if (providerType != null)
            {
                IMailingProviderConfigFactory configFactory = CreateConfigFactory(provider.ConfigFactoryClassName);
                _mailingProvider = CreateProviderInstance(providerType, configFactory);
                var configurableProvider = _mailingProvider as IConfigurableMailingProvider;
                if (configurableProvider != null)
                {
                    configurableProvider.Configure();
                }
            }
            else
            {
                string msg = string.Format("Could not initiate provider instance. Provider UId: {0}", _providerId);
                throw new Exception(msg);
            }
        }
示例#2
0
        /// <summary>
        /// Enables handlers of the active mailing provider.
        /// </summary>
        /// <param name="userConnection">Instance of user connection.</param>
        public static void EnableActiveProviderHandlers(UserConnection userConnection)
        {
            Guid                          providerId            = MailingUtilities.GetActiveProviderId(userConnection);
            EntityCollection              mailingHandlers       = GetMailingHandlers(userConnection);
            IEnumerable <string>          activeHandlersNames   = GetProviderHandlers(providerId, mailingHandlers);
            IEnumerable <string>          inactiveHandlersNames = GetDisabledHandlers(mailingHandlers, activeHandlersNames);
            IEnumerable <IMailingHandler> activeHandlers        = InstantiateHandlers(activeHandlersNames);
            IEnumerable <IMailingHandler> inactiveHandlers      = InstantiateHandlers(inactiveHandlersNames);

            DeactivateHandlers(inactiveHandlers);
            ActivateHandlers(activeHandlers, userConnection);
        }
示例#3
0
 protected bool IsMandrillProviderActive()
 {
     return(MandrillProviderId == MailingUtilities.GetActiveProviderId(_userConnection));
 }