Example #1
0
        /// <summary>
        /// Refreshes the configuration of the ServiceConnection.
        /// </summary>
        public override void RefreshConfiguration()
        {
            base.RefreshConfiguration();
            DataAccessSection section           = DataAccessSection.GetSection();
            ConnectionElement connectionElement = section.ConnectionList[this.Name];

            if (connectionElement == null)
            {
                throw new Exception("Could not find connection element '" + this.Name + "' in the configuration file.");
            }
            else
            {
                _affiliateApplication = connectionElement.Affiliate;
                _userId                      = connectionElement.UserId;
                _password                    = connectionElement.Password;
                _connectionTemplate          = connectionElement.ConnectionTemplate;
                _retryConnectionCount        = connectionElement.RetryConnectionCount;
                _retryIntervalInMilliseconds = connectionElement.RetryIntervalInMilliseconds;
                ClassSpecificationElement connectionProvider = connectionElement.DbConnectionProvider;
                _connectionProviderName     = connectionProvider.Name;
                _connectionProviderAssembly = connectionProvider.Assembly;
                _connectionProviderClass    = connectionProvider.Class;
                GetConnectionString();
            }
        }
Example #2
0
        /// <summary>
        /// Creates an ITicketProvider implementation. The instance is a singleton.
        /// </summary>
        /// <returns>A reference to the ITicketProvider implementation.</returns>
        public static ITicketProvider GetTicketProvider()
        {
            string          instanceName   = "";
            string          className      = "";
            string          assemblyName   = "";
            ITicketProvider ticketProvider = null;

            try
            {
                lock (ticketProviderLock)
                {
                    if (ticketProviderInstance == null)
                    {
                        SecuritySection           section = SecuritySection.GetSection();
                        ClassSpecificationElement spec    = section.TicketProvider;
                        instanceName           = spec.Name;
                        className              = spec.Class;
                        assemblyName           = spec.Assembly;
                        ticketProviderInstance = (ITicketProvider)Factory.CreateComponent(instanceName, className, assemblyName);
                    }
                    ticketProvider = ticketProviderInstance;
                }
            }
            catch (Exception exception)
            {
                throw new Exception("Failed to create ITicketProvider implementation.", exception);
            }
            return(ticketProvider);
        }
Example #3
0
        /// <summary>
        /// Creates an ILogger implementation. The instance is a singleton.
        /// </summary>
        /// <returns>A reference to the ILogger implementation.</returns>
        public static ILogger GetLogger()
        {
            string  instanceName = "";
            string  className    = "";
            string  assemblyName = "";
            ILogger logger       = null;

            try
            {
                lock (_lock)
                {
                    if (_instance == null)
                    {
                        // Try to load the logging congiguration section.
                        LoggingSection section = null;
                        try
                        {
                            section = LoggingSection.GetSection();
                        }
                        catch (Exception exception)
                        {
                            _instance = new NullLogger("NullLogger");
                            logger.WriteWarning("Logging is not configured. No logging will be performed.", 152);
                        }
                        // If the logging configuration section was loaded, try to load the logging provider.
                        if (section != null)
                        {
                            try
                            {
                                ClassSpecificationElement spec = section.LoggingProvider;
                                instanceName = spec.Name;
                                className    = spec.Class;
                                assemblyName = spec.Assembly;
                                _instance    = (ILogger)Factory.CreateComponent(instanceName, className, assemblyName);
                                _instance.RefreshConfiguration();
                            }
                            catch (Exception exception)
                            {
                                _instance = new NullLogger("NullLogger");
                                logger.WriteError("Failed to create ILogger implementation. No logging will be performed.", 152);
                            }
                        }
                    }
                    logger = _instance;
                }
            }
            catch (Exception exception)
            {
                logger.WriteError("Failed to create ILogger implementation.: " + exception.ToString(), 152);
                throw exception;
            }
            return(logger);
        }
Example #4
0
        /// <summary>
        /// Creates ICredentials for an affiliate application.
        /// </summary>
        /// <param name="affiliateName">The name of the affiliate application for the credentials.</param>
        /// <returns>A reference to the ICredentials implementation.</returns>
        public static ICredentials GetCredentials(string affiliateName)
        {
            string       instanceName = "";
            string       className    = "";
            string       assemblyName = "";
            ICredentials credentials  = null;

            try
            {
                lock (credentialsLock)
                {
                    // Construct ist if needed.
                    if (credentialsList == null)
                    {
                        credentialsList = new Dictionary <string, ICredentials>();
                    }
                    // Check list for the requested affiliate.
                    if (credentialsList.ContainsKey(affiliateName))
                    {
                        credentials = credentialsList[affiliateName];
                    }
                    else
                    {
                        SecuritySection           section = SecuritySection.GetSection();
                        ClassSpecificationElement spec    = section.CredentialsProvider;
                        instanceName = affiliateName;
                        className    = spec.Class;
                        assemblyName = spec.Assembly;
                        credentials  = (ICredentials)Factory.CreateComponent(instanceName, className, assemblyName);
                        credentialsList[affiliateName] = credentials;
                    }
                }
            }
            catch (Exception exception)
            {
                throw new Exception("Failed to create ICredentials implementation.", exception);
            }
            return(credentials);
        }