private void LoadTaskCreateAndModifyTime(UTrackTask task) { string url = string.Format("https://ustr-vm-0315.na.uis.unisys.com:8443/uTrack/TaskAdmin?tid={0}", task.ID); HtmlAgilityPack.HtmlNode htmlNode = FeatureData(url); var allRow = htmlNode.Descendants().Where(t => t.Attributes.Contains("class") && t.Attributes["class"].Value == "row").ToList(); if (allRow.Any()) { var createLabelText = SpiderUtil.TrimHtmlTag(allRow[10].InnerText); var modifiedLabelText = SpiderUtil.TrimHtmlTag(allRow[11].InnerText); var createdLable = createLabelText.Substring(createLabelText.Length - 10, 10); var modifiedLabel = modifiedLabelText.Substring(modifiedLabelText.Length - 10, 10); task.CreatedOwner = createLabelText.Substring(0, createLabelText.Length - 10).Replace("Created:", string.Empty).Trim(); task.ModifiedOwner = modifiedLabelText.Substring(0, modifiedLabelText.Length - 10).Replace("Modified:", string.Empty).Trim(); if (string.IsNullOrEmpty(task.ModifiedOwner)) { task.ModifiedOwner = task.CreatedOwner; } task.Created = DateTime.Parse(createdLable); task.Modified = DateTime.Parse(modifiedLabel); } }
private void LoadStoryTaskInfomation(Story story) { string url = string.Format("https://ustr-vm-0315.na.uis.unisys.com:8443/uTrack/TaskList?fid={0}", story.ID); HtmlAgilityPack.HtmlNode htmlNode = FeatureData(url); var taskList = htmlNode.Descendants().Where(t => t.Name == "tr").ToList(); bool alreadySkippedHeader = false; foreach (var taskItem in taskList) { if (!alreadySkippedHeader) { alreadySkippedHeader = true; continue; } var taskItemColumn = taskItem.ChildNodes.Where(t => t.Name == "td").ToList(); var Id = SpiderUtil.TrimHtmlTag(taskItemColumn[0].ChildNodes.Where(t => t.Name == "a").ToList().First().InnerText); if (string.IsNullOrEmpty(Id)) { Id = SpiderUtil.TrimHtmlTag(taskItemColumn[0].ChildNodes.First().InnerText); } var name = SpiderUtil.TrimHtmlTag(taskItemColumn[1].ChildNodes.First().InnerText); var type = SpiderUtil.TrimHtmlTag(taskItemColumn[2].Attributes["title"].Value); var priority = int.Parse(SpiderUtil.TrimHtmlTag(taskItemColumn[3].InnerText)); var owner = SpiderUtil.TrimHtmlTag(taskItemColumn[4].ChildNodes.Last().InnerText); var status = SpiderUtil.TrimHtmlTag(taskItemColumn[5].Attributes["title"].Value); decimal estimate = decimal.Parse(SpiderUtil.TrimHtmlTag(taskItemColumn[6].InnerText)); decimal workDone = decimal.Parse(SpiderUtil.TrimHtmlTag(taskItemColumn[7].InnerText)); decimal workTodo = decimal.Parse(SpiderUtil.TrimHtmlTag(taskItemColumn[8].InnerText)); UTrackTask task = new UTrackTask(); task.ID = Id; task.Description = name; task.Type = ConvertToTaskType(type); task.Priority = priority; task.Owner = owner; task.Status = (Unisys.Trend.DataModel.TaskStatus)Enum.Parse(typeof(Unisys.Trend.DataModel.TaskStatus), status.Replace(" ", "")); task.Estimate = estimate; task.WorkDone = workDone; task.WorkToDo = workTodo; if (story.Status == StoryStatus.Done || story.Status == StoryStatus.Pending || story.Status == StoryStatus.InProcess) { LoadTaskCreateAndModifyTime(task); } story.Tasks.Add(task); } }
private HtmlAgilityPack.HtmlNode FeatureData(string url) { string cookieData = CookieUtil.GetCookies(ConfigManager.uTrackRootUrl); string reponseTaskHtml = SpiderUtil.GetHtml(url, cookieData, string.Empty); HADocument hadoc = new HADocument(); hadoc.LoadHtml(reponseTaskHtml); HtmlAgilityPack.HtmlNode htmlNode = hadoc.DocumentNode; return(htmlNode); }
private void LoadStoryInformation(Sprint sprint) { HtmlAgilityPack.HtmlNode htmlNode = FeatureData(sprint.Url); LoadSprintInformation(sprint, htmlNode); var storyList = htmlNode.SelectSingleNode("//*[@id='iterationfeatures']").Descendants().Where(t => t.Name == "tr").ToList(); int total = storyList.Count(); int current = 0; foreach (var storyItem in storyList) { var storyItemColumn = storyItem.ChildNodes.Where(t => t.Name == "td").ToList(); var Id = SpiderUtil.TrimHtmlTag(storyItemColumn[1].ChildNodes.Where(t => t.Name == "a").ToList().First().InnerText); if (string.IsNullOrEmpty(Id)) { Id = SpiderUtil.TrimHtmlTag(storyItemColumn[1].ChildNodes.First().InnerText); } var name = SpiderUtil.TrimHtmlTag(storyItemColumn[2].ChildNodes.Where(t => t.Name == "div").ToList().First().InnerText); var type = SpiderUtil.TrimHtmlTag(storyItemColumn[3].Attributes["title"].Value); var priority = int.Parse(SpiderUtil.TrimHtmlTag(storyItemColumn[4].InnerText)); var owner = SpiderUtil.TrimHtmlTag(storyItemColumn[5].ChildNodes.Last().InnerText); var status = SpiderUtil.TrimHtmlTag(storyItemColumn[6].Attributes["title"].Value); decimal size = decimal.Parse(SpiderUtil.TrimHtmlTag(storyItemColumn[7].InnerText)); Story story = new Story(); story.ID = Id; story.Title = name; story.Type = ConvertToStoryType(type); story.Priority = priority; story.Owner = owner; story.Status = (StoryStatus)Enum.Parse(typeof(StoryStatus), status.Replace(" ", "")); story.Size = size; LoadStoryCreateAndModifiedTime(story); LoadStoryTaskInfomation(story); sprint.Stories.Add(story); if (!IsFirstFetch) { current++; FetchProgressChanged(total, current); } } }