public ActionResult InterventionInteractionReportCSV(string from, string to) { int courseId = ActiveCourseUser.AbstractCourseID; //get options from the filter checkboxes Dictionary <string, bool> options = new Dictionary <string, bool>(); var filterTypes = OSBLEInteractionReportFiltersExtensions.GetValues <OSBLEInteractionReportFilters>(); foreach (var filter in filterTypes) { string filterName = OSBLEInteractionReportFiltersExtensions.Explode(filter); string filterOption = Request.Form[filterName]; if (!String.IsNullOrEmpty(filterOption)) { options.Add(filterName, true); } } List <OSBLEInterventionReportItem> interventionReport = DBHelper.GetInterventionInteractionReport(courseId, Convert.ToDateTime(from), Convert.ToDateTime(to), options); //make a csv for export var csv = new StringBuilder(); csv.Append(String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16}{17}", "FirstName", "LastName", "AbstractCourseID", "OSBLEInterventionId", "InteractionDateTime", "InteractionDetails", "InterventionFeedback", "InterventionDetailBefore", "InterventionDetailAfter", "AdditionalActionDetails", "InterventionTrigger", "InterventionType", "InterventionTemplateText", "InterventionSuggestedCode", "IsDismissed", "RefreshThreshold", "ShowInIDESuggestions", Environment.NewLine)); foreach (var row in interventionReport) { var newLine = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16}{17}", row.FirstName, row.LastName, row.CourseId, row.OSBLEInterventionId, row.InteractionDateTime, row.InteractionDetails, row.InterventionFeedback, row.InterventionDetailBefore, row.InterventionDetailAfter, row.AdditionalActionDetails, row.InterventionTrigger, row.InterventionType, row.InterventionTemplateText, row.InterventionSuggestedCode, row.IsDismissed, row.RefreshThreshold, row.ShowInIDESuggestions, Environment.NewLine); csv.Append(newLine); } const string contentType = "text/plain"; var bytes = Encoding.UTF8.GetBytes(csv.ToString()); return(File(bytes, contentType, "Intervention Interaction " + DateTime.Now + " (Exported Report).csv")); }
public ActionResult InterventionInteractionReport(string from, string to) { int courseId = ActiveCourseUser.AbstractCourseID; //get options from the filter checkboxes Dictionary <string, bool> options = new Dictionary <string, bool>(); var filterTypes = OSBLEInteractionReportFiltersExtensions.GetValues <OSBLEInteractionReportFilters>(); foreach (var filter in filterTypes) { string filterName = OSBLEInteractionReportFiltersExtensions.Explode(filter); string filterOption = Request.Form[filterName]; if (!String.IsNullOrEmpty(filterOption)) { options.Add(filterName, true); } } List <OSBLEInterventionReportItem> interventionReport = DBHelper.GetInterventionInteractionReport(courseId, Convert.ToDateTime(from), Convert.ToDateTime(to), options); ViewBag.ReportItems = interventionReport; return(View()); }