예제 #1
0
        public EmailDetails GetEmailDetails(string AppCode, int PersID, MySqlConnection conn, string ContractNumber, string ContractName, string ContractEndDate, string DaysUntilExpired, string ToEmails, string CCEmails)
        {
            try
            {
                using (conn)
                {
                    //Open connection if not open
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }

                    using (cmd)
                    {
                        cmd.Connection = conn;

                        cmd.Parameters.Clear();

                        cmd.Parameters.AddWithValue("AppCode", AppCode);
                        cmd.Parameters.AddWithValue("PersonID", PersID);
                        cmd.Parameters.AddWithValue("ContractNumber", ContractNumber);
                        cmd.Parameters.AddWithValue("ContractName", ContractName);
                        cmd.Parameters.AddWithValue("ContractEndDate", ContractEndDate);
                        cmd.Parameters.AddWithValue("DaysUntilExpired", DaysUntilExpired);
                        cmd.Parameters.AddWithValue("ToEmails", ToEmails);
                        cmd.Parameters.AddWithValue("CCEmails", CCEmails);

                        cmd.CommandText = "HSPD12Email_Main";
                        cmd.CommandType = CommandType.StoredProcedure;

                        MySqlDataReader emailData = cmd.ExecuteReader();

                        //Return details depending on type
                        while (emailData.Read())
                        {
                            return(EmailDetails.GetEmailDetails(emailData));
                        }

                        return(null);
                    }
                }
            }
            catch (MySqlException)
            {
                //Log exception
                throw;
            }
        }
예제 #2
0
        private static EmailDetails GetEmailDetails(IDataRecord record)
        {
            try
            {
                var emailData = new EmailDetails
                {
                    /*
                     * Pers_FullName = record["fullname"].ToString(),
                     * Pers_SubjectName = record["subjectname"].ToString(),
                     * Pers_Position = record["position"].ToString(),
                     * Pers_Region = record["region"].ToString(),
                     * Pers_MajorOrg = record["majororg"].ToString(),
                     * Pers_IsCitizen = record["iscitizen"].ToString(),
                     * Pers_InvestigationDate = record["investigationdate"].ToString(),
                     * Pers_InvestigationRequested = record["investigationrequested"].ToString(),
                     * Pers_InvestigationType = record["investigationtype"].ToString(),
                     * Pers_SponsorDate = record["sponsoreddate"].ToString(),
                     * Pers_PortofEntry = record["portofentry"].ToString(),
                     * boolTemplate = record["Templates"].ToString(),
                     * boolAttachement = record["Attachments"].ToString(),
                     * boolSummary = record["Summary"].ToString(),
                     * GSAPOCEMails = record["gsaPOCEMails"].ToString(),
                     * VendorPOCEmails = record["vendorPOCEmails"].ToString(),
                     * FASEMail = record["fasEMail"].ToString(),
                     * ChildcareEMail = record["childcareEMail"].ToString(),
                     * RegionalEMail = record["zone_email"].ToString(),
                     * SponsorshipEmails = record["sponsorshipEmails"].ToString(),
                     * PhoneNumber = record["zone_phone"].ToString()
                     */

                    EmailBody       = record["eMailBody"].ToString(),
                    EmailSubject    = record["eMailSubject"].ToString(),
                    EmailFromAdd    = record["eMailFromAdd"].ToString(),
                    EmailToAdd      = record["eMailToAdd"].ToString(),
                    EmailCCAdd      = record["eMailCCAdd"].ToString(),
                    EmailBCCAdd     = record["eMailBCCAdd"].ToString(),
                    EmailAttachment = record["eMailAttachment"].ToString()
                };
                return(emailData);
                //return null;
            }
            catch (Exception)
            {
                //Log exception
                throw;
            }
        }
예제 #3
0
        /// <summary>
        /// New method that access the DB and gets the email details.
        /// Developed as part of email consolidation.
        /// <summary>
        /// <param name="AppCode"></param>
        private void HSPD12Email(string AppCode, string ContractNumber, string ContractName, string ContractEndDate, string DaysUntilExpired, string ToEmails, string CCEmails)
        {
            //Declare function variables
            EmailDetails emailData = new EmailDetails();

            emailData = emailData.GetEmailDetails(AppCode, personID, conn, ContractNumber, ContractName, ContractEndDate, DaysUntilExpired, ToEmails, CCEmails);
            if (emailData != null)
            {
                string strEmailAttachment = string.Empty;
                if (emailData.EmailAttachment.IndexOf(";") > 0)
                {
                    strEmailAttachment = onboardingLocation + emailData.EmailAttachment.Replace(";", string.Concat(";", onboardingLocation));
                }

                if (emailData.EmailFromAdd.Contains("@"))
                {
                    message.Send(emailData.EmailFromAdd, emailData.EmailToAdd, emailData.EmailCCAdd, emailData.EmailBCCAdd, emailData.EmailSubject, emailData.EmailBody, strEmailAttachment, smtpServer, true);
                }
            }
        }