async void getUserStories(string uri) { if (string.IsNullOrWhiteSpace(uri)) { uri = string.Format("{0}/api/v1/UserStories?acid={1}&format=xml&include={2}&where={3}", targetProcessServer, acid, Uri.EscapeDataString(USERSTORY_INCLUDE), Uri.EscapeDataString(USERSTORY_WHERE)); } var req = await client.GetAsync(new Uri(uri)); if (req.IsSuccessStatusCode) { string responseText = await req.Content.ReadAsStringAsync(); var doc = XDocument.Parse(responseText); req.Dispose(); foreach (XElement UserStory in doc.Root.Elements("UserStory")) { XElement CreateDate = UserStory.Element("CreateDate"); XElement StartDate = UserStory.Element("StartDate"); XElement EndDate = UserStory.Element("EndDate"); XElement Feature = UserStory.Element("Feature"); UserStory u = new UserStory(); u.id = int.Parse(UserStory.Attribute("Id").Value); u.name = UserStory.Attribute("Name").Value; XAttribute FeatureId = Feature != null?Feature.Attribute("Id") : null; u.featureId = FeatureId != null?int.Parse(Feature.Attribute("Id").Value) : 0; if (features.ContainsKey(u.featureId)) { u.featureName = features[u.featureId].name; } if (!string.IsNullOrWhiteSpace(u.featureName)) { u.title = string.Format("{0} in {1}", u.name, u.featureName); } else { u.title = u.name; } u.createdate = DateTime.Parse(CreateDate.Value); u.opened = Math.Max(0, (int)((u.createdate - start).Days / 7)); if (StartDate != null && !string.IsNullOrWhiteSpace(StartDate.Value)) { u.startdate = DateTime.Parse(StartDate.Value); u.started = Math.Max(u.opened, (int)((u.startdate.Value - start).Days / 7)); if (EndDate != null && !string.IsNullOrWhiteSpace(EndDate.Value)) { u.enddate = DateTime.Parse(EndDate.Value); u.closed = Math.Max(u.started, (int)((u.enddate.Value - start).Days / 7)); } else { u.enddate = null; u.closed = -1; } } else { u.startdate = null; u.started = -1; u.enddate = null; u.closed = -1; } userStories.Add(u); } XAttribute Next = doc.Root.Attribute("Next"); if (Next != null && !string.IsNullOrWhiteSpace(Next.Value)) { getUserStories(Next.Value); } else { showData(); } } else { progressRing.IsActive = false; var popup = new MessageDialog("Check username/password and try again.", "Access denied"); req.Dispose(); await popup.ShowAsync(); client.Dispose(); resetUserNamePasswordField(); } }