Esempio n. 1
0
        public string GetPdf(int patientId, int noteId)
        {
            string converted = string.Empty;

            tblDocMaster patientNotes = _unitOfWork.DocMasterRepo.Get(o => o.PTrowid == patientId && o.Docrowid == noteId).FirstOrDefault();

            if (!string.IsNullOrEmpty(patientNotes.PDFName))
            {
                byte[] pdfBytes = CloudeStoreg.ByteFromFile(patientNotes.PDFName);
                //byte[] pdfBytes;
                //string pdfName = Path.GetFileName(filePath);

                //string networkPath = filePath.Replace("\\" + pdfName, "");
                //string username = Convert.ToString(ConfigurationManager.AppSettings["NetworkUserName"]);
                //string password = Convert.ToString(ConfigurationManager.AppSettings["NetworkPassword"]);
                //var credentials = new NetworkCredential(username, password);
                //using (new NetworkConnection(networkPath, credentials))
                //{
                //    pdfBytes = System.IO.File.ReadAllBytes(filePath);
                //}


                //   filePath = @"C:\Users\Shukraj Khadse\Downloads\Driving Licence.pdf";

                //  byte[] pdfBytes = System.IO.File.ReadAllBytes(filePath);
                converted = Encoding.UTF8.GetString(pdfBytes, 0, pdfBytes.Length);
            }
            else
            {
                converted = "Note has not been signed, Please sign the note first";
            }

            return(converted);
        }
Esempio n. 2
0
        public bool SendRefEMail(string recipient, int npinum, int patientId, int noteId)
        {
            bool isMessageSent = true;
            //Intialise Parameters
            //   string aa = "appdatafiles\\EasyDoc\\D1\\121-108590_ALINA_YELIZAROV_PPOC_1_11-21-2017_5-19-2019-6-41-26-PM_RefSigned.pdf";
            tblPatients     patientNotes  = _unitOfWork.PatientEntityRepo.Get(o => o.Prowid == patientId).FirstOrDefault();
            tblReferrerSign _ReferralSign = _unitOfWork.ReferrerSignRepo.Get(o => o.NPINumber == npinum &&
                                                                             o.PTrowid == patientId && o.Docrowid == noteId
                                                                             ).FirstOrDefault();
            var smtpEmail    = Convert.ToString(ConfigurationManager.AppSettings["SMTPEmail"]);
            var smtpPassword = Convert.ToString(ConfigurationManager.AppSettings["SMTPPassword"]);

            try
            {
                byte[]      pdfBytes   = CloudeStoreg.ByteFromFile(_ReferralSign.PDFName);
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");
                string      filename   = "Sign Notes " + DateTime.Now.ToString("yyyyMMdd_hhss") + ".pdf";
                mail.From = new MailAddress(smtpEmail);
                mail.To.Add(recipient);
                mail.Subject = "Referral Notes PDF for " + patientNotes.LastName + ", " + patientNotes.FirstName;
                mail.Body    = "Sign note Attchment - " + patientNotes.LastName + ", " + patientNotes.FirstName;;
                var memStream = new MemoryStream(pdfBytes);
                memStream.Position = 0;
                var contentType      = new System.Net.Mime.ContentType(System.Net.Mime.MediaTypeNames.Application.Pdf);
                var reportAttachment = new Attachment(memStream, contentType);
                reportAttachment.ContentDisposition.FileName = filename;
                mail.Attachments.Add(reportAttachment);
                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential(smtpEmail, smtpPassword);
                SmtpServer.EnableSsl   = true;

                SmtpServer.Send(mail);
            }

            catch (Exception ex)
            {
                isMessageSent = false;
            }
            return(isMessageSent);
        }