/// <summary> /// Generates a report using the default or custom report template with optional sort expression and filter applied to the dataset. /// </summary> /// <param name="args">A collection of parameters that control the report generation.</param> /// <returns>A binary array representing the report data.</returns> public static byte[] Execute(ReportArgs args) { ReportBase reportHandler = ((ReportBase)(ApplicationServices.CreateInstance("MyCompany.Handlers.Report"))); Stream output = new MemoryStream(); reportHandler.OutputStream = output; reportHandler.Arguments = args; PageRequest request = new PageRequest(); reportHandler.Request = request; request.Controller = args.Controller; request.View = args.View; request.SortExpression = args.SortExpression; if (args.Filter != null) { DataViewExtender dve = new DataViewExtender(); dve.AssignStartupFilter(args.Filter); request.Filter = ((List <string>)(dve.Properties["StartupFilter"])).ToArray(); } ((IHttpHandler)(reportHandler)).ProcessRequest(HttpContext.Current); // return report data output.Position = 0; byte[] data = new byte[output.Length]; output.Read(data, 0, data.Length); return(data); }
/// <summary> /// Generates a report using the default or custom report template with optional sort expression and filter applied to the dataset. /// </summary> /// <param name="args">A collection of parameters that control the report generation.</param> /// <returns>A binary array representing the report data.</returns> public static byte[] Execute(ReportArgs args) { Report reportHandler = new Report(); Stream output = new MemoryStream(); reportHandler.OutputStream = output; reportHandler.Arguments = args; PageRequest request = new PageRequest(); reportHandler.Request = request; request.Controller = args.Controller; request.View = args.View; request.SortExpression = args.SortExpression; if (args.Filter != null) { DataViewExtender dve = new DataViewExtender(); dve.AssignStartupFilter(args.Filter); request.Filter = ((List<string>)(dve.Properties["StartupFilter"])).ToArray(); } ((IHttpHandler)(reportHandler)).ProcessRequest(HttpContext.Current); // return report data output.Position = 0; byte[] data = new byte[output.Length]; output.Read(data, 0, data.Length); return data; }