private void OpenLocalQueue(RecentQueueConnection rqc = null)
        {
            if (rqc != null)
            {
                bool automaticOpenOk = false;
                ShellService.WithGlobalBusy(() =>
                {
                    var q = MqController.TryOpenQueue(rqc);
                    if (q != null)
                    {
                        OpenQueueView(q);
                        UserSettings.AddRecentConnection(rqc);
                        automaticOpenOk = true;
                    }
                });
                if (automaticOpenOk)
                {
                    return;
                }
            }

            SelectQueueInternal(null, rqc, q =>
            {
                if (q != null)
                {
                    AddRecentConnection(q, rqc);
                    OpenQueueView(q);
                }
            });
        }
Exemplo n.º 2
0
 public IQueue TryOpenQueue(RecentQueueConnection rc)
 {
     if (rc == null)
     {
         return(null);
     }
     try
     {
         var qm = this.ConnectQueueManager(rc.QueueManagerName);
         var q  = qm.OpenQueue(rc.QueueName);
         return(q);
     }
     catch (MqException ex)
     {
         ex.Log();
         return(null);
     }
 }
        private void AddRecentConnection(IQueue q, IRecentQueueConnection previous)
        {
            RecentConnection data = null;

            if (previous != null)
            {
                if (q.QueueManager.ConnectionProperties.IsLocal)
                {
                    var temp = previous as RecentQueueConnection;
                    if (temp != null)
                    {
                        if (temp.QueueManagerName == q.QueueManager.Name &&
                            temp.QueueName == q.Name)
                        {
                            data = temp;
                        }
                    }
                }
                else
                {
                    var temp = previous as RecentRemoteQueueConnection;
                    if (temp != null)
                    {
                        if (temp.QueueManagerName == q.QueueManager.Name &&
                            temp.QueueName == q.Name &&
                            temp.HostName == q.QueueManager.ConnectionProperties.HostName &&
                            temp.Port == q.QueueManager.ConnectionProperties.Port &&
                            temp.Channel == q.QueueManager.ConnectionProperties.Channel &&
                            (temp.UserId ?? "") == (q.QueueManager.ConnectionProperties.UserId ?? ""))
                        {
                            data = temp;
                        }
                    }
                }
            }
            if (data == null)
            {
                if (q.QueueManager.ConnectionProperties.IsLocal)
                {
                    data = new RecentQueueConnection
                    {
                        QueueManagerName = q.QueueManager.Name,
                        QueueName        = q.Name
                    };
                }
                else
                {
                    data = new RecentRemoteQueueConnection
                    {
                        QueueManagerName = q.QueueManager.Name,
                        QueueName        = q.Name,
                        HostName         = q.QueueManager.ConnectionProperties.HostName,
                        Port             = q.QueueManager.ConnectionProperties.Port,
                        Channel          = q.QueueManager.ConnectionProperties.Channel
                    };
                    if (!string.IsNullOrEmpty(q.QueueManager.ConnectionProperties.UserId))
                    {
                        ((RecentRemoteQueueConnection)data).UserId = q.QueueManager.ConnectionProperties.UserId;
                    }
                }
            }
            UserSettings.AddRecentConnection(data);
        }
 internal RecentQueueConnectionConfigElement(RecentQueueConnection rc) : this()
 {
     QueueManagerName = rc.QueueManagerName;
     QueueName        = rc.QueueName;
 }