Ejemplo n.º 1
0
        public ActionResult PrescribePatient(Prescription prescription, int AppointmentId)
        {
            ViewBag.PrescribePatient = "active";
            string name;

            name = DateTime.Now.ToString("dd-MM-yyyy") + "_" + prescription.PatientId + "_" + Guid.NewGuid() + ".pdf";
            using (var ctx = new HospitalContext())
            {
                Appointment apt = ctx.Appointment.Find(AppointmentId);
                apt.Chat = baseControl.Encrypt(prescription.Chat);

                if (prescription.WardId > 0)
                {
                    apt.WardId = prescription.WardId;
                }
                ctx.SaveChanges();
                var kl = from a in ctx.Appointment
                         join p in ctx.Patient
                         on a.PatientId equals p.Id
                         join d in ctx.Doctor
                         on a.DoctorId equals d.Id
                         where a.Id == AppointmentId
                         select new
                {
                    DoctorName        = d.Name,
                    DoctorDesignation = d.Designation,
                    DoctorDegree      = d.Degree,
                    PatientName       = p.Name,
                    PatientPhone      = p.PhoneNo,
                    PatientAge        = p.Age
                };
                foreach (var v in kl)
                {
                    prescription.DoctorDesignation = baseControl.Decrypt(v.DoctorDesignation);
                    prescription.DoctorName        = baseControl.Decrypt(v.DoctorName);
                    prescription.DoctorDegree      = baseControl.Decrypt(v.DoctorDegree);
                    prescription.PatientName       = baseControl.Decrypt(v.PatientName);
                    prescription.PatientAge        = v.PatientAge;
                    prescription.PatientPhone      = baseControl.Decrypt(v.PatientPhone);
                }

                Appointment ap = ctx.Appointment.Single(c => c.Id == AppointmentId);
                ap.Prescription = "PatientPrescriptions/" + name;
                ap.Approval     = 3;
                ctx.SaveChanges();
            }

            var printpdf = new ActionAsPdf("MakePdf", prescription)
            {
                FileName = name
            };
            string path       = Server.MapPath("~/PatientPrescriptions");
            string pth        = Path.Combine(path, name);
            var    byteArray  = printpdf.BuildPdf(ControllerContext);
            var    fileStream = new FileStream(pth, FileMode.Create, FileAccess.Write);

            fileStream.Write(byteArray, 0, byteArray.Length);
            fileStream.Close();
            return(printpdf);
        }
        private void CreatePDF(int orderId, OrderStatus status)
        {
            var order = svc.GetOrder(orderId);

            if (order == null)
            {
                throw new Exception("order not found");
            }

            if (order.ISP == null)
            {
                throw new Exception("ISP is null");
            }

            string fileName     = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-") + order.ISP.Name + "-" + status + ".pdf";
            string targetFolder = System.Web.HttpContext.Current.Server.MapPath("~/Assets/OrderPDF/");
            string targetPath   = Path.Combine(targetFolder, fileName);
            var    asset        = new Asset {
                AssetPath = targetPath, Name = fileName, CreatedDate = DateTime.Now
            };

            svc.SaveOrderPDFAsset(order, asset);
            var actionResult = new ActionAsPdf("Details", new { id = order.OrderId });
            var byteArray    = actionResult.BuildPdf(ControllerContext);
            var fileStream   = new FileStream(targetPath, FileMode.Create, FileAccess.Write);

            fileStream.Write(byteArray, 0, byteArray.Length);
            fileStream.Close();
        }
Ejemplo n.º 3
0
        public ActionResult ImprimirPDF()
        {
            var actionResult = new ActionAsPdf("PDF")
            {
                FileName = FileName + Extencion
            };
            var misDatos  = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, RutaPDF + ArchivoReporte);
            var byteArray = actionResult.BuildPdf(ControllerContext);

            try
            {
                using (var fileStream = new FileStream(misDatos, FileMode.OpenOrCreate, FileAccess.ReadWrite))
                {
                    fileStream.Write(byteArray, 0, byteArray.Length);
                    fileStream.Close();
                }
            }
            catch (Exception)
            {
                ArchivoReporte = NombreReporte + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + Extencion;
                misDatos       = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, RutaPDF + ArchivoReporte);
                using (var fileStream = new FileStream(misDatos, FileMode.OpenOrCreate, FileAccess.ReadWrite))
                {
                    fileStream.Write(byteArray, 0, byteArray.Length);
                    fileStream.Close();
                }
            }


            return(actionResult);
        }
Ejemplo n.º 4
0
        public ActionResult BinaryTest()
        {
            var pdfResult = new ActionAsPdf("Index", new { name = "Giorgio" }) { FileName = "Test.pdf" };

            var binary = pdfResult.BuildPdf(this.ControllerContext);

            return File(binary, "application/pdf");
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> SendInvoice(int id)
        {
            Order order = await db.Orders.FindAsync(id);

            if (order != null)
            {
                Dictionary <string, string> cookieCollection = new Dictionary <string, string>();
                foreach (var key in Request.Cookies.AllKeys)
                {
                    cookieCollection.Add(key, Request.Cookies.Get(key).Value);
                }

                ActionAsPdf pdf = new ActionAsPdf("Invoice", new { id })
                {
                    FileName        = $"Order#{order.Id}-{DateTime.Now.ToFileTime()}.pdf",
                    RotativaOptions = new DriverOptions
                    {
                        Cookies = cookieCollection,
                    }
                };

                var message = new MimeMessage();
                message.From.Add(new MailboxAddress("Kishor", "*****@*****.**"));
                message.To.Add(new MailboxAddress($"{order.Customer.FirstName} {order.Customer.LastName}", $"{order.Customer.Email}"));
                message.Subject = $"Order#{order.Id} Invoice";

                var builder = new BodyBuilder();
                // Set the plain-text version of the message text

                builder.TextBody = $"Hey {order.Customer.FirstName} {order.Customer.LastName}, Here is your invoice for Order#{order.Id}";

                // We may also want to attach a calendar event for Monica's party...
                builder.Attachments.Add(pdf.FileName, pdf.BuildPdf(ControllerContext));

                // Now we just need to set the message body and we're done
                message.Body = builder.ToMessageBody();



                using (var client = new SmtpClient())
                {
                    client.Connect("smtp.gmail.com", 587);

                    // Note: since we don't have an OAuth2 token, disable
                    // the XOAUTH2 authentication mechanism.
                    client.AuthenticationMechanisms.Remove("XOAUTH2");

                    // Note: only needed if the SMTP server requires authentication
                    client.Authenticate("*****@*****.**", "kxbcyuqhwtbhzjml");

                    client.Send(message);
                    client.Disconnect(true);
                    return(Json("Email Sent", JsonRequestBehavior.AllowGet));
                }
            }

            return(HttpNotFound());
        }
Ejemplo n.º 6
0
        public ActionResult BinaryTest()
        {
            var pdfResult = new ActionAsPdf("Index", new { name = "Giorgio" })
            {
                FileName = "Test.pdf"
            };

            var binary = pdfResult.BuildPdf(this.ControllerContext);

            return(File(binary, "application/pdf"));
        }
Ejemplo n.º 7
0
        public ActionResult Prescription(Prescription prescription, int AppointmentId)
        {
            prescription.DocId   = Convert.ToInt32(Session["DoctorId"]);
            ViewBag.Prescription = "active";
            string searchdate = DateTime.Now.ToString("MM/dd/yyyy");
            string pdfname;

            pdfname = DateTime.Now.ToString("dd-MM-yyyy") + "_" + Guid.NewGuid() + ".pdf";
            using (var db = new MedicalContext())
            {
                if (prescription.WardId > 0)
                {
                    PatientAppointmentModel appointment = db.Appointment.Find(AppointmentId);
                    appointment.WardId = prescription.WardId;
                    db.SaveChanges();
                }
                var presdoc = from ap in db.Appointment
                              join p in db.Registers
                              on ap.PatientId equals p.Id
                              join d in db.Doctors
                              on ap.DoctorId equals d.Id
                              where ap.Id == AppointmentId
                              select new
                {
                    PatientName = p.Name,
                    PatientAge  = p.Age
                };
                foreach (var v in presdoc)
                {
                    prescription.PatientName = privacy.Decrypt(v.PatientName);
                    prescription.PatientAge  = v.PatientAge;
                }

                PatientAppointmentModel app = db.Appointment.Single(c => c.Id == AppointmentId && c.DoctorId == prescription.DocId &&
                                                                    c.Date == searchdate);
                app.Prescription = "Prescriptions/" + pdfname;
                db.SaveChanges();
            }

            var printpdf = new ActionAsPdf("MakePdf", prescription)
            {
                FileName = pdfname
            };
            string path       = Server.MapPath("~/Prescriptions");
            string a          = Path.Combine(path, pdfname);
            var    byteArray  = printpdf.BuildPdf(ControllerContext);
            var    fileStream = new FileStream(a, FileMode.Create, FileAccess.Write);

            fileStream.Write(byteArray, 0, byteArray.Length);
            fileStream.Close();

            return(printpdf);
        }
        public ActionResult GetPdfreceipt()
        {
            var actionPDF = new ActionAsPdf("Receipt")
            {
                FileName        = "TestView.pdf",
                PageSize        = Size.A4,
                PageOrientation = Orientation.Landscape,
                PageMargins     = { Left = 1, Right = 1 }
            };
            Stream applicationPDFData = new MemoryStream(actionPDF.BuildPdf(ControllerContext));

            return(RedirectToAction("SendOrder", applicationPDFData));
        }
Ejemplo n.º 9
0
        public ActionResult ResultatSendtoPDF(int Quizzid)
        {
            var pdf    = new ActionAsPdf("Details", new { id = Quizzid });
            var binary = pdf.BuildPdf(ControllerContext);

            var quizz = _quizzService.GetQuizz(Quizzid);

            var contact = _contactService.GetContactById(quizz.ContactId);

            string from = "*****@*****.**";
            string to   = contact.Email;

            MailMessage message = new MailMessage(from, to);

            message.Subject         = "resultat du test de " + contact.Name + contact.UserName;
            message.SubjectEncoding = Encoding.UTF8;
            message.Body            = "Bonjour,vous trouverez ci-joint le résultat de votre quizz en PJ.";
            message.IsBodyHtml      = true;

            MemoryStream file = new MemoryStream(binary);

            file.Seek(0, SeekOrigin.Begin);

            Attachment         data        = new Attachment(file, "Resultat", "application/pdf");
            ContentDisposition disposition = data.ContentDisposition;

            disposition.CreationDate     = DateTime.Now;
            disposition.ModificationDate = DateTime.Now;
            disposition.DispositionType  = DispositionTypeNames.Attachment;

            message.Attachments.Add(data);

            SmtpClient smtpMail = new SmtpClient();

            smtpMail.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Admin:2018");
            smtpMail.Host        = "smtp.gmail.com";
            smtpMail.Port        = 587;
            smtpMail.EnableSsl   = true;

            smtpMail.Send(message);


            return(RedirectToAction("Details", new { id = Quizzid }));
        }
Ejemplo n.º 10
0
        public byte[] crearArchivo(int id, int abonoNro)
        {
            var pdfResult = new ActionAsPdf("ComprobanteAbono", new { id = id })
            {
                FileName = "Comprobante.pdf"
            };
            var binary = pdfResult.BuildPdf(this.ControllerContext);

            try
            {
                string file = this.nombreArchivo(id, abonoNro);
                using (System.IO.FileStream fs = System.IO.File.Create(file))
                {
                    fs.Write(binary, 0, (int)binary.Length);
                }
            }catch (Exception e)
            {}
            return(binary);
        }
Ejemplo n.º 11
0
        //public ActionResult FacturaPdf()
        //{
        //    var Juegos = GetViewModel();

        //    return new ViewAsPdf("Factura", Juegos);
        //}


        public ActionResult EnviarC()
        {
            MailMessage msg = new MailMessage();

            string From = "*****@*****.**";

            foreach (var item in db.Factura)
            {
                var To = item.Clientes.Email;

                msg.To.Add(new MailAddress(To));
                msg.From    = new MailAddress(From, "Sistema de ventas");
                msg.Subject = "Factura Comercial";
                msg.Body    = "Aquí anexamos la factura correspondiente a su compra";

                var actionPdf = new ActionAsPdf("RetornaPdf")
                {
                    FileName = "factura.pdf",
                    PageSize = Rotativa.Options.Size.Letter
                };

                byte[] PdfData = actionPdf.BuildPdf(ControllerContext);

                MemoryStream stream = new MemoryStream(PdfData);
                Attachment   pdf    = new Attachment(stream, "factura.pdf", "application/pdf");
                msg.Attachments.Add(pdf);
                msg.IsBodyHtml      = true;
                msg.BodyEncoding    = System.Text.Encoding.UTF8;
                msg.SubjectEncoding = System.Text.Encoding.Default;

                SmtpClient smtp = new SmtpClient();
                smtp.Host      = "smtp.gmail.com";
                smtp.EnableSsl = true;
                NetworkCredential inicioSesion = new NetworkCredential(From, "wilmer041198");
                smtp.UseDefaultCredentials = true;
                smtp.Credentials           = inicioSesion;
                smtp.Port = 587;
                smtp.Send(msg);
            }
            ViewBag.Mensaje = "Mensaje enviado";
            return(View());
        }
Ejemplo n.º 12
0
        public FileContentResult Export(int fieldOfWaterId, int statusId, int userId, string searchText, string exportType)
        {
            ExportResult result = null;

            if (exportType == "pdf")
            {
                object      routevalues = new { fieldOfWaterId, statusId, userId, searchText };
                ActionAsPdf pdf         = new ActionAsPdf("SearchResultsHtml", routevalues);
                byte[]      pdfResult   = pdf.BuildPdf(ControllerContext);
                result = new ExportResult
                {
                    ResultBytes = pdfResult,
                    ContentType = "application/pdf",
                    FileName    = "Ideas.pdf"
                };
            }
            else
            {
                ExportCriteria criteria = new ExportCriteria
                {
                    UserId         = userId,
                    FieldOfWaterId = fieldOfWaterId,
                    StatusId       = statusId,
                    SearchText     = searchText,
                    ExportType     = exportType
                };
                result = ProcessFactory.GetExportProcess().Export(criteria, UserId);
            }
            AuditDataObject audit = new AuditDataObject
            {
                AuditTypeKey = AuditType.IDEAS_EXPORT.ToString(),
                LoginUserId  = UserId,
                Description  = string.Format("Exported ideas to {0} format", exportType)
            };

            Audit(audit);
            return(File(result.ResultBytes, result.ContentType, result.FileName));
        }