public ActionResult Add_New_Tab(int widget_Id) { ViewBag.Chart_Id = 0; Dashboard_Widget_VM_DTO dto_dashboard_widget = _dashboardRepository.Get_Dashboard_Widget_By_Id_New_Chart(widget_Id); return(PartialView("_Dashboard_Widget_Add_Edit", dto_dashboard_widget)); }
public ActionResult Add_Dashboard_Widget(int dashboard_Id) { ViewBag.Chart_Id = 0; Dashboard_Widget_VM_DTO dto_dashboard_widget = new Dashboard_Widget_VM_DTO { Dashboard_Id = dashboard_Id }; return(PartialView("_Dashboard_Widget_Add_Edit", dto_dashboard_widget)); }
public ActionResult Choose_Metric(int dashboard_Id, string chart_type, string widget_title, int widget_Id, int chart_id) { //Set the static list of metric if (_list_metric == null) { if (User.IsInRole("Admin")) { _list_metric = _iMetricRepository.GetMetricForDropdownList(); } else { _list_metric = _iMetricRepository.GetMetricForDropdownListByUserId(User.Identity.GetUserId()); } } ChartType _chart_type; Enum.TryParse(chart_type, out _chart_type); if (!Enum.IsDefined(typeof(ChartType), chart_type)) { throw new Exception(String.Format(Common.App_CommonGlobalResources.Resources.Invalid_Chart_Type + " {0}", chart_type)); } //Widget is greater than the 0 it mean it is for the Edit, 0 widget_id for new widget if (widget_Id > 0 && chart_id > 0) { Dashboard_Widget_VM_DTO dto_dashboard_widget = _iChartRepository.Get_Chart_By_Chart_ID(_chart_type, chart_id); return(PartialView("_Dashboard_Widget_Choose_Metric", dto_dashboard_widget)); } else if (widget_Id > 0 && chart_id == 0) // this is for adding the new tab into the widget { //Dashboard_Widget_VM_DTO dashboard_widget_dto = new Dashboard_Widget_VM_DTO(_chart_type); //dashboard_widget_dto.Widget_Title = widget_title; //dashboard_widget_dto.Dashboard_Id = dashboard_Id; //dashboard_widget_dto.Id = widget_Id; Dashboard_Widget_VM_DTO dto_dashboard_widget = _dashboardRepository.Get_Dashboard_Widget_By_Id_New_Chart(widget_Id); return(PartialView("_Dashboard_Widget_Choose_Metric", dto_dashboard_widget)); } else // this for to add new widget into the dahsboard { Dashboard_Widget_VM_DTO dashboard_widget_dto = new Dashboard_Widget_VM_DTO(_chart_type); dashboard_widget_dto.Widget_Title = widget_title; dashboard_widget_dto.Dashboard_Id = dashboard_Id; dashboard_widget_dto.widget_width = 12; dashboard_widget_dto.widget_height = 10; return(PartialView("_Dashboard_Widget_Choose_Metric", dashboard_widget_dto)); } }
public long Add_Dashboard_Widget(Dashboard_Widget_VM_DTO dashboard_widget) { try { dashboard_widget = Set_Primary_Key_For_Multi_Metrics(dashboard_widget); tblDashboard_Widget tbl_dashboard_widget = _dbcontext.tblDashboard_Widget.Add(Dashboard_Widget_VM_DTO_Convert.Dashboard_Widget_DTO_Convert_DTO_To_Table(dashboard_widget)); _dbcontext.SaveChanges(); return(tbl_dashboard_widget.Id); } catch (Exception ex) { throw ex; } }
public ActionResult Edit_Dashboard_Widget(string chart_type, int chart_id) { ChartType _chart_type; Enum.TryParse(chart_type, out _chart_type); if (!Enum.IsDefined(typeof(ChartType), chart_type)) { throw new Exception(String.Format(Common.App_CommonGlobalResources.Resources.Invalid_Chart_Type + " {0}", chart_type)); } ViewBag.Chart_Id = chart_id; Dashboard_Widget_VM_DTO dto_dashboard_widget = _iChartRepository.Get_Chart_By_Chart_ID(_chart_type, chart_id); return(PartialView("_Dashboard_Widget_Add_Edit", dto_dashboard_widget)); }
public ActionResult Add_Edit_Dashboard_Widget(Dashboard_Widget_VM_DTO dashboard_widget_dto) { try { if (dashboard_widget_dto.Id > 0) { _dashboardRepository.Edit_Dashboard_Widget(dashboard_widget_dto); return(Json(new { dashboard_id = dashboard_widget_dto.Dashboard_Id, success = true, message = Resources.Resources.Widget_Edit_Success }, JsonRequestBehavior.AllowGet)); } else { _dashboardRepository.Add_Dashboard_Widget(dashboard_widget_dto); return(Json(new { dashboard_id = dashboard_widget_dto.Dashboard_Id, success = true, message = Resources.Resources.Widget_Add_Success }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { throw ex; } }
/// <summary> /// this method use for to add new tab into the widget, tblDashboard_Widget will not change, only add new chart /// </summary> /// <param name="Id"></param> /// <returns></returns> public Dashboard_Widget_VM_DTO Get_Dashboard_Widget_By_Id_New_Chart(int widget_Id) { tblDashboard_Widget tbl_dashboard_widget = _dbcontext.tblDashboard_Widget.SingleOrDefault(DashboardWidget => DashboardWidget.Id == widget_Id); if (tbl_dashboard_widget != null) { Dashboard_Widget_VM_DTO _dto = Dashboard_Widget_VM_DTO_Convert.Dashboard_Widget_DTO_Convert_Table_To_DTO(tbl_dashboard_widget); _dto.BarDTO = new ChartBarDTO { Dashboard_Widget_Id = widget_Id }; _dto.DonutDTO = new ChartDonutDTO { Dashboard_Widget_Id = widget_Id }; _dto.GaugeDTO = new ChartGaugeDTO { Dashboard_Widget_Id = widget_Id }; _dto.HeapMapDTO = new ChartHeatMapDTO { Dashboard_Widget_Id = widget_Id }; _dto.PieDTO = new ChartPieDTO { Dashboard_Widget_Id = widget_Id }; _dto.StackedDTO = new ChartStackedDTO { Dashboard_Widget_Id = widget_Id }; _dto.LineDTO = new ChartLineDTO { Dashboard_Widget_Id = widget_Id }; _dto.TreeMapDTO = new ChartTreeMapDTO { Dashboard_Widget_Id = widget_Id }; _dto.CounterDTO = new ChartCounterDTO { Dashboard_Widget_Id = widget_Id }; return(_dto); } else { return(null); } }
public long Edit_Dashboard_Widget(Dashboard_Widget_VM_DTO dashboard_widget) { try { dashboard_widget = Set_Primary_Key_For_Multi_Metrics(dashboard_widget); tblDashboard_Widget tbl_dashboard_widget = _dbcontext.tblDashboard_Widget.Find(dashboard_widget.Id); tblDashboard_Widget tbl_dashboard_widget_new = Dashboard_Widget_VM_DTO_Convert.Dashboard_Widget_DTO_Convert_DTO_To_Table(dashboard_widget); _dbcontext.Entry(tbl_dashboard_widget).CurrentValues.SetValues(tbl_dashboard_widget_new); foreach (tblChart_Gauge tbl_dashboard_widget_Chart in tbl_dashboard_widget_new.tblChart_Gauge) { if (tbl_dashboard_widget_Chart.Id > 0) { _dbcontext.tblChart_Gauge.Attach(tbl_dashboard_widget_Chart); _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Modified; } else { _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Added; } } foreach (tblChart_Bar tbl_dashboard_widget_Chart in tbl_dashboard_widget_new.tblChart_Bar) { if (tbl_dashboard_widget_Chart.Id > 0) { _dbcontext.tblChart_Bar.Attach(tbl_dashboard_widget_Chart); _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Modified; } else { _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Added; } } foreach (tblChart_TreeMap tbl_dashboard_widget_Chart in tbl_dashboard_widget_new.tblChart_TreeMap) { if (tbl_dashboard_widget_Chart.Id > 0) { _dbcontext.tblChart_TreeMap.Attach(tbl_dashboard_widget_Chart); _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Modified; } else { _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Added; } } foreach (tblChart_Pie tbl_dashboard_widget_Chart in tbl_dashboard_widget_new.tblChart_Pie) { foreach (tblChart_Metric tbl_chart_metric in tbl_dashboard_widget_Chart.tblChart_Metric) { _dbcontext.Entry(tbl_chart_metric).State = System.Data.Entity.EntityState.Added; } if (tbl_dashboard_widget_Chart.Id > 0) { _dbcontext.tblChart_Pie.Attach(tbl_dashboard_widget_Chart); _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Modified; } else { _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Added; } } foreach (tblChart_Donut tbl_dashboard_widget_Chart in tbl_dashboard_widget_new.tblChart_Donut) { foreach (tblChart_Metric tbl_chart_metric in tbl_dashboard_widget_Chart.tblChart_Metric) { _dbcontext.Entry(tbl_chart_metric).State = System.Data.Entity.EntityState.Added; } if (tbl_dashboard_widget_Chart.Id > 0) { _dbcontext.tblChart_Donut.Attach(tbl_dashboard_widget_Chart); _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Modified; } else { _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Added; } } foreach (tblChart_Stacked tbl_dashboard_widget_Chart in tbl_dashboard_widget_new.tblChart_Stacked) { foreach (tblChart_Metric tbl_chart_metric in tbl_dashboard_widget_Chart.tblChart_Metric) { _dbcontext.Entry(tbl_chart_metric).State = System.Data.Entity.EntityState.Added; } if (tbl_dashboard_widget_Chart.Id > 0) { _dbcontext.tblChart_Stacked.Attach(tbl_dashboard_widget_Chart); _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Modified; } else { _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Added; } } foreach (tblChart_Line tbl_dashboard_widget_Chart in tbl_dashboard_widget_new.tblChart_Line) { foreach (tblChart_Metric tbl_chart_metric in tbl_dashboard_widget_Chart.tblChart_Metric) { _dbcontext.Entry(tbl_chart_metric).State = System.Data.Entity.EntityState.Added; } if (tbl_dashboard_widget_Chart.Id > 0) { _dbcontext.tblChart_Line.Attach(tbl_dashboard_widget_Chart); _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Modified; } else { _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Added; } } foreach (tblChart_Heatmap tbl_dashboard_widget_Chart in tbl_dashboard_widget_new.tblChart_Heatmap) { if (tbl_dashboard_widget_Chart.Id > 0) { _dbcontext.tblChart_Heatmap.Attach(tbl_dashboard_widget_Chart); _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Modified; } else { _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Added; } } foreach (tblChart_Counter tbl_dashboard_widget_Chart in tbl_dashboard_widget_new.tblChart_Counter) { if (tbl_dashboard_widget_Chart.Id > 0) { _dbcontext.tblChart_Counter.Attach(tbl_dashboard_widget_Chart); _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Modified; } else { _dbcontext.Entry(tbl_dashboard_widget_Chart).State = System.Data.Entity.EntityState.Added; } } _dbcontext.SaveChanges(); return(tbl_dashboard_widget.Id); } catch (Exception ex) { throw ex; } }
/// <summary> /// This function only those charts which has mutiple metrics /// </summary> /// <param name="dashboard_widget"></param> /// <returns></returns> private Dashboard_Widget_VM_DTO Set_Primary_Key_For_Multi_Metrics(Dashboard_Widget_VM_DTO dashboard_widget) { if (dashboard_widget.StackedDTO != null) { IEnumerable <tblChart_Metric> tbl_chart_metric = _dbcontext.tblChart_Metric.Where(chart_metric => chart_metric.Stacked_Chart_Id == dashboard_widget.StackedDTO.Id); if (tbl_chart_metric != null) { _dbcontext.tblChart_Metric.RemoveRange(tbl_chart_metric); _dbcontext.SaveChanges(); } foreach (int metric_id in dashboard_widget.StackedDTO.Chart_Metric_Ids) { dashboard_widget.StackedDTO.Chart_Id_Metric_Ids.Add(new Chart_Id_Metric_Ids() { Chart_Metric_Id = 0, Metric_Id = metric_id }); } } if (dashboard_widget.LineDTO != null) { IEnumerable <tblChart_Metric> tbl_chart_metric = _dbcontext.tblChart_Metric.Where(chart_metric => chart_metric.Line_Chart_Id == dashboard_widget.LineDTO.Id); if (tbl_chart_metric != null) { _dbcontext.tblChart_Metric.RemoveRange(tbl_chart_metric); _dbcontext.SaveChanges(); } foreach (int metric_id in dashboard_widget.LineDTO.Chart_Metric_Ids) { dashboard_widget.LineDTO.Chart_Id_Metric_Ids.Add(new Chart_Id_Metric_Ids() { Chart_Metric_Id = 0, Metric_Id = metric_id }); } } if (dashboard_widget.PieDTO != null) { IEnumerable <tblChart_Metric> tbl_chart_metric = _dbcontext.tblChart_Metric.Where(chart_metric => chart_metric.Pie_Chart_Id == dashboard_widget.PieDTO.Id); if (tbl_chart_metric != null) { _dbcontext.tblChart_Metric.RemoveRange(tbl_chart_metric); _dbcontext.SaveChanges(); } foreach (int metric_id in dashboard_widget.PieDTO.Chart_Metric_Ids) { dashboard_widget.PieDTO.Chart_Id_Metric_Ids.Add(new Chart_Id_Metric_Ids() { Chart_Metric_Id = 0, Metric_Id = metric_id }); } } if (dashboard_widget.DonutDTO != null) { IEnumerable <tblChart_Metric> tbl_chart_metric = _dbcontext.tblChart_Metric.Where(chart_metric => chart_metric.Donut_Chart_Id == dashboard_widget.DonutDTO.Id); if (tbl_chart_metric != null) { _dbcontext.tblChart_Metric.RemoveRange(tbl_chart_metric); _dbcontext.SaveChanges(); } foreach (int metric_id in dashboard_widget.DonutDTO.Chart_Metric_Ids) { dashboard_widget.DonutDTO.Chart_Id_Metric_Ids.Add(new Chart_Id_Metric_Ids() { Chart_Metric_Id = 0, Metric_Id = metric_id }); } } return(dashboard_widget); }