コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="emaildata"></param>
        /// <param name="profilename"></param>
        /// <returns></returns>
        private async Task <bool> SendSQLEMail(EMailData emaildata, string profilename)
        {
            bool _retVal = false;

            try
            {
                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection  = new SqlConnection(this.ConnectionString);
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "usp_SendDBMail";
                    command.Parameters.AddWithValue("@ProfileName", profilename);
                    command.Parameters.AddWithValue("@RecipientAddress", emaildata.RecipientAddress);
                    command.Parameters.AddWithValue("@FromAddress", this.FromAddress);
                    command.Parameters.AddWithValue("@CCAddress", emaildata.CCAddress);
                    command.Parameters.AddWithValue("@SubjectText", emaildata.Subject_Text);
                    command.Parameters.AddWithValue("@BodyText", emaildata.Body_Text);
                    command.Connection.Open();
                    await command.ExecuteNonQueryAsync();

                    command.Connection.Close();
                }
                _retVal = true;
                return(_retVal);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
ファイル: ProcessMonster.cs プロジェクト: GSA/ERIS
        //Constructor
        public ProcessMonster(IMapper dataMapper, ref EMailData emailData, Lookup lookups)
        {
            retrieve = new RetrieveData(dataMapper);

            this.lookups = lookups;

            this.emailData = emailData;
        }
コード例 #3
0
        public void GenerateSummaryFiles(EMailData emailData)
        {
            if (SuccessfulUsersProcessed.Count > 0)
            {
                SuccessfulUsersProcessed = SuccessfulUsersProcessed.OrderBy(o => o.LastName).ThenBy(t => t.FirstName).ToList();

                emailData.HRSuccessfulFilename = SummaryFileGenerator.GenerateSummaryFile <ProcessedSummary, ProcessedSummaryMapping>(ConfigurationManager.AppSettings["SUCCESSSUMMARYFILENAME"].ToString(), SuccessfulUsersProcessed);
                log.Info("HR Success File: " + emailData.HRSuccessfulFilename);
            }

            if (UnsuccessfulUsersProcessed.Count > 0)
            {
                UnsuccessfulUsersProcessed = UnsuccessfulUsersProcessed.OrderBy(o => o.LastName).ThenBy(t => t.FirstName).ToList();

                emailData.HRUnsuccessfulFilename = SummaryFileGenerator.GenerateSummaryFile <ProcessedSummary, ProcessedSummaryMapping>(ConfigurationManager.AppSettings["ERRORSUMMARYFILENAME"].ToString(), UnsuccessfulUsersProcessed);
                log.Info("HR Error File: " + emailData.HRUnsuccessfulFilename);
            }

            if (IdenticalRecords.Count > 0)
            {
                IdenticalRecords = IdenticalRecords.OrderBy(o => o.LastName).ThenBy(t => t.FirstName).ToList();

                emailData.HRIdenticalFilename = SummaryFileGenerator.GenerateSummaryFile <IdenticalRecordSummary, IdenticalRecordSummaryMapping>(ConfigurationManager.AppSettings["IDENTICALSUMMARYFILENAME"].ToString(), IdenticalRecords);
                log.Info("HR Identical File:" + emailData.HRIdenticalFilename);
            }

            if (SocialSecurityNumberChanges.Count > 0)
            {
                SocialSecurityNumberChanges = SocialSecurityNumberChanges.OrderBy(o => o.LastName).ThenBy(t => t.FirstName).ToList();

                emailData.HRSocialSecurityNumberChangeFilename = SummaryFileGenerator.GenerateSummaryFile <SocialSecurityNumberChangeSummary, SocialSecurityNumberChangeSummaryMapping>(ConfigurationManager.AppSettings["SOCIALSECURITYNUMBERCHANGESUMMARYFILENAME"].ToString(), SocialSecurityNumberChanges);
                log.Info("HR Social Security Number Change File: " + emailData.HRSocialSecurityNumberChangeFilename);
            }

            if (InactiveRecords.Count > 0)
            {
                InactiveRecords = InactiveRecords.OrderBy(o => o.LastName).ThenBy(t => t.FirstName).ToList();

                emailData.HRInactiveFilename = SummaryFileGenerator.GenerateSummaryFile <InactiveSummary, InactiveSummaryMapping>(ConfigurationManager.AppSettings["INACTIVESUMMARYFILENAME"].ToString(), InactiveRecords);
                log.Info("HR Inactive File: " + emailData.HRInactiveFilename);
            }

            if (RecordsNotFound.Count > 0)
            {
                RecordsNotFound = RecordsNotFound.OrderBy(o => o.LastName).ThenBy(t => t.FirstName).ToList();

                emailData.HRRecordsNotFoundFileName = SummaryFileGenerator.GenerateSummaryFile <RecordNotFoundSummary, RecordNotFoundSummaryMapping>(ConfigurationManager.AppSettings["RECORDNOTFOUNDSUMMARYFILENAME"].ToString(), RecordsNotFound);
                log.Info("HR Name Not Found File: " + emailData.HRRecordsNotFoundFileName);
            }
        }
コード例 #4
0
        public void GenerateSummaryFiles(EMailData emailData)
        {
            if (SuccessfulUsersProcessed.Count > 0)
            {
                SuccessfulUsersProcessed = SuccessfulUsersProcessed.OrderBy(o => o.EmployeeID).ToList();

                emailData.SeparationSuccessfulFilename = SummaryFileGenerator.GenerateSummaryFile <SeparationSummary, SeperationSummaryMapping>(ConfigurationManager.AppSettings["SEPARATIONSUMMARYFILENAME"].ToString(), SuccessfulUsersProcessed);
                log.Info("Separation Success File: " + emailData.SeparationSuccessfulFilename);
            }

            if (UnsuccessfulUsersProcessed.Count > 0)
            {
                UnsuccessfulUsersProcessed = UnsuccessfulUsersProcessed.OrderBy(o => o.EmployeeID).ToList();

                emailData.SeparationErrorFilename = SummaryFileGenerator.GenerateSummaryFile <SeparationSummary, SeperationErrorMapping>(ConfigurationManager.AppSettings["SEPARATIONERRORSUMMARYFILENAME"].ToString(), UnsuccessfulUsersProcessed);
                log.Info("Separation Error File: " + emailData.SeparationErrorFilename);
            }
        }
コード例 #5
0
ファイル: ProcessSummary.cs プロジェクト: GSA/ERIS
        public void GenerateSummaryFiles(EMailData emailData)
        {
            if (CreatedRecordsProcessed.Count > 0)
            {
                CreatedRecordsProcessed = CreatedRecordsProcessed.OrderBy(o => o.MonsterID).ToList();

                emailData.CreatedRecordFilename = SummaryFileGenerator.GenerateSummaryFile <CreatedSummary, CreatedSummaryMapping>(ConfigurationManager.AppSettings["CREATEDSUMMARYFILENAME"].ToString(), CreatedRecordsProcessed);

                Log.Info("Created File: " + emailData.CreatedRecordFilename);
            }

            if (UpdatedRecordsProcessed.Count > 0)
            {
                UpdatedRecordsProcessed = UpdatedRecordsProcessed.OrderBy(o => o.MonsterID).ToList();

                emailData.UpdatedRecordFilename = SummaryFileGenerator.GenerateSummaryFile <UpdatedSummary, UpdatedSummaryMapping>(ConfigurationManager.AppSettings["UPDATEDSUMMARYFILENAME"].ToString(), UpdatedRecordsProcessed);

                Log.Info("Updated File: " + emailData.UpdatedRecordFilename);
            }

            if (FlaggedRecordsProcessed.Count > 0)
            {
                FlaggedRecordsProcessed = FlaggedRecordsProcessed.OrderBy(o => o.MonsterID).ToList();

                emailData.FlaggRecordFilename = SummaryFileGenerator.GenerateSummaryFile <FlaggedSummary, FlaggedSummaryMapping>(ConfigurationManager.AppSettings["FLAGGEDSUMMARYFILENAME"].ToString(), FlaggedRecordsProcessed);

                Log.Info("Flagged File: " + emailData.FlaggRecordFilename);
            }

            if (UnsuccessfulProcessed.Count > 0)
            {
                UnsuccessfulProcessed = UnsuccessfulProcessed.OrderBy(o => o.MonsterID).ToList();

                emailData.ErrorFilename = SummaryFileGenerator.GenerateSummaryFile <ErrorSummary, ErrorSummaryMapping>(ConfigurationManager.AppSettings["ERRORSUMMARYFILENAME"].ToString(), UnsuccessfulProcessed);

                Log.Info("Error File: " + emailData.ErrorFilename);
            }
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="emaildata"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        private bool SendDotNetEMail(EMailData emaildata, string smtpusername = null, string smtppassword = null)
        {
            bool _retVal = false;

            try
            {
                var mailMessage = new MimeMessage();
                mailMessage.From.Add(new MailboxAddress("", this.FromAddress));
                mailMessage.To.Add(new MailboxAddress("", emaildata.RecipientAddress));
                if (emaildata.CCAddress != null)
                {
                    mailMessage.Cc.Add(new MailboxAddress("", emaildata.CCAddress));
                }
                mailMessage.Subject = emaildata.Subject_Text;
                mailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Plain)
                {
                    Text = emaildata.Body_Text
                };

                using (var smtpClient = new SmtpClient())
                {
                    smtpClient.Connect(this.SMTPServerNameOrIP, int.Parse(this.SMTPPortNumber));
                    if (smtpusername != null && smtppassword != null)
                    {
                        smtpClient.Authenticate(smtpusername, smtppassword);
                    }
                    smtpClient.Send(mailMessage);
                    smtpClient.Disconnect(true);
                }
                _retVal = true;
                return(_retVal);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #7
0
 public SendSummary(ref EMailData emailData)
 {
     this.emailData = emailData;
 }
コード例 #8
0
 public ProcessSeparation(ref EMailData emailData)
 {
     this.emailData = emailData;
 }
コード例 #9
0
        /// <summary>
        /// This method creates a list of E-Mail recipients and required data for the E-Mail.
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="emailtypeid"></param>
        /// <param name="includealternateaddress"></param>
        /// <param name="courseid"></param>
        /// <param name="newstudentaccountpassword"></param>
        /// <param name="ccuserid"></param>
        /// <returns></returns>
        private async Task <bool> BuildEMailListAsync(int userid, int emailtypeid, bool includealternateaddress, int?courseid = null, string newstudentaccountpassword = null, int?ccuserid = null)
        {
            bool _retVal = false;

            try
            {
                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection  = new SqlConnection(this.ConnectionString);
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "usp_GetEMailElements";
                    command.Parameters.AddWithValue("@UserID", userid);
                    command.Parameters.AddWithValue("@EMailTypeID", emailtypeid);
                    command.Parameters.AddWithValue("@GetAlternateAddress", includealternateaddress);
                    command.Parameters.AddWithValue("@CourseID", courseid);
                    command.Parameters.AddWithValue("@NewStudentAccountPWord", newstudentaccountpassword);
                    command.Parameters.AddWithValue("@CCUserID", ccuserid);
                    command.Connection.Open();
                    SqlDataReader rdr = await command.ExecuteReaderAsync();

                    if (rdr.HasRows)
                    {
                        while (rdr.Read())
                        {
                            // Create an EMail for the user's primary address, and
                            // add it to the "EMailList" list.

                            EMailData primaryemaildata = new EMailData();
                            primaryemaildata.FromAddress      = this.FromAddress;
                            primaryemaildata.RecipientAddress = rdr.GetString(0);
                            primaryemaildata.Subject_Text     = rdr.GetString(2);
                            primaryemaildata.Body_Text        = rdr.GetString(3);
                            if (!rdr.IsDBNull(4))
                            {
                                primaryemaildata.CCAddress = rdr.GetString(4);
                            }

                            EMailList.Add(primaryemaildata);

                            if (!rdr.IsDBNull(1))
                            {
                                // Create an EMail for the user's secondary address, and
                                // add it to the "EMailList" list.

                                EMailData altemaildata = new EMailData();
                                altemaildata.FromAddress      = this.FromAddress;
                                altemaildata.RecipientAddress = rdr.GetString(1);
                                altemaildata.Subject_Text     = rdr.GetString(2);
                                altemaildata.Body_Text        = rdr.GetString(3);
                                if (rdr.IsDBNull(4))
                                {
                                    altemaildata.CCAddress = rdr.GetString(4);
                                }

                                EMailList.Add(altemaildata);
                            }
                        }
                    }
                    rdr.Close();
                    command.Connection.Close();
                }
                _retVal = true;
                return(_retVal);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }