public JsonResult GetIncomingOutgoingThirdArea(String iIntervalStart, String iIntervalEnd, String culture, String scope) { try { DateTime intervalStart = DateTime.ParseExact(iIntervalStart, "yyyy-MM-dd", CultureInfo.InvariantCulture); DateTime intervalEnd = DateTime.ParseExact(iIntervalEnd, "yyyy-MM-dd", CultureInfo.InvariantCulture); intervalEnd = intervalEnd.Date.AddHours(23).AddMinutes(59).AddSeconds(59); IEnumerable<WorkingPoint> workingPoints = mEFInterface.GetWorkingPointsForAUser(scope, User.Identity.Name, context); var incomingNoOfSms = ComputeNoOfIncomingSms(intervalStart, intervalEnd, workingPoints); var outgoingNoOfSms = ComputeNoOfOutgoingSms(intervalStart, intervalEnd, workingPoints); // Prepare Json result var row1 = new RepDataRow(new RepDataRowCell[] { new RepDataRowCell(Resources.Global.RepIncomingSmsChart, Resources.Global.RepIncomingSmsChart), new RepDataRowCell(incomingNoOfSms, incomingNoOfSms + " sms") }); var row2 = new RepDataRow(new RepDataRowCell[] { new RepDataRowCell(Resources.Global.RepOutgoingSmsChart, Resources.Global.RepOutgoingSmsChart), new RepDataRowCell(outgoingNoOfSms, outgoingNoOfSms + " sms") }); List<RepDataRow> content = new List<RepDataRow>(); content.Add(row1); content.Add(row2); RepChartData chartSource = new RepChartData(new RepDataColumn[] { new RepDataColumn("17", Constants.STRING_COLUMN_TYPE, Resources.Global.RepTypeTable), new RepDataColumn("18", Constants.STRING_COLUMN_TYPE, Resources.Global.RepValueTable) }, content); return Json(chartSource, JsonRequestBehavior.AllowGet); } catch (Exception e) { logger.Error("GetIncomingOutgoingThirdArea", e); } return Json("Request failed", JsonRequestBehavior.AllowGet); }
public JsonResult GetPosNegTransitionsThirdArea(String iIntervalStart, String iIntervalEnd, String culture, String scope) { DateTime intervalStart = DateTime.ParseExact(iIntervalStart, "yyyy-MM-dd", CultureInfo.InvariantCulture); DateTime intervalEnd = DateTime.ParseExact(iIntervalEnd, "yyyy-MM-dd", CultureInfo.InvariantCulture); intervalEnd = intervalEnd.Date.AddHours(23).AddMinutes(59).AddSeconds(59); KeyAndCount posToNegTransitions = new KeyAndCount(Constants.POS_TO_NEG_EVENT, 0); KeyAndCount negToPosTransitions = new KeyAndCount(Constants.NEG_TO_POS_EVENT, 0); IEnumerable<WorkingPoint> workingPoints = mEFInterface.GetWorkingPointsForAUser(scope, User.Identity.Name, context); foreach (var wp in workingPoints) { foreach (var conv in wp.Conversations) { if (!conv.Client.isSupportClient) { IEnumerable<KeyAndCount> convEvents = from convEvent in conv.ConversationEvents where ((convEvent.EventTypeName.Equals(Constants.POS_TO_NEG_EVENT) || convEvent.EventTypeName.Equals(Constants.NEG_TO_POS_EVENT)) && (convEvent.Date >= intervalStart && convEvent.Date <= intervalEnd)) group convEvent by new { eventType = convEvent.EventTypeName } into g select new KeyAndCount(g.Key.eventType, g.Count()); foreach (var eventType in convEvents) { if (eventType.key.Equals(Constants.POS_TO_NEG_EVENT)) posToNegTransitions.count += eventType.count; else if (eventType.key.Equals(Constants.NEG_TO_POS_EVENT)) negToPosTransitions.count += eventType.count; } } } } List<RepDataRow> content = new List<RepDataRow>(); RepDataRow row1 = new RepDataRow(new RepDataRowCell[] { new RepDataRowCell(Resources.Global.RepPosToNegFeedback, Resources.Global.RepPosToNegFeedback), new RepDataRowCell(posToNegTransitions.count, posToNegTransitions.count + " " + Resources.Global.RepPosToNegFeedback) }); RepDataRow row2 = new RepDataRow(new RepDataRowCell[] { new RepDataRowCell(Resources.Global.RepNegToPosFeedback, Resources.Global.RepNegToPosFeedback), new RepDataRowCell(negToPosTransitions.count, negToPosTransitions.count + " " + Resources.Global.RepNegToPosFeedback) }); content.Add(row1); content.Add(row2); RepChartData chartSource = new RepChartData(new RepDataColumn[] { new RepDataColumn("17", Constants.STRING_COLUMN_TYPE, Resources.Global.RepTypeTable), new RepDataColumn("18", Constants.STRING_COLUMN_TYPE, Resources.Global.RepValueTable) }, content); return Json(chartSource, JsonRequestBehavior.AllowGet); }