Example #1
0
        public ActionResult GetDateBasedChartImage(DateBasedFilterType filterType, DateBasedChartType chartType, DateTime startDate, DateTime endDate, Guid filterId)
        {
            IList <DateBasedStatistics> stats;

            switch (filterType)
            {
            case DateBasedFilterType.Regions:
                stats = _statisticsManager.GetRegionStatistics(startDate.ToUniversalTime(), endDate.ToUniversalTime().AddDays(1.0), filterId);
                break;

            case DateBasedFilterType.SipAccounts:
                stats = _statisticsManager.GetSipStatistics(startDate.ToUniversalTime(), endDate.ToUniversalTime().AddDays(1.0), filterId);
                break;

            default:
                stats = _statisticsManager.GetCodecTypeStatistics(startDate.ToUniversalTime(), endDate.ToUniversalTime().AddDays(1.0), filterId);
                break;
            }

            var chart = new Chart(800, 600)
                        .AddTitle(chartType == DateBasedChartType.NumberOfCalls ? Resources.Stats_Number_Of_Calls : Resources.Stats_Total_Call_Time_In_Minutes)
                        .SetXAxis(title: Resources.Date)
                        .AddSeries(
                chartType: "Column",
                xValue: stats.Select(s => s.Date.ToString("yyyy-MM-dd", CultureInfo.CreateSpecificCulture("sv-SE"))).ToArray(),
                yValues: stats.Select(s => chartType == DateBasedChartType.NumberOfCalls ? s.NumberOfCalls : s.TotaltTimeForCalls).ToArray())
            ;

            return(File(chart.GetBytes("png"), "image/png"));
        }
Example #2
0
        public ActionResult GetDateBasedChart(DateBasedFilterType filterType, DateBasedChartType chartType, DateTime startDate, DateTime endDate, Guid filterId)
        {
            var model = new DateBasedChartModel
            {
                FilterType = filterType,
                ChartType  = chartType,
                EndDate    = endDate,
                FilterId   = filterId,
                StartDate  = startDate
            };

            return(PartialView(model));
        }