private FileResult ExportPerformanceReport(vmAdmin_PerformanceReport report, vmAdmin_PerformanceFilter filter, string title, string filename) { int rowNumber = 0; NPOI.SS.UserModel.IRow row; //Create new Excel workbook var workbook = new HSSFWorkbook(); //Create new Excel sheet var sheet = CreateSheet(workbook); var allStyles = ReportUtilities.CreateStyles(workbook); ReportUtilities.ExportReportHeader(title, sheet, allStyles, ref rowNumber); ExportReportSubheader(sheet, filter, allStyles, ref rowNumber); ExportReportValues(report, sheet, allStyles, ref rowNumber); ExportReportTshirts(report, sheet, allStyles, ref rowNumber); ExportReportFees(report, sheet, allStyles, ref rowNumber); ExportReportCharges(report, sheet, allStyles, ref rowNumber); //Write the workbook to a memory stream var output = new MemoryStream(); workbook.Write(output); //Return the result to the end user return(File(output.ToArray(), //The binary data of the XLS file "application/vnd.ms-excel", //MIME type of Excel files filename)); //Suggested file name in the "Save as" dialog which will be displayed to the end user }
public ActionResult EventPerformance(vmAdmin_EventFilter filter) { var eventFilter = SetEventFilter(filter); if (filter.EventId.HasValue) { var performanceFilter = new vmAdmin_PerformanceFilter { EventId = filter.EventId }; performanceFilter = SetPerformanceFilter(performanceFilter); var sizeTotals = (_service as ReportingService).GetTShirtSizeTotalsByEventId((int)filter.EventId); var vm = new vmAdmin_EventPerformance { Filter = eventFilter, Report = GetPerformanceReport(performanceFilter) }; if (sizeTotals != null) { vm.Report.TShirtSizes = (List <Dictionary <String, int> >)sizeTotals; } else { vm.Report.TShirtSizes = new List <Dictionary <String, int> >(); } return(View(vm)); } return(View(new vmAdmin_EventPerformance { Filter = eventFilter, Report = new vmAdmin_PerformanceReport() })); }
public FileResult ExportPerformance(vmAdmin_PerformanceFilter filter) { vmAdmin_PerformanceFilter performanceFilter = SetPerformanceFilter(filter); var report = GetPerformanceReport(performanceFilter); return(ExportPerformanceReport(report, performanceFilter, "Performance Report", "PerformanceExport.xls")); }
public ActionResult Performance(vmAdmin_PerformanceFilter filter) { var performanceFilter = SetPerformanceFilter(filter); var vm = new vmAdmin_Performance { Filter = performanceFilter, Report = GetPerformanceReport(performanceFilter) }; return(View(vm)); }
private vmAdmin_PerformanceFilter SetPerformanceFilter(vmAdmin_PerformanceFilter filter) { var newFilter = new vmAdmin_PerformanceFilter { EventList = GetEventList(), EventId = filter.EventId, startDate = filter.startDate, endDate = filter.endDate, fullEvent = false }; if (filter.EventId.HasValue) { var evt = _service.GetEventById(filter.EventId.Value); if (!filter.startDate.HasValue) { newFilter.startDate = evt.EventFees.Min(x => x.EffectiveDate).Date; newFilter.fullEvent = true; } if (!filter.endDate.HasValue) { newFilter.endDate = DateTime.Now >= evt.EventDates.Max(x => x.DateOfEvent).Date ? evt.EventDates.Max(x => x.DateOfEvent) : DateTime.Now.Date; } } else { if (!filter.startDate.HasValue) { newFilter.startDate = DateTime.Now.AddDays(-(DateTime.Now.Day - 1)).Date; } if (!filter.endDate.HasValue) { newFilter.endDate = DateTime.Now.Date; } } newFilter.endDate = newFilter.endDate.Value.AddDays(1).Date.AddSeconds(-1); return(newFilter); }
private void ExportReportSubheader(NPOI.SS.UserModel.ISheet sheet, vmAdmin_PerformanceFilter filter, StyleContainer allStyles, ref int rowNumber) { var row = sheet.CreateRow(rowNumber++); if (filter.EventId.HasValue && filter.EventId.Value > 0) { var thisEvent = _service.GetEventById(filter.EventId.Value); ReportUtilities.CreateCell(row, 0, string.Format("{0} - {1}", thisEvent.GeneralLocality, thisEvent.EventDates.Min().DateOfEvent.ToShortDateString()), allStyles.Header2Style); row = sheet.CreateRow(rowNumber++); } else { if (filter.startDate.HasValue) { var value = string.Format("Events from {0} to {1}", filter.startDate.Value.ToShortDateString(), filter.endDate.Value.ToShortDateString()); ReportUtilities.CreateCell(row, 0, value, allStyles.Header2Style); row = sheet.CreateRow(rowNumber++); } } }
public FileResult ExportEventPerformance(vmAdmin_EventFilter filter) { var performanceFilter = new vmAdmin_PerformanceFilter { EventId = filter.EventId }; performanceFilter = SetPerformanceFilter(performanceFilter); var sizeTotals = (_service as ReportingService).GetTShirtSizeTotalsByEventId((int)filter.EventId); var report = GetPerformanceReport(performanceFilter); if (sizeTotals != null) { report.TShirtSizes = (List <Dictionary <String, int> >)sizeTotals; } else { report.TShirtSizes = new List <Dictionary <String, int> >(); } return(ExportPerformanceReport(report, performanceFilter, "Event Performance", "EventPerformance.xls")); }
private vmAdmin_PerformanceReport GetPerformanceReport(vmAdmin_PerformanceFilter filter) { DateTime sDate = filter.startDate.Value; if (filter.fullEvent && filter.EventId.HasValue) // if getting a single event, set the start back to the oldest registration { var regs = _service.GetRegistrationsByEventId(filter.EventId.Value); if (regs.Any()) { sDate = regs.Min(x => x.DateAdded); } } return(new vmAdmin_PerformanceReport { FeeReport = _service.GetFeeReport(filter.EventId, sDate, filter.endDate.Value), ChargeReport = _service.GetEventChargeReport(filter.EventId, sDate, filter.endDate.Value), DayCount = (filter.endDate.Value - sDate).Days + 1, TotalSpots = _service.GetSpotsAvailable(filter.EventId, sDate, filter.endDate.Value), SpotsTaken = _service.GetSpotsTaken(filter.EventId, sDate, filter.endDate.Value), RedemptionRegCount = _service.GetRedemptionSpots(filter.EventId, sDate, filter.endDate.Value), EventCount = _service.GetEventCount(filter.EventId, sDate, filter.endDate.Value) }); }
public ActionResult _AjaxPerformanceReport(vmAdmin_PerformanceFilter filter) { var report = GetPerformanceReport(filter); return(PartialView("partial/PerformanceReport", report)); }