protected void btnSearchPlanReplace_Click(object sender, EventArgs e) { Position position = currentPosition; File searchPlan = FileBLL.SavePDF(fileSearchPlanReplace, SearchPlanFileType); if (searchPlan != null) { //Delete the old file FileBLL.DeletePDF(position.SearchPlanFile); //Save the new reference using (var ts = new TransactionScope()) { position.SearchPlanFile = searchPlan; PositionBLL.EnsurePersistent(position); ts.CommitTransaction(); } } else { lblInvalidSearchPlanFileType.Text = " *Job Description Must Be a PDF File"; } }
protected void ibtnPublicationsRemoveFile_Click(object sender, EventArgs e) { int FileID = 0; bool success = false; success = int.TryParse(((ImageButton)sender).CommandArgument, out FileID); if (success) { File fileToDelete = FileBLL.GetByID(FileID); using (var ts = new TransactionScope()) { FileBLL.DeletePDF(fileToDelete); //Update the current application Application application = selectedApplication; application.Files.Remove(fileToDelete); ApplicationBLL.EnsurePersistent(application); ts.CommitTransaction(); } } rptPublications.DataSource = GetFilesOfType(STR_Publication); rptPublications.DataBind(); }
/// <summary> /// Close the position and upload the final recruitment report /// </summary> protected void ClosePosition(object sender, EventArgs e) { Position position = CurrentPosition; File finalRecruitmentReport = FileBLL.SavePDF(fileFinalRecruitmentReport, FinalRecruitmentReportFileType); if (finalRecruitmentReport != null) { //Delete the old file if (position.FinalRecruitmentReportFile != null) { FileBLL.DeletePDF(position.FinalRecruitmentReportFile); } //Save the new reference using (var ts = new TransactionScope()) { position.FinalRecruitmentReportFile = finalRecruitmentReport; position.Closed = true; PositionBLL.EnsurePersistent(position); ts.CommitTransaction(); } Response.Redirect("ClosePositionSuccess.aspx"); } else { lblFileError.Text = "Uploaded File Must Be In PDF Format"; } }
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(); } } }
/// <summary> /// Removes all files of the given type from the current applicaiton. This removes the files themselves, /// the file info entry and the application files link /// </summary> private void RemoveAllFilesOfType(string fileTypeName) { List <File> existingFiles = GetFilesOfType(fileTypeName); Application application = selectedApplication; if (existingFiles.Count != 0) { using (var ts = new TransactionScope()) { foreach (File existingFile in existingFiles) { application.Files.Remove(existingFile); FileBLL.DeletePDF(existingFile); } ApplicationBLL.EnsurePersistent(application); ts.CommitTransaction(); } } }