Пример #1
0
        private void LoadSubscriptionTypes(ServerConfig3 server = null, Action onCompleted = null)
        {
            if (server == null)
            {
                server = (cbServer.SelectedItem as ServerConfig3);
            }

            var currSrv = _sys.Config.CurrentServer;

            if (server.ServiceBus == currSrv.ServiceBus && server.ServiceBusVersion != currSrv.ServiceBusVersion)
            {
                _allItems.Clear();
                _items.Clear();
                SetInfoText("Can't load subscriptions as Service Bus has a different version from the Currently Active");
                return;
            }


            var serverName = server.ConnectionSettings["server"];

            imgServerLoading.Visibility = System.Windows.Visibility.Visible;
            btnRefresh.Visibility       = System.Windows.Visibility.Hidden;
            cbServer.IsEnabled          = false;

            BackgroundWorker w = new BackgroundWorker();

            w.DoWork             += (s, e) => { e.Result = _sys.GetMessageSubscriptions(server); };
            w.RunWorkerCompleted += (s, e) => {
                MessageSubscription[] subs = e.Result as MessageSubscription[];

                _allItems.Clear();
                _items.Clear();
                foreach (var ms in subs)
                {
                    var key = ms.FullName.ToLower() + ": " + ms.Publisher.ToLower() + " => " + ms.Subscriber.ToLower();
                    if (!_allItems.ContainsKey(key))
                    {
                        _allItems.Add(key, ms);
                    }
                    else
                    {
                        SetInfoText("Found a duplicate Pub/Sub, for message " + key);
                    }

                    _items.Add(ms);
                }

                imgServerLoading.Visibility = System.Windows.Visibility.Hidden;
                btnRefresh.Visibility       = System.Windows.Visibility.Visible;
                cbServer.IsEnabled          = true;

                Filter();

                if (onCompleted != null)
                {
                    onCompleted();
                }
            };
            w.RunWorkerAsync();
        }
Пример #2
0
        private void LoadSubscriptionTypes(string serverName = null)
        {
            if (serverName == null)
            {
                serverName = cbServer.SelectedValue as string;
            }

            if (!Tools.IsLocalHost(serverName))
            {
                imgServerLoading.Visibility = System.Windows.Visibility.Visible;
                btnRefresh.Visibility       = System.Windows.Visibility.Hidden;
                cbServer.IsEnabled          = false;
            }

            BackgroundWorker w = new BackgroundWorker();

            w.DoWork             += (s, e) => { e.Result = _sys.GetMessageSubscriptions(serverName); };
            w.RunWorkerCompleted += (s, e) => {
                MessageSubscription[] subs = e.Result as MessageSubscription[];

                _allItems.Clear();
                _items.Clear();
                foreach (var ms in subs)
                {
                    _allItems.Add(ms.FullName.ToLower() + " " + ms.Publisher.ToLower() + " " + ms.Subscriber.ToLower(), ms);

                    _items.Add(ms);
                }

                if (!Tools.IsLocalHost(serverName))
                {
                    imgServerLoading.Visibility = System.Windows.Visibility.Hidden;
                    btnRefresh.Visibility       = System.Windows.Visibility.Visible;
                    cbServer.IsEnabled          = true;
                }

                Filter();
            };
            w.RunWorkerAsync();
        }