public override void ExecuteResult(ControllerContext context)
        {
            string defaultExtension = Config.Report.Writers[Config.Report.DefaultWriter].FileExtension;

            string extension = Path.GetExtension(context.HttpContext.Request.RawUrl);
            if(string.IsNullOrEmpty(extension))
            {
                extension = defaultExtension;
            }

            WriterElement e = Config.Report.Writers.GetWriterConfigurationForFileExtension(extension);
            if(e == null)
                throw new InvalidOperationException(string.Format("Unable to locate a report writer for the extension '{0}'. Did you add this fileExtension to the web.config for DoddleReport?", extension));

            var writer = e.LoadWriter();

            context.HttpContext.Response.ContentType = e.ContentType;
            
            writer.WriteReport(_report, context.HttpContext.Response.OutputStream);
        }
        public virtual void ProcessRequest(HttpContext context)
        {
            Context = context;
            string format = GetReportType(context);

            elementConfig = Config.Report.Writers[format];

            context.Response.ContentType = elementConfig.ContentType;

            if (OfferDownload)
            {
                context.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}{1}", FileName, elementConfig.FileExtension));
            }

            Report report = new Report();

            report.Source = ReportSource;

            CustomizeReport(report);

            IReportWriter writer = elementConfig.LoadWriter();

            writer.WriteReport(report, context.Response.OutputStream);
        }
Esempio n. 3
0
        public virtual void ProcessRequest(HttpContext context)
        {
            string format = GetReportType(context);

            _elementConfig = Config.Report.Writers.GetWriterConfigurationByFormat(format);

            context.Response.ContentType = _elementConfig.ContentType;

            if (OfferDownload)
            {
                var extension = Path.HasExtension(FileName) ? "" : _elementConfig.FileExtension;
                context.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}{1}", FileName, extension));
            }

            var report = new Report {
                Source = ReportSource
            };

            CustomizeReport(report);

            var writer = _elementConfig.LoadWriter();

            writer.WriteReport(report, context.Response.OutputStream);
        }