internal RecentRemoteConnectionConfigElement(RecentRemoteQueueManagerConnection rc) : this()
 {
     QueueManagerName = rc.QueueManagerName;
     FilterPrefix     = rc.ObjectNamePrefix;
     if (rc.QueueList != null && rc.QueueList.Count > 0)
     {
         QueueList = new CommaDelimitedStringCollection();
         QueueList.AddRange(rc.QueueList.ToArray());
     }
     Host    = rc.HostName;
     Port    = rc.Port;
     Channel = rc.Channel;
     UserId  = rc.UserId;
 }
        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 override RecentConnection ConvertToModel()
        {
            var item = new RecentRemoteQueueManagerConnection
            {
                QueueManagerName = this.QueueManagerName,
                ObjectNamePrefix = this.FilterPrefix,
                HostName         = this.Host,
                Channel          = this.Channel,
                Port             = this.Port,
                UserId           = this.UserId
            };

            if (this.QueueList != null && this.QueueList.Count > 0)
            {
                item.QueueList = new List <string>();
                foreach (string x in this.QueueList)
                {
                    item.QueueList.Add(x);
                }
            }
            return(item);
        }
Beispiel #4
0
 public IQueueManager TryOpenRemoteQueueManager(RecentRemoteQueueManagerConnection rc)
 {
     if (rc == null)
     {
         return(null);
     }
     try
     {
         if (!string.IsNullOrWhiteSpace(rc.UserId))
         {
             return(null);
         }
         var cp = CreateConnectionProperties(rc.HostName, rc.Port, rc.Channel);
         var qm = this.ConnectQueueManager(rc.QueueManagerName, cp);
         return(qm);
     }
     catch (MqException ex)
     {
         ex.Log();
         return(null);
     }
 }
        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);
        }