示例#1
0
        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)));
                    Task <Atlassian.Jira.JiraUser> j = jira.GetUserAsync(name);
                    string h = j.Result.DisplayName;
                    _knownUsers.Add(name, user = new JiraUser(name, h));
                }
                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);
        }
示例#2
0
        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(GetType().FullName, user.Id, user.Name);
                _store.Write(GetType().FullName, ALL_USERS_KEY,
                             String.Join(";", new List <String>(_knownUsers.Keys).ToArray()));
            }

            return(user);
        }
示例#3
0
        Atlassian.Jira.Jira jira;       // This is the object that interfaces with the atlassian.net-sdk library.

        public JiraConnection(string url, string userName, string password, Converter <string, string> settings)
        {
            Log.Verbose("Creating a new connection");
            _rootUrl = url.TrimEnd('\\', '/');
            int offset = _rootUrl.LastIndexOf("/rpc/soap/jirasoapservice-v2");

            if (offset > 0)
            {
                _rootUrl = _rootUrl.Substring(0, offset);
            }

            Log.Info("Root Url: {0}", _rootUrl);
            _settings    = settings;
            _knownUsers  = new Dictionary <string, JiraUser>(StringComparer.OrdinalIgnoreCase);
            _lookupUsers = StringComparer.OrdinalIgnoreCase.Equals(settings("resolveUserNames"), "true");
            Log.Info("LookUp Users: {0}", _lookupUsers);

            LoadUsers();
            _statuses = new Dictionary <string, JiraStatus>(StringComparer.Ordinal);

            _userName = userName;
            _password = password;
            Log.Verbose("Creating a new internal Soap Service");
            _service = new JiraSoapServiceService();
            Log.Verbose("Service Created");
//          _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;

            Log.Verbose("Connecting...");
            Connect();
            Log.Verbose("Connection Successfull");
            _currentUser = GetUser(_userName);

            Log.Verbose("Getting Statuses");
            //	foreach (RemoteStatus rs in _service.getStatuses(_token))
            foreach (IssueStatus status in jira.GetIssueStatuses())
            {// Convert IssueStatus to RemoteStatus
                RemoteStatus rs = new RemoteStatus {
                    id = status.Id, name = status.Name
                };
                _statuses[rs.id] = new JiraStatus(rs);
            }
            Log.Verbose("JiraConnection(): _statuses.Count = {0}", _statuses.Count);
            Log.Verbose("Finished creating a new connection");
        }
示例#4
0
        private void LoadUsers()
        {
            string usersList;

            if (_store.Read(GetType().FullName, ALL_USERS_KEY, out usersList))
            {
                foreach (string suser in usersList.Split(';'))
                {
                    if (_lookupUsers)
                    {
                        string fullName;
                        if (_store.Read(GetType().FullName, suser, out fullName))
                        {
                            _knownUsers[suser] = new JiraUser(suser, fullName);
                        }
                    }
                    else
                    {
                        _knownUsers[suser] = new JiraUser(suser, suser);
                    }
                }
            }
        }
示例#5
0
        private void LoadUsers()
        {
            string usersList;

            // Next line gets the value from the Registry at: Computer/HKEY_USERS/.../Software/httpstortoisegit.org/TortoiseGit/JiraSVN.Jira.JiraConnection
            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);
                    }
                }
            }
        }