Пример #1
0
 private void FormEmailTemplateEdit_Load(object sender, System.EventArgs e)
 {
     gridAttachments.ContextMenu = contextMenuAttachments;
     textSubject.Text            = ETcur.Subject;
     textDescription.Text        = ETcur.Description;
     if (ETcur.EmailTemplateNum == 0)           //New email template
     {
         _listEmailAttachDisplayed = new List <EmailAttach>();
         ETcur.BodyText            = "";
     }
     else
     {
         _listEmailAttachDisplayed = EmailAttaches.GetForTemplate(ETcur.EmailTemplateNum);
         foreach (EmailAttach attachment in _listEmailAttachDisplayed)
         {
             _listEmailAttachOld.Add(attachment.Copy());
         }
     }
     textBodyText.Text = ETcur.BodyText;
     if (EmailMessages.IsHtmlEmail(ETcur.TemplateType))
     {
         _hasTextChanged = true;
         _isRaw          = (ETcur.TemplateType == EmailType.RawHtml);
         ChangeView(true);
     }
     FillAttachments();
 }
Пример #2
0
		public void FillAttachments() {
			_listEmailAttachDisplayed=new List<EmailAttach>();
			if(!_isComposing) {
				SetSig(null);
			}
			gridAttachments.BeginUpdate();
			gridAttachments.ListGridRows.Clear();
			gridAttachments.ListGridColumns.Clear();
			gridAttachments.ListGridColumns.Add(new OpenDental.UI.GridColumn("",0));//No name column, since there is only one column.
			for(int i=0;i<_emailMessage.Attachments.Count;i++) {
				if(_emailMessage.Attachments[i].DisplayedFileName.ToLower()=="smime.p7s") {
					if(!_isComposing) {
						string smimeP7sFilePath=FileAtoZ.CombinePaths(EmailAttaches.GetAttachPath(),_emailMessage.Attachments[i].ActualFileName);
						string localFile=PrefC.GetRandomTempFile(".p7s");
						FileAtoZ.Copy(smimeP7sFilePath,localFile,FileAtoZSourceDestination.AtoZToLocal,doOverwrite:true);
						SetSig(EmailMessages.GetEmailSignatureFromSmimeP7sFile(localFile));
					}
					//Do not display email signatures in the attachment list, because "smime.p7s" has no meaning to a user
					//Also, Windows will install the smime.p7s into an useless place in the Windows certificate store.
					continue;
				}
				OpenDental.UI.GridRow row=new UI.GridRow();
				row.Cells.Add(_emailMessage.Attachments[i].DisplayedFileName);
				gridAttachments.ListGridRows.Add(row);
				_listEmailAttachDisplayed.Add(_emailMessage.Attachments[i]);
			}
			gridAttachments.EndUpdate();
			if(gridAttachments.ListGridRows.Count>0) {
				gridAttachments.SetSelected(0,true);
			}
		}
 private void butSubmit_Click(object sender, EventArgs e)
 {
     if (comboProv.SelectedIndex == -1)
     {
         MessageBox.Show("Please select a provider first.");
         return;
     }
     try {
         DateTime.Parse(textDateStart.Text);
         DateTime.Parse(textDateEnd.Text);
     }
     catch {
         MessageBox.Show("Invalid dates.");
         return;
     }
     if (listQ == null)
     {
         MessageBox.Show("Click Refresh first.");
         return;
     }
     Cursor = Cursors.WaitCursor;
     try {
         EmailMessages.SendTestUnsecure("PQRI", "pqri.xml", GeneratePQRS_xml());
     }
     catch (Exception ex) {
         Cursor = Cursors.Default;
         MessageBox.Show(ex.Message);
         return;
     }
     Cursor = Cursors.Default;
     MessageBox.Show("Sent");
 }
Пример #4
0
        private void butTransmit_Click(object sender, EventArgs e)
        {
            if (textInput.Text.Trim() == string.Empty)
            {
                MessageBox.Show("No input text to send.");
                return;
            }
            //Encrypt the message.
            string encryptedMessage = Encryption(textInput.Text);
            //Generate a hash for the message.
            string hashedMessage = GenerateHash(textInput.Text);
            //Encrypt the hash.
            //string encryptedHash=Encryption(hashedMessage);
            string attachContents = "Encrypted message:\r\n" + encryptedMessage + "\r\n\r\nHash:\r\n" + hashedMessage;

            //Send the encrypted message followed by encrypted hash.
            Cursor = Cursors.WaitCursor;
            try {
                EmailMessages.SendTestUnsecure("Encryption", "encryption.txt", attachContents);
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show(ex.Message);
                return;
            }
            Cursor = Cursors.Default;
            MessageBox.Show("Sent");
        }
Пример #5
0
        private void gridEmailMessages_CellDoubleClick(object sender, UI.ODGridClickEventArgs e)
        {
            if (e.Row == -1)
            {
                return;
            }
            EmailMessage emailMessage = (EmailMessage)gridEmailMessages.Rows[e.Row].Tag;

            if (emailMessage.SentOrReceived == EmailSentOrReceived.WebMailReceived ||
                emailMessage.SentOrReceived == EmailSentOrReceived.WebMailRecdRead ||
                emailMessage.SentOrReceived == EmailSentOrReceived.WebMailSent ||
                emailMessage.SentOrReceived == EmailSentOrReceived.WebMailSentRead)
            {
                //web mail uses special secure messaging portal
                FormWebMailMessageEdit FormWMME = new FormWebMailMessageEdit(emailMessage.PatNum, emailMessage.EmailMessageNum);
                if (FormWMME.ShowDialog() != DialogResult.Abort)                //will only return Abort if validation fails on load, in which case the message will remain unread
                {
                    EmailMessages.UpdateSentOrReceivedRead(emailMessage);       //Mark the message read.
                }
            }
            else
            {
                FormEmailMessageEdit formEME = new FormEmailMessageEdit(emailMessage);
                formEME.ShowDialog();
                emailMessage = EmailMessages.GetOne(emailMessage.EmailMessageNum);                                //Fetch from DB, in case changed to to decrypt.
                if (emailMessage != null && emailMessage.SentOrReceived != EmailSentOrReceived.ReceivedEncrypted) //emailMessage could be null if the message was deleted in FormEmailMessageEdit().
                {
                    EmailMessages.UpdateSentOrReceivedRead(emailMessage);
                }
            }
            FillGridEmailMessages();            //To show the email is read.
        }
Пример #6
0
        private void SaveMsg()
        {
            //allowed to save message with invalid fields, so no validation here.  Only validate when sending.
            MessageCur.FromAddress = textFromAddress.Text;
            MessageCur.ToAddress   = textToAddress.Text;
            MessageCur.Subject     = textSubject.Text;
            MessageCur.BodyText    = textBodyText.Text;
            MessageCur.MsgDateTime = DateTime.Now;
            //Notice that SentOrReceived does not change here.
            if (IsNew)
            {
                EmailMessages.Insert(MessageCur);

                /*Commlog CommlogCur=new Commlog();
                 * CommlogCur.PatNum=MessageCur.PatNum;
                 * CommlogCur.CommDateTime=DateTime.Now;
                 * CommlogCur.CommType=CommItemType.Misc;
                 * CommlogCur.EmailMessageNum=MessageCur.EmailMessageNum;
                 * CommlogCur.Mode=CommItemMode.Email;
                 * CommlogCur.SentOrReceived=CommSentOrReceived.Sent;
                 * CommlogCur.Note=MessageCur.Subject;
                 * Commlogs.Insert(CommlogCur);*/
            }
            else
            {
                EmailMessages.Update(MessageCur);
            }
        }
Пример #7
0
		private void butSig_Click(object sender,EventArgs e) {
			FormEmailDigitalSignature form=new FormEmailDigitalSignature(_certSig);
			if(form.ShowDialog()==DialogResult.OK) {
				//If the user just added trust, then refresh to pull the newly added certificate into the memory cache.
				EmailMessages.RefreshCertStoreExternal(EmailAddressPreview);
			}
		}
Пример #8
0
        private void butSubmitImmunization_Click(object sender, EventArgs e)
        {
            if (gridVaccine.SelectedIndices.Length == 0)
            {
                MessageBox.Show("Please select at least one vaccine.");
                return;
            }
            List <VaccinePat> vaccines = new List <VaccinePat>();

            for (int i = 0; i < gridVaccine.SelectedIndices.Length; i++)
            {
                vaccines.Add(VaccineList[gridVaccine.SelectedIndices[i]]);
            }
            OpenDentBusiness.HL7.EhrVXU vxu = null;
            try {
                vxu = new OpenDentBusiness.HL7.EhrVXU(PatCur, vaccines);
            }
            catch (Exception ex) {           //Exception happens when validation fails.
                MessageBox.Show(ex.Message); //Show validation error messages.
                return;
            }
            string outputStr = vxu.GenerateMessage();

            Cursor = Cursors.WaitCursor;
            try {
                EmailMessages.SendTestUnsecure("Immunization Submission", "vxu.txt", outputStr);
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show(ex.Message);
                return;
            }
            Cursor = Cursors.Default;
            MessageBox.Show("Sent");
        }
Пример #9
0
        ///<summary>Gets new messages from email inbox, as well as older messages from the db. Also fills the grid.</summary>
        private int GetMessages()
        {
            AddressInbox = EmailAddresses.GetByClinic(0); //Default for clinic/practice.
            Cursor       = Cursors.WaitCursor;
            FillGridEmailMessages();                      //Show what is in db.
            Cursor = Cursors.Default;
            if (AddressInbox.Pop3ServerIncoming == "")    //Email address not setup.
            {
                Text         = "Email Inbox";
                AddressInbox = null;
                //todo: Message Box is too instrusive, move this to a status label.
                //MsgBox.Show(this,"Default email address has not been setup completely.");
                return(0);
            }
            Text = "Email Inbox for " + AddressInbox.EmailUsername;
            Application.DoEvents();                                                                         //So that something is showing while the page is loading.
            if (!CodeBase.ODEnvironment.IdIsThisComputer(PrefC.GetString(PrefName.EmailInboxComputerName))) //This is not the computer to get new messages from.
            {
                return(0);
            }
            if (PrefC.GetString(PrefName.EmailInboxComputerName) == "")
            {
                MsgBox.Show(this, "Computer name to fetch new email from has not been setup.");
                return(0);
            }
            Cursor = Cursors.WaitCursor;
            int emailMessagesTotalCount = 0;

            Text = "Email Inbox for " + AddressInbox.EmailUsername + " - Fetching new email...";
            try {
                bool hasMoreEmail = true;
                while (hasMoreEmail)
                {
                    List <EmailMessage> emailMessages = EmailMessages.ReceiveFromInbox(1, AddressInbox);
                    emailMessagesTotalCount += emailMessages.Count;
                    if (emailMessages.Count == 0)
                    {
                        hasMoreEmail = false;
                    }
                    else                       //Show messages as they are downloaded, to indicate to the user that the program is still processing.
                    {
                        FillGridEmailMessages();
                        Application.DoEvents();
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show(Lan.g(this, "Error retrieving email messages") + ": " + ex.Message);
            }
            finally {
                Text = "Email Inbox for " + AddressInbox.EmailUsername;
            }
            Text = "Email Inbox for " + AddressInbox.EmailUsername + " - Resending any acknowledgments which previously failed...";
            EmailMessages.SendOldestUnsentAck(AddressInbox);
            Text   = "Email Inbox for " + AddressInbox.EmailUsername;
            Cursor = Cursors.Default;
            return(emailMessagesTotalCount);
        }
Пример #10
0
 ///<summary>Returns distinct list of email strings to be recommended to user.
 ///Splits all email address fields into a large list of individual addresses into one large distinct list.
 ///When given list is null, will run query.</summary>
 private void SetHistoricContacts(List <EmailMessage> listEmailMessages)
 {
     if (listEmailMessages == null)
     {
         _listHistoricContacts = EmailMessages.GetHistoricalEmailAddresses(EmailAddressPreview);
         return;
     }
     _listHistoricContacts = EmailMessages.GetAddressesFromMessages(listEmailMessages);
 }
Пример #11
0
 private void butMarkRead_Click(object sender, EventArgs e)
 {
     Cursor = Cursors.WaitCursor;
     for (int i = 0; i < gridEmailMessages.SelectedIndices.Length; i++)
     {
         EmailMessage emailMessage = (EmailMessage)gridEmailMessages.Rows[gridEmailMessages.SelectedIndices[i]].Tag;
         EmailMessages.UpdateSentOrReceivedRead(emailMessage);
     }
     FillGridEmailMessages();
     Cursor = Cursors.Default;
 }
Пример #12
0
 private void FormEmailMessageEdit_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (DialogResult == DialogResult.OK)
     {
         return;
     }
     if (IsNew)
     {
         EmailMessages.Delete(MessageCur);
     }
 }
Пример #13
0
        private void comboEmailFrom_SelectionChangeCommitted(object sender, EventArgs e)
        {
            EmailAddress emailAddressSelected = _listEmailAddresses[comboEmailFrom.SelectedIndex];

            textFromAddress.Text = emailAddressSelected.GetFrom();
            if (!_isComposing || !_isSigningEnabled)
            {
                return;
            }
            SetSig(EmailMessages.GetCertFromPrivateStore(emailAddressSelected.EmailUsername));
        }
 private void butTrust_Click(object sender, EventArgs e)
 {
     try {
         EmailMessages.TryAddTrustForSignature(_certSig);
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
         return;
     }
     MsgBox.Show(this, "Trust added for digital signature.");
     DialogResult = DialogResult.OK;
 }
Пример #15
0
		private void LoadSig() {
			if(!_isComposing || !_isSigningEnabled) {
				return;
			}
			EmailAddress emailAddressDefault=EmailAddresses.GetByClinic(ClinicNum);
			if(emailAddressDefault!=null) {//Must have a default emailaddress to be allowed to set a signature/cert.  Presumably 
				EmailAddress emailAddressSelected=null;
				if(TryGetFromEmailAddress(out emailAddressSelected)==FromAddressMatchResult.Failed) {
					return;
				}
				SetSig(EmailMessages.GetCertFromPrivateStore(emailAddressSelected.EmailUsername));
			}
		}
Пример #16
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
         //It will be deleted in the FormClosing() Event.
     }
     else
     {
         if (MsgBox.Show(this, true, "Delete this email?"))
         {
             EmailMessages.Delete(MessageCur);
             DialogResult = DialogResult.OK;
         }
     }
 }
Пример #17
0
 private void SaveMsg()
 {
     //allowed to save message with invalid fields, so no validation here.  Only validate when sending.
     MessageCur.FromAddress = textFromAddress.Text;
     MessageCur.ToAddress   = textToAddress.Text;
     MessageCur.Subject     = textSubject.Text;
     MessageCur.BodyText    = textBodyText.Text;
     MessageCur.MsgDateTime = DateTime.Now;
     //Notice that SentOrReceived does not change here.
     if (IsNew)
     {
         EmailMessages.Insert(MessageCur);
     }
     else
     {
         EmailMessages.Update(MessageCur);
     }
 }
Пример #18
0
        private void butTransmit_Click(object sender, EventArgs e)
        {
            if (textHash.Text.Trim() == "" || textMessage.Text.Trim() == "")
            {
                MessageBox.Show("Data or hash should not be blank.");
                return;
            }
            string attachContents = "Original message:\r\n" + textMessage.Text + "\r\n\r\n\r\nHash:\r\n" + textHash.Text;

            Cursor = Cursors.WaitCursor;
            try {
                EmailMessages.SendTestUnsecure("Hash", "hash.txt", attachContents);
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show(ex.Message);
                return;
            }
            Cursor = Cursors.Default;
            MessageBox.Show("Sent");
        }
Пример #19
0
		///<summary>Accepts a list of MimeEntity and parses it for paths, htmls and other key factors. It will test that the resulting parts
		///have a valid image extension. If they do, they are saved to a temporary web page for presentation to the user. If they are not
		///then they are disreguarded an a message is sent to the user warning them of potentially malicious content.</summary>
		private string ParseAndSaveAttachement(string htmlFolderPath,string html,List<MimeEntity> listParts) {
				bool hasDangerousAttachment=false;
				foreach(MimeEntity entity in listParts) {
					string contentId=EmailMessages.GetMimeImageContentId(entity);
					string fileName=EmailMessages.GetMimeImageFileName(entity);
					//Only show image types.  Otherwise, prompt user that potentially dangerous code is attached to the email and will not be shown.
					if(!ImageStore.HasImageExtension(fileName)) {//Check file format against known image format extensions.
						hasDangerousAttachment=true;
						continue;
					}
					html=html.Replace("cid:"+contentId,fileName);
					EmailAttach attachment=_listEmailAttachDisplayed.FirstOrDefault(x => x.DisplayedFileName.ToLower().Trim()==fileName.ToLower().Trim());
					//The path and filename must be directly accessed from the EmailAttach object in question, otherwise subsequent code would have accessed
					//an empty bodied message and never shown an image.
					EmailMessages.SaveMimeImageToFile(entity,htmlFolderPath,attachment?.ActualFileName);
				}
				if(hasDangerousAttachment) {
					//Since the extension is not within the image formats it may contain mallware and we will not parse or present it.
					MsgBox.Show("This message contains some elements that may not be safe and will not be loaded.");
				}
				return html;
		}
Пример #20
0
		///<summary>Returns distinct list of email strings to be recommended to user.
		///Splits all email address fields into a large list of individual addresses into one large distinct list.
		///When given list is null, will run query.</summary>
		private void SetHistoricContacts(List<EmailMessage> listEmailMessages) {
			if(EmailAddressPreview==null) {
				//Only null when failed to match from address. If we do not know the from address then we can't load anything useful.
				return;
			}
			EmailAddress emailAddressPreview=EmailAddressPreview.Clone();
			ODThread thread=new ODThread(o => {
				List<string> listHistoricContacts;
				if(listEmailMessages==null) {
					listHistoricContacts=EmailMessages.GetHistoricalEmailAddresses(emailAddressPreview);
				}
				else {
					listHistoricContacts=EmailMessages.GetAddressesFromMessages(listEmailMessages);
				}
				this.InvokeIfRequired(() => {
					_listHistoricContacts=listHistoricContacts;
					_hasSetHistoricContacts=true;
				});
			});
			thread.Name="SetHistoricContacts";
			thread.Start();
		}
Пример #21
0
        private void butChangePat_Click(object sender, EventArgs e)
        {
            if (gridEmailMessages.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "Please select an email message.");
                return;
            }
            FormPatientSelect form = new FormPatientSelect();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            for (int i = 0; i < gridEmailMessages.SelectedIndices.Length; i++)
            {
                EmailMessage emailMessage = (EmailMessage)gridEmailMessages.Rows[gridEmailMessages.SelectedIndices[i]].Tag;
                emailMessage.PatNum = form.SelectedPatNum;
                EmailMessages.UpdatePatNum(emailMessage);
            }
            MessageBox.Show(Lan.g(this, "Email messages moved successfully") + ": " + gridEmailMessages.SelectedIndices.Length);
            FillGridEmailMessages();            //Refresh grid to show changed patient.
        }
Пример #22
0
        private void butDelete_Click(object sender, EventArgs e)
        {
            if (_emailMessage == null)
            {
                DialogResult = DialogResult.Abort;              //Nothing to do the message doesn't exist.
                return;
            }
            if (!MsgBox.Show(this, true, "Are you sure you want to delete this webmail?"))
            {
                return;
            }
            EmailMessages.Delete(_emailMessage);
            string logText = "";

            logText += "\r\n" + Lan.g(this, "From") + ": " + _emailMessage.FromAddress + ". ";
            logText += "\r\n" + Lan.g(this, "To") + ": " + _emailMessage.ToAddress + ". ";
            if (!String.IsNullOrEmpty(_emailMessage.Subject))
            {
                logText += "\r\n" + Lan.g(this, "Subject") + ": " + _emailMessage.Subject + ". ";
            }
            if (!String.IsNullOrEmpty(_emailMessage.BodyText))
            {
                if (_emailMessage.BodyText.Length > 50)
                {
                    logText += "\r\n" + Lan.g(this, "Body Text") + ": " + _emailMessage.BodyText.Substring(0, 49) + "... ";
                }
                else
                {
                    logText += "\r\n" + Lan.g(this, "Body Text") + ": " + _emailMessage.BodyText;
                }
            }
            if (_emailMessage.MsgDateTime != DateTime.MinValue)
            {
                logText += "\r\n" + Lan.g(this, "Date") + ": " + _emailMessage.MsgDateTime.ToShortDateString() + ". ";
            }
            SecurityLogs.MakeLogEntry(Permissions.WebMailDelete, _emailMessage.PatNum, Lan.g(this, "Web Mail deleted.") + " " + logText);
            DialogResult = DialogResult.Abort;          //We want to abort here to avoid using the email in parent windows when it's been deleted.
        }
Пример #23
0
 private void butShowImages_Click(object sender, EventArgs e)
 {
     try {
         //We need a folder in order to place the images beside the html file in order for the relative image paths to work correctly.
         string htmlFolderPath = ODFileUtils.CreateRandomFolder(PrefC.GetTempFolderPath());              //Throws exceptions.
         string filePathHtml   = ODFileUtils.CreateRandomFile(htmlFolderPath, ".html");
         string html           = webBrowser.DocumentText;
         for (int i = 0; i < _listImageParts.Count; i++)
         {
             string contentId = EmailMessages.GetMimeImageContentId(_listImageParts[i]);
             string fileName  = EmailMessages.GetMimeImageFileName(_listImageParts[i]);
             html = html.Replace("cid:" + contentId, fileName);
             EmailMessages.SaveMimeImageToFile(_listImageParts[i], htmlFolderPath);
         }
         File.WriteAllText(filePathHtml, html);
         _isLoading = true;
         webBrowser.Navigate(filePathHtml);
         butShowImages.Visible = false;
     }
     catch (Exception ex) {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #24
0
        private void butReceive_Click(object sender, EventArgs e)
        {
            /*string sample=@"MSH|^~\&|KAM|DGI|Y|OU|20100920093000||ORU^R01^ORU_R01|20100920093000|P|2.5.1
             * PID||405979410 |405979410^^^&2.16.840.1.113883.19.3.2.1&ISO^MR||Lewis^Frank ||19500101|M||2106-3^White^HL70005|622 Chestnut^^Springfield^Tennessee^37026^^M||^^^^^615^3826396|||||405979410 ||||N^Not Hispanic or Latino^HL70189
             * OBR|1|OrderNum-1001|FillOrder-1001|24331-1^Lipid Panel^LN||20100920083000|20100920083000|20100920083000|||||Hemolyzed ||LNA&Arterial Catheter&Hl70070| ProviderIDNum-100^Crow^Tom^Black^III^Dr.||||Aloha Laboratories 575 Luau Street Honolulu Hawaii 96813 ||||CH|F|
             * OBX|1|NM|14647-2^Total cholesterol^LN |134465|162|mg/dl |<200| N|||F|||20100920083000
             * OBX|2|NM|14646-4^HDL cholesterol^LN|333123|43|mg/dl|>=40| N|||F|||20100920083000
             * OBX|3|NM|2089-1^LDL cholesterol^LN|333123|84|mg/dl|<100| N|||F|||20100920083000
             * OBX|4|NM|14927-8^Triglycerides^LN|333123|127|mg/dl|<150| N|||F|||20100920083000";*/
            string sample = "";

            Cursor = Cursors.WaitCursor;
            try {
                sample = EmailMessages.ReceiveOneForEhrTest();
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show(ex.Message);
                return;
            }
            Cursor          = Cursors.Default;
            textHL7Raw.Text = sample;
        }
Пример #25
0
 private void butSend_Click(object sender, EventArgs e)
 {
     if (!_allowSendSecureMessage)
     {
         MsgBox.Show(this, "Send not permitted");
         return;
     }
     if (!VerifyOutputs())
     {
         return;
     }
     //Insert the message. The patient will not see this as an actual email.
     //Rather, they must login to the patient portal (secured) and view the message that way.
     //This is how we get around sending the patient a secure message, which would be a hassle for all involved.
     _secureMessage.Subject     = textSubject.Text;
     _secureMessage.BodyText    = textBody.Text;
     _secureMessage.MsgDateTime = DateTime.Now;
     _secureMessage.PatNumSubj  = GetPatNumSubj();
     EmailMessages.Insert(_secureMessage);
     if (_allowSendNotificationMessage)
     {
         //Send an insecure notification email to the patient.
         _insecureMessage.MsgDateTime = DateTime.Now;
         _insecureMessage.PatNumSubj  = GetPatNumSubj();
         try {
             EmailMessages.SendEmailUnsecure(_insecureMessage, _emailAddressSender);
             //Insert the notification email into the emailmessage table so we have a record that it was sent.
             EmailMessages.Insert(_insecureMessage);
         }
         catch (Exception ex) {
             MsgBox.Show(this, ex.Message);
             return;
         }
     }
     DialogResult = DialogResult.OK;
 }
Пример #26
0
		public EmailAddress PickEmailAccount() {
			FormEmailAddresses formEA=new FormEmailAddresses();
			formEA.IsSelectionMode=true;
			formEA.ShowDialog();
			if(formEA.DialogResult==DialogResult.OK) {
				EmailAddress emailAccountSelected=_listEmailAddresses.Find(x => x.EmailAddressNum==formEA.EmailAddressNum);
				if(emailAccountSelected!=null) {
					EmailAddressPreview=emailAccountSelected;
				}
				else {
					MsgBox.Show(this,"Error selecting email account.");
					return null;
				}
				textFromAddress.Text=EmailAddressPreview.GetFrom();
				if(!_isComposing || !_isSigningEnabled) {
					return null;
				}
				SetSig(EmailMessages.GetCertFromPrivateStore(emailAccountSelected.EmailUsername));
			}
			else {
				EmailAddressPreview=null;
			}
			return EmailAddressPreview;
		}
        private void FormEmailDigitalSignature_Load(object sender, EventArgs e)
        {
            string signedByAddress = EmailNameResolver.GetCertSubjectName(_certSig);

            textSignedBy.Text             = signedByAddress;
            textCertificateAuthority.Text = _certSig.IssuerName.Name;
            textValidFrom.Text            = _certSig.NotBefore.ToShortDateString() + " to " + _certSig.NotAfter.ToShortDateString();
            textThumbprint.Text           = _certSig.Thumbprint;
            textVersion.Text = _certSig.Version.ToString();
            _isTrusted       = (EmailMessages.GetReceiverUntrustedCount(signedByAddress) == -1);
            if (_isTrusted)
            {
                butTrust.Visible          = false;
                textTrustStatus.Text      = Lan.g(this, "Trusted");
                textTrustExplanation.Text = Lan.g(this, "Encrypted email and EHR Direct messaging are currently enabled for the signer.");
            }
            else
            {
                butTrust.Visible          = true;
                textTrustStatus.Text      = Lan.g(this, "Untrusted or invalid");
                textTrustExplanation.Text = Lan.g(this, "Encrypted email and EHR Direct messaging will not work until this digital signature is trusted by you.") + "  "
                                            + Lan.g(this, "Click the Trust button to add trust for this digital signature.");
            }
        }
Пример #28
0
        private void butSubmit_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length == 0)
            {
                MessageBox.Show("Please select lab panels first.");
                return;
            }
            List <LabPanel> panels = new List <LabPanel>();

            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                panels.Add(listLP[gridMain.SelectedIndices[i]]);
            }
            OpenDentBusiness.HL7.EhrORU oru = new OpenDentBusiness.HL7.EhrORU();
            Cursor = Cursors.WaitCursor;
            try {
                oru.Initialize(panels);
            }
            catch (ApplicationException ex) {
                Cursor = Cursors.Default;
                MessageBox.Show(ex.Message);
                return;
            }
            string outputStr = oru.GenerateMessage();

            try {
                EmailMessages.SendTestUnsecure("Public Health", "oru.txt", outputStr);
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show(ex.Message);
                return;
            }
            Cursor = Cursors.Default;
            MessageBox.Show("Sent");
        }
Пример #29
0
        private void butPrint_Click(object sender, EventArgs e)
        {
            if (!TryToSaveData())
            {
                return;
            }
            SheetCur = Sheets.GetSheet(SheetCur.SheetNum);
            //whether this is a new sheet, or one pulled from the database,
            //it will have the extra parameter we are looking for.
            //A new sheet will also have a PatNum parameter which we will ignore.
            FormSheetOutputFormat FormS = new FormSheetOutputFormat();

            if (SheetCur.SheetType == SheetTypeEnum.ReferralSlip ||
                SheetCur.SheetType == SheetTypeEnum.ReferralLetter)
            {
                FormS.PaperCopies = 2;
            }
            else
            {
                FormS.PaperCopies = 1;
            }
            if (SheetCur.PatNum != 0 &&
                SheetCur.SheetType != SheetTypeEnum.DepositSlip)
            {
                Patient pat = Patients.GetPat(SheetCur.PatNum);
                if (SheetCur.SheetType == SheetTypeEnum.LabSlip)
                {
                    FormS.IsForLab = true;                  //Changes label to "E-mail to Lab:"
                }
                else if (pat.Email != "")
                {
                    FormS.EmailPatOrLabAddress = pat.Email;
                    //No need to email to a patient for sheet types: LabelPatient (0), LabelCarrier (1), LabelReferral (2), ReferralSlip (3), LabelAppointment (4), Rx (5), Consent (6), ReferralLetter (8), ExamSheet (13), DepositSlip (14)
                    //The data is too private to email unencrypted for sheet types: PatientForm (9), RoutingSlip (10), MedicalHistory (11), LabSlip (12)
                    //A patient might want email for the following sheet types and the data is not very private: PatientLetter (7)
                    if (SheetCur.SheetType == SheetTypeEnum.PatientLetter)
                    {
                        //This just defines the default selection. The user can manually change selections in FormSheetOutputFormat.
                        FormS.EmailPatOrLab = true;
                        FormS.PaperCopies--;
                    }
                }
            }
            Referral referral = null;

            if (SheetCur.SheetType == SheetTypeEnum.ReferralSlip ||
                SheetCur.SheetType == SheetTypeEnum.ReferralLetter)
            {
                FormS.Email2Visible = true;
                SheetParameter parameter = SheetParameter.GetParamByName(SheetCur.Parameters, "ReferralNum");
                if (parameter == null)              //it can be null sometimes because of old bug in db.
                {
                    FormS.Email2Visible = false;    //prevents trying to attach email to nonexistent referral.
                }
                else
                {
                    long referralNum = PIn.Long(parameter.ParamValue.ToString());
                    referral = Referrals.GetReferral(referralNum);
                    if (referral.EMail != "")
                    {
                        FormS.Email2Address = referral.EMail;
                        FormS.Email2        = true;
                        FormS.PaperCopies--;
                    }
                }
            }
            else
            {
                FormS.Email2Visible = false;
            }
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (FormS.PaperCopies > 0)
            {
                SheetPrinting.Print(SheetCur, FormS.PaperCopies, RxIsControlled);
            }
            EmailMessage message;
            Random       rnd        = new Random();
            string       attachPath = EmailMessages.GetEmailAttachPath();
            string       fileName;
            string       filePathAndName;
            EmailAddress emailAddress;
            Patient      patCur = Patients.GetPat(SheetCur.PatNum);

            if (patCur == null)
            {
                emailAddress = EmailAddresses.GetByClinic(0);
            }
            else
            {
                emailAddress = EmailAddresses.GetByClinic(patCur.ClinicNum);
            }
            //Graphics g=this.CreateGraphics();
            if (FormS.EmailPatOrLab)
            {
                fileName        = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString() + ".pdf";
                filePathAndName = ODFileUtils.CombinePaths(attachPath, fileName);
                SheetPrinting.CreatePdf(SheetCur, filePathAndName);
                //Process.Start(filePathAndName);
                message             = new EmailMessage();
                message.PatNum      = SheetCur.PatNum;
                message.ToAddress   = FormS.EmailPatOrLabAddress;
                message.FromAddress = emailAddress.SenderAddress;              //Can be blank just as it could with the old pref.
                message.Subject     = SheetCur.Description.ToString();         //this could be improved
                EmailAttach attach        = new EmailAttach();
                string      shortFileName = Regex.Replace(SheetCur.Description.ToString(), @"[^\w'@-_()&]", "");
                attach.DisplayedFileName = shortFileName + ".pdf";
                attach.ActualFileName    = fileName;
                message.Attachments.Add(attach);
                FormEmailMessageEdit FormE = new FormEmailMessageEdit(message);
                FormE.IsNew = true;
                FormE.ShowDialog();
            }
            if ((SheetCur.SheetType == SheetTypeEnum.ReferralSlip ||
                 SheetCur.SheetType == SheetTypeEnum.ReferralLetter) &&
                FormS.Email2)
            {
                //email referral
                fileName        = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString() + ".pdf";
                filePathAndName = ODFileUtils.CombinePaths(attachPath, fileName);
                SheetPrinting.CreatePdf(SheetCur, filePathAndName);
                //Process.Start(filePathAndName);
                message             = new EmailMessage();
                message.PatNum      = SheetCur.PatNum;
                message.ToAddress   = FormS.Email2Address;
                message.FromAddress = emailAddress.SenderAddress;                                         //Can be blank just as it could with the old pref.
                message.Subject     = Lan.g(this, "RE: ") + Patients.GetLim(SheetCur.PatNum).GetNameLF(); //works even if patnum invalid
                //SheetCur.Description.ToString()+" to "+Referrals.GetNameFL(referral.ReferralNum);//this could be improved
                EmailAttach attach        = new EmailAttach();
                string      shortFileName = Regex.Replace(SheetCur.Description.ToString(), @"[^\w,'@-_()&]", "");
                attach.DisplayedFileName = shortFileName + ".pdf";
                attach.ActualFileName    = fileName;
                message.Attachments.Add(attach);
                FormEmailMessageEdit FormE = new FormEmailMessageEdit(message);
                FormE.IsNew = true;
                FormE.ShowDialog();
            }
            //g.Dispose();
            DialogResult = DialogResult.OK;
        }
Пример #30
0
		private void butEmail_Click(object sender,EventArgs e) {
			if(grid.Rows.Count==0) {
				MsgBox.Show(this,"There are no Patients in the table.  Must have at least one.");
				return;
			}
			if(!EmailAddresses.ExistsValidEmail()) {
				MsgBox.Show(this,"You need to enter an SMTP server name in e-mail setup before you can send e-mail.");
				return;
			}
			if(PrefC.GetLong(PrefName.ConfirmStatusEmailed)==0) {
				MsgBox.Show(this,"You need to set a status first for confirmation e-mails in the Recall Setup window.");
				return;
			}
			if(grid.SelectedIndices.Length==0) {
				ContactMethod cmeth;
				for(int i=0;i<Table.Rows.Count;i++) {
					cmeth=(ContactMethod)PIn.Int(Table.Rows[i]["PreferConfirmMethod"].ToString());
					if(cmeth!=ContactMethod.Email) {
						continue;
					}
					if(Table.Rows[i]["confirmed"].ToString()==DefC.GetName(DefCat.ApptConfirmed,PrefC.GetLong(PrefName.ConfirmStatusEmailed))) {//Already confirmed by email
						continue;
					}
					if(Table.Rows[i]["email"].ToString()=="") {
						continue;
					}
					grid.SetSelected(i,true);
				}
				if(grid.SelectedIndices.Length==0) {
					MsgBox.Show(this,"Confirmations have been sent to all patients of email type who also have an email address entered.");
					return;
				}
			}
			else {//deselect the ones that do not have email addresses specified
				int skipped=0;
				for(int i=grid.SelectedIndices.Length-1;i>=0;i--) {
					if(Table.Rows[grid.SelectedIndices[i]]["email"].ToString()=="") {
						skipped++;
						grid.SetSelected(grid.SelectedIndices[i],false);
					}
				}
				if(grid.SelectedIndices.Length==0) {
					MsgBox.Show(this,"None of the selected patients had email addresses entered.");
					return;
				}
				if(skipped>0) {
					MessageBox.Show(Lan.g(this,"Selected patients skipped due to missing email addresses: ")+skipped.ToString());
				}
			}
			if(!MsgBox.Show(this,MsgBoxButtons.YesNo,"Send email to all of the selected patients?")) {
				return;
			}
			Cursor=Cursors.WaitCursor;
			EmailMessage message;
			string str="";
			List<long> patNumsSelected=new List<long>();
			List<long> patNumsFailed=new List<long>();
			EmailAddress emailAddress;
			for(int i=0;i<grid.SelectedIndices.Length;i++){
				message=new EmailMessage();
				message.PatNum=PIn.Long(Table.Rows[grid.SelectedIndices[i]]["PatNum"].ToString());
				message.ToAddress=Table.Rows[grid.SelectedIndices[i]]["email"].ToString();//Could be guarantor email.
				emailAddress=EmailAddresses.GetByClinic(PIn.Long(Table.Rows[grid.SelectedIndices[i]]["ClinicNum"].ToString()));
				message.FromAddress=emailAddress.SenderAddress;				
				message.Subject=PrefC.GetString(PrefName.ConfirmEmailSubject);
				patNumsSelected.Add(message.PatNum);
				str=PrefC.GetString(PrefName.ConfirmEmailMessage);
				str=str.Replace("[NameF]",Table.Rows[grid.SelectedIndices[i]]["nameF"].ToString());
				str=str.Replace("[NameFL]",Table.Rows[grid.SelectedIndices[i]]["nameFL"].ToString());
				str=str.Replace("[date]",((DateTime)Table.Rows[grid.SelectedIndices[i]]["AptDateTime"]).ToShortDateString());
				str=str.Replace("[time]",((DateTime)Table.Rows[grid.SelectedIndices[i]]["AptDateTime"]).ToShortTimeString());
				message.BodyText=str;
				try {
					EmailMessages.SendEmailUnsecure(message,emailAddress);
				}
				catch {
					patNumsFailed.Add(message.PatNum);
					continue;
				}
				message.MsgDateTime=DateTime.Now;
				message.SentOrReceived=EmailSentOrReceived.Sent;
				EmailMessages.Insert(message);
				Appointments.SetConfirmed(PIn.Long(Table.Rows[grid.SelectedIndices[i]]["AptNum"].ToString()),PrefC.GetLong(PrefName.ConfirmStatusEmailed));
			}
			Cursor=Cursors.Default;
			if(patNumsFailed.Count==grid.SelectedIndices.Length){ //all failed
				//no need to refresh
				MsgBox.Show(this,"All emails failed. Possibly due to invalid email addresses, a loss of connectivity, or a firewall blocking communication.");//msg: all failed
				return;
			}
			else if(patNumsFailed.Count>0){//if some failed
				FillMain();
				//reselect only the failed ones
				for(int i=0;i<Table.Rows.Count;i++) { //table.Rows.Count=grid.Rows.Count
					long patNum=PIn.Long(Table.Rows[i]["PatNum"].ToString());
					if(patNumsFailed.Contains(patNum)) {
						grid.SetSelected(i,true);
					}
				}
				MsgBox.Show(this,"Some emails failed to send.");
				return;
			}
			//none failed
			FillMain();
			//reselect the original list 
			for(int i=0;i<Table.Rows.Count;i++) {
				long patNum=PIn.Long(Table.Rows[i]["PatNum"].ToString());
				if(patNumsSelected.Contains(patNum)) {
					grid.SetSelected(i,true);
				}
			}
		}