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 <QueriesDataResponse> GetQueriesNReportsNameList(string categoryId) { CategoriesDal categoriesDal = new CategoriesDal(); ReportsDal reportsDal = new ReportsDal(); var responseData = new QueriesDataResponse(); List <QueryData> Querieslst = new List <QueryData>(); int categoryIdNum = 0; int.TryParse(categoryId, out categoryIdNum); var category = categoriesDal.GetCategoryById(categoryIdNum); var queriesData = await HttpProvider.GetHttpRequest(StaticParams.TfsUrl, "Enterprise/_apis/wit/queries/Shared%20Queries/Release%20Dashboard/Reports/" + category.CategoryName + "?$depth=1"); QueriesDataRequest queriesDataObject = JsonConvert.DeserializeObject <QueriesDataRequest>(queriesData); foreach (var item in queriesDataObject.children) { var queryData = new QueryData() { Id = item.id, Name = item.name }; Querieslst.Add(queryData); } responseData.AllAvailableQueries = Querieslst.ToArray(); responseData.AllReports = reportsDal.GetReportsByCategoryId(categoryIdNum).ToArray(); return(responseData); }
public async Task <string> GeneratTempQuery(string newWiql, string queryName) { string QueryUrl = ""; var uniqueKey = string.Format("{0} ({1})", queryName, Guid.NewGuid().ToString("N").Substring(0, 4)); newWiql = newWiql.Replace("%3D", "="); var newQueryData = new NewQueryClass() { Name = uniqueKey, Wiql = newWiql }; string query = JsonConvert.SerializeObject(newQueryData, Formatting.None); var responseUrl = await HttpProvider.PostHttpRequest("Enterprise/_apis/wit/queries/Shared%20Queries%2FRelease%20Dashboard%2FTemp%20Queries?api-version=2.2", query); QueriesDataRequest queryDataObject = JsonConvert.DeserializeObject <QueriesDataRequest>(responseUrl); QueryUrl = queryDataObject._links.html.href; Task.Run(() => RemoveTempQueryFromTfs(queryDataObject.id)); return(QueryUrl); }
public async Task <string> GetFilterQueryLink(string categoryName, string reportName, string chartName, string filterBy) { string QueryUrl = ""; var queriesData = await HttpProvider.GetHttpRequest(StaticParams.TfsUrl, "Enterprise/_apis/wit/queries/Shared%20Queries/Release%20Dashboard/Temp%20Queries?$depth=1"); QueriesDataRequest queriesDataObject = JsonConvert.DeserializeObject <QueriesDataRequest>(queriesData); if (queriesDataObject.children == null || queriesDataObject.children.Count() <= 50) { var chartData = GetCart(categoryName, reportName, chartName); if (chartData != null) { var wiql = await GetQueryWiql(chartData.QueryId); var newWiql = wiql.Replace("where", string.Format(@"where [{0}] = ""{1}"" and", chartData.ColumnReferenceName, filterBy)); var uniqueKey = string.Format("{0} - {1}", chartData.ChartName, filterBy); QueryUrl = await GeneratTempQuery(newWiql, uniqueKey); } } return(QueryUrl); }
internal static async Task <Tuple <int, int, int, List <InformationChartData> > > getGradeValuesByFilters(string GradeFolder, List <Tuple <string, string, string> > filters) { var queriesData = await HttpProvider.GetHttpRequest(StaticParams.TfsUrl, "Enterprise/_apis/wit/queries/Shared%20Queries/Release%20Dashboard/" + GradeFolder + "?$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 }; var workItemData = await GetWorkItemData(queryData.Id, filters); queryData.workItems = workItemData.Item1; var wiql = workItemData.Item2.Replace("=", "%3D"); item._links.html.href = wiql; 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; var infoData = new List <InformationChartData> { new InformationChartData { Data = critical.ToString(), DataName = "Critical", Wiql = queriesDataObject.children.FirstOrDefault(q => q.name.Contains("Critical #"))._links.html.href }, new InformationChartData { Data = high.ToString(), DataName = "High", Wiql = queriesDataObject.children.FirstOrDefault(q => q.name.Contains("High #"))._links.html.href }, new InformationChartData { Data = medium.ToString(), DataName = "Medium", Wiql = queriesDataObject.children.FirstOrDefault(q => q.name.Contains("Medium #"))._links.html.href } }; return(new Tuple <int, int, int, List <InformationChartData> >(critical, high, medium, infoData)); }