Exemple #1
0
        public JsonResult SendEmail(string email, string tipdoc, string serie, string correlativo, string fecha, string importe)
        {
            try
            {
                appbosaEntities db              = new appbosaEntities();
                setupmail       stmail          = db.setupmail.ToList().First();
                usrfile         u               = new usrfile();
                string          FromEmail       = stmail.DIRMAIL;
                string          FromDisplayName = stmail.NOMMAIL;
                string          FromPassword    = u.Desencripta(stmail.PASSMAIL);
                string          subject         = "Documento Electrónico";
                string          body            = "";
                string          host            = stmail.SMTPMAIL;
                int             port            = int.Parse(stmail.PUERTO_SMTP);
                string          SslAct          = stmail.CONEXION_SSL;

                var fromAddress = new MailAddress(FromEmail, FromDisplayName);
                var toAddress   = new MailAddress(email);
                var smtp        = new SmtpClient
                {
                    Host                  = host,
                    Port                  = port,
                    EnableSsl             = SslAct.Equals("S"),
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials           = new NetworkCredential(fromAddress.Address, FromPassword)
                };

                var root = Server.MapPath("~/PDF/");
                if (!System.IO.Directory.Exists(@root))
                {
                    System.IO.Directory.CreateDirectory(@root);
                }
                var pdfname = String.Format("{0} - {1}.pdf", "Documento Electrónico", DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss"));
                var path    = Path.Combine(root, pdfname);
                path = Path.GetFullPath(path);
                var something = new Rotativa.ActionAsPdf("Respuesta", new { tipdoc = tipdoc, serie = serie, correlativo = correlativo, fecha = fecha, importe = importe })
                {
                    FileName = pdfname,
                };
                var binary = something.BuildPdf(this.ControllerContext);
                System.IO.File.Create(path).Close();
                System.IO.File.WriteAllBytes(@path, binary);

                using (var message = new MailMessage(fromAddress, toAddress)
                {
                    Subject = subject, Body = body
                })
                {
                    message.Attachments.Add(new Attachment(path));
                    smtp.Send(message);
                }
                System.IO.File.Delete(@path);
                return(Json(new { respuesta = "EXITO: Email enviado a " + email }, JsonRequestBehavior.AllowGet));
            }
            catch (System.Data.EntityException ex) { return(Json(new { respuesta = "ERROR: " + ex.Message }, JsonRequestBehavior.AllowGet)); }
            catch (Exception ex) { return(Json(new { respuesta = "ERROR: " + ex.Message }, JsonRequestBehavior.AllowGet)); }
        }
Exemple #2
0
        public ActionResult ViewPDF(int id)
        {
            var report = new Rotativa.ActionAsPdf("Invoice", new { id = id })
            {
                FileName = "Invoice.pdf"
            };

            return(report);

            //return new ViewAsPdf("Invoice", new { id = id });
        }
        public ActionResult ExportPDF()

        {
            
            ActionAsPdf resultPdf = new ActionAsPdf("GetStudentResultInfo")
            {
                FileName = Server.MapPath("~Content/resultSheet.pdf")
            };
            return resultPdf;

        }
Exemple #4
0
        /// <summary>
        /// PrintLoanSummaryPDF
        ///
        /// The following ActionResult takes the LoanSummaryPDF action and transforms it's output from HTML to PDF;
        ///
        /// It always the requesting member and carp employee to have the document printed on paper after a loan request
        /// from the this application.
        ///
        /// </summary>
        /// <returns>the view with the loan summary the rates and all CONVERTED TO PDF </returns>
        public ActionResult PrintLoanSummaryAsPDF(int idOfLoan)
        {
            // Here we have the View itself, not the partial view, this one includes the website header and footer
            var report = new Rotativa.ActionAsPdf("LoanSummary", new { idOfLoan });



            // Here we have the partial view which only includes the effective PDF part
            //var loan = db.Loans.Include(r => r.Rates)
            //    .SingleOrDefault(b => b.IdLoan == idOfLoan);

            //var report = new Rotativa.PartialViewAsPdf("_LoanSummaryPDF", loan);
            return(report);
        }
Exemple #5
0
        public ActionResult Imprimir1(int?id)
        {
            Facturas factura = new Facturas();

            dat.Id = id;
            var actionPDF = new Rotativa.ActionAsPdf("ImprimirFactura", new { id = id }) //some route values)
            {
                //FileName = "TestView.pdf",
            };

            byte[] applicationPDFData = actionPDF.BuildFile(this.ControllerContext);
            factura.Factura = applicationPDFData;
            db.Facturas.Add(factura);
            db.SaveChanges();
            return(actionPDF);
        }
        public void ShelfStockPrint(string Shelfstockid, string pagecopies)
        {
            int id = Convert.ToInt32(Shelfstockid);
            string printerName = @"AThermalZebraNet";                           // Set printer name or UNC eg; @"\\CMCNMPS2\RcvShelf"

            var actionPDF = new Rotativa.ActionAsPdf("PrintShelfStockLabel", new { id })
            {
                PageMargins = new Margins(2, 2, 0, 2),
                PageWidth = 200,
                PageHeight = 75,
                CustomSwitches = "--disable-smart-shrinking --load-error-handling ignore --copies " + pagecopies + ""
            };

            byte[] pdfContent = actionPDF.BuildPdf(ControllerContext);          // PDF stream content

            string fileName = Shelfstockid + ".pdf";                            // Set file and extension name
            PrintFile file = new PrintFile(pdfContent, fileName);               // Build file

            ClientPrintJob cpj = new ClientPrintJob();                          // Create a ClientPrintJob and send it back to the client!
            cpj.PrintFile = file;                                               // Set file to print
            cpj.ClientPrinter = new InstalledPrinter(printerName);              // Set client printer
            //cpj.ClientPrinter = new NetworkPrinter("192.168.0.60", 9100);     // Set IP printer: ipaddress, port
            cpj.SendToClient(System.Web.HttpContext.Current.Response);          // Send it
        }
        public void LabelPrint()
        {
            int pagecopies = 1;
            string printerName = @"AThermalZebraNet";                           // @"\\CMCNMPS2\RcvShelf";

            var actionPDF = new Rotativa.ActionAsPdf("PrintLabel")
            {
                PageMargins = new Margins(2, 2, 0, 2),
                PageWidth = 200,
                PageHeight = 75,
                CustomSwitches = "--disable-smart-shrinking --load-error-handling ignore --copies " + pagecopies + ""
            };

            byte[] pdfContent = actionPDF.BuildPdf(ControllerContext);

            string fileName = "thermallabel.pdf";                               // Create a temp file name for our PDF report...
            PrintFile file = new PrintFile(pdfContent, fileName);               // Create a PrintFile object with the pdf report

            ClientPrintJob cpj = new ClientPrintJob();                          // Create a ClientPrintJob and send it back to the client!
            cpj.PrintFile = file;                                               // Set file to print...
            cpj.ClientPrinter = new InstalledPrinter(printerName);              // Set client printer...//cpj.ClientPrinter = new NetworkPrinter("10.0.0.8", 9100);
            cpj.SendToClient(System.Web.HttpContext.Current.Response);          // Send it...
        }
Exemple #8
0
        public ActionResult PrintAppointmentDeatils(int?id)
        {
            var report = new Rotativa.ActionAsPdf("Details", new { id = id });

            return(report);
        }
        public ActionResult GetRCTInvoice()
        {
            try
            {
                List<RCTIUserDto> specialists = Services.Users.GetActivatedUserByRole(Role.Specialist);

                foreach (var spec in specialists)
                {
                    if (Services.Invoices.HasInvoiceInPreMonth(spec.Id, DateTime.UtcNow, DateTime.UtcNow))
                    {
                        DateTime prevMonth = GetPrevMonth();
                        DateTime lastDayOfMonth = new DateTime(
                            prevMonth.Year, prevMonth.Month, DateTime.DaysInMonth(prevMonth.Year, prevMonth.Month));
                        object transformWith = new
                        {
                            Name = string.Format("{0} {1} {2} {3}", spec.Title, spec.FirstName, spec.LastName, spec.PostNominal),
                            Content = string.Format(EmailContentMessage.RCTI,
                            prevMonth.ToString(Constants.GlobalDateFormat), lastDayOfMonth.ToString(Constants.GlobalDateFormat))
                        };

                        string subject = string.Format(ConstEmailSubject.RCTInvoice, prevMonth.ToString("MMMM-yyyy"));

                        string fileName = string.Format("RCTI_{0}.pdf",
                            DateTime.UtcNow.ToString(Constants.GlobalDateFormat));

                        //Generate pdf from view
                        var pdf = new ActionAsPdf("RCTIEmailTemplate",
                            new { specialistId = spec.Id }) { FileName = fileName };

                        byte[] buffer_ = pdf.BuildPdf(this.ControllerContext);

                        Attachment attachment = HtmlToPdf.GetAttachFile(buffer_, fileName);

                        Services.Mail.SendMail(ConstEmailTemplateKey.SimpleEmailTemplate, spec.Email, subject,
                            transformWith, "RCTI", attachment);
                    }
                }
                return null;
            }
            catch (Exception e)
            {
                Log.Error("Create RCTI", e);
                return null;
            }
        }
        public ActionResult PrintInvoice(int id)
        {
            var report = new Rotativa.ActionAsPdf("Invoice", new { id = id });

            return(report);
        }
Exemple #11
-2
 public PartialViewResult CallISFToPdf()
 {
     //Se optiene el objeto del TempData.
     Reporte model = (Reporte)TempData["model"];
     //Se guarda el resultado de la vista PDF en una variable.
     var pdfResult = new ActionAsPdf("ISFToPdf", model.jga_reportespdf) { FileName = "ISF.pdf" };
     //Se pasa la vista a binario.
     var binary = pdfResult.BuildPdf(this.ControllerContext);
     //Instancia de proyecciones para ser enviada al partialView.
     List<JGA_PROYECCION> proyecciones = db.JGA_PROYECCION.Where(x => x.PROY_EMP == model.usuario.USR_CODEMP).Where(x => x.PROY_ESTADO == 1).Where(x => x.PROY_ESTADODEL == 1).ToList();
     //Se envian los datos al método enviar enviarCorreoISF para continuar con el proceso de enviar el correo.
     enviarCorreoISF(model.consignatario, model.contactosConsig, model.agenciaExterior, model.contactosAgenE, model.embarcador, model.contactosEmb, model.usuario, model.jga_reportespdf, binary);
     return PartialView("PartialProjections", proyecciones);
 }