Beispiel #1
0
        private void FillComboEmail()
        {
            _listEmailAddresses = EmailAddresses.GetDeepCopy();          //Does not include user specific email addresses.
            List <Clinic> listClinicsAll = Clinics.GetDeepCopy();

            _listEmailAddresses.RemoveAll(x => listClinicsAll.Any(y => x.EmailAddressNum == y.EmailAddressNum));          //Exclude any email addresses that are associated to a clinic.
            //Exclude default practice email address.
            _listEmailAddresses.RemoveAll(x => x.EmailAddressNum == PrefC.GetLong(PrefName.EmailDefaultAddressNum));
            //Exclude web mail notification email address.
            _listEmailAddresses.RemoveAll(x => x.EmailAddressNum == PrefC.GetLong(PrefName.EmailNotifyAddressNum));
            comboEmailFrom.Items.Add(Lan.g(this, "Practice/Clinic"));           //default
            comboEmailFrom.SelectedIndex = 0;
            textFromAddress.Text         = EmailAddresses.GetByClinic(Clinics.ClinicNum).EmailUsername;
            //Add all email addresses which are not associated to a user, a clinic, or either of the default email addresses.
            for (int i = 0; i < _listEmailAddresses.Count; i++)
            {
                comboEmailFrom.Items.Add(_listEmailAddresses[i].EmailUsername);
            }
            //Add user specific email address if present.
            EmailAddress emailAddressMe = EmailAddresses.GetForUser(Security.CurUser.UserNum);            //can be null

            if (emailAddressMe != null)
            {
                _listEmailAddresses.Insert(0, emailAddressMe);
                comboEmailFrom.Items.Insert(1, Lan.g(this, "Me") + " <" + emailAddressMe.EmailUsername + ">");        //Just below Practice/Clinic
                comboEmailFrom.SelectedIndex = 1;
                textFromAddress.Text         = emailAddressMe.EmailUsername;
            }
        }
Beispiel #2
0
        private void FillGrid()
        {
            EmailAddresses.RefreshCache();
            _listEmailAddresses = EmailAddresses.GetDeepCopy();
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            col = new ODGridColumn(Lan.g(this, "User Name"), 240);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Sender Address"), 270);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Default"), 50, HorizontalAlignment.Center);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Notify"), 0, HorizontalAlignment.Center);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < _listEmailAddresses.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(_listEmailAddresses[i].EmailUsername);
                row.Cells.Add(_listEmailAddresses[i].SenderAddress);
                row.Cells.Add((_listEmailAddresses[i].EmailAddressNum == PrefC.GetLong(PrefName.EmailDefaultAddressNum))?"X":"");
                row.Cells.Add((_listEmailAddresses[i].EmailAddressNum == PrefC.GetLong(PrefName.EmailNotifyAddressNum))?"X":"");
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Beispiel #3
0
        private void FillGrid()
        {
            EmailAddresses.RefreshCache();
            _listEmailAddresses = EmailAddresses.GetDeepCopy();
            //Add user specific email addresses to the list
            List <Userod> listUsers = new List <Userod>();

            if (Security.IsAuthorized(Permissions.SecurityAdmin, true) && !IsSelectionMode)
            {
                listUsers.AddRange(Userods.GetUsers());                //If authorized, get all non-hidden users.
            }
            else
            {
                listUsers.Add(Security.CurUser);                //Otherwise, just this user.
            }
            foreach (Userod user in listUsers)
            {
                EmailAddress userAddress = EmailAddresses.GetForUser(user.UserNum);
                if (userAddress != null)
                {
                    _listEmailAddresses.Insert(0, userAddress);
                }
            }
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col;

            col = new GridColumn(Lan.g(this, "User Name"), 240);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "Sender Address"), 270);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "User"), 135);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "Default"), 50, HorizontalAlignment.Center);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "Notify"), 0, HorizontalAlignment.Center);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            GridRow row;

            foreach (EmailAddress emailAddress in _listEmailAddresses)
            {
                row = new GridRow();
                row.Cells.Add(emailAddress.EmailUsername);
                row.Cells.Add(emailAddress.SenderAddress);
                row.Cells.Add(Userods.GetName(emailAddress.UserNum));
                row.Cells.Add((emailAddress.EmailAddressNum == PrefC.GetLong(PrefName.EmailDefaultAddressNum))?"X":"");
                row.Cells.Add((emailAddress.EmailAddressNum == PrefC.GetLong(PrefName.EmailNotifyAddressNum))?"X":"");
                row.Tag = emailAddress;
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }
		public void LoadEmailAddresses(long clinicNum) {
      //emails to include: 
      //1. Default Practice/Clinic
      //2. Me
      //3. All other email addresses not tied to a user
      _listEmailAddresses=new List<EmailAddress>();
      EmailAddress emailAddressDefault=EmailAddresses.GetByClinic(clinicNum);
      EmailAddress emailAddressMe=EmailAddresses.GetForUser(Security.CurUser.UserNum);
      if(emailAddressDefault!=null) {
        _listEmailAddresses.Add(emailAddressDefault);
      }
      if(emailAddressMe!=null) {
        _listEmailAddresses.Add(emailAddressMe);
      }
			foreach(EmailAddress emailCur in EmailAddresses.GetDeepCopy()) {
        if((emailAddressDefault!=null && emailCur.EmailUsername==emailAddressDefault.EmailUsername)
          || (emailAddressMe!=null && emailCur.EmailUsername==emailAddressMe.EmailUsername)) {
          continue;
        }
        _listEmailAddresses.Add(emailCur);
      }
		}
        private void FillComboEmail()
        {
            //emails to include:
            //1. Default Practice/Clinic
            //2. Me
            //3. All other email addresses not tied to a user
            _listEmailAddresses = new List <EmailAddress>();
            EmailAddress emailAddressDefault = EmailAddresses.GetByClinic(ClinicNum);
            EmailAddress emailAddressMe      = EmailAddresses.GetForUser(Security.CurUser.UserNum);

            if (emailAddressDefault != null)
            {
                _listEmailAddresses.Add(emailAddressDefault);
            }
            if (emailAddressMe != null)
            {
                _listEmailAddresses.Add(emailAddressMe);
            }
            foreach (EmailAddress emailCur in EmailAddresses.GetDeepCopy())
            {
                if ((emailAddressDefault != null && emailCur.EmailUsername == emailAddressDefault.EmailUsername) ||
                    (emailAddressMe != null && emailCur.EmailUsername == emailAddressMe.EmailUsername))
                {
                    continue;
                }
                _listEmailAddresses.Add(emailCur);
            }
            _listEmailAddresses.ForEach(x => {
                if (emailAddressDefault != null && x.EmailUsername == emailAddressDefault.EmailUsername)
                {
                    comboEmailFrom.Items.Add(Lan.g(this, "Practice/Clinic") + " <" + x.EmailUsername + ">");
                }
                else if (emailAddressMe != null && x.EmailUsername == emailAddressMe.EmailUsername)
                {
                    comboEmailFrom.Items.Add(Lan.g(this, "Me") + " <" + x.EmailUsername + ">");
                }
                else
                {
                    comboEmailFrom.Items.Add(x.EmailUsername);
                }
            });
            for (int i = 0; i < _listEmailAddresses.Count; i++)
            {
                //Sending email address should be set before loading this control.  This is the best approach to matching email account.
                if (EmailAddressPreview != null)
                {
                    if (_listEmailAddresses[i].EmailAddressNum == EmailAddressPreview.EmailAddressNum)
                    {
                        comboEmailFrom.SelectedIndex = i;
                        break;                        //Found the right emailaddress, no need to look further.
                    }
                }
                else                  //Less reliable, but works in most email account setups.
                {
                    string senderAddress = _listEmailAddresses[i].SenderAddress.Trim().ToLower();
                    string emailUserName = _listEmailAddresses[i].EmailUsername.Trim().ToLower();
                    string fromAddress   = _emailMessage.FromAddress.Trim().ToLower();
                    if ((senderAddress != "" && fromAddress.Contains(senderAddress)) ||
                        (emailUserName != "" && fromAddress.Contains(emailUserName)) ||
                        (fromAddress != "" && (emailUserName.Contains(fromAddress) || senderAddress.Contains(fromAddress))))
                    {
                        comboEmailFrom.SelectedIndex = i;
                        break;                        //Found an emailaddress that is probably right, best to stop here as opposed to finding another potential match.
                    }
                }
            }
            if (!_isComposing || !_isSigningEnabled)
            {
                return;
            }
            if (emailAddressDefault != null)
            {
                SetSig(EmailMessages.GetCertFromPrivateStore(GetOutgoingEmailAddress().EmailUsername));
            }
        }
Beispiel #6
0
        private void FillComboEmail()
        {
            //emails to include:
            //1. Default Practice/Clinic
            //2. Me
            //3. All other email addresses not tied to a user
            _listEmailAddresses = new List <EmailAddress>();
            EmailAddress emailAddressDefault = EmailAddresses.GetByClinic(ClinicNum);
            EmailAddress emailAddressMe      = EmailAddresses.GetForUser(Security.CurUser.UserNum);

            if (emailAddressDefault != null)
            {
                _listEmailAddresses.Add(emailAddressDefault);
            }
            if (emailAddressMe != null)
            {
                _listEmailAddresses.Add(emailAddressMe);
            }
            foreach (EmailAddress emailCur in EmailAddresses.GetDeepCopy())
            {
                if ((emailAddressDefault != null && emailCur.EmailUsername == emailAddressDefault.EmailUsername) ||
                    (emailAddressMe != null && emailCur.EmailUsername == emailAddressMe.EmailUsername))
                {
                    continue;
                }
                _listEmailAddresses.Add(emailCur);
            }
            _listEmailAddresses.ForEach(x => {
                if (emailAddressDefault != null && x.EmailUsername == emailAddressDefault.EmailUsername)
                {
                    comboEmailFrom.Items.Add(Lan.g(this, "Practice/Clinic") + " <" + x.EmailUsername + ">");
                }
                else if (emailAddressMe != null && x.EmailUsername == emailAddressMe.EmailUsername)
                {
                    comboEmailFrom.Items.Add(Lan.g(this, "Me") + " <" + x.EmailUsername + ">");
                }
                else
                {
                    comboEmailFrom.Items.Add(x.EmailUsername);
                }
            });
            //not perfect. Tries to guess what the selected combobox item should be based on the current text in FromAddress.
            for (int i = 0; i < _listEmailAddresses.Count; i++)
            {
                string senderAddress = _listEmailAddresses[i].SenderAddress.Trim().ToLower();
                string emailUserName = _listEmailAddresses[i].EmailUsername.Trim().ToLower();
                string fromAddress   = _emailMessage.FromAddress.Trim().ToLower();
                if ((senderAddress != "" && fromAddress.Contains(senderAddress)) ||
                    (emailUserName != "" && fromAddress.Contains(emailUserName)) ||
                    (fromAddress != "" && (emailUserName.Contains(fromAddress) || senderAddress.Contains(fromAddress))))
                {
                    comboEmailFrom.SelectedIndex = i;
                }
            }
            if (!_isComposing || !_isSigningEnabled)
            {
                return;
            }
            if (emailAddressDefault != null)
            {
                SetSig(EmailMessages.GetCertFromPrivateStore(GetOutgoingEmailAddress().EmailUsername));
            }
        }