public JsonResult InitializeMonthlyRFCReport(IenumerableReportResult model, string param)
        {
            if (string.IsNullOrEmpty(param))
            {
                return(Json(new { status = false, resCode = "0", msg = "Something went wrong with report parameters. Please re-generate report or contact support. Thank you." }, JsonRequestBehavior.AllowGet));
            }

            string[] values = User.Identity.Name.Split('|');

            ReportClass rptH = new ReportClass();


            rptH.FileName = Server.MapPath("~/CrystalReport/rptDailyReport.rpt");

            rptH.Load();

            Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            rptH.Close();
            rptH.Dispose();
            rptH = null;

            Session["MonthlyRFCRptSession"] = stream;
            string pdfname = "daily-report" + DateTime.Now;

            return(Json(new { status = true, resCode = "1", msg = "Success", pdfName = pdfname }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public Stream GetReportPDF(object report, Dictionary <string, object> items)
        {
            // ReportDocument rd = new ReportDocument();
            ReportClass reporte = (ReportClass)report;

            reporte.Load();
            foreach (var item in items)
            {
                if (item.Key.Split('.')?.ToList()?.Count() > 1)
                {
                    string subReport  = item.Key.Split('.')[0];
                    string dataSource = item.Key.Split('.')[1];
                    reporte.Subreports[subReport].Database.Tables[dataSource].SetDataSource(item.Value);
                }
                else
                {
                    reporte.Database.Tables[item.Key].SetDataSource(item.Value);
                }
            }
            //reporte.SetDataSource(items);

            Stream stream = reporte.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            reporte.Close();
            return(stream);
        }
        public ActionResult DescargarReporteAsignaciones(int?id)
        {
            try
            {
                //var asignaciones = ProyectoCN.ListarAsignaciones();

                var rptH = new ReportClass();
                rptH.FileName = Server.MapPath("/Reportes/AsignacionReport.rpt");
                rptH.Load();

                if (id == null)
                {
                    rptH.SetDataSource(ProyectoCN.ListarAsignaciones());
                }
                else
                {
                    rptH.SetDataSource(ProyectoCN.ListarAsignaciones(id.Value));
                }

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                //En PDF
                Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat);
                rptH.Dispose();
                rptH.Close();
                return(new FileStreamResult(stream, "application/pdf"));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public ActionResult DescargarReporteProyectos()
        {
            try
            {
                var proyectos = ProyectoCN.ListarProyectos();

                var rptH = new ReportClass();
                rptH.FileName = Server.MapPath("/Reportes/ProyectosListas.rpt");
                rptH.Load();

                rptH.SetDataSource(proyectos);

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                //En PDF
                Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat);
                rptH.Dispose();
                rptH.Close();
                return(new FileStreamResult(stream, "application/pdf"));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #5
0
        public static void exportarReporte(ReportClass pReporte,
                                           string pNombre,
                                           string pFormula,
                                           ExportFormatType pFormato)
        {
            try
            {
                PrincipalUI.cursorEnEspera();
                ConnectionInfo connInfo = obtenerConexionReporte();
                SetDBLogonForReport(connInfo, pReporte);
                SetDBLogonForSubreports(connInfo, pReporte);
                if (pFormula != null)
                {
                    pReporte.RecordSelectionFormula = pFormula;
                }
                string ruta = System.IO.Path.GetTempPath() +
                              pNombre +
                              DateTime.Now.Ticks +
                              obtenerExtensionReporte(pFormato.ToString());

                pReporte.ExportToDisk(pFormato, ruta);
                pReporte.Load(ruta);
                pReporte.Close();
                Process.Start(ruta);
            }
            catch (Exception ex)
            {
                Mensajes.mensajeError(ex);
            }
            PrincipalUI.cursorPredeterminado();
        }
Пример #6
0
        public ActionResult DescargarVentaProductos()
        {
            try
            {
                var rptH = new ReportClass();
                rptH.FileName = Server.MapPath("/Reportes/ReportesProductos/VentaProductos.rpt");
                rptH.Load();

                var            connInfo  = CrystalReportCnn.GetConnectionInfo();
                TableLogOnInfo logOnInfo = new TableLogOnInfo();
                Tables         tables;
                tables = rptH.Database.Tables;
                foreach (Table table in tables)
                {
                    logOnInfo = table.LogOnInfo;
                    logOnInfo.ConnectionInfo = connInfo;
                    table.ApplyLogOnInfo(logOnInfo);
                }

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat);
                rptH.Dispose();
                rptH.Close();

                return(new FileStreamResult(stream, "application/pdf"));
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #7
0
        public Stream GetReportPDF(ReportClass report)
        {
            Stream stream = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            report.Close();

            return(stream);
        }
Пример #8
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     stop = true;
     if (rpt != null)
     {
         rpt.Close();
         rpt.Dispose();
     }
 }
Пример #9
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (rpt != null)
     {
         rpt.Close();
         rpt.Dispose();
     }
     if (thread != null)
     {
         thread.Abort();
     }
 }
Пример #10
0
        public Stream GetReportPDF <TItemSource>(Object report, List <TItemSource> items)
        {
            // ReportDocument rd = new ReportDocument();
            ReportClass reporte = (ReportClass)report;

            reporte.Load();
            //reporte.Database.Tables[""].SetDataSource()
            reporte.SetDataSource(items);

            Stream stream = reporte.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            reporte.Close();
            return(stream);
        }
Пример #11
0
        private void Page_Unload(object sender, EventArgs e)
        {
            if (cr != null)
            {
                cr.Close();
                cr.Dispose();
                GC.Collect();
            }

            queryEncrypt = null;
            query        = null;
            filtros      = null;
            rpt          = null;
            tipo         = null;
        }
        public JsonResult InitializeHistoryReport(IenumerableReportResult model, string param)
        {
            if (string.IsNullOrEmpty(param))
            {
                return(Json(new { status = false, resCode = "0", msg = "Something went wrong with report parameters. Please re-generate report or contact support. Thank you." }, JsonRequestBehavior.AllowGet));
            }

            string[]       values     = User.Identity.Name.Split('|');
            string[]       paramValue = param.Split('|');
            ReportClass    rptH       = new ReportClass();
            dsTransHistory ds         = new dsTransHistory();

            try
            {
                DataTable dt = ListToDataTable.ToDataTable(model.HistoryReport);

                rptH.FileName = Server.MapPath("~/CrystalReport/rptTransHistory.rpt");
                rptH.Load();

                ds.Tables[0].Merge(dt);
                rptH.SetDataSource(ds);

                rptH.SetParameterValue("@date", paramValue[0].Trim().ToUpper());
                rptH.SetParameterValue("@printBy", paramValue[2].Trim());
                rptH.SetParameterValue("@runDate", paramValue[1].Trim().ToUpper());
                rptH.SetParameterValue("@TotalCredit", Convert.ToDecimal(paramValue[6].Trim()));
                rptH.SetParameterValue("@TotalDebit", Convert.ToDecimal(paramValue[4].Trim()));
                rptH.SetParameterValue("@EndingBalance", Convert.ToDecimal(paramValue[7].Trim()));
                rptH.SetParameterValue("@CreditCount", Convert.ToInt32(paramValue[5].Trim()));
                rptH.SetParameterValue("@DebitCount", Convert.ToInt32(paramValue[3].Trim()));
            }
            catch (Exception ex)
            {
                return(Json(new { status = false, resCode = "0", msg = ex.Message }, JsonRequestBehavior.AllowGet));
            }


            Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            rptH.Close();
            rptH.Dispose();
            rptH = null;

            Session["HistorySession"] = stream;
            string pdfname = "history-report" + DateTime.Now;

            return(Json(new { status = true, resCode = "1", msg = "Success", pdfName = pdfname }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DescargarReporteEmpleado(int codigo, string algo)
        //public ActionResult DescargarReporteEmpleado(int codigo)
        {
            try
            {
                var rptH = new ReportClass();
                rptH.FileName = Server.MapPath("/Reportes/EmpleadoReporte1.rpt");
                rptH.Load();

                // por parametro
                rptH.SetParameterValue("DptoId", codigo);
                //rptH.SetParameterValue("ParamAlgo", algo);

                // Report connection
                var            connInfo  = CrystalReportsCnn.GetConnectionInfo();
                TableLogOnInfo logonInfo = new TableLogOnInfo();
                Tables         tables;
                tables = rptH.Database.Tables;
                foreach (Table table in tables)
                {
                    logonInfo = table.LogOnInfo;
                    logonInfo.ConnectionInfo = connInfo;
                    table.ApplyLogOnInfo(logonInfo);
                }

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                // Descargar en PDF
                Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat);
                rptH.Dispose();
                rptH.Close();
                return(new FileStreamResult(stream, "application/pdf"));

                // Descargar en Excel
                //Stream stream = rptH.ExportToStream(ExportFormatType.Excel);
                //stream.Seek(0, SeekOrigin.Begin);
                //return File(stream, "application/vnd.ms-excel", "empleadoRpt.xls");
            }
            catch (Exception ex)
            {
                return(Json(new { ok = false, msg = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #14
0
        public byte[] readRPT()
        {
            ReportClass rptH = new ReportClass();
            try
            {
                ParameterDiscreteValue par;
                rptH.FileName = file;
                rptH.Load();

                rptH.SetDataSource(listData["table"]);

                foreach (ReportDocument subreport in rptH.Subreports)
                {
                    if (listData.ContainsKey(subreport.Name.Trim().ToLower()))
                    {
                        subreport.SetDataSource(listData[subreport.Name.Trim().ToLower()]);
                    }
                }

                parameters = insencitiveParameter();
                foreach (ParameterField field in rptH.ParameterFields)
                {
                    if (parameters != null)
                    {
                        if (parameters.ContainsKey(field.Name.Trim().ToLower()))
                        {
                            par = new ParameterDiscreteValue();
                            par.Value = parameters[field.Name.Trim().ToLower()];
                            field.CurrentValues.Add(par);
                        }
                    }
                }

                System.IO.Stream stream = rptH.ExportToStream(this.type);
                byte[] buffer = new byte[stream.Length];
                stream.Read(buffer, 0, (int)stream.Length);

                return buffer;
            }
            finally
            {
                rptH.Close();
                rptH.Dispose();
            }
        }
Пример #15
0
        /*
         * sin parametro
         * public ActionResult DescargarReporte_empleado()
         * {
         *  try
         *  {
         *      var rptH = new ReportClass();
         *      rptH.FileName = Server.MapPath("/Reportes/EmpleadoReporte.rpt");
         *      rptH.Load();
         *
         *      // Report connection
         *      var conInfo = CrystalReportCn.GetConnectionInfo();
         *      TableLogOnInfo logonInfo = new TableLogOnInfo();
         *      Tables tables;
         *      tables = rptH.Database.Tables;
         *      foreach (Table table in tables)
         *      {
         *          logonInfo = table.LogOnInfo;
         *          logonInfo.ConnectionInfo = conInfo;
         *          table.ApplyLogOnInfo(logonInfo);
         *      }
         *
         *      Response.Buffer = false;
         *      Response.ClearContent();
         *      Response.ClearHeaders();
         *
         *      Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat);
         *      rptH.Dispose();
         *      rptH.Close();
         *      return new FileStreamResult(stream, "application/pdf");
         *
         *      //Stream stream = rptH.ExportToStream(ExportFormatType.Excel);
         *      //stream.Seek(0,SeekOrigin.Begin);
         *      //return File(stream, "application/vnd.ms-excel","EmpleadoRpt.xls");
         *  }
         *  catch (Exception ep)
         *  {
         *
         *      throw;
         *  }
         * }  */


        //con parametro
        public ActionResult DescargarReporte_empleado(int Codigo, string algo)
        {
            try
            {
                var rptH = new ReportClass();
                rptH.FileName = Server.MapPath("/Reportes/EmpleadoReporte.rpt");
                rptH.Load();

                rptH.SetParameterValue("IdDpto", Codigo);
                //rptH.SetParameterValue("Nuevo_Parametro", algo);

                // Report connection
                var            conInfo   = CrystalReportCn.GetConnectionInfo();
                TableLogOnInfo logonInfo = new TableLogOnInfo();
                Tables         tables;
                tables = rptH.Database.Tables;
                foreach (Table table in tables)
                {
                    logonInfo = table.LogOnInfo;
                    logonInfo.ConnectionInfo = conInfo;
                    table.ApplyLogOnInfo(logonInfo);
                }

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat);
                rptH.Dispose();
                rptH.Close();
                return(new FileStreamResult(stream, "application/pdf"));

                //Stream stream = rptH.ExportToStream(ExportFormatType.Excel);
                //stream.Seek(0,SeekOrigin.Begin);
                //return File(stream, "application/vnd.ms-excel","EmpleadoRpt.xls");
            }
            catch (Exception ep)
            {
                throw;
            }
        }
Пример #16
0
        public ActionResult OutStationDuty()
        {
            var User = (User)Session["UserName"];
            //return View();
            ReportClass rpt = new ReportClass();

            rpt.FileName = Server.MapPath("~/WebReport/Reports/rptOutStationDuty.rpt");
            rpt.Load();
            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add("@ID", User.EmpCode);
            DataTable DT = Models.DAL.storedProc2(HRStoredProcedureName.usp_rpt_LeaveApplicationForm, param, DBName.HR);

            //string path = @"~\\WebReport\\DataSets\\dsLeaveApplicationFrom.xsd";
            //DT.WriteXmlSchema(Server.MapPath(path));
            rpt.SetDataSource(DT);
            Stream stream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            //CLOSE REPORT OBJECT
            rpt.Close();
            rpt.Dispose();
            return(File(stream, "application/pdf"));
        }
Пример #17
0
        public ActionResult DescargarReporteEmpleado()
        {
            try
            {
                var reportE = new ReportClass();
                reportE.FileName = Server.MapPath("/Reports/EmpleadoOLE_DBReport.rpt");
                reportE.Load();
                //report connection
                var            connInfo  = CrystalReportsCnn.GetConnectionInfo();
                TableLogOnInfo logonInfo = new TableLogOnInfo();
                Tables         tables;
                tables = reportE.Database.Tables;
                foreach (Table table in tables)
                {
                    logonInfo = table.LogOnInfo;
                    logonInfo.ConnectionInfo = connInfo;
                    table.ApplyLogOnInfo(logonInfo);
                }
                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();
                //pdf
                Stream reportStream = reportE.ExportToStream(ExportFormatType.PortableDocFormat);
                reportE.Dispose();
                reportE.Close();
                return(new FileStreamResult(reportStream, "application/pdf "));

                //Exel
                //Stream reportStream = reportE.ExportToStream(ExportFormatType.Excel);
                //reportStream.Seek(0, SeekOrigin.Begin);
                //return  File(reportStream, "application/vnd.ms-exel","Empleados.xls");
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #18
0
        public static dynamic getReport(string reportType, System.Data.DataSet ds, DocumentDownloadSection param)
        {
            string      mimeType = "", extension = "";
            Stream      stream    = new MemoryStream();
            ReportClass report    = new ReportClass();
            bool        isValid   = true;
            var         rptSource = ds;

            if (string.IsNullOrEmpty(param.OperationName))
            {
                isValid = false;
            }
            if (isValid)
            {
                string strRptPath = string.Empty;
                //if (param.OperationName.Equals("rptCostCenterWiseIncomeTaxYearly") || param.OperationName.Equals("rptCostCenterWiseIncomeNonTaxYearly"))
                //{
                //    strRptPath = System.Web.HttpContext.Current.Server.MapPath("~/WebReport/Reports/") + param.OperationName + ".rpt";
                //}
                //else
                //{

                //}

                strRptPath = System.Web.HttpContext.Current.Server.MapPath("~/WebReport/Reports/") + param.OperationName + ".rpt";

                //dsReport = rptSource.Copy();
                report.FileName = strRptPath;
                //===========Data set=====
                //var path = "~//WebReport//DataSet//dsLeaveForm.xsd";
                //ds.WriteXmlSchema(HostingEnvironment.MapPath(path));

                report.Load(strRptPath);
                if (ds != null && ds.GetType().ToString() != "System.String")
                {
                    report.SetDataSource(ds);
                    if (param.OperationName.Equals("rptCostCenterWiseIncomeTaxYearly") || param.OperationName.Equals("rptCostCenterWiseIncomeNonTaxYearly"))
                    {
                        report.SetParameterValue("Option", param.IncomeTaxYear);
                        report.SetParameterValue("Option1", param.FromMonth);
                        report.SetParameterValue("Option2", param.ToMonth);
                        report.SetParameterValue("Option3", param.AYear);
                    }
                }


                if (reportType == "pdf")
                {
                    mimeType  = "application/pdf";
                    extension = ".pdf";
                    stream    = report.ExportToStream(ExportFormatType.PortableDocFormat);
                }
                else if (reportType == "excel")
                {
                    mimeType  = "application/vnd.ms-excel";
                    extension = ".xls";
                    stream    = report.ExportToStream(ExportFormatType.Excel);
                }
                else if (reportType == "word")
                {
                    mimeType  = "application/msword";
                    extension = ".doc";
                    stream    = report.ExportToStream(ExportFormatType.WordForWindows);
                }
                else if (reportType == "RichText")
                {
                    mimeType  = "application/rtf";
                    extension = ".rtf";
                    stream    = report.ExportToStream(ExportFormatType.RichText);
                }
                report.Close();
                report.Dispose();

                return(new { mimeType = mimeType, stream = stream, extension = extension });
            }
            else
            {
                return("<H2>Nothing Found; </H2>");
            }
        }