protected void btnEmailOverdue_Click(object sender, EventArgs e) { IAM = Person.GetPersonFromActiveDirectory(iAm); Training training = Training.ThisTraining(Convert.ToInt32(ddlTraining.SelectedValue)); MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress(IAM.EmailAddress.ToString()); mailMessage.Subject = "Overdue Training"; mailMessage.Body = "Please complete " + training.Name + " at " + System.Configuration.ConfigurationManager.AppSettings["TakeTrainingURLString"].ToString() + training.Ident.ToString(); ArrayList alOverdue = new ArrayList(TrainingPerson.TrainingPersonList(training.Ident)); foreach (TrainingPerson userOverdue in alOverdue) { if (Convert.ToBoolean(userOverdue.Overdue)) { mailMessage.To.Add(userOverdue.EmailAddress.ToString()); } } try { //string xxx = mailMessage.To.ToString(); SmtpClient smtpClient = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["SMTPHost"].ToString()); smtpClient.Send(mailMessage); lblEmailResult.ForeColor = System.Drawing.Color.Maroon; lblEmailResult.Text = "Overdue email sent."; btnEmailOverdue.Visible = false; } catch (Exception ex) { lblEmailResult.Text = ex.InnerException.ToString(); } lblEmailResult.Visible = true; }
protected void GetPersonnelCollection(int training_ident) { Stopwatch watch = new Stopwatch(); watch.Start(); ArrayList alTrainingPersonList = new ArrayList(TrainingPerson.TrainingPersonList(training_ident)); watch.Stop(); Label mplblMessage = (Label)((SiteMaster)this.Master).FindControl("lblMessage"); mplblMessage.Text = alTrainingPersonList.Count.ToString() + " Total Records"; mplblMessage.Text += " Loaded in " + watch.Elapsed.Seconds.ToString() + " seconds."; dlPersonnel.DataSource = alTrainingPersonList; dlPersonnel.DataBind(); dlPersonnel.Visible = true; GetMajorCommandCollection(); GetCommandCollection(); GetOrganizationCollection(); }
private void ExtractSubCollection() { Stopwatch watch = new Stopwatch(); watch.Start(); int training_ident; training_ident = Convert.ToInt32(ddlTraining.SelectedValue); ArrayList alTrainingPersonList = new ArrayList(TrainingPerson.TrainingPersonList(training_ident)); ArrayList alFromFind = new ArrayList(); //if (txtFind.Text != "") //{ // foreach (TrainingPerson userFind in alTrainingPersonList) // { // if ((userFind.DisplayName.ToUpper().Contains(txtFind.Text.ToUpper()) == true) // || ((userFind.EmailAddress != null) && (userFind.EmailAddress.ToUpper().Contains(txtFind.Text.ToUpper()) == true)) // || ((userFind.DsnNumber != null) && (userFind.DsnNumber.ToUpper().Contains(txtFind.Text.ToUpper()) == true)) // || ((userFind.PhoneNumber != null) && (userFind.PhoneNumber.ToUpper().Contains(txtFind.Text.ToUpper()) == true)) // || ((userFind.Organization != null) && (userFind.Organization.ToUpper().Contains(txtFind.Text.ToUpper()) == true)) // || (userFind.WindowsLogonUserName.ToUpper().Contains(txtFind.Text.ToUpper()) == true) // ) // { // alFromFind.Add(userFind); // } // } //} //else //{ alFromFind = alTrainingPersonList; //} ArrayList alFromSelectedPersonnelType = new ArrayList(); if (rblPersonnelType.SelectedItem.Value == " All ") { alFromSelectedPersonnelType = alFromFind; } else { foreach (TrainingPerson userType in alFromFind) { if (((userType.EmployeeType != null) && ((userType.EmployeeType.ToUpper() == rblPersonnelType.SelectedItem.Value.ToUpper()))) || ((userType.EmployeeType != null) && ((rblPersonnelType.SelectedItem.Value.ToUpper() == "V") && (userType.EmployeeType.ToUpper() == "A")))) { alFromSelectedPersonnelType.Add(userType); } } } ArrayList alFromSelectedMajorCommand = new ArrayList(); if (ddlMajorCommands.SelectedItem.Value == " All ") { alFromSelectedMajorCommand = alFromSelectedPersonnelType; } else { foreach (TrainingPerson userMajorCommands in alFromSelectedPersonnelType) { if (userMajorCommands.MajorCommand.ToUpper() == ddlMajorCommands.SelectedItem.Value.ToUpper()) { alFromSelectedMajorCommand.Add(userMajorCommands); } } } ArrayList alFromSelectedCommand = new ArrayList(); if (ddlCommands.SelectedItem.Value == " All ") { alFromSelectedCommand = alFromSelectedMajorCommand; } else { foreach (TrainingPerson userCommands in alFromSelectedMajorCommand) { if (userCommands.Command.ToUpper() == ddlCommands.SelectedItem.Value.ToUpper()) { alFromSelectedCommand.Add(userCommands); } } } ArrayList alFromSelectedOrganization = new ArrayList(); if (ddlOrgainizations.SelectedItem.Value == " All ") { alFromSelectedOrganization = alFromSelectedCommand; } else { foreach (TrainingPerson userOfficeSymbols in alFromSelectedCommand) { if (userOfficeSymbols.Organization.ToUpper() == ddlOrgainizations.SelectedItem.Value.ToUpper()) { alFromSelectedOrganization.Add(userOfficeSymbols); } } } ArrayList alFromChkNoCompletion = new ArrayList(); if (!chkNoCompletion.Checked) { alFromChkNoCompletion = alFromSelectedOrganization; } else { foreach (TrainingPerson userNoCompletion in alFromSelectedOrganization) { if (userNoCompletion.LastCompleted == null) { alFromChkNoCompletion.Add(userNoCompletion); } } } ArrayList alFromChkLT30 = new ArrayList(); if (!chkLT30.Checked) { alFromChkLT30 = alFromChkNoCompletion; } else { foreach (TrainingPerson userLT30 in alFromChkNoCompletion) { if (Convert.ToBoolean(userLT30.DueLT30)) { alFromChkLT30.Add(userLT30); } } } ArrayList alFromChkOverdue = new ArrayList(); //StringBuilder recipientAddresses = new StringBuilder(); if (!chkOverdue.Checked) { alFromChkOverdue = alFromChkLT30; } else { foreach (TrainingPerson userOverdue in alFromChkLT30) { if (Convert.ToBoolean(userOverdue.Overdue)) { alFromChkOverdue.Add(userOverdue); //recipientAddresses.Append(" " + userOverdue.EmailAddress.ToString() + ";"); } } } watch.Stop(); Label mplblMessage = (Label)((SiteMaster)this.Master).FindControl("lblMessage"); mplblMessage.Text = alFromChkOverdue.Count.ToString() + " Total Records"; mplblMessage.Text += " Loaded in " + watch.Elapsed.Seconds.ToString() + " seconds."; dlPersonnel.DataSource = alFromChkOverdue; dlPersonnel.DataBind(); dlPersonnel.Visible = true; //if (chkOverdue.Checked) //{ // HyperLink lbtnOverdue = new HyperLink(); // lbtnOverdue.Text = "Email Overdue"; // lbtnOverdue.NavigateUrl = @"mailto:" + recipientAddresses.ToString().TrimEnd(';') + @"?subject=Overdue%20Training&body=You%20are%20required%20to%20complete "+ training_name + @"%0A" + System.Configuration.ConfigurationManager.AppSettings["TakeTrainingURLString"].ToString() + training_ident.ToString(); // phEmailOverdue.Controls.Add(lbtnOverdue); //} }