예제 #1
0
        private SystemConfig3 MapConfig2ToConfig3(SystemConfig2 cfg2)
        {
            var cfg3 = new SystemConfig3();

            if (cfg2 != null)
            {
                cfg3.Id = cfg2.Id;

                cfg3.Servers = cfg2.Servers.Select(s => new ServerConfig3()
                {
                    Name                = s.Name,
                    ServiceBus          = s.MessageBus,
                    ServiceBusVersion   = "3", // V2 only NServiceBus3 was available
                    ServiceBusQueueType = s.MessageBusQueueType,
                    MonitorInterval     = s.MonitorInterval,
                    ConnectionSettings  = new Dictionary <string, object> {
                        { "server", s.Name }
                    },
                    MonitorQueues = s.MonitorQueues,

                    CommandsAssemblyPaths = cfg2.CommandsAssemblyPaths,
                    CommandDefinition     = cfg2.CommandDefinition,
                    CommandContentType    = cfg2.CommandContentType
                }).ToList();

                cfg3.ShowOnNewMessages = cfg2.ShowOnNewMessages;

                cfg3.VersionCheck = cfg2.VersionCheck;
                cfg3.StartCount   = cfg2.StartCount;

                cfg3.MonitorServerName = cfg2.MonitorServer;
            }

            return(cfg3);
        }
예제 #2
0
    public ConfigWindow(SbmqSystem system, bool showSendCommand = false) {
      InitializeComponent();

      Topmost = SbmqSystem.UIState.AlwaysOnTop;

      _sys = system;
      _config = system.Config;


      _managerTypes = ServiceBusFactory.AvailableServiceBusManagers();


      cbContentFormat.ItemsSource = _managerTypes[0].MessageContentTypes;
      cbContentFormat.SelectedItem = _config.CurrentServer.CommandContentType;

      cShowOnNewMessages.IsChecked = _config.ShowOnNewMessages;
      cCheckForNewVer.IsChecked = _config.VersionCheck.Enabled;
      cStartOnWinStartup.IsChecked = GetStartOnWinStartupState();

      BindServers(_config.Servers);

      SelectServer(_config.MonitorServerName, false);

      //tbServer.Init(string.Empty, typeof(string), false);
      //tbServer.Visibility = System.Windows.Visibility.Hidden;

      BindSendCommandView(_config.CurrentServer);

      UpdateSendCommandInfo(false);
      UpdateQueueuInfo(false);

      if( showSendCommand )
        scroller.ScrollToBottom();

    }
    public CommandHistoryManager(SystemConfig3 config) {
      _config = config;

      _itemsFolder = SbmqSystem.AppDataPath + @"\savedCommands\";
      _itemsFileV2 = SbmqSystem.AppDataPath + "savedCommands.dat";
      _itemsFile = SbmqSystem.AppDataPath + "savedCommands3.dat";

      if( !Directory.Exists(_itemsFolder) )
        Directory.CreateDirectory(_itemsFolder);

    }
예제 #4
0
        public ManageServerDialog(SbmqSystem system, ServerConfig3 server, bool copy = false)
        {
            InitializeComponent();

            Topmost = SbmqSystem.UIState.AlwaysOnTop;

            _sys    = system;
            _config = system.Config;
            _server = server;

            _managerTypes = ServiceBusFactory.AvailableServiceBusManagers();

            Result = new ConfigWindow.AddServerResult();

            Result.Server = new ServerConfig3();
            if (server != null)
            {
                server.CopyTo(Result.Server);

                if (copy)
                {
                    Result.Server.Name = string.Empty;
                    Result.Server.ConnectionSettings = new Dictionary <string, object>();
                }
            }
            DialogActionType = server == null ? ActionType.Add : (copy ? ActionType.Copy : ActionType.Edit);

            string verb = (DialogActionType == ActionType.Edit) ? "Edit" : "Add";

            lbTitle.Content = Title = "{0} Server".With(verb);
            lbInfo.Content  = string.Empty;

            cbServiceBus.ItemsSource = _managerTypes.GroupBy(g => g.DisplayName).Select(x => x.Key).ToArray();
            //cbServiceBus.DisplayMemberPath = "DisplayName";
            //cbServiceBus.SelectedValuePath = "Name";

            tbName.Init(Result.Server.Name, typeof(string), false);

            //var s = cbServiceBus.SelectedValue as string;
            //cbTransport.ItemsSource = _managerTypes.GroupBy(g => g.Name).Single(x => x.Key == s).Select(x => x.QueueType);

            //tbInterval.Init(750, typeof(int), false);

            if (DialogActionType == ActionType.Edit)
            {
                _nameEdited = GetDefaultServerName(_server.ConnectionSettings.First().Value as string, _server.ServiceBus, _server.ServiceBusVersion, _server.ServiceBusQueueType) != _server.Name;
            }

            BindServerInfo();
        }
예제 #5
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);
        }
        public ManageServerDialog(SbmqSystem system, ServerConfig3 server, bool copy = false)
        {
            InitializeComponent();

              Topmost = SbmqSystem.UIState.AlwaysOnTop;

              _sys = system;
              _config = system.Config;
              _server = server;

              _managerTypes = ServiceBusFactory.AvailableServiceBusManagers();

              Result = new ConfigWindow.AddServerResult();

              Result.Server = new ServerConfig3();
              if( server != null ) {
            server.CopyTo(Result.Server);

            if( copy ) {
              Result.Server.Name = string.Empty;
              Result.Server.ConnectionSettings = new Dictionary<string, object>();
            }
              }
              DialogActionType = server == null ? ActionType.Add : ( copy ? ActionType.Copy : ActionType.Edit );

              string verb = ( DialogActionType == ActionType.Edit ) ? "Edit" : "Add";
              lbTitle.Content = Title = "{0} Server".With(verb);
              lbInfo.Content = string.Empty;

              cbServiceBus.ItemsSource = _managerTypes.GroupBy(g => g.DisplayName).Select(x => x.Key).ToArray();
              //cbServiceBus.DisplayMemberPath = "DisplayName";
              //cbServiceBus.SelectedValuePath = "Name";

              tbName.Init(Result.Server.Name, typeof(string), false);

              //var s = cbServiceBus.SelectedValue as string;
              //cbTransport.ItemsSource = _managerTypes.GroupBy(g => g.Name).Single(x => x.Key == s).Select(x => x.QueueType);

              //tbInterval.Init(750, typeof(int), false);

              if( DialogActionType == ActionType.Edit ) {
            _nameEdited = GetDefaultServerName(_server.ConnectionSettings.First().Value as string, _server.ServiceBus, _server.ServiceBusVersion, _server.ServiceBusQueueType) != _server.Name;
              }

              BindServerInfo();
        }
예제 #7
0
    private SystemConfig3 MapConfig2ToConfig3(SystemConfig2 cfg2) {
      var cfg3 = new SystemConfig3();

      if( cfg2 != null ) {

        cfg3.Id = cfg2.Id;

        cfg3.Servers = cfg2.Servers.Select(s => new ServerConfig3() {
          Name = s.Name,
          ServiceBus = s.MessageBus, 
          ServiceBusVersion = "3", // V2 only NServiceBus3 was available
          ServiceBusQueueType = s.MessageBusQueueType,
          MonitorInterval = s.MonitorInterval,
          ConnectionSettings = new Dictionary<string, object> { { "server", s.Name } },
          MonitorQueues = s.MonitorQueues,

          CommandsAssemblyPaths = cfg2.CommandsAssemblyPaths,
          CommandDefinition = cfg2.CommandDefinition,
          CommandContentType = cfg2.CommandContentType

        }).ToList();

        cfg3.ShowOnNewMessages = cfg2.ShowOnNewMessages;

        cfg3.VersionCheck = cfg2.VersionCheck;
        cfg3.StartCount = cfg2.StartCount;

        cfg3.MonitorServerName = cfg2.MonitorServer;
      }

      return cfg3;
    }