internal RecentRemoteQueueConnectionConfigElement(RecentRemoteQueueConnection rc) : this()
 {
     QueueManagerName = rc.QueueManagerName;
     QueueName        = rc.QueueName;
     QueueName        = rc.QueueName;
     Host             = rc.HostName;
     Port             = rc.Port;
     Channel          = rc.Channel;
     UserId           = rc.UserId;
 }
예제 #2
0
 public IQueue TryOpenRemoteQueue(RecentRemoteQueueConnection 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);
         var q  = qm.OpenQueue(rc.QueueName);
         return(q);
     }
     catch (MqException ex)
     {
         ex.Log();
         return(null);
     }
 }
        private void OpenRemoteQueue(RecentRemoteQueueConnection rrqc = null)
        {
            if (rrqc != null)
            {
                bool automaticOpenOk = false;
                ShellService.WithGlobalBusy(() =>
                {
                    var q = MqController.TryOpenRemoteQueue(rrqc);
                    if (q != null)
                    {
                        OpenQueueView(q);
                        UserSettings.AddRecentConnection(rrqc);
                        automaticOpenOk = true;
                    }
                });
                if (automaticOpenOk)
                {
                    return;
                }
            }

            SelectQueueManagerInternal(true, false, rrqc, (qm, qpfx) =>
            {
                if (qm != null)
                {
                    SelectQueueInternal(qm, rrqc, q =>
                    {
                        if (q != null)
                        {
                            AddRecentConnection(q, rrqc);
                            OpenQueueView(q);
                        }
                    });
                }
            });
        }
        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);
        }