internal JiraUser GetUser(string name) { JiraUser user; if (String.IsNullOrEmpty(name)) { return(JiraUser.Unknown); } if (!_knownUsers.TryGetValue(name, out user)) { if (_lookupUsers) { _knownUsers.Add(name, user = new JiraUser(_service.getUser(_token, name))); } else { _knownUsers.Add(name, user = new JiraUser(name, name)); } _store.Write(this.GetType().FullName, user.Id, user.Name); _store.Write(this.GetType().FullName, ALL_USERS_KEY, String.Join(";", new List <String>(_knownUsers.Keys).ToArray())); } return(user); }
public JiraConnection(string url, string userName, string password, Converter <string, string> settings) { _rootUrl = url.TrimEnd('\\', '/'); int offset = _rootUrl.LastIndexOf("/rpc/soap/jirasoapservice-v2"); if (offset > 0) { _rootUrl = _rootUrl.Substring(0, offset); } _settings = settings; _knownUsers = new Dictionary <string, JiraUser>(StringComparer.OrdinalIgnoreCase); _lookupUsers = StringComparer.OrdinalIgnoreCase.Equals(settings("resolveUserNames"), "true"); LoadUsers(); _statuses = new Dictionary <string, JiraStatus>(StringComparer.Ordinal); _userName = userName; _password = password; _service = new CSharpTest.Net.SvnJiraIntegration.Jira.JiraSoapServiceService(); _service.Url = _rootUrl + "/rpc/soap/jirasoapservice-v2"; _service.UseDefaultCredentials = true; if (!String.IsNullOrEmpty(settings("jira:proxyurl"))) { System.Net.ICredentials proxyAuth = System.Net.CredentialCache.DefaultCredentials; UriBuilder proxyuri = new UriBuilder(settings("jira:proxyurl")); if (!String.IsNullOrEmpty(proxyuri.UserName)) { proxyAuth = new System.Net.NetworkCredential(proxyuri.UserName, proxyuri.Password); proxyuri.Password = proxyuri.UserName = String.Empty; } _service.Proxy = new System.Net.WebProxy(proxyuri.Uri); _service.Proxy.Credentials = proxyAuth; } _token = null; Connect(); _currentUser = GetUser(_userName); foreach (RemoteStatus rs in _service.getStatuses(_token)) { _statuses[rs.id] = new JiraStatus(rs); } }
private void LoadUsers() { string usersList; if (_store.Read(this.GetType().FullName, ALL_USERS_KEY, out usersList)) { foreach (string suser in usersList.Split(';')) { if (_lookupUsers) { string fullName; if (_store.Read(this.GetType().FullName, suser, out fullName)) { _knownUsers[suser] = new JiraUser(suser, fullName); } } else { _knownUsers[suser] = new JiraUser(suser, suser); } } } }