//public JsonResult LineChart(string txtTargetDate, int ddlShift, int Interval, int agentCount) //{ // WFMDBDataContext db = new WFMDBDataContext(); // List<tblChart> lstCalls = db.uspWFMGetMinInboundCallPrediction(this.TenantID, txtTargetDate, txtTargetDate, ddlShift, Interval, 0, 0).ToList(); // LineChart line = new LineChart(); // List<Dataset> datasets = new List<Dataset>(); // Dataset inCallDs = new Dataset(); // string lables = ""; // int[] datas = new int[lstCalls.Count]; // int index = 0; // foreach (var item in lstCalls) // { // lables += "," + item.dtCreatedCall.ToString("HH:mm"); // datas[index] = item.iCountOfInboundCall; // index++; // } // inCallDs.data = datas; // line.labels = lables.Substring(1).Split(','); // inCallDs.fillColor = "rgba(151,187,205,0.2)"; // inCallDs.strokeColor = "rgba(151,187,205,1)"; // inCallDs.pointColor = "rgba(151,187,205,1)"; // inCallDs.pointStrokeColor = "#fff"; // inCallDs.label = "予測着信数"; // datasets.Add(inCallDs); // line.datasets = datasets; // HttpRuntime.Cache.Insert("chatLine", lstCalls); // return this.Json(line, JsonRequestBehavior.AllowGet); //} public JsonResult LineChartForAgent(string txtTargetDate, int ddlShift, int Interval, int agentCount, bool needRefresh) { var cacheValue = HttpRuntime.Cache.Get("chatLine"); List <tblChart> lstCalls = null; if (cacheValue == null || needRefresh) { WFMDBDataContext db = new WFMDBDataContext(); lstCalls = db.uspWFMGetMinInboundCallPrediction(this.TenantID, txtTargetDate, txtTargetDate, ddlShift, Interval, 0, 0).ToList(); } else { lstCalls = cacheValue as List <tblChart>; } LineChart line = new LineChart(); List <Dataset> datasets = new List <Dataset>(); Dataset inCallDs = new Dataset(); Dataset zero = new Dataset(); string lables = ""; int[] datas = new int[lstCalls.Count]; int[] zeroDatas = new int[lstCalls.Count]; int index = 0; foreach (var item in lstCalls) { lables += "," + item.dtCreatedCall.ToString("HH:mm"); datas[index] = item.iCountOfInboundCall - agentCount; zeroDatas[index] = 0; index++; } inCallDs.data = datas; line.labels = lables.Substring(1).Split(','); inCallDs.fillColor = "rgba(151,187,205,0.2)"; inCallDs.strokeColor = "rgba(151,187,205,1)"; inCallDs.pointColor = "rgba(151,187,205,1)"; inCallDs.pointStrokeColor = "#fff"; inCallDs.label = "予測着信数"; zero.data = zeroDatas; zero.fillColor = "rgba(255,0,0,1)"; zero.strokeColor = "rgba(255,0,0,1)"; zero.pointColor = "rgba(255,0,0,1)"; zero.pointStrokeColor = "#FF0"; zero.label = "基准"; datasets.Add(inCallDs); datasets.Add(zero); line.datasets = datasets; HttpRuntime.Cache.Insert("chatLine", lstCalls); return(this.Json(line, JsonRequestBehavior.AllowGet)); }
//public JsonResult LineChart(string txtTargetDate, int ddlShift, int Interval, int agentCount) //{ // WFMDBDataContext db = new WFMDBDataContext(); // List<tblChart> lstCalls = db.uspWFMGetMinInboundCallPrediction(this.TenantID, txtTargetDate, txtTargetDate, ddlShift, Interval, 0, 0).ToList(); // LineChart line = new LineChart(); // List<Dataset> datasets = new List<Dataset>(); // Dataset inCallDs = new Dataset(); // string lables = ""; // int[] datas = new int[lstCalls.Count]; // int index = 0; // foreach (var item in lstCalls) // { // lables += "," + item.dtCreatedCall.ToString("HH:mm"); // datas[index] = item.iCountOfInboundCall; // index++; // } // inCallDs.data = datas; // line.labels = lables.Substring(1).Split(','); // inCallDs.fillColor = "rgba(151,187,205,0.2)"; // inCallDs.strokeColor = "rgba(151,187,205,1)"; // inCallDs.pointColor = "rgba(151,187,205,1)"; // inCallDs.pointStrokeColor = "#fff"; // inCallDs.label = "予測着信数"; // datasets.Add(inCallDs); // line.datasets = datasets; // HttpRuntime.Cache.Insert("chatLine", lstCalls); // return this.Json(line, JsonRequestBehavior.AllowGet); //} public JsonResult LineChartForAgent(string txtTargetDate, int ddlShift, int Interval, int agentCount,bool needRefresh) { var cacheValue = HttpRuntime.Cache.Get("chatLine"); List<tblChart> lstCalls = null; if (cacheValue == null || needRefresh) { WFMDBDataContext db = new WFMDBDataContext(); lstCalls = db.uspWFMGetMinInboundCallPrediction(this.TenantID, txtTargetDate, txtTargetDate, ddlShift, Interval, 0, 0).ToList(); } else { lstCalls = cacheValue as List<tblChart>; } LineChart line = new LineChart(); List<Dataset> datasets = new List<Dataset>(); Dataset inCallDs = new Dataset(); Dataset zero = new Dataset(); string lables = ""; int[] datas = new int[lstCalls.Count]; int[] zeroDatas = new int[lstCalls.Count]; int index = 0; foreach (var item in lstCalls) { lables += "," + item.dtCreatedCall.ToString("HH:mm"); datas[index] = item.iCountOfInboundCall - agentCount; zeroDatas[index] = 0; index++; } inCallDs.data = datas; line.labels = lables.Substring(1).Split(','); inCallDs.fillColor = "rgba(151,187,205,0.2)"; inCallDs.strokeColor = "rgba(151,187,205,1)"; inCallDs.pointColor = "rgba(151,187,205,1)"; inCallDs.pointStrokeColor = "#fff"; inCallDs.label = "予測着信数"; zero.data = zeroDatas; zero.fillColor = "rgba(255,0,0,1)"; zero.strokeColor = "rgba(255,0,0,1)"; zero.pointColor = "rgba(255,0,0,1)"; zero.pointStrokeColor = "#FF0"; zero.label = "基准"; datasets.Add(inCallDs); datasets.Add(zero); line.datasets = datasets; HttpRuntime.Cache.Insert("chatLine", lstCalls); return this.Json(line, JsonRequestBehavior.AllowGet); }