Exemplo n.º 1
0
        public static IEnumerable<FogbugzUser> ParseUsersXml(string xml)
        {
            using (var sr = new StringReader(xml))
            {
                var x = XmlDynamo.Load(sr);

                var persons = x.people.Elements("person");
                var fogbugzUsers = new List<FogbugzUser>();
                foreach (var person in persons)
                {
                    var newUser = new FogbugzUser();
                    newUser.Email = person.sEmail;
                    newUser.FullName = person.sFullName;
                    newUser.UserId = int.Parse(person.ixPerson);

                    fogbugzUsers.Add(newUser);
                }

                return fogbugzUsers;
            }
        }
        private void UpdateFogbugzUser()
        {
            if (_fogbugzUser != null)
                return;

            LoadApiKey();

            var parameters = new Dictionary<string, string>();

            var xmlString = MakeFogbugzRequest("listPeople", parameters);
            var users = FogbugzUser.ParseUsersXml(xmlString);

            _fogbugzUser = users.SingleOrDefault(x => x.Email == _currentUserEmail);

            if (_fogbugzUser == null)
                throw new Exception("Could not find a user with the email " + _currentUserEmail);
        }