Exemplo n.º 1
0
        private static string FormatContactInfo(Family[] roster, Group group)
        {
            StringBuilder contactInfo = new StringBuilder();

            foreach (string id in group.Members)
            {
                if (id == null) continue;

                var family = Array.Find(roster, f => f.FamilyId == id);
                Debug.Assert(family != null);

                contactInfo.AppendFormat("{0}, {1} and {2}", family.LastName, GetStringFor(family.FirstNames, 0), GetStringFor(family.FirstNames, 1));
                contactInfo.AppendLine();
                contactInfo.AppendFormat("\t{0}\t{1}", GetStringFor(family.EmailAddresses, 0), GetStringFor(family.PhoneNumbers, 0));
                string email2 = GetStringFor(family.EmailAddresses, 1);
                string phone2 = GetStringFor(family.PhoneNumbers, 1);
                if (!String.IsNullOrWhiteSpace(email2))
                {
                    contactInfo.AppendLine();
                    contactInfo.AppendFormat("\t{0}\t{1}", email2, phone2);
                }
                contactInfo.AppendLine();
                contactInfo.AppendLine();
            }

            return contactInfo.ToString();
        }
Exemplo n.º 2
0
 private void AddGroupToBlacklists(Group group)
 {
     for (int i = 0; i < group.Members.Length; ++i)
     {
         for (int j = i + 1; j < group.Members.Length; ++j)
         {
             AddBlacklistItems(group.Members[i], group.Members[j]);
         }
     }
 }
Exemplo n.º 3
0
        private static void SendEmailToGroups(Family[] roster, Group[] generatedGroups)
        {
            foreach (Group g in generatedGroups)
            {
                using (MailMessage mail = new MailMessage())
                {
                    mail.From = new MailAddress("*****@*****.**", "Kevin and Sarah Reynolds");
                    AddEMailRecipients(roster, g.Members, mail.To);
                    //mail.CC.Add(new MailAddress("*****@*****.**", "Larry Rutledge"));
                    //mail.CC.Add(new MailAddress("*****@*****.**", "Tina Rutledge"));
                    mail.Subject = "Your Dinners for 6 Group";
                    mail.IsBodyHtml = false;

                    // assign a random group member to initiate first contact.
                    int n = new Random().Next(g.Members.Length);
                    var initiatingFamily = Array.Find(roster, f => f.FamilyId == g.Members[n]);

                    mail.Body = "Below is your dinners for 6 group for this quarter.  To help get things started, one couple in each group has been chosen at random to initiate first contact.  Try to meet three times this quarter.  Please make an earnest effort to get together with your group--they will likely not meet without you!\n\nOne more thing: Please include the Rutledges in your group correspondence ([email protected]; [email protected]).  They would like to crash some dinners for six groups--unless you're going to McDonald's.\n\n";
                    mail.Body += "Couple responsible for getting the ball rolling: " + initiatingFamily.LastName + "\n\n";
                    mail.Body += FormatContactInfo(roster, g);

                    using (SmtpClient smtpClient = new SmtpClient("smtp.live.com", 587))
                    {
                        smtpClient.UseDefaultCredentials = false;
                        smtpClient.EnableSsl = true;
                        smtpClient.Credentials = new NetworkCredential("*****@*****.**", "*Kevin2Olathe*");
                        smtpClient.Send(mail);
                    }
                }
            }
        }
Exemplo n.º 4
0
        private bool CanAddToGroup(Group group, string familyId)
        {
            if (group.IsFull()) return false;

            List<string> familyBlacklist;
            if (!_blacklists.TryGetValue(familyId, out familyBlacklist) ||
                familyBlacklist == null ||
                familyBlacklist.Count == 0)
            {
                return true;
            }

            return !Array.Exists(group.Members, id => familyBlacklist.Contains(id));
        }