protected void btnUpdateList_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow row in gViewReferences.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    //Get the unsolicited check box and then current reference
                    CheckBox cboxUnsolicited = (CheckBox)row.FindControl("chkUnsolicited");

                    int       referenceID      = (int)gViewReferences.DataKeys[row.RowIndex]["id"];
                    Reference currentReference = ReferenceBLL.GetByID(referenceID);

                    //Only save the information if it has changed
                    if (currentReference.UnsolicitedReference != cboxUnsolicited.Checked)
                    {
                        using (var ts = new TransactionScope())
                        {
                            currentReference.UnsolicitedReference = cboxUnsolicited.Checked;

                            ReferenceBLL.EnsurePersistent(currentReference);

                            ts.CommitTransaction();
                        }
                    }
                }
            }

            //Notify the user that the update was successful
            lblResult.Text = "Unsolicited List Updated";
        }
        /// <summary>
        /// Sends a unsolicited letter to the selected reference
        /// </summary>
        protected void sendEmail_Click(object sender, EventArgs e)
        {
            Button btnSender = (Button)sender;

            int referenceID = int.Parse(btnSender.CommandArgument);

            Reference currentReference = ReferenceBLL.GetByID(referenceID);

            SmtpClient  client  = new SmtpClient();
            MailMessage message = new MailMessage(WebConfigurationManager.AppSettings["emailFromEmail"],
                                                  currentReference.Email,
                                                  "UC Davis Recruitment Unsolicited Letter Response",
                                                  new TemplateProcessing().ProcessTemplate(currentReference, currentReference.AssociatedApplication, UnsolicitedTemplate.TemplateText, false)
                                                  );

            message.IsBodyHtml = true;
            client.Send(message);

            //Record when the unsolicited email was sent out
            using (var ts = new TransactionScope())
            {
                currentReference.UnsolicitedEmailDate = DateTime.Now;

                ReferenceBLL.EnsurePersistent(currentReference);

                ts.CommitTransaction();
            }

            lblResult.Text = "Email sent successfully";
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called from the Refences Grid whenever a row is selected (Edited).
        /// Populates the reference's information into the info table and then shows the popup
        /// </summary>
        protected void gviewReferences_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridView referenceGrid = sender as GridView;

            //Grab the reference from the dataKey ID
            int       currentReferenceID = (int)referenceGrid.SelectedDataKey["ID"];
            Reference currentReference   = ReferenceBLL.GetByID(currentReferenceID);

            //Now fill in the form fields with the current reference
            txtReferencesTitle.Text     = currentReference.Title;
            txtReferencesFirstName.Text = currentReference.FirstName;
            txtReferencesLastName.Text  = currentReference.LastName;

            txtReferencesAcadTitle.Text = currentReference.AcadTitle;
            txtReferencesExpertise.Text = currentReference.Expertise;

            txtReferencesDepartment.Text = currentReference.Dept;
            txtReferencesInstitute.Text  = currentReference.Institution;

            txtReferencesAddress1.Text = currentReference.Address1;
            txtReferencesAddress2.Text = currentReference.Address2;
            txtReferencesCity.Text     = currentReference.City;
            txtReferencesState.Text    = currentReference.State;
            txtReferencesZip.Text      = currentReference.Zip;
            txtReferencesCountry.Text  = currentReference.Country;

            txtReferencesPhone.Text = currentReference.Phone;
            txtReferencesEmail.Text = currentReference.Email;

            //Now show the popup control
            mpopupReferencesEntry.Show();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns true if a file exists, else false
        /// </summary>
        protected bool GetRefernceFileStatusString(int referenceID)
        {
            Reference reference = ReferenceBLL.GetByID(referenceID);

            if (reference.ReferenceFile != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Send a email from the given positions's HR Rep to the given reference's email account.  On success the reference is marked as being
        /// sent the email so she will not be sent another.  The automated email account is BCC'd for reference.
        /// </summary>
        /// <returns>Returns null on success, else returns the name of the offending reference and applicant</returns>
        private string sendReferenceEmail(Position position, Application application, Reference reference)
        {
            TemplateProcessing template = new TemplateProcessing();

            //Process the template to get the body text of the email
            string bodyText = template.ProcessTemplate(reference, application, position.ReferenceTemplate.TemplateText, true);

            //Exchange Ops is commented out because it will not send HTML emails currently (also needs MSXML2)
            //Now configure the email host
            //CAESDO.ExchangeOps exops = new ExchangeOps();
            //exops.ConfigureServer(WebConfigurationManager.AppSettings["ServerName"], WebConfigurationManager.AppSettings["Protocol"]);
            //exops.ConfigureEmail(WebConfigurationManager.AppSettings["emailDomainUserName"], WebConfigurationManager.AppSettings["emailUserName"], WebConfigurationManager.AppSettings["emailPassword"]);

            System.Net.Mail.SmtpClient mail = new System.Net.Mail.SmtpClient();

            //Try to send the email -- if there are errors, return the email of the offending reference
            try
            {
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(currentPosition.HREmail, reference.Email, "Reference Request for " + application.AssociatedProfile.FullName, bodyText);
                message.Bcc.Add(WebConfigurationManager.AppSettings["AppMailTo"]); //BCC the recruitments email account
                message.IsBodyHtml = true;

                //System.IO.FileStream descriptionStream = new System.IO.FileStream(FilePath + position.DescriptionFile.ID, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);

                //message.Attachments.Add(new System.Net.Mail.Attachment(descriptionStream, position.DescriptionFile.FileName));

                mail.Send(message);

                //After the message is sent, close the stream.
                //descriptionStream.Close();

                //exops.SendEmail(reference.Email, "Reference Request for Application" + position.PositionTitle, bodyText, WebConfigurationManager.AppSettings["emailFromEmail"]);
            }
            catch (Exception)
            {
                return(string.Format("{0} ({1})", reference.FullName, application.AssociatedProfile.FullName));
            }

            //No errors, so save the fact that we sent an email to the current reference
            using (var ts = new TransactionScope())
            {
                reference.SentEmail = true;
                reference.EmailDate = DateTime.Now;

                ReferenceBLL.EnsurePersistent(reference);

                ts.CommitTransaction();
            }

            return(null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// For each application with GetReferences = true, all references are emailed (unless they have been emailed previously)
        /// </summary>
        protected void btnEmailReferences_Click(object sender, EventArgs e)
        {
            if (currentPosition == null)
            {
                return;
            }

            btnUpdateList_Click(sender, e); //Always update the list before sending emails to avoid confusion

            List <string> errorReferences = new List <string>();

            var referencesToNotify = ReferenceBLL.GetReferencesToBeNotified(currentPosition);

            foreach (var reference in referencesToNotify)
            {
                //Before sending the email, make sure we have a uid
                this.ensureUniqueID(reference);

                string result = sendReferenceEmail(currentPosition, reference.AssociatedApplication, reference);

                //If a result was returned, then add it to the error emails
                if (!string.IsNullOrEmpty(result))
                {
                    errorReferences.Add(result);
                }
            }

            if (errorReferences.Count == 0)
            {
                lblResult.ForeColor = System.Drawing.Color.Green;
                lblResult.Text      = "All References Successfully Emailed";
            }
            else
            {
                StringBuilder delimitedReferenceErrorList = new StringBuilder();

                foreach (string s in errorReferences)
                {
                    if (delimitedReferenceErrorList.Length != 0)
                    {
                        delimitedReferenceErrorList.Append(", "); //Add a comma if there are existing emails in the list
                    }
                    delimitedReferenceErrorList.Append(s);
                }

                lblResult.ForeColor = System.Drawing.Color.Red;
                lblResult.Text      = "The Following References Were Not Sent Emails: " + delimitedReferenceErrorList.ToString();
            }

            lviewReferencesToBeNotified.DataBind();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Returns immediately if a uniqueID exists for the given reference, else it generates and saves a new one
        /// into the existing reference's record
        /// </summary>
        private void ensureUniqueID(Reference reference)
        {
            if (string.IsNullOrEmpty(reference.UploadID))
            {
                //We don't have an uploadID, so create a new GUID and assign it to the reference
                using (var ts = new TransactionScope())
                {
                    reference.UploadID = Guid.NewGuid().ToString();

                    ReferenceBLL.EnsurePersistent(reference);

                    ts.CommitTransaction();
                }
            }
        }
Exemplo n.º 8
0
        private void UploadReferences()
        {
            FileType  referenceFileType = FileTypeBLL.GetByName(STR_LetterOfRec);
            Reference selectedReference = ReferenceBLL.GetByID(int.Parse(dlistReferences.SelectedValue));

            //If there is already a reference file, we need to delete it
            if (selectedReference.ReferenceFile != null)
            {
                using (var ts = new TransactionScope())
                {
                    FileBLL.DeletePDF(selectedReference.ReferenceFile);
                    selectedReference.ReferenceFile = null;

                    ReferenceBLL.EnsurePersistent(selectedReference);

                    ts.CommitTransaction();
                }
            }

            if (fileUpload.HasFile)
            {
                using (var ts = new TransactionScope())
                {
                    File file = FileBLL.SavePDFWithWatermark(fileUpload, referenceFileType);

                    if (file != null)
                    {
                        selectedReference.ReferenceFile        = file;
                        selectedReference.UnsolicitedReference = chkUnsolicited.Checked;

                        ReferenceBLL.EnsurePersistent(selectedReference);

                        lblStatus.Text = "File Uploaded Successfully";
                    }
                    else
                    {
                        lblStatus.Text = "File Upload Did Not Succeed: Ensure That File Is A PDF File";
                    }

                    ts.CommitTransaction();
                }
            }
        }
Exemplo n.º 9
0
        private void UploadReferences()
        {
            FileType referenceFileType = FileTypeBLL.GetByName(STR_LetterOfRec);

            if (fileUploadReference.HasFile)
            {
                if (FileBLL.IsPostedFilePDF(fileUploadReference.PostedFile))
                {
                    File file = new File();

                    file.FileName = fileUploadReference.FileName;
                    file.FileType = referenceFileType;

                    using (var ts = new TransactionScope())
                    {
                        FileBLL.EnsurePersistent(file, true);

                        ts.CommitTransaction();
                    }

                    if (ValidateBO <File> .isValid(file))
                    {
                        SaveReferenceWithWatermark(fileUploadReference, file.ID.ToString());

                        currentReference.ReferenceFile = file;

                        using (var ts = new TransactionScope())
                        {
                            ReferenceBLL.EnsurePersistent(currentReference);

                            ts.CommitTransaction();
                        }

                        //Send confirmation email after success -- if there are errors, ignore
                        try
                        {
                            System.Net.Mail.SmtpClient mail = new System.Net.Mail.SmtpClient();

                            string subject = "Reference Upload Confirmation";

                            StringBuilder bodyText = new StringBuilder();

                            bodyText.AppendFormat("Your reference letter for {0}, who applied to the {1} position at the University of California, has been successfully received.", currentReference.AssociatedApplication.AssociatedProfile.FullName, currentReference.AssociatedApplication.AppliedPosition.PositionTitle);
                            bodyText.AppendFormat("  We appreciate your comments.", currentReference.AssociatedApplication.AssociatedProfile.LastName);

                            MailMessage message = new MailMessage(currentReference.AssociatedApplication.AppliedPosition.HREmail, currentReference.Email, subject, bodyText.ToString());
                            message.IsBodyHtml = true;

                            mail.Send(message); //Send the message
                        }
                        catch (Exception) { } //Continue on failure

                        Response.Redirect(UploadReferenceSuccessURL);
                    }
                    else
                    {
                        lblUploadStatus.Text = "There was an unexpected error uploading your file";
                    }
                }
                else
                {
                    lblUploadStatus.Text = "Please upload a file in PDF format";
                }
            }
        }