public object Relation(int id, bool Export = false) { Models.ExpandWI.Value v = new Models.ExpandWI.Value(); v = ((RootObject)System.Web.HttpContext.Current.Session["EWorkItems"]).value.Find(x => x.id == id); Dictionary <string, List <Models.ExpandWI.Value> > rel = new Dictionary <string, List <distribution_copy.Models.ExpandWI.Value> >(); var ForwardList = new List <Models.ExpandWI.Value>(); var RevereseList = new List <Models.ExpandWI.Value>(); if (v.relations != null) { foreach (var j in v.relations) { if (j.rel == "System.LinkTypes.Hierarchy-Forward") { var valueArray = j.url.Split('/'); if (!(valueArray.Count() > 8)) { continue; } if (int.TryParse(valueArray[8], out int Fid)) { var item = ((RootObject)System.Web.HttpContext.Current.Session["EWorkItems"]).value.Find(x => x.id == Fid); ForwardList.Add(item); } } else { var valueArray = j.url.Split('/'); if (!(valueArray.Count() > 8)) { continue; } if (int.TryParse(valueArray[8], out int Fid)) { var item = ((RootObject)System.Web.HttpContext.Current.Session["EWorkItems"]).value.Find(x => x.id == Fid); RevereseList.Add(item); } } } rel.Add("Forward", ForwardList); rel.Add("Reverse", RevereseList); } else { rel.Add("Forward", ForwardList); rel.Add("Reverse", RevereseList); } if (Export) { return(rel); } return(Json(rel, JsonRequestBehavior.AllowGet)); }
public int GetTitleCount(Models.ExpandWI.Value WI, int w = 1) { var Relations = (Dictionary <string, List <Models.ExpandWI.Value> >)Relation(WI.id, true); foreach (var j in Relations["Forward"]) { GetTitleCount(j, w + 1); if (i < w) { i = w; } } return(i); }
public JsonResult CommitList(InputModel inp, int Id) { string url = "https://dev.azure.com/" + inp.OrganizationName + "/" + inp.ProjectName + "/_apis/wit/workitems/" + Id + "?$expand=all&api-version=5.1"; Models.ExpandWI.Value WI = service.GetApi <Models.ExpandWI.Value>(url); var Commits = WI.relations.Where(x => x.attributes.name.ToLower().Contains("commit")); List <Models.CommitModel.CommitModel> commitDetails = new List <Models.CommitModel.CommitModel>(); foreach (var commit in Commits) { string[] separator = { "%2F" }; var arr = commit.url.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (!(arr.Length > 0)) { continue; } string commiturl = "https://dev.azure.com/" + inp.OrganizationName + "/" + inp.ProjectName + "/_apis/git/repositories/" + arr[1] + "/commits/" + arr[2] + "?api-version=5.1"; commitDetails.Add(service.GetApi <Models.CommitModel.CommitModel>(commiturl)); } return(Json(commitDetails, JsonRequestBehavior.AllowGet)); }
public void FindRelations(Models.ExpandWI.Value WI, int tInd) { added.Add(WI); int max = columnNo; int col = 0; workSheet.Cells[recordIndex, ++col].Value = WI.id; workSheet.Cells[recordIndex, ++col].Value = WI.fields.WorkItemType; workSheet.Cells[recordIndex, tInd].Value = WI.fields.Title; workSheet.Cells[recordIndex, columnNo++].Value = WI.fields.TeamProject; workSheet.Cells[recordIndex, columnNo++].Value = WI.fields.State; workSheet.Cells[recordIndex, columnNo++].Value = WI.fields.AreaPath; workSheet.Cells[recordIndex, columnNo++].Value = WI.fields.IterationPath; recordIndex++; columnNo = max; var Relations = (Dictionary <string, List <distribution_copy.Models.ExpandWI.Value> >)Relation(WI.id, true); foreach (var j in Relations["Forward"]) { int n = tInd + 1; FindRelations(j, n); } }