private static void ProcessAdLibFileGen() { ProcessLogObject.Add("Processing AdLib File Generation"); var sorts = SortMainObject.GetSortNeedingAdlibDocument(); if (sorts != null && sorts.Count > 0) { foreach (var sort in sorts) { if (SortAttachmentObject.GetFinalDocAttachment(sort.SortMainId.Value) != null) { ProcessLogObject.Add(sort.SortMainId, $"Processing AdLib File"); bool success = false; byte[] file = Config.DigitalLibraryManager.GenerateExportFile(sort.SortMainId.Value, sort.CoverPageRequired, ref success); if (success) { SortAttachmentObject.AddOstiAttachment(sort.SortMainId.Value, $"Sort_{sort.SortMainId}.pdf", "System", file.Length, file); ProcessLogObject.Add(sort.SortMainId, $"AdLib File Generation was Successful"); } else { ProcessLogObject.Add(sort.SortMainId, $"AdLib File Generation Failed"); } } } } }
public ActionResult CreateOstiDocument(int?id, bool?aRtn) { if (id.HasValue) { ProcessLogObject.Add(id, "Start CreateOstiDocument"); if (SortAttachmentObject.GetFinalDocAttachment(id.Value) != null) { bool success = false; byte[] file = Config.DigitalLibraryManager.GenerateExportFile(id.Value, SortMainObject.GetSortMain(id.Value).CoverPageRequired, ref success); if (success) { SortAttachmentObject.AddOstiAttachment(id.Value, $"Sort_{id}.pdf", UserObject.CurrentUser.EmployeeId, file.Length, file); } else { TempData.Add("FailMessage", "AdLib Failed to generate the OSTI File! Please try again."); } } ProcessLogObject.Add(id, "End CreateOstiDocument"); } if (aRtn.HasValue && aRtn.Value) { return(RedirectToAction("Index", "Artifact", new { id })); } return(RedirectToAction("Index", "Home")); }
public void HydrateData() { Sort = SortMainObject.GetSortMain(SortMainId); Attachments = SortAttachmentObject.GetSortAttachments(SortMainId); Sort?.CheckForMissingData(); UserHasWriteAccess = Sort?.UserHasWriteAccess() ?? true; UserHasReadAccess = Sort?.UserHasReadAccess() ?? true; }
/// <summary> /// /// </summary> /// <param name="id">Sort Main Id</param> /// <returns></returns> public ActionResult GetAttachments(int?id) { var model = new List <SortAttachmentObject>(); if (id.HasValue && SortMainObject.CheckUserHasReadAccess(id.Value)) { model = SortAttachmentObject.GetSortAttachments(id.Value); } return(PartialView("Partials/_attachmentList", model)); }
/// <summary> /// /// </summary> /// <param name="id">Sort Attachment Id</param> /// <returns></returns> public ActionResult DeleteAttachment(int?id) { if (id.HasValue) { SortAttachmentObject asa = SortAttachmentObject.GetSortAttachment(id.Value); asa?.Delete(); return(GetAttachments(asa?.SortMainId)); } return(null); }
public string AttachmentMultiUpload(int id, int partNum) { var attachment = SortAttachmentObject.GetSortAttachment(id); if (attachment != null) { MemoryStream ms = new MemoryStream(); Request.InputStream.CopyTo(ms); attachment.AddPart(partNum, ms.ToArray()); } return("done"); }
public FileResult GetFinalDocument(int?id) { if (id.HasValue) { var file = SortAttachmentObject.GetFinalDocAttachment(id.Value); if (file != null) { return(File(file.Contents, System.Net.Mime.MediaTypeNames.Application.Octet, file.FileName)); } } return(null); }
public ActionResult DeleteOstiDocument(int?id, bool?aRtn) { if (id.HasValue) { if (SortMainObject.CheckUserHasWriteAccess(id.Value)) { SortAttachmentObject.GetOstiAttachment(id.Value)?.PerminateDelete(); } } if (aRtn.HasValue && aRtn.Value) { return(RedirectToAction("Index", "Artifact", new { id })); } return(RedirectToAction("Index", "Home")); }
/// <summary> /// /// </summary> /// <param name="id">Sort Attachment Id</param> /// <returns></returns> public FileResult DownloadAttachment(int?id) { if (id.HasValue) { SortAttachmentObject aa = SortAttachmentObject.GetSortAttachment(id.Value); if (aa != null && SortMainObject.CheckUserHasReadAccess(aa.SortMainId)) { var content = aa.Contents; if (content != null) { content.Seek(0, SeekOrigin.Begin); // Need this turned off for large files Response.BufferOutput = false; return(File(content, System.Net.Mime.MediaTypeNames.Application.Octet, aa.FileName)); } } } return(null); }
public void Save() { SortAttachmentId = SortAttachmentObject.AddAttachment(SortMainId, Filename, AttachmentNote, AttachmentType, Size).SortAttachmentId; }
public bool DuplicateFinal() { return(AttachmentType == AttachmentTypeEnum.FinalDoc && SortAttachmentObject.GetSortAttachments(SortMainId).Exists(n => !n.IsDeleted && n.AttachmentTypeEnum == AttachmentTypeEnum.FinalDoc)); }
public AttachmentModel(int sortMainId) { SortMainId = sortMainId; Attachments = SortAttachmentObject.GetSortAttachments(sortMainId); }