public JsonResult GetProjectsTreeList() { var currentUserId = User.Identity.GetUserId(); GetProjectsAndSub createJson = new GetProjectsAndSub(); var treeList = createJson.getProjects((int)currentUserId); dynamic json = JsonConvert.DeserializeObject(treeList); return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult SlaMonthlyChartDetailTable(string projects, string month, string year) { SlaReport slaReport = new SlaReport(); SlaDetailTable dataTable = new SlaDetailTable(); GetProjectsAndSub calculate = new GetProjectsAndSub(); string selectedProjectNumbers = calculate.getProjects(projects); List <SingleSlaTable> singleSla = new List <SingleSlaTable>(); singleSla = slaReport.getSingleSlaTables("close", monthsNumber[month.Trim()], Convert.ToInt32(year.Trim()), selectedProjectNumbers); string filterTicketId = Request.QueryString["ticketId"]; string filterCreatedOn = Request.QueryString["created_on"]; string filterClosedOn = Request.QueryString["closed_on"]; string filterRate = Request.QueryString["rate"]; var result = from s in singleSla where (string.IsNullOrEmpty(filterTicketId) || s.id.Equals(filterTicketId)) && (string.IsNullOrEmpty(filterCreatedOn) || s.closed_on.Equals(filterCreatedOn)) && (string.IsNullOrEmpty(filterClosedOn) || s.success_rate.Equals(filterClosedOn)) && (string.IsNullOrEmpty(filterRate) || s.success_rate.Equals(filterRate)) select s; dataTable.data = result.ToArray(); dataTable.recordsTotal = singleSla.Count; dataTable.recordsFiltered = result.Count(); string link = "http://89.106.1.162/redmine/issues/"; for (int i = 0; i < singleSla.Count; i++) { singleSla[i].redmine_link = "<a href=" + link + singleSla[i].id + " target =\"_blank\">" + singleSla[i].id + "</a>"; singleSla[i].created_on_str = singleSla[i].created_on.ToString("dd/MM/yyyy HH:mm:ss"); singleSla[i].closed_on_str = singleSla[i].closed_on.ToString("dd/MM/yyyy HH:mm:ss"); } return(Json(dataTable, JsonRequestBehavior.AllowGet)); }
public JsonResult SlaMonthlyChart(string projectsName) { SlaReport sr = new SlaReport(); List <SingleSlaTable> singleSla = new List <SingleSlaTable>(); GetProjectsAndSub calculate = new GetProjectsAndSub(); string selectedProjectNumbers = calculate.getProjects(projectsName); Dictionary <string, List <string> > dictionary = new Dictionary <string, List <string> >(); double success_count; double fail_count; int month = DateTime.Now.Month; int year = DateTime.Now.Year; for (int i = 0; i < 12; i++) { success_count = 0; fail_count = 0; singleSla = sr.getSingleSlaTables("close", month, year, selectedProjectNumbers); for (int j = 0; j < singleSla.Count; j++) { if (singleSla[j].success_rate < 100) { success_count++; } else if (singleSla[j].success_rate >= 100) { fail_count++; } } double success_rate = Math.Round((success_count * 100) / (success_count + fail_count), 2); double fail_rate = Math.Round((fail_count * 100) / (success_count + fail_count), 2); List <string> successAndFail2 = new List <string>(); successAndFail2.Add(CheckNull(success_rate)); successAndFail2.Add(CheckNull(fail_rate)); dictionary[months[month]] = successAndFail2; if (month > 1) { month--; } else { month = 12; year -= 1; } } List <object> iData = new List <object>(); //Creating sample data DataTable dt = new DataTable(); dt.Columns.Add("ay", System.Type.GetType("System.String")); dt.Columns.Add("pozitif", System.Type.GetType("System.Double")); dt.Columns.Add("negatif", System.Type.GetType("System.Double")); int month_count = DateTime.Now.Month + 1; int yearlabel = DateTime.Now.Year - 1; for (int i = 0; i < dictionary.Count; i++) { DataRow dr = dt.NewRow(); dr["ay"] = yearlabel + " - " + months[month_count]; dr["pozitif"] = Math.Round(Convert.ToDouble(dictionary[months[month_count]][0]), 2); dr["negatif"] = Math.Round(Convert.ToDouble(dictionary[months[month_count]][1]), 2); dt.Rows.Add(dr); if (month_count < 12) { month_count++; } else { month_count = 1; yearlabel = DateTime.Now.Year; } } //Looping and extracting each DataColumn to List<Object> foreach (DataColumn dc in dt.Columns) { List <object> y = new List <object>(); y = (from DataRow drr in dt.Rows select drr[dc.ColumnName]).ToList(); iData.Add(y); } List <string> slaLable = new List <string>(); slaLable.Add(L("SlaProviders")); slaLable.Add(L("SlaPassed")); slaLable.Add(L("SlaMontlyPercent")); iData.Add(slaLable); //Source data returned as JSON return(Json(iData, JsonRequestBehavior.AllowGet)); }