Ejemplo n.º 1
0
        // Send file stream for download
        private ActionResult SendFile(string ClaimGUID, int? claimDetailId, FileIO.mode fMode, string filename)
        {
            try
            {
                string filePath = FileIO.GetClaimFilePath(ClaimGUID, claimDetailId, fMode, filename, true);

                if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + filePath))
                    /*System.IO.Path.GetFileName(filePath)*/
                    return File("~/" + filePath, "Content-Disposition: attachment;", filename);
                else/*Invalid or deleted file (from Log)*/
                { ViewData["Message"] = "File not found"; return View("DataNotFound"); }

            }
            catch (Exception ex) { return View(); }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check and Save Claim File being uploaded. Set error in ModelState if any issue
        /// </summary>
        /// <param name="hpFileKey">HttpPost file browser control Id</param>
        /// <param name="ClaimId">Claim Id</param>
        /// <param name="ClaimDetailId">Claim Detail Id</param>
        /// <param name="upMode">FileIO.mode (Async or Sync & Header  or Detail)</param>
        /// <returns>File upload name</returns>
        string ChkAndSaveClaimFile(string hpFileKey, int ClaimId, FileIO.mode upMode, string ClaimGUID, int? ClaimDetailId = null)
        {
            HttpPostedFileBase hpFile = Request.Files[hpFileKey];

            string docName = string.Empty;
            FileIO.result uploadResult = FileIO.UploadAndSave(hpFile, ref docName, ClaimGUID, ClaimDetailId, upMode);

            #region Add error in case of an Upload issue

            switch (uploadResult)
            {
                case FileIO.result.duplicate:
                    ModelState.AddModelError("FileName", "Duplicate file found"); break;
                case FileIO.result.noextension:
                    ModelState.AddModelError("FileName", "File must have an extension"); break;
                case FileIO.result.contentLength:
                    ModelState.AddModelError("FileName", string.Format("File size cannot exceed {0}MB", Config.MaxFileSizMB)); break;
                case FileIO.result.successful: break;
                default://Any other issue
                    ModelState.AddModelError("FileName", "Unable to upload file"); break;
            }

            #endregion

            return docName;
        }