private bool FilterEquals(RecentQueueManagerConnection conn, IObjectNameFilter filter)
 {
     if (filter is StaticQueueList)
     {
         return(QueueListEquals(conn.QueueList, ((StaticQueueList)filter).Names));
     }
     return(conn.ObjectNamePrefix == filter?.NamePrefix[0]);
 }
        internal WsObjectProvider(WsQueueManager qm, IObjectNameFilter filter)
        {
            Filter       = filter ?? throw new ArgumentNullException(nameof(filter));
            QueueManager = qm ?? throw new ArgumentNullException(nameof(qm));

            if (filter is StaticQueueList)
            {
                SupportChannels  = false;
                SupportListeners = false;
            }
            else
            {
                SupportChannels  = true;
                SupportListeners = true;
            }
        }
        private void OpenRemoteQueueManager(RecentRemoteQueueManagerConnection rrqmc = null)
        {
            if (rrqmc != null)
            {
                bool automaticOpenOk = false;
                ShellService.WithGlobalBusy(() =>
                {
                    var qm = MqController.TryOpenRemoteQueueManager(rrqmc);
                    if (qm != null)
                    {
                        IObjectNameFilter filter = null;
                        if (rrqmc.QueueList != null && rrqmc.QueueList.Count > 0)
                        {
                            filter = new StaticQueueList(rrqmc.QueueList.ToArray());
                        }
                        else
                        {
                            filter = qm.NewObjectNameFilter(rrqmc.ObjectNamePrefix);
                        }
                        var provider = qm.NewObjectProvider(filter);
                        OpenQueueManagerView(qm, provider);
                        UserSettings.AddRecentConnection(rrqmc);
                        automaticOpenOk = true;
                    }
                });
                if (automaticOpenOk)
                {
                    return;
                }
            }

            SelectQueueManagerInternal(true, true, rrqmc, (qm, qpfx) =>
            {
                if (qm != null)
                {
                    AddRecentConnection(qm, qpfx, rrqmc);
                    var provider = qm.NewObjectProvider(qpfx);
                    OpenQueueManagerView(qm, provider);
                }
            });
        }
 public IObjectProvider NewObjectProvider(IObjectNameFilter filter)
 {
     return(new WsObjectProvider(this, filter));
 }
        private void AddRecentConnection(IQueueManager qm, IObjectNameFilter filter, IRecentConnection previous)
        {
            RecentConnection data = null;

            if (previous != null)
            {
                if (qm.ConnectionProperties.IsLocal)
                {
                    var temp = previous as RecentQueueManagerConnection;
                    if (temp != null)
                    {
                        if (temp.QueueManagerName == qm.Name &&
                            FilterEquals(temp, filter))
                        {
                            data = temp;
                        }
                    }
                }
                else
                {
                    var temp = previous as RecentRemoteQueueManagerConnection;
                    if (temp != null)
                    {
                        if (temp.QueueManagerName == qm.Name &&
                            FilterEquals(temp, filter) &&
                            temp.HostName == qm.ConnectionProperties.HostName &&
                            temp.Port == qm.ConnectionProperties.Port &&
                            temp.Channel == qm.ConnectionProperties.Channel &&
                            (temp.UserId ?? "") == (qm.ConnectionProperties.UserId ?? ""))
                        {
                            data = temp;
                        }
                    }
                }
            }
            if (data == null)
            {
                if (qm.ConnectionProperties.IsLocal)
                {
                    data = new RecentQueueManagerConnection
                    {
                        QueueManagerName = qm.Name
                    };
                    if (filter is StaticQueueList)
                    {
                        ((RecentQueueManagerConnection)data).QueueList = new List <string>(((StaticQueueList)filter).Names);
                    }
                    else
                    {
                        ((RecentQueueManagerConnection)data).ObjectNamePrefix = filter?.NamePrefix?[0];
                    }
                }
                else
                {
                    data = new RecentRemoteQueueManagerConnection
                    {
                        QueueManagerName = qm.Name,
                        HostName         = qm.ConnectionProperties.HostName,
                        Port             = qm.ConnectionProperties.Port,
                        Channel          = qm.ConnectionProperties.Channel,
                        UserId           = qm.ConnectionProperties.UserId
                    };
                    if (filter is StaticQueueList)
                    {
                        ((RecentRemoteQueueManagerConnection)data).QueueList = new List <string>(((StaticQueueList)filter).Names);
                    }
                    else
                    {
                        ((RecentRemoteQueueManagerConnection)data).ObjectNamePrefix = filter?.NamePrefix?[0];
                    }
                    if (!string.IsNullOrWhiteSpace(qm.ConnectionProperties.UserId))
                    {
                        ((RecentRemoteQueueManagerConnection)data).UserId = qm.ConnectionProperties.UserId;
                    }
                }
            }
            UserSettings.AddRecentConnection(data);
        }