Ejemplo n.º 1
0
 public MailboxManagerFactory(EWSConnectionManager connectionManager)
 {
     this.connectionManager = connectionManager;
 }
Ejemplo n.º 2
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");
        }