public async Task <IEnumerable <InformationChart> > GetApplicationGrade() { List <InformationChart> infoChartLst = new List <InformationChart>(); var queriesData = await HttpProvider.GetHttpRequest("Enterprise/_apis/wit/queries/Shared%20Queries/Release%20Dashboard/Application%20Grade?$depth=1"); QueriesDataRequest queriesDataObject = JsonConvert.DeserializeObject <QueriesDataRequest>(queriesData); List <QueryData> Querieslst = new List <QueryData>(); foreach (var item in queriesDataObject.children) { var queryData = new QueryData() { Id = item.id, Name = item.name }; queryData.workItems = await GetWorkItemData(queryData.Id); Querieslst.Add(queryData); } int critical = Querieslst.FirstOrDefault(q => q.Name.Contains("Critical #")).workItems.WorkItemCount; int high = Querieslst.FirstOrDefault(q => q.Name.Contains("High #")).workItems.WorkItemCount; int medium = Querieslst.FirstOrDefault(q => q.Name.Contains("Medium #")).workItems.WorkItemCount; double totalCalc = 100 - (5 * critical) - (0.5 * high) - (0.1 * medium); InformationChart infoChart = new InformationChart { name = "Application server grade", Data = totalCalc.ToString(), ChartData = new List <InformationChartData> { new InformationChartData { Data = critical.ToString(), DataName = "Critical", Link = queriesDataObject.children.FirstOrDefault(q => q.name.Contains("Critical #"))._links.html.href }, new InformationChartData { Data = high.ToString(), DataName = "High", Link = queriesDataObject.children.FirstOrDefault(q => q.name.Contains("High #"))._links.html.href }, new InformationChartData { Data = medium.ToString(), DataName = "Medium", Link = queriesDataObject.children.FirstOrDefault(q => q.name.Contains("Medium #"))._links.html.href } } }; if (totalCalc >= 70) { infoChart.color = "green"; infoChart.Marx = "check"; } else if (totalCalc >= 60) { infoChart.color = "yellow"; infoChart.Marx = "exclamation"; } else { infoChart.color = "red"; infoChart.Marx = "times"; } infoChartLst.Add(infoChart); return(infoChartLst); }
public async Task <InformationChart> GetApplicationGrade() { var applicationGradeResult = await getGradeValues("Application%20Grade"); double totalCalc = 100 - (5 * applicationGradeResult.Item1) - (0.5 * applicationGradeResult.Item2) - (0.1 * applicationGradeResult.Item3); InformationChart infoChart = new InformationChart { Name = "Core Application quality grade", Data = totalCalc.ToString(), ChartData = applicationGradeResult.Item4 }; if (applicationGradeResult.Item1 > 0 || totalCalc < 60) { infoChart.Color = "red"; infoChart.Marx = "times"; } else if (totalCalc < 82.3) { infoChart.Color = "yellow"; infoChart.Marx = "exclamation"; } else { infoChart.Color = "green"; infoChart.Marx = "check"; } return(infoChart); }