コード例 #1
0
        private static List <int> UpdateEmailTable(List <string> OverallEmailList)
        {
            using (QuarksoftDBEmailsEntities database = new QuarksoftDBEmailsEntities())
            {
                List <int> emailIDList = new List <int>();

                foreach (string emailItem in OverallEmailList)
                {
                    var foundEmail = database.Emails.FirstOrDefault(x => x.Email.Equals(emailItem));
                    if (foundEmail != null)
                    {
                        emailIDList.Add(foundEmail.EmailID);
                    }
                    else
                    {
                        //Add a New email
                        Emails newEmail = new Emails()
                        {
                            Email = emailItem, DateAdded = DateTime.Now
                        };
                        database.Emails.Add(newEmail);
                        database.SaveChanges();
                        //Add new EmailID
                        emailIDList.Add(newEmail.EmailID);
                    }
                }
                return(emailIDList);
            }
        }
コード例 #2
0
        private static List <int> UpdateDomainTable(List <string> OverallDomainList)
        {
            using (QuarksoftDBEmailsEntities database = new QuarksoftDBEmailsEntities())
            {
                List <int> emailIDList = new List <int>();

                foreach (string domainItem in OverallDomainList)
                {
                    var foundDomain = database.Domains.FirstOrDefault(x => x.DomainName.Equals(domainItem));
                    if (foundDomain != null)
                    {
                        emailIDList.Add(foundDomain.DomainID);
                    }
                    else
                    {
                        //Add a New Domain
                        Domains newDomain = new Domains()
                        {
                            DomainName = domainItem, DateAdded = DateTime.Now
                        };
                        database.Domains.Add(newDomain);
                        database.SaveChanges();
                        //Add new DomainID
                        emailIDList.Add(newDomain.DomainID);
                    }
                }
                return(emailIDList);
            }
        }
コード例 #3
0
 private static int?GetEmailID(string emailName)
 {
     using (QuarksoftDBEmailsEntities database = new QuarksoftDBEmailsEntities())
     {
         var Email = database.Emails.FirstOrDefault(x => x.Email.Equals(emailName));
         return((Email != null) ? Email.EmailID : -1);
     }
 }
コード例 #4
0
        private static long SaveEmailHeader(EmailHeader emailHeader)
        {
            using (QuarksoftDBEmailsEntities database = new QuarksoftDBEmailsEntities())
            {
                emailHeader.SenderEmailID = GetEmailID(ExtractEmails(emailHeader.Sender).First());
                //adding the timestamp
                emailHeader.DateAdded = DateTime.Now;

                database.EmailHeader.Add(emailHeader);
                database.SaveChanges();
                return(emailHeader.EmailHeaderID);
            }
        }
コード例 #5
0
 private static void SaveEmailDomains(long headerID, List <int> domainIDList)
 {
     using (QuarksoftDBEmailsEntities database = new QuarksoftDBEmailsEntities())
     {
         foreach (int domainID in domainIDList)
         {
             database.EmailDomains.Add(new EmailDomains()
             {
                 EmailHeaderID = headerID, DomainID = domainID, DateAdded = DateTime.Now
             });
         }
         database.SaveChanges();
     }
 }
コード例 #6
0
 private static void SaveEmailRecipients(long headerID, List <int> emailIDList)
 {
     using (QuarksoftDBEmailsEntities database = new QuarksoftDBEmailsEntities())
     {
         foreach (int emailID in emailIDList)
         {
             database.EmailRecipients.Add(new EmailRecipients()
             {
                 EmailHeaderID = headerID, EmailID = emailID, DateAdded = DateTime.Now
             });
         }
         database.SaveChanges();
     }
 }