/// <summary> /// Download Attachments /// </summary> /// <param name="attachmentId"></param> /// <returns></returns> public ActionResult DownloadPWAttchments(long attachmentId) { byte[] fileBytes = null; string fileName = string.Empty; ExceptionTypes result = new ExceptionTypes(); DOGEN_Attachments objDOGEN_Attachments = new DOGEN_Attachments(); try { result = objBLCommon.DownloadPWAttachments(attachmentId, out objDOGEN_Attachments, out errorMessage); if (result != (long)ExceptionTypes.Success) { BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Attachments, (long)ExceptionTypes.Uncategorized, errorMessage, errorMessage); return(null); } fileBytes = System.IO.File.ReadAllBytes(objDOGEN_Attachments.FilePath); fileName = objDOGEN_Attachments.FileName; return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName)); } catch (System.IO.FileNotFoundException ex) { BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Attachments, (long)ExceptionTypes.Uncategorized, "File Not Found", ex.Message); return(Content("File Not Available.")); } catch (Exception ex) { BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Attachments, (long)ExceptionTypes.Uncategorized, string.Empty, ex.ToString()); return(Content("An error occoured.")); } }