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>
        /// 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.º 4
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.º 5
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.º 6
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";
                }
            }
        }