private static async Task <Linear> GeneratLinear(ReportChartModel item, int position) { var linear = new Linear() { Type = item.ChartType.ToString().ToLower(), Element = "linear" + position }; return(linear); }
/// <summary> /// Load report chart /// </summary> /// <returns></returns> public ActionResult ReportChart(string questionId = null, string frDt = null, string toDt = null) { TempData["qnId"] = questionId; TempData["frDt"] = frDt; TempData["toDt"] = toDt; var model = new ReportChartModel(); return(PartialView(model)); }
public void UpdateChart(int id, ReportChartModel report) { using (DashboardContext dbContext = new DashboardContext()) { var chart = dbContext.ReportCharts.FirstOrDefault(c => c.ReportChartId == id); if (chart != null) { dbContext.Entry(chart).CurrentValues.SetValues(report); dbContext.SaveChanges(); } } }
public async Task <bool> SaveChart(ReportChartModel chart) { if (chart != null) { using (DashboardContext dbContext = new DashboardContext()) { dbContext.ReportCharts.Add(chart); await dbContext.SaveChangesAsync(); return(true); } } return(false); }
public async Task <IHttpActionResult> SaveNewChart([FromBody] ReportChartModel report) { if (report == null) { return(BadRequest("report cannot be null")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var settingsRepo = new SettingsRepository(); var result = await settingsRepo.AddReportChart(report); return(Ok()); }
public ReportChartModelResponse GetChartByName(string categoryName, string reportName, string chartName) { ReportChartModel currentChart = GetCart(categoryName, reportName, chartName); var reportChrtData = new ReportChartModelResponse() { ReportChartId = currentChart.ReportChartId, DataShowType = currentChart.DataShowType.ToString().ToLower(), ChartType = currentChart.ChartType.ToString().ToLower(), aggregationColumnReferenceName = currentChart.aggregationColumnReferenceName, CategoryId = currentChart.CategoryId.ToString(), ChartName = currentChart.ChartName, ColumnReferenceName = currentChart.ColumnReferenceName, QueryId = currentChart.QueryId, ReportName = currentChart.ReportName.ToString() }; return(reportChrtData); }
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 IHttpActionResult UpdateChart(int id, [FromBody] ReportChartModel report) { try { if (report == null) { return(BadRequest("Report cannot be null!")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ReportsRepository reportRepo = new ReportsRepository(); reportRepo.UpdateChart(id, report); return(Ok()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <bool> AddReportChart(ReportChartModel report) { ReportChartDal dal = new ReportChartDal(); return(await dal.SaveChart(report)); }
/// <summary> /// Load chart data /// </summary> /// <returns></returns> public JsonResult GetChartData(string reportType) { int fromMnth = Convert.ToInt32(TempData["frDt"].ToString().Split('/')[0]); int toMnth = 12; //int toMnth = Convert.ToInt32(TempData["toDt"].ToString().Split('/')[0]); //Load Report details DataTable dtReport = AccountDbAccess.GetMonthlyRecordOfQuestion(reportType, TempData["qnId"].ToString(), fromMnth, toMnth); if (dtReport != null) { var model = new ReportChartModel(); model.ChartDataList = new List <ReportChartData>(); model.QusetionId = TempData["qnId"].ToString(); switch (dtReport.Columns.Count) { case 4: model.FieldType = ChartTypes.OneField.ToString(); break; case 5: model.FieldType = ChartTypes.TwoField.ToString(); break; case 6: model.FieldType = ChartTypes.ThreeField.ToString(); break; case 8: model.FieldType = ChartTypes.FiveField.ToString(); break; } foreach (DataRow row in dtReport.Rows) { if (model.FieldType == ChartTypes.OneField.ToString()) { model.ChartDataList.Add(new ReportChartData { Data1 = row["Ans"].ToString(), Total = row["Total"].ToString(), ReportMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(Convert.ToInt32(row["ReportMonth"])), }); } else if (model.FieldType == ChartTypes.TwoField.ToString()) { model.ChartDataList.Add(new ReportChartData { Data1 = row["YES"].ToString(), Data2 = row["NO"].ToString(), Total = row["Total"].ToString(), ReportMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(Convert.ToInt32(row["ReportMonth"])), }); } else if (model.FieldType == ChartTypes.ThreeField.ToString()) { model.ChartDataList.Add(new ReportChartData { Data1 = row["YES"].ToString(), Data2 = row["NO"].ToString(), Data3 = row["NA"].ToString(), Total = row["Total"].ToString(), ReportMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(Convert.ToInt32(row["ReportMonth"])), }); } else if (model.FieldType == ChartTypes.FiveField.ToString()) { model.ChartDataList.Add(new ReportChartData { Data1 = row["VD"].ToString(), Data2 = row["SD"].ToString(), Data3 = row["SS"].ToString(), Data4 = row["VS"].ToString(), Data5 = row["NA"].ToString(), Total = row["Total"].ToString(), ReportMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(Convert.ToInt32(row["ReportMonth"])), }); } } return(Json(new { data = model }, JsonRequestBehavior.AllowGet)); } else { return(null); } }
public void UpdateChart(int id, ReportChartModel report) { ReportChartDal reportChart = new ReportChartDal(); reportChart.UpdateChart(id, report); }
private static async Task <Pie> GeneratPie(ReportChartModel item, int position) { var workItemData = await GetWorkItemData(item.QueryId, null); WorkItems workItemsData = workItemData.Item1; var ids = workItemsData.GetAllIds(); WorkItemResponse response = null; bool aggregation = false; foreach (var id in ids) { string aggregationFiled = ""; if (!string.IsNullOrEmpty(item.aggregationColumnReferenceName)) { aggregationFiled = "," + item.aggregationColumnReferenceName; aggregation = true; } var chartData = await HttpProvider.GetHttpRequest(StaticParams.TfsUrl, "_apis/wit/workItems?ids=" + id + "&fields=" + item.ColumnReferenceName + aggregationFiled); 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)).Select(g => new { titel = g.Key, value = (double)g.Count() }); if (aggregation) { var aggregationPropName = item.aggregationColumnReferenceName.Replace(".", ""); groupedData = response.value.GroupBy(p => p.fields.GetType().GetProperty(propName).GetValue(p.fields)).Select(g => new { titel = g.Key, value = g.Sum(f => (double)f.fields.GetType().GetProperty(aggregationPropName).GetValue(f.fields)) }); } List <Datum> PieLabels = new List <Datum>(); int total = response.value.Count; foreach (var PieData in groupedData) { PieLabels.Add(new Datum { Label = PieData.titel == null ? "No data" : PieData.titel.ToString(), Value = PieData.value, }); } var pie = new Pie { Name = item.ChartName, Element = "pie-chart" + position, Type = item.ChartType.ToString().ToLower(), Data = PieLabels.ToArray(), TotalData = total.ToString(), DataShowType = item.DataShowType.ToString().ToLower() }; return(pie); }