Пример #1
0
		public Mail2BugEngine(Config.InstanceConfig configInstance, MailboxManagerFactory mailboxManagerFactory)
		{
		    _config = configInstance;

		    Logger.InfoFormat("Initalizing MailboxManager");
            _mailboxManager = mailboxManagerFactory.CreateMailboxManager(_config.EmailSettings);

		    Logger.InfoFormat("Initializing WorkItemManager");
            _messageProcessingStrategy = new Lazy<IMessageProcessingStrategy>(InitProcessingStrategy);
		}
Пример #2
0
 public TemporaryInstanceRunner(Config.InstanceConfig instanceConfig, MailboxManagerFactory mailboxManagerFactory)
 {
     _instanceConfig = instanceConfig;
     _mailboxManagerFactory = mailboxManagerFactory;
     Name = instanceConfig.Name;
 }
Пример #3
0
 public PersistentInstanceRunner(Config.InstanceConfig instanceConfig, MailboxManagerFactory mailboxManagerFactory)
 {
     Name = instanceConfig.Name;
     _engine = new Mail2BugEngine(instanceConfig, mailboxManagerFactory);
 }
Пример #4
0
        private static void InitInstances(IEnumerable<Config> configs)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            _instances = new List<IInstanceRunner>();
            _ewsConnectionManger = new EWSConnectionManager(true);
            var mailboxManagerFactory = new MailboxManagerFactory(_ewsConnectionManger);

            foreach (var config in configs)
            {
                foreach (var instance in config.Instances)
                {
                    if (!File.Exists(instance.EmailSettings.EWSPasswordFile))
                    {
                        Logger.Error($"Failed to find password file for instance '{instance.Name}' at path: '{instance.EmailSettings.EWSPasswordFile}'");
                        continue;
                    }

                    try
                    {
                        var usePersistentInstances = ReadBoolFromAppConfig("UsePersistentInstances", true);
                        Logger.Info($"Initializing engine for instance '{instance.Name}' (Persistent? {usePersistentInstances})");

                        if (usePersistentInstances)
                        {
                            _instances.Add(new PersistentInstanceRunner(instance, mailboxManagerFactory));
                        }
                        else
                        {
                            _instances.Add(new TemporaryInstanceRunner(instance, mailboxManagerFactory));
                        }

                        Logger.Info($"Finished initialization of engine for instance '{instance.Name}'");
                    }
                    catch (Exception ex)
                    {
                        Logger.Error($"Exception while initializing instance '{instance.Name}'\n{ex}");
                    }
                }
            }

            stopwatch.Stop();
            ILogger logger = Microsoft.Applications.Telemetry.Server.LogManager.GetLogger();
            logger.LogSampledMetric("AllInstanceInitializeTime", stopwatch.ElapsedMilliseconds, "milliseconds");
        }
Пример #5
0
        private static void InitInstances(IEnumerable<Config> configs)
        {
            _instances = new List<IInstanceRunner>();
            _ewsConnectionManger = new EWSConnectionManger(true);
            var mailboxManagerFactory = new MailboxManagerFactory(_ewsConnectionManger);

            foreach (var config in configs)
            {
                foreach (var instance in config.Instances)
                {
                    try
                    {
                        var usePersistentInstances = ReadBoolFromAppConfig("UsePersistentInstances", true);
                        Logger.InfoFormat("Initializing engine for instance '{0}' (Persistent? {1})", instance.Name, usePersistentInstances);
                        
                        if (usePersistentInstances)
                        {
                            _instances.Add(new PersistentInstanceRunner(instance, mailboxManagerFactory));
                        }
                        else
                        {
                            _instances.Add(new TemporaryInstanceRunner(instance, mailboxManagerFactory));
                        }

                        Logger.InfoFormat("Finished initialization of engine for instance '{0}'", instance.Name);
                    }
                    catch (Exception ex)
                    {
                        Logger.ErrorFormat("Exception while initializing instance '{0}'\n{1}", instance.Name, ex);
                    }
                }
            }
        }