// Bindings... private void SetFieldsFromConfig(IJIRAConfiguration config) { config.Load(); _entryBaseUrl.Text = config.BaseUrl; _entryUsername.Text = config.Username; _entryPassword.Text = config.Password; _entryProjects.Text = string.Join(",", config.Projects); }
/// <summary> /// Determine the project ids of the given project codes by contacting the JIRA soap service. /// Then do an initial query for issues with these given ids /// </summary> private void DoInit() { try { Monitor.Enter(_lock); // Pre cleaning... _hasInit = true; // by the time this is done, we will have init... _projectStatuses.Clear(); _projectIds.Clear(); lock ( _items ) { _items.Clear(); } // Check to make sure the config is valid... _config.Load(); if (!_config.IsValid()) { Log("Configuration for JIRA is not valid, see the plugin settings page"); // we failed to init _hasInit = false; return; } Log("Initializing repository: " + _config.BaseUrl); // init the service connection _service = new JIRAServerFacade(_config.BaseUrl, _config.Username, _config.Password); // Identify the available resolutions for an issue foreach (RemoteStatus status in _service.getStatuses()) { _projectStatuses.Add(int.Parse(status.id)); Log("Init Status: {0} => {1}", status.name, status.id); } // We want all issues that have a status that isn't 5 or 6 (resolved/closed) // we need to do it this way because JIRA doesn't support logical operators // for exclusion: see JRA-1560 List <int> reqStatuses = new List <int>(_projectStatuses); reqStatuses.Remove(JIRAIssueItem.STATUS_RESOLVED); reqStatuses.Remove(JIRAIssueItem.STATUS_CLOSED); // Identify the project id's that we're interested in foreach (string projectKey in _config.Projects) { RemoteProject project = _service.getProjectByKey(projectKey); long projectId = long.Parse(project.id); // Use the rss client to discover the issues for this project that are open List <JIRAIssueItem> issues = ConvertFromRemoteIssues( _service.GetAllIssuesWithStatus( new List <long>(new long[] { projectId }), reqStatuses)); // Store this project and it's issues _projectIds.Add(projectId); lock ( _items ) { _items.AddRange(issues.ToArray()); } Log("Init Project: {0} [{1}=>{2}] with: {3} issues.", project.name, project.key, project.id, issues.Count); } } catch (System.Web.Services.Protocols.SoapException e) { Log("Failure (re-)initializating JIRA plugin...\n{0}", e); } finally { Monitor.Exit(_lock); } }