public SendCommandWindow(SbmqSystem system) { InitializeComponent(); _sys = system; _asmPath = system.Config.CurrentServer.CommandsAssemblyPaths; Topmost = SbmqSystem.UIState.AlwaysOnTop; BindCommands(); savedCommands.Init(system.SavedCommands); BindServer(); cmdAttrib.SendCommandManager = _sys.Manager as ISendCommand; // TEMP: Service Bus Specific Logic, TODO: Refactor var srv = _sys.Config.CurrentServer; if (srv.ServiceBus == "MassTransit") { if (srv.ConnectionSettings.HasValidValue("subscriptionQueueService")) { lblServer.Visibility = Visibility.Hidden; lblRouterQueue.Content = "Subscription service: {0}".With(srv.ConnectionSettings["subscriptionQueueService"]); lblRouterQueue.Visibility = Visibility.Visible; } } }
private void InitSystem() { this.Icon = BitmapFrame.Create(this.GetImageResourceStream("main.ico")); _uiState = SbmqSystem.UIState; RestoreWindowState(); this.IsEnabled = false; lbLoading.Visibility = System.Windows.Visibility.Visible; BackgroundWorker w = new BackgroundWorker(); w.DoWork += (s, e) => { try { _sys = SbmqSystem.Create(); _sys.ItemsChanged += sys_ItemsChanged; _sys.ErrorOccured += _sys_ErrorOccured; _sys.WarningOccured += _sys_WarningOccured; _mgr = _sys.Manager; } catch (Exception ex) { Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { LogError("Failed to initialize System", ex, true); })); } }; w.RunWorkerCompleted += (s, e) => { RestoreQueueButtonsState(); this.IsEnabled = true; lbLoading.Visibility = System.Windows.Visibility.Hidden; btnSendCommand.IsEnabled = _sys.CanSendCommand; btnViewSubscriptions.IsEnabled = _sys.CanViewSubscriptions; lbItems.ItemsSource = _sys.Items; SetupContextMenu(); UpdateNotifyIconText(); if (_sys.Config.StartCount == 1) { ShowConfigDialog(); } else if (_sys.Config.VersionCheck.Enabled) { if (_sys.Config.VersionCheck.LastCheck < DateTime.Now.AddDays(-14)) { CheckIfLatestVersion(false); } } UpdateTitle(); _sys.StartMonitoring(); }; w.RunWorkerAsync(); }
public ViewSubscriptionsWindow(SbmqSystem system) { InitializeComponent(); _sys = system; lbInfo.Opacity = 0; lbInfo.Visibility = System.Windows.Visibility.Hidden; Topmost = SbmqSystem.UIState.AlwaysOnTop; }
public ConfigWindow(SbmqSystem system, bool showSendCommand = false) { InitializeComponent(); Topmost = SbmqSystem.UIState.AlwaysOnTop; _sys = system; _config = system.Config; _managerTypes = ServiceBusFactory.AvailableServiceBusManagers(); cbServiceBus.ItemsSource = _managerTypes; cbServiceBus.DisplayMemberPath = "Name"; cbServiceBus.SelectedValuePath = "Name"; cbServiceBus.SelectedIndex = 0; cbTransport.ItemsSource = _managerTypes[0].QueueTypes; cbContentFormat.ItemsSource = _managerTypes[0].MessageContentTypes; cbContentFormat.SelectedItem = _config.CommandContentType; cShowOnNewMessages.IsChecked = _config.ShowOnNewMessages; cCheckForNewVer.IsChecked = _config.VersionCheck.Enabled; asmPaths.BindItems(_config.CommandsAssemblyPaths); BindServers(_config.Servers); tbInterval.Init(750, typeof(int), false); SelectServer(_config.MonitorServer); tbServer.Init(string.Empty, typeof(string), false); tbServer.Visibility = System.Windows.Visibility.Hidden; tbNamespace.Init(_config.CommandDefinition.NamespaceContains, typeof(string), true); tbCmdInherits.Text = _config.CommandDefinition.InheritsType; UpdateSendCommandInfo(false); UpdateQueueuInfo(false); if (showSendCommand) { scroller.ScrollToBottom(); } }
public ViewSubscriptionsWindow(SbmqSystem system) { InitializeComponent(); _sys = system; Topmost = SbmqSystem.UIState.AlwaysOnTop; BindServers(); lvTypes.ItemsSource = _items; WindowTools.SetSortColumn(lvTypes, "Name"); }
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(); }
public SelectDataTypeDialog(SbmqSystem system, string[] asmPaths) { InitializeComponent(); _asmPaths = asmPaths; Topmost = SbmqSystem.UIState.AlwaysOnTop; LoadTypes(); lvTypes.ItemsSource = _types; WindowTools.SetSortColumn(lvTypes, "Name", ListSortDirection.Ascending); tbFilter.Focus(); }
public SendCommandWindow(SbmqSystem system) { InitializeComponent(); _sys = system; _asmPath = system.Config.CommandsAssemblyPaths; Topmost = SbmqSystem.UIState.AlwaysOnTop; BindCommands(); savedCommands.Init(system.SavedCommands); BindServers(); cmdAttrib.SendCommandManager = _sys.Manager as ISendCommand; }
private void RestartSystem() { _timer.Stop(); if (_sys != null) { _sys.Manager.Terminate(); } this.IsEnabled = false; lbItems.ItemsSource = null; BackgroundWorker w = new BackgroundWorker(); w.DoWork += (s, e) => { _sys = SbmqSystem.Create(); _sys.ItemsChanged += MessageMgr_ItemsChanged; _mgr = _sys.Manager; }; w.RunWorkerCompleted += (s, e) => { this.IsEnabled = true; RestoreMonitorQueueState(); btnSendCommand.IsEnabled = _sys.CanSendCommand; btnViewSubscriptions.IsEnabled = _sys.CanViewSubscriptions; lbItems.ItemsSource = _sys.Items; SetupContextMenu(); timer_Tick(this, EventArgs.Empty); _timer.Interval = TimeSpan.FromMilliseconds(_sys.Config.MonitorInterval); _timer.Start(); }; w.RunWorkerAsync(); }
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(); } }
private void RestartSystem() { StopMonitoring(); if (_sys != null) { _sys.Manager.Terminate(); } this.IsEnabled = false; lbItems.ItemsSource = null; BackgroundWorker w = new BackgroundWorker(); w.DoWork += (s, e) => { _sys = SbmqSystem.Create(); _sys.ItemsChanged += MessageMgr_ItemsChanged; _mgr = _sys.Manager; }; w.RunWorkerCompleted += (s, e) => { this.IsEnabled = true; RestoreMonitorQueueState(); btnSendCommand.IsEnabled = _sys.CanSendCommand; btnViewSubscriptions.IsEnabled = _sys.CanViewSubscriptions; lbItems.ItemsSource = _sys.Items; SetupContextMenu(); RestartMonitoring(); }; w.RunWorkerAsync(); }
protected override void OnStartup(StartupEventArgs e) { List <Arg> args = ProcessArgs(e.Args); StartMinimized = args.Any(a => a.Type == ArgType.Minimized); _silent = args.Any(a => a.Type == ArgType.Silent); var arg = args.FirstOrDefault(a => a.Type == ArgType.Send); if (arg != null) { AttachConsole(-1); PrintHeader(); string[] cmds = arg.Param.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); var sys = SbmqSystem.Create(); try { foreach (var cmd in cmds) { var itm = sys.SavedCommands.Items.FirstOrDefault(c => c.DisplayName == cmd); if (itm != null) { Out(string.Format("Sending Command '{0}'...", cmd)); sys.SendCommand(itm.SentCommand.ConnectionStrings, itm.SentCommand.Queue, itm.SentCommand.Command); } else { Out(string.Format("No Command with name '{0}' found, exiting...", cmd)); } } } finally { sys.Manager.Terminate(); } Application.Current.Shutdown(0); return; } if (args.Where(a => (int)a.Type < 20).Count() > 0) { AttachConsole(-1); PrintHeader(); PrintHelp(); Application.Current.Shutdown(0); return; } if (!args.Any(a => a.Type == ArgType.Force)) { // Check if we are already running... Process currProc = Process.GetCurrentProcess(); Process existProc = Process.GetProcessesByName(currProc.ProcessName).Where(p => p.Id != currProc.Id).FirstOrDefault(); if (existProc != null) { try { // Show the already started SBMQM WindowTools.EnumWindows(new WindowTools.EnumWindowsProc((hwnd, lparam) => { uint procId; WindowTools.GetWindowThreadProcessId(hwnd, out procId); if (procId == existProc.Id) { if (WindowTools.SendMessage(hwnd, ServiceBusMQManager.MainWindow.WM_SHOWWINDOW, 0, 0) == 1) { return(false); } } return(true); }), 0); } finally { Application.Current.Shutdown(); } return; } } base.OnStartup(e); }