コード例 #1
0
        public ActionResult ExportChart(long IdModuloActual)
        {
            switch (IdModuloActual)
            {
            case 13010300:
                ChartControlSettings settings = ChartHelpers.GetChartSettings();
                using (MemoryStream stream = new MemoryStream())
                {
                    settings.SaveToStream(stream);
                    stream.Seek(0, SeekOrigin.Begin);
                    WebChartControl chartControl = new WebChartControl();
                    chartControl.LoadFromStream(stream);
                    chartControl.Width      = Convert.ToInt16(settings.Width.Value);
                    chartControl.Height     = Convert.ToInt16(settings.Height.Value);
                    chartControl.DataSource = new DataView(ChartHelpers.GenerateDataIO(Metodos.GetDataGraficoImpactoOperacional()));
                    var pcl = new PrintableComponentLink(new PrintingSystem());
                    pcl.Component = ((IChartContainer)chartControl).Chart;
                    pcl.Landscape = true;
                    pcl.CreateDocument();

                    using (var exstream = new MemoryStream())
                    {
                        pcl.PrintingSystem.ExportToPdf(exstream);
                        byte[] buf = new byte[(int)exstream.Length];
                        exstream.Seek(0, SeekOrigin.Begin);
                        exstream.Read(buf, 0, buf.Length);

                        return(File(buf, "application/pdf", "chart" + Guid.NewGuid().ToString() + ".pdf"));
                    }
                }

            case 13010600:
                //< div id = "multichart" >

                //     < div class="MTD">
                //        <div class="Titulo">
                //            @Html.Raw(Resources.ReporteResource.captionMDTHeader)
                //        </div>
                //        @Html.Partial("GraficoMTDPartialView", Model.DataMTD)
                //    </div>
                //    <div class="RPO">
                //        <div class="Titulo">
                //            @Html.Raw(Resources.ReporteResource.captionRPOHeader)
                //        </div>
                //        @Html.Partial("GraficoRPOPartialView", Model.DataRPO)
                //    </div>
                //    <div class="RTO">
                //        <div class="Titulo">
                //            @Html.Raw(Resources.ReporteResource.captionRTOHeader)
                //        </div>
                //        @Html.Partial("GraficoRTOPartialView", Model.DataRTO)
                //    </div>
                //    <div class="WRT">
                //        <div class="Titulo">
                //            @Html.Raw(Resources.ReporteResource.captionWRTHeader)
                //        </div>
                //        @Html.Partial("GraficoWRTPartialView", Model.DataWRT)
                //    </div>
                //</div>
                break;

            case 13010900:
                //chartControl.DataSource = new DataView(ChartHelpers.GenerateDataIO(Metodos.GetNroProcesosByImpactoOperacional()));
                break;
            }
            return(null);
        }