Пример #1
0
        public void SetFromAlias(ServerAlias alias)
        {
            tbAliasName.Text = alias.Name;
            CopyInstance(alias.SessionInfo, _sessionInfo);
            SessionInfoPropertyGrid.Refresh();
            cbIsUserAlias.Checked = alias.IsUserAlias;

            InProcessAlias  inProcess  = alias as InProcessAlias;
            ConnectionAlias connection = alias as ConnectionAlias;

            if (inProcess != null)
            {
                tcAliasType.SelectedTab       = tpInProcessAlias;
                _cbInProcessInstanceName.Text = inProcess.InstanceName;
                cbEmbedded.Checked            = inProcess.IsEmbedded;
            }
            else
            {
                tcAliasType.SelectedTab          = tpConnectionAlias;
                tbHost.Text                      = connection.HostName;
                cbInstanceName.Text              = connection.InstanceName;
                OverridePortNumber               = connection.OverridePortNumber;
                SecurityMode                     = connection.SecurityMode;
                OverrideListenerPortNumber       = connection.OverrideListenerPortNumber;
                ListenerSecurityMode             = connection.ListenerSecurityMode;
                tbEndpointConfigurationName.Text = connection.ClientConfigurationName;
                cbClientSideLogging.Checked      = connection.ClientSideLoggingEnabled;
            }
        }
Пример #2
0
        private void AddAliasButton_Click(object sender, System.EventArgs e)
        {
            ServerAlias alias = EditAliasForm.ExecuteAdd();

            _configuration.Aliases.Add(alias);
            AddItem(alias);
            SelectAlias(alias.Name);
        }
Пример #3
0
        private void AddItem(ServerAlias alias)
        {
            ListViewItem item = new ListViewItem(String.Empty, (alias is InProcessAlias ? 0 : 1));

            item.SubItems.Add(alias.ToString());
            item.Tag = alias;
            _serverList.Items.Add(item);
        }
Пример #4
0
 public static ServerAlias ExecuteEdit(ServerAlias alias)
 {
     using (EditAliasForm form = new EditAliasForm())
     {
         form.SetFromAlias(alias);
         if (form.ShowDialog() != DialogResult.OK)
         {
             throw new AbortException();
         }
         return(form.CreateAlias());
     }
 }
Пример #5
0
        private void FLogin_Click(object sender, System.EventArgs e)
        {
            ServerAlias alias = _configuration.Aliases[_configuration.DefaultAliasName];

            alias.SessionInfo.UserID = UserIDTextBox.Text;

            _configuration.Save(AliasConfigurationFileName);

            alias.SessionInfo.Password = PasswordTextBox.Text;

            AdvanceToApplication();
        }
Пример #6
0
        private void FAcceptButton_Click(object sender, System.EventArgs e)
        {
            ServerAlias alias = CreateAlias();

            if (_mode == "edit")
            {
                Configuration.Aliases.Remove(Configuration.DefaultAliasName);
            }
            Configuration.Aliases.Add(alias);
            Configuration.DefaultAliasName = alias.Name;
            Configuration.Save(AliasManager.AliasConfigurationFileName);

            Response.Redirect("Connect.aspx");
        }
Пример #7
0
        private void EditAliasButton_Click(object sender, System.EventArgs e)
        {
            ServerAlias oldAlias = SelectedAlias;

            if (oldAlias != null)
            {
                ServerAlias newAlias = EditAliasForm.ExecuteEdit(oldAlias);
                RemoveItem(oldAlias);
                _configuration.Aliases.Remove(oldAlias.Name);
                _configuration.Aliases.Add(newAlias);
                AddItem(newAlias);
                SelectAlias(newAlias.Name);
            }
        }
Пример #8
0
        /// <remarks> Does nothing if not found. </remarks>
        private void RemoveItem(ServerAlias alias)
        {
            ListViewItem item;

            for (int i = 0; i < _serverList.Items.Count; i++)
            {
                item = _serverList.Items[i];
                if (item.Tag == alias)
                {
                    _serverList.Items.RemoveAt(i);
                }
            }
            EnsureServerSelected();
        }
Пример #9
0
        public void SetFromAlias(ServerAlias alias)
        {
            _aliasNameTextBox.Text = alias.Name;

            InProcessAlias  inProcess  = alias as InProcessAlias;
            ConnectionAlias connection = alias as ConnectionAlias;

            if (inProcess != null)
            {
                _inProcessRadioButton.Checked      = true;
                _inProcessInstanceNameTextBox.Text = inProcess.InstanceName;
            }
            else
            {
                _connectionRadioButton.Checked    = true;
                _hostNameTextBox.Text             = connection.HostName;
                _instanceNameTextBox.Text         = connection.InstanceName;
                _portNumberConnectionTextBox.Text = connection.OverridePortNumber.ToString();
            }

            _password.Text = alias.SessionInfo.Password;
            _userID.Text   = alias.SessionInfo.UserID;
        }
Пример #10
0
        public static void Execute(AliasConfiguration configuration)
        {
            using (ServerConnectForm form = new ServerConnectForm())
            {
                form.SetConfiguration(configuration);
                form.EnsureServerSelected();

                DialogResult result = form.ShowDialog();

                ServerAlias selected = form.SelectedAlias;
                if (selected != null)
                {
                    selected.SessionInfo.UserID = form.UserIDTextBox.Text;
                }

                if (selected != null)
                {
                    form.Configuration.DefaultAliasName = selected.Name;
                }
                else
                {
                    form.Configuration.DefaultAliasName = String.Empty;
                }

                AliasManager.SaveConfiguration(form.Configuration);

                if (result != DialogResult.OK)
                {
                    throw new AbortException();
                }

                if (selected != null)
                {
                    selected.SessionInfo.Password = form.PasswordTextBox.Text;
                }
            }
        }
Пример #11
0
        private void DeleteAliasButton_Click(object sender, System.EventArgs e)
        {
            ServerAlias alias = SelectedAlias;

            if
            (
                (alias != null) &&
                (
                    MessageBox.Show
                    (
                        Strings.CConfirmAliasDeleteText,
                        Strings.CConfirmAliasDeleteCaption,
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Warning,
                        MessageBoxDefaultButton.Button1
                    ) == DialogResult.Yes
                )
            )
            {
                RemoveItem(alias);
                _configuration.Aliases.Remove(alias.Name);
            }
            EnsureServerSelected();
        }
Пример #12
0
 public DAEConnection(ServerAlias alias)
 {
     Alias = alias;
 }
Пример #13
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            _configuration = (AliasConfiguration)Session["AliasConfiguration"];
            if (_configuration == null)
            {
                _configuration = AliasConfiguration.Load(AliasConfigurationFileName);
                Session["AliasConfiguration"] = _configuration;
            }

            // End any previous session
            Web.Session session = (Web.Session)Session["WebSession"];
            if (session != null)
            {
                try
                {
                    session.Dispose();
                }
                finally
                {
                    Session["WebSession"] = null;
                }
            }

            string aliasName = Request.QueryString["Alias"];

            if (aliasName == null)
            {
                aliasName = String.Empty;
            }

            if (IsPostBack)
            {
                if (aliasName != String.Empty)
                {
                    UserIDTextBox.Text = _configuration.Aliases[aliasName].SessionInfo.UserID;
                    _configuration.DefaultAliasName = aliasName;
                }

                string deleteAlias = Request.QueryString["Delete"];
                if ((deleteAlias != null) && (deleteAlias != String.Empty))
                {
                    _configuration.Aliases.Remove(deleteAlias);
                    if (String.Compare(deleteAlias, _configuration.DefaultAliasName, true) == 0)
                    {
                        _configuration.DefaultAliasName = String.Empty;
                    }
                    _configuration.Save(AliasConfigurationFileName);
                }
            }
            else
            {
                if (_configuration.DefaultAliasName != String.Empty)
                {
                    ServerAlias connection = _configuration.Aliases[_configuration.DefaultAliasName];
                    if (connection != null)
                    {
                        UserIDTextBox.Text = connection.SessionInfo.UserID;
                    }
                }

                string applicationID = Request.QueryString["ApplicationID"];
                if ((applicationID != null) && (applicationID != String.Empty))
                {
                    Session["ApplicationID"] = applicationID;
                }

                if (aliasName != String.Empty)
                {
                    _configuration.DefaultAliasName = aliasName;
                    AdvanceToApplication();
                }
            }

            _editButton.Enabled   = _configuration.Aliases.Count > 0;
            _deleteButton.Enabled = _editButton.Enabled;
            _deleteButton.Attributes.Add
            (
                "onclick",
                HttpUtility.HtmlAttributeEncode
                (
                    String.Format
                    (
                        @"if (confirm('{0}')) Submit('Connect.aspx?Delete={1}',event)",
                        Strings.Get("ConfirmAliasDeleteMessage"),
                        HttpUtility.UrlEncode(Configuration.DefaultAliasName).Replace("'", "\\'")
                    )
                )
            );
            UserIDTextBox.Attributes.Add("onkeydown", "TrapKeyDown(FLogin, event)");
            PasswordTextBox.Attributes.Add("onkeydown", "TrapKeyDown(FLogin, event)");
        }
Пример #14
0
        private static ServerAlias RetrievePreparedServerAlias(ManagedComputer computer, string serverInstance, string aliasName)
        {
            ServerAlias alias = new ServerAlias(computer, aliasName);
            alias.ProtocolName = "np";
            alias.ServerName = ".";

            string instanceName = ParseInstanceNameFromFullName(serverInstance);

            if (serverInstance.IndexOf('\\') < 0)
            {
                alias.ConnectionString = @"sql\query";
            }
            else
            {
                alias.ConnectionString = String.Format("MSSQL${0}\\sql\\query", instanceName);
            }

            return alias;
        }