private void comboBoxInstance_DropDownOpened(object sender, EventArgs e) { this.DisableInputMode(); String[] instanceArray = null; try { this.resetServerName(); if (!String.IsNullOrEmpty(this.serverName)) { using (ImpersonationHelper impersonationHelper = new ImpersonationHelper()) { //PropertyBagDictionary.Instance.SafeAdd("SQLMachineName", this.serverName); instanceArray = SetupDatabaseHelper.GetSqlInstanceNames(this.serverName); } } this.comboBoxInstance.Text = String.Empty; this.comboBoxInstance.Items.Clear(); if (instanceArray != null && instanceArray.Length > 0) { foreach (String instanceName in instanceArray) { this.comboBoxInstance.Items.Add(instanceName); } if (this.comboBoxInstance.Items.Contains(this.selectedInstance)) { this.comboBoxInstance.Text = this.selectedInstance; } else { this.selectedInstance = instanceArray[0]; this.comboBoxInstance.Text = this.selectedInstance; } } } catch (Exception backEndErrorException) { SetupLogger.LogException(backEndErrorException); SetupHelpers.ShowError(backEndErrorException.Message); } this.EnableInputMode(); }
private void PopulateInstanceItemsWorker(object sender, DoWorkEventArgs e) { BackgroundWorker backgroundWorker = sender as BackgroundWorker; if (backgroundWorker == null) { return; } String[] instanceArray = null; if (!String.IsNullOrEmpty(this.serverName)) { using (ImpersonationHelper impersonationHelper = new ImpersonationHelper()) { instanceArray = SetupDatabaseHelper.GetSqlInstanceNames(this.serverName); } } e.Result = instanceArray; }