public JsonResult ViewReportPage(string reportPath, int?page = 0)
        {
            var model = this.GetReportViewerModel(Request);

            model.ViewMode   = ReportViewModes.View;
            model.ReportPath = reportPath;

            var contentData = ReportServiceHelpers.ExportReportToFormat(model, ReportFormats.Html4_0, page, page);
            var content     = model.Encoding.GetString(contentData.ReportData);

            if (model.UseCustomReportImagePath && model.ReportImagePath.HasValue())
            {
                content = ReportServiceHelpers.ReplaceImageUrls(model, content);
            }

            var jsonResult = Json(
                new
            {
                CurrentPage = contentData.CurrentPage,
                Content     = content,
                TotalPages  = contentData.TotalPages
            },
                new Newtonsoft.Json.JsonSerializerSettings()
            {
                ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver()
            }
                );

            return(jsonResult);
        }
        public JsonResult FindStringInReport(string reportPath, string searchText, int?page = 0)
        {
            var model = this.GetReportViewerModel(Request);

            model.ViewMode   = ReportViewModes.View;
            model.ReportPath = reportPath;

            return(Json(ReportServiceHelpers.FindStringInReport(model, searchText, page).ToInt32()));
        }
Ejemplo n.º 3
0
 private void Init()
 {
     ReportViewModel            = ReportHelper.GetReportViewerModel(this.Request);
     ReportViewModel.ReportPath = ReportServiceHelpers.AddCharacterStartEnd(_configuration["Report:BitacoraFolder"], true, true, "/")
                                  + _configuration["Report:ReportName_Audit_Bitacora"]; // "/DemandaBI/Auditoria/Audit_Bitacora";
     ReportViewModel.Title          = "Bitácora";
     this.ControllerPath            = "/Bitacora/ReportBitacora";
     ReportViewModel.ControllerPath = this.ControllerPath;
 }
Ejemplo n.º 4
0
        public void OnGet()
        {
            ViewData["Message"] = "Indicadores de demanda de energía";
            ReportViewModel     = ReportHelper.GetReportViewerModel(this.Request);

            ReportViewModel.ReportPath = ReportServiceHelpers.AddCharacterStartEnd(_configuration["Report:DemandaFolder"], true, true, "/")
                                         + _configuration["Report:ReportName_DashBoardBI"]; // "/DemandaBI/DashBoardBI";
            ReportViewModel.Title = "Indicadores de demanda de energía";
        }
        public ActionResult PrintReport(string reportPath)
        {
            var model = this.GetReportViewerModel(Request);

            model.ViewMode   = ReportViewModes.Print;
            model.ReportPath = reportPath;

            var contentData = ReportServiceHelpers.ExportReportToFormat(model, ReportFormats.Html4_0);
            var content     = model.Encoding.GetString(contentData.ReportData);

            content = ReportServiceHelpers.ReplaceImageUrls(model, content);

            var sb = new System.Text.StringBuilder();

            sb.AppendLine("<html>");
            sb.AppendLine("	<body>");
            //sb.AppendLine($"		<img src='data:image/tiff;base64,{Convert.ToBase64String(contentData.ReportData)}' />");
            sb.AppendLine($"		{content}");
            sb.AppendLine("		<script type='text/javascript'>");
            sb.AppendLine("			(function() {");

            /*
             * sb.AppendLine("				var beforePrint = function() {");
             * sb.AppendLine("					console.log('Functionality to run before printing.');");
             * sb.AppendLine("				};");
             */
            sb.AppendLine("				var afterPrint = function() {");
            sb.AppendLine("					window.onfocus = function() { window.close(); };");
            sb.AppendLine("					window.onmousemove = function() { window.close(); };");
            sb.AppendLine("				};");

            sb.AppendLine("				if (window.matchMedia) {");
            sb.AppendLine("					var mediaQueryList = window.matchMedia('print');");
            sb.AppendLine("					mediaQueryList.addListener(function(mql) {");
            sb.AppendLine("						if (mql.matches) {");
            //sb.AppendLine("							beforePrint();");
            sb.AppendLine("						} else {");
            sb.AppendLine("							afterPrint();");
            sb.AppendLine("						}");
            sb.AppendLine("					});");
            sb.AppendLine("				}");

            //sb.AppendLine("				window.onbeforeprint = beforePrint;");
            sb.AppendLine("				window.onafterprint = afterPrint;");

            sb.AppendLine("			}());");
            sb.AppendLine("			window.print();");
            sb.AppendLine("		</script>");
            sb.AppendLine("	</body>");

            sb.AppendLine("<html>");

            return(Content(sb.ToString(), "text/html"));
        }
Ejemplo n.º 6
0
        public IActionResult OnGetDemandaDepartamento()
        {
            ViewData["Message"] = "DemandaDepartamento";

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            ReportViewModel            = ReportHelper.GetReportViewerModel(this.Request);
            ReportViewModel.ReportPath = ReportServiceHelpers.AddCharacterStartEnd(_configuration["Report:DemandaFolder"], true, true, "/")
                                         + _configuration["Report:ReportName_DemandaDepartamento"]; // "/DemandaBI/DemandaDepartamento";
            ReportViewModel.Title = "Demanda por geografía";

            return(Page());
        }
Ejemplo n.º 7
0
        public IActionResult OnGetDemandaComercialAgente(string agente)
        {
            ViewData["Message"] = "DemandaComercialAgente" + " - Agente: " + agente;

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            ReportViewModel            = ReportHelper.GetReportViewerModel(this.Request);
            ReportViewModel.ReportPath = ReportServiceHelpers.AddCharacterStartEnd(_configuration["Report:DemandaFolder"], true, true, "/")
                                         + _configuration["Report:ReportName_DemandaComercialAgente"]; // "/DemandaBI/DemandaComercialAgente";
            ReportViewModel.Title = "Demanda comercial por agente";

            return(Page());
        }
Ejemplo n.º 8
0
        public IActionResult OnGetDemandaRealComercialPerdida()
        {
            ViewData["Message"] = "DemandaRealComercialPerdida";

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            ReportViewModel            = ReportHelper.GetReportViewerModel(this.Request);
            ReportViewModel.ReportPath = ReportServiceHelpers.AddCharacterStartEnd(_configuration["Report:DemandaFolder"], true, true, "/")
                                         + _configuration["Report:ReportName_DemandaRealComercialPerdida"]; // "/DemandaBI/DemandaRealComercialPerdida";
            ReportViewModel.Title = "Demanda real comercial y pérdidas";

            return(Page());
        }
Ejemplo n.º 9
0
        public IActionResult OnGetBitacoraEstadistica()
        {
            ViewData["Message"] = "BitacoraEstadistica";

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            ReportViewModel            = ReportHelper.GetReportViewerModel(this.Request);
            ReportViewModel.ReportPath = ReportServiceHelpers.AddCharacterStartEnd(_configuration["Report:BitacoraFolder"], true, true, "/")
                                         + _configuration["Report:ReportName_Audit_BitacoraEstadisticas"]; // "/DemandaBI/Auditoria/Audit_BitacoraEstadisticas";
            ReportViewModel.Title = "Bitácora estadísticas de procesos";

            return(Page());
        }
Ejemplo n.º 10
0
        public JsonResult Execute(string reportPath, [FromBody] Dictionary <string, string[]> parameters, int page = 0)
        {
            try
            {
                var model = this.GetReportViewerModel(Request);

                model.ViewMode   = ReportViewModes.View;
                model.ReportPath = reportPath;

                if (parameters.Any())
                {
                    model.Parameters = parameters;
                }

                var contentData = ReportServiceHelpers.ExportReportToFormat(model, ReportFormats.Html4_0, page, page);
                var content     = model.Encoding.GetString(contentData.ReportData ?? new byte[] { });
                if (model.UseCustomReportImagePath && model.ReportImagePath.HasValue())
                {
                    content = ReportServiceHelpers.ReplaceImageUrls(model, content);
                }

                var jsonResult = Json(
                    new
                {
                    contentData.CurrentPage,
                    content,
                    contentData.Parameters,
                    contentData.TotalPages
                },
                    new Newtonsoft.Json.JsonSerializerSettings()
                {
                    ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
                }
                    );

                return(jsonResult);
            }
            catch (Exception exception)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(new
                {
                    ExceptionMessage = exception.Message,
                }));
            }
        }
        public FileResult ExportReport(string reportPath, string format)
        {
            var model = this.GetReportViewerModel(Request);

            model.ViewMode   = ReportViewModes.Export;
            model.ReportPath = reportPath;

            var extension = "";

            switch (format.ToUpper())
            {
            case "CSV":
                format    = "CSV";
                extension = ".csv";
                break;

            case "MHTML":
                format    = "MHTML";
                extension = ".mht";
                break;

            case "PDF":
                format    = "PDF";
                extension = ".pdf";
                break;

            case "TIFF":
                format    = "IMAGE";
                extension = ".tif";
                break;

            case "XML":
                format    = "XML";
                extension = ".xml";
                break;

            case "WORDOPENXML":
                format    = "WORDOPENXML";
                extension = ".docx";
                break;

            case "EXCELOPENXML":
            default:
                format    = "EXCELOPENXML";
                extension = ".xlsx";
                break;
            }

            var contentData = ReportServiceHelpers.ExportReportToFormat(model, format);

            var filename = reportPath;

            if (filename.Contains("/"))
            {
                filename = filename.Substring(filename.LastIndexOf("/"));
                filename = filename.Replace("/", "");
            }

            filename = filename + extension;

            return(File(contentData.ReportData, contentData.MimeType, filename));
        }