Пример #1
0
        private SystemConfig1 LoadConfig0As1()
        {
            var appSett = ConfigurationManager.AppSettings;

            SystemConfig1 c = new SystemConfig1();

            c.MonitorServer = !string.IsNullOrEmpty(appSett["server"]) ? appSett["server"] : Environment.MachineName;

            c.Servers = new List <ServerConfig>();
            c.Servers.Add(new ServerConfig()
            {
                Name = c.MonitorServer
            });

            c.CurrentServer.MessageBus          = appSett["messageBus"] ?? "NServiceBus";
            c.CurrentServer.MessageBusQueueType = appSett["messageBusQueueType"] ?? "MSMQ";

            c.CurrentServer.WatchEventQueues   = ParseStringList("event.queues");
            c.CurrentServer.WatchCommandQueues = ParseStringList("command.queues");
            c.CurrentServer.WatchMessageQueues = ParseStringList("message.queues");
            c.CurrentServer.WatchErrorQueues   = ParseStringList("error.queues");

            c.CurrentServer.MonitorInterval = Convert.ToInt32(appSett["interval"] ?? "750");

            c.ShowOnNewMessages = Convert.ToBoolean(appSett["showOnNewMessages"] ?? "true");

            c.CommandsAssemblyPaths = ParseStringList("commandsAssemblyPath");

            return(c);
        }
Пример #2
0
        private SystemConfig2 MapConfig1ToConfig2(SystemConfig1 cfg1)
        {
            var cfg2 = new SystemConfig2();

            if (cfg1 != null)
            {
                cfg2.Servers = cfg1.Servers.Select(s => new ServerConfig2()
                {
                    MessageBus          = s.MessageBus,
                    MessageBusQueueType = s.MessageBusQueueType,
                    MonitorInterval     = s.MonitorInterval,
                    Name          = s.Name,
                    MonitorQueues = ConvertMultipleQueueConfigToOne(s.WatchCommandQueues, s.WatchEventQueues, s.WatchMessageQueues, s.WatchErrorQueues)
                }).ToList();

                cfg2.ShowOnNewMessages     = cfg1.ShowOnNewMessages;
                cfg2.CommandsAssemblyPaths = cfg1.CommandsAssemblyPaths;
                cfg2.CommandDefinition     = cfg1.CommandDefinition;

                cfg2.VersionCheck = cfg1.VersionCheck;
                cfg2.StartCount   = cfg1.StartCount;

                cfg2.MonitorServer = cfg1.MonitorServer;
            }

            return(cfg2);
        }
Пример #3
0
        public SystemConfig3 Create()
        {
            SystemConfig3 cfg = null;

            if (File.Exists(_configFileV3))
            {
                try {
                    cfg = JsonFile.Read <SystemConfig3>(_configFileV3);
                } catch { }
            }
            else if (File.Exists(_configFileV2))
            {
                SystemConfig2 cfg2 = null;
                try {
                    cfg2 = JsonFile.Read <SystemConfig2>(_configFileV2);
                } catch { }

                cfg = MapConfig2ToConfig3(cfg2);
            }
            else if (File.Exists(_configFileV1))
            {
                bool          loaded = false;
                SystemConfig1 cfg1   = null;
                try {
                    cfg1   = JsonFile.Read <SystemConfig1>(_configFileV1);
                    loaded = cfg1.Servers != null;
                } catch { }

                if (!loaded) // Old ConfigFile + Defaults fallback
                {
                    cfg1 = LoadConfig0As1();
                }

                var cfg2 = MapConfig1ToConfig2(cfg1);
                cfg = MapConfig2ToConfig3(cfg2);

                Store(cfg);
            }
            else
            {
                var cfg2 = MapConfig1ToConfig2(LoadConfig0As1());
                cfg = MapConfig2ToConfig3(cfg2);
            }

            return(cfg);
        }
Пример #4
0
    private SystemConfig2 MapConfig1ToConfig2(SystemConfig1 cfg1) {
      var cfg2 = new SystemConfig2();

      if( cfg1 != null ) {

        cfg2.Servers = cfg1.Servers.Select(s => new ServerConfig2() {
          MessageBus = s.MessageBus,
          MessageBusQueueType = s.MessageBusQueueType,
          MonitorInterval = s.MonitorInterval,
          Name = s.Name,
          MonitorQueues = ConvertMultipleQueueConfigToOne(s.WatchCommandQueues, s.WatchEventQueues, s.WatchMessageQueues, s.WatchErrorQueues)
        }).ToList();

        cfg2.ShowOnNewMessages = cfg1.ShowOnNewMessages;
        cfg2.CommandsAssemblyPaths = cfg1.CommandsAssemblyPaths;
        cfg2.CommandDefinition = cfg1.CommandDefinition;

        cfg2.VersionCheck = cfg1.VersionCheck;
        cfg2.StartCount = cfg1.StartCount;

        cfg2.MonitorServer = cfg1.MonitorServer;
      }

      return cfg2;
    }
Пример #5
0
    private SystemConfig1 LoadConfig0As1() {
      var appSett = ConfigurationManager.AppSettings;

      SystemConfig1 c = new SystemConfig1();
      c.MonitorServer = !string.IsNullOrEmpty(appSett["server"]) ? appSett["server"] : Environment.MachineName;

      c.Servers = new List<ServerConfig>();
      c.Servers.Add(new ServerConfig() { Name = c.MonitorServer });

      c.CurrentServer.MessageBus = appSett["messageBus"] ?? "NServiceBus";
      c.CurrentServer.MessageBusQueueType = appSett["messageBusQueueType"] ?? "MSMQ";

      c.CurrentServer.WatchEventQueues = ParseStringList("event.queues");
      c.CurrentServer.WatchCommandQueues = ParseStringList("command.queues");
      c.CurrentServer.WatchMessageQueues = ParseStringList("message.queues");
      c.CurrentServer.WatchErrorQueues = ParseStringList("error.queues");

      c.CurrentServer.MonitorInterval = Convert.ToInt32(appSett["interval"] ?? "750");

      c.ShowOnNewMessages = Convert.ToBoolean(appSett["showOnNewMessages"] ?? "true");

      c.CommandsAssemblyPaths = ParseStringList("commandsAssemblyPath");

      return c;
    }