public async Task <IEnumerable <Pie> > GetChartList(string reportName, string categoryName) { CategoriesDal categoriesDal = new CategoriesDal(); ReportChartDal chartsDal = new ReportChartDal(); var ChartsList = new List <Pie>(); Category category = categoriesDal.GetAllCategoriesIncludeReports().FirstOrDefault(r => r.CategoryName == categoryName); Report report = category.Reports.FirstOrDefault(r => r.ReportName == reportName); IEnumerable <ReportChartModel> reportsCarts = chartsDal.GetChartsList(r => r.ReportName == report.ReportId); foreach (var item in reportsCarts) { WorkItems workItemsData = await GetWorkItemData(item.QueryId); var ids = workItemsData.GetAllIds(); WorkItemResponse response = null; foreach (var id in ids) { var chartData = await HttpProvider.GetHttpRequest("_apis/wit/workItems?ids=" + id + "&fields=" + item.ColumnReferenceName); var currentItem = JsonConvert.DeserializeObject <WorkItemResponse>(chartData); if (response == null) { response = currentItem; } else { response.value.AddRange(currentItem.value); } } var propName = item.ColumnReferenceName.Replace(".", ""); var groupedData = response.value.GroupBy(p => p.fields.GetType().GetProperty(propName).GetValue(p.fields)); List <Datum> PieLabels = new List <Datum>(); int total = 0; foreach (var PieData in groupedData) { total += PieData.Count(); PieLabels.Add(new Datum { Label = PieData.Key == null ? "No data" : PieData.Key.ToString(), Value = PieData.Count() }); } var pie = new Pie { Name = item.ChartName, Element = "morris-donut-chart" + ChartsList.Count, Type = "Donut", Data = PieLabels.ToArray(), TotalData = total.ToString(), DataShowType = item.DataShowType.ToString().ToLower() }; ChartsList.Add(pie); } return(ChartsList); }
private static ReportChartModel GetCart(string categoryName, string reportName, string chartName) { ReportChartModel currentChart = null; CategoriesDal categoryDal = new CategoriesDal(); var categoryId = categoryDal.GetCategoryIdByName(categoryName); if (categoryId > 0) { ReportsDal reportDal = new ReportsDal(); var reportId = reportDal.GetReportIdByNameAndCategoryId(categoryId, reportName); if (reportId > 0) { ReportChartDal reportChart = new ReportChartDal(); currentChart = reportChart.GetChartByNameAndCartegoryReportIds(categoryId, reportId, chartName); } } return(currentChart); }
public async Task <IEnumerable <Chart> > GetChartList(string reportName, string categoryName) { CategoriesDal categoriesDal = new CategoriesDal(); ReportChartDal chartsDal = new ReportChartDal(); var ChartsList = new List <Chart>(); Category category = categoriesDal.GetAllCategoriesIncludeReports().FirstOrDefault(r => r.CategoryName == categoryName); Report report = category.Reports.FirstOrDefault(r => r.ReportName == reportName); IEnumerable <ReportChartModel> reportsCarts = chartsDal.GetChartsList(r => r.ReportName == report.ReportId); foreach (var item in reportsCarts) { try { switch (item.ChartType) { case Entities.Enums.ChartType.Pie: Pie pie = await GeneratPie(item, ChartsList.Count); ChartsList.Add(pie); break; case Entities.Enums.ChartType.Line: Linear linear = await GeneratLinear(item, ChartsList.Count); ChartsList.Add(linear); break; default: break; } } catch (Exception ex) { continue; } } return(ChartsList); }
public async Task <bool> AddReportChart(ReportChartModel report) { ReportChartDal dal = new ReportChartDal(); return(await dal.SaveChart(report)); }
public void UpdateChart(int id, ReportChartModel report) { ReportChartDal reportChart = new ReportChartDal(); reportChart.UpdateChart(id, report); }
public async Task <bool> RemoveChart(int id) { ReportChartDal reportDal = new ReportChartDal(); return(await reportDal.DeleteChart(id)); }