internal static void OnAddinStartUp(UISolution solution) { //checks if the solution is linked to JIRA if (UserSettingsHelper.IsSolutionLinked(solution) && solution.LoadType != SolutionLoadType.Ask) { //solution is linked if (solution.LoadType == SolutionLoadType.Link) { LoadConfiguration(solution); InitializeAddIn(); } } else { //solution is not linked, check if it is necessary to link it if (UserSettingsHelper.CanSolutionBeLinked(solution.FullName)) { DialogResult result = MessageBox.Show( "JIRA Connector has detected a solution that hasn't been linked to JIRA. Would you like to link the solution to a JIRA project?\n Click 'YES' to link, 'NO' to never link the solution or 'CANCEL' to see this message next time this solution is opened.", "JIRA Connector", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); if (result == DialogResult.No) { solution.LoadType = SolutionLoadType.NeverLink; UserSettingsHelper.SaveSolutionSettings(solution); } else if (result == DialogResult.Yes) { LogManager.WriteMessage("Saving solution settings."); solution.LoadType = SolutionLoadType.Link; SolutionLinkSettings solutionSettings = new SolutionLinkSettings(solution); DialogResult settingsResult = solutionSettings.ShowDialog(); if (settingsResult == DialogResult.OK) { //Settings were entered, initializing addin LoadConfiguration(solution); InitializeAddIn(); } else { //User cancel settings, so we ask him next time he opens the solution solution.LoadType = SolutionLoadType.Ask; } UserSettingsHelper.SaveSolutionSettings(solution); } else if (result == DialogResult.Cancel) { solution.LoadType = SolutionLoadType.Ask; UserSettingsHelper.SaveSolutionSettings(solution); } } } }
public void HandleTestSettingsRequest(SolutionLinkSettings settingsDialog){ try { //Try to authenticate the user first Proxy.AuthenticateUser( settingsDialog.Solution.Settings.Url, settingsDialog.Solution.Settings.Port, settingsDialog.Solution.Settings.Username, settingsDialog.Solution.Settings.Password); //If the login was sucessful, we save to memory te settings entered by the user so we can obtain the project keys JiraConfigurationHelper.Password = settingsDialog.Solution.Settings.Password; JiraConfigurationHelper.Port = settingsDialog.Solution.Settings.Port; JiraConfigurationHelper.Url = settingsDialog.Solution.Settings.Url; JiraConfigurationHelper.UserName = settingsDialog.Solution.Settings.Username; List<string> keys = this.GetAllProjectKeys(); settingsDialog.DisplayProjectKeys(keys); } catch (Exception e){ settingsDialog.DisplayTestFailedMessage(); this.HandleException(e); } }