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 RecentConnectionConfigElement(RecentQueueManagerConnection rc) : this()
 {
     QueueManagerName = rc.QueueManagerName;
     FilterPrefix     = rc.ObjectNamePrefix;
     if (rc.QueueList != null && rc.QueueList.Count > 0)
     {
         QueueList = new CommaDelimitedStringCollection();
         QueueList.AddRange(rc.QueueList.ToArray());
     }
 }
Esempio n. 3
0
        public void Initialize(bool remote = false, bool showObjectFilter = true, RecentQueueManagerConnection rqmc = null)
        {
            IsRemote         = remote;
            ShowObjectFilter = showObjectFilter;


            if (rqmc != null)
            {
                QueueManagerName      = rqmc.QueueManagerName;
                QueueNamePrefixFilter = rqmc.ObjectNamePrefix;
                if (rqmc.QueueList != null && rqmc.QueueList.Count > 0)
                {
                    FilterByPrefix     = false;
                    FilterByQueueNames = true;
                    foreach (var s in rqmc.QueueList)
                    {
                        StaticQueueNames.List.Add(s);
                    }
                }
                if (rqmc is RecentRemoteQueueManagerConnection && remote)
                {
                    var rrqmc = (RecentRemoteQueueManagerConnection)rqmc;
                    RemoteConfig = new RemoteConfiguration
                    {
                        Host    = rrqmc.HostName,
                        Channel = rrqmc.Channel,
                        Port    = rrqmc.Port
                    };
                    if (!string.IsNullOrEmpty((rrqmc.UserId)))
                    {
                        RemoteConfig.UserId = rrqmc.UserId;
                    }
                }
            }
            else
            {
                if (!remote)
                {
                    App.ShellService.WithGlobalBusy(() => QueueManagerName = App.MqController.TryGetDefaultQueueManagerName());
                }
                else
                {
                    RemoteConfig = new RemoteConfiguration
                    {
                        Channel = App.UserSettings.Channel,
                        Port    = App.UserSettings.Port
                    };
                }
            }
        }
        private void SelectQueueManagerInternal(bool remote, bool showObjectFilter, RecentQueueManagerConnection rqmc, Action <IQueueManager, IObjectNameFilter> onOk)
        {
            var oqmvm = CompositionHost.GetInstance <OpenQueueManagerViewModel>();

            oqmvm.Initialize(remote, showObjectFilter, rqmc);


            ViewService.ShowModalView(oqmvm, () =>
            {
                if (oqmvm.Result == MessageBoxResult.OK)
                {
                    onOk?.Invoke(oqmvm.QueueManager, oqmvm.GetObjectNameFilter());
                }
            });
        }
Esempio n. 5
0
 public IQueueManager TryOpenQueueManager(RecentQueueManagerConnection rc)
 {
     if (rc == null)
     {
         return(null);
     }
     try
     {
         var qm = this.ConnectQueueManager(rc.QueueManagerName);
         return(qm);
     }
     catch (MqException ex)
     {
         ex.Log();
         return(null);
     }
 }
        public virtual RecentConnection ConvertToModel()
        {
            var item = new RecentQueueManagerConnection
            {
                QueueManagerName = this.QueueManagerName,
                ObjectNamePrefix = this.FilterPrefix,
            };

            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);
        }
        private void OpenLocalQueueManager(RecentQueueManagerConnection recentConn = null)
        {
            if (recentConn != null)
            {
                bool automaticOpenOk = false;
                ShellService.WithGlobalBusy(() =>
                {
                    var qm = MqController.TryOpenQueueManager(recentConn);
                    if (qm != null)
                    {
                        IObjectNameFilter filter = null;
                        if (recentConn.QueueList != null && recentConn.QueueList.Count > 0)
                        {
                            filter = new StaticQueueList(recentConn.QueueList.ToArray());
                        }
                        else
                        {
                            filter = qm.NewObjectNameFilter(recentConn.ObjectNamePrefix);
                        }
                        var provider = qm.NewObjectProvider(filter);
                        OpenQueueManagerView(qm, provider);
                        UserSettings.AddRecentConnection(recentConn);
                        automaticOpenOk = true;
                    }
                });
                if (automaticOpenOk)
                {
                    return;
                }
            }

            SelectQueueManagerInternal(false, true, recentConn, (qm, qpfx) =>
            {
                if (qm != null)
                {
                    AddRecentConnection(qm, qpfx, recentConn);
                    var provider = qm.NewObjectProvider(qpfx);
                    OpenQueueManagerView(qm, provider);
                }
            });
        }
        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);
        }