Beispiel #1
0
        /// <summary>
        /// Gets the logins for selected server.
        /// </summary>
        private void GetLoginsForSelectedServer()
        {
            this.uxDeleteLogin.IsEnabled  = false;
            this.uxDeleteServer.IsEnabled = false;
            this.uxLogins.Items.Clear();
            if (this.uxServers.SelectedItem != null)
            {
                var serverPair = this.Servers.FirstOrDefault(s => s.Value.Name == this.uxServers.SelectedItem.ToString());
                if (serverPair.Value != null)
                {
                    this.uxDeleteServer.IsEnabled = true;
                    ServerConnectionItem serverInstance = serverPair.Value.ServerConnectionItem;
                    if (serverInstance.Connections.Any())
                    {
                        foreach (var connection in serverInstance.Connections.OrderBy(k => k.UserName))
                        {
                            this.uxLogins.Items.Add(connection.UserName);
                        }

                        this.uxLogins.SelectedIndex  = 0;
                        this.uxDeleteLogin.IsEnabled = true;
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets a unique name for the connection.
        /// </summary>
        /// <param name="serverConnectionItem">The server connection item.</param>
        /// <param name="existingServers">The existing servers.</param>
        /// <returns>A unique name for the connection</returns>
        private static string GetServerName(ServerConnectionItem serverConnectionItem, Dictionary <string, Server> existingServers)
        {
            var key     = string.Format("{0} ({1})", serverConnectionItem.Instance, serverConnectionItem.AuthenticationMethod == 0 ? "Windows" : "Sql");
            var testKey = key;
            int i       = 2;

            while (existingServers.Any(s => s.Value.Name == testKey))
            {
                testKey = key + " " + i;
                i++;
                if (existingServers.All(s => s.Value.Name != testKey))
                {
                    key = testKey;
                }
            }

            return(key);
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Server"/> class.
 /// </summary>
 /// <param name="serverConnectionItem">The server connection item.</param>
 /// <param name="name">The name.</param>
 internal Server(ServerConnectionItem serverConnectionItem, string name)
 {
     this.ServerConnectionItem = serverConnectionItem;
     this.Name = name;
 }