コード例 #1
0
        private bool ValidateInvoiceData(AddInvoiceViewModel vm)
        {
            bool result = false;

            if (!String.IsNullOrEmpty(vm.IMAGEID))
            {
                // Verify image file path.
                string imagePath = GSA.R7BD.Utility.Utilities.GetImageNowPath(vm.IMAGEID);
                if (!string.IsNullOrEmpty(imagePath) && System.IO.File.Exists(imagePath))
                {
                    vm.IMAGEPATH = imagePath;

                    // Grab page count.
                    string extension = Path.GetExtension(imagePath);
                    byte   pageCount = 1;
                    if (extension == ".tiff" || extension == ".tif")
                    {
                        TIF TheFile = new TIF(imagePath);
                        pageCount = (byte)TheFile.PageCount;
                        TheFile.Dispose();
                    }

                    vm.DOCPAGE = pageCount;
                    result     = true;
                }
            }
            return(result);
        }
コード例 #2
0
        public static ActionResult TiffViewResult(string Type, string TypeId, string FilePath, Controller controller, HttpResponseBase Response)
        {
            var model = new UserExceptionViewModel();

            model.TiffType   = Type;
            model.TiffTypeId = TypeId;

            string extension = Path.GetExtension(FilePath);

            if (extension == ".tiff" || extension == ".tif")
            {
                TIF TheFile = new TIF(FilePath);
                model.TotalTIFPgs = TheFile.PageCount;
                TheFile.Dispose();

                var result = GetViewResult(controller, "UserException/TiffViewerModal", model);
                return(result);
            }
            else
            {
                byte[] fileBytes = System.IO.File.ReadAllBytes(FilePath);
                var    cd        = new System.Net.Mime.ContentDisposition
                {
                    FileName = Path.GetFileName(FilePath),

                    // always prompt the user for downloading, set to true if you want
                    // the browser to try to show the file inline
                    Inline = false,
                };
                Response.AppendHeader("Content-Disposition", cd.ToString());
                var result = new FileContentResult(fileBytes, MimeMapping.GetMimeMapping(FilePath));
                return(result);
            }
        }