/// <summary>
        /// Downloads the report.
        /// </summary>
        /// <param name="reportFileName">Name of the report file.</param>
        /// <param name="fileType">Type of the file.</param>
        /// <param name="reportType">Type of the report.</param>
        /// <param name="currentDateTime">The time zone information.</param>
        /// <returns></returns>
        public ActionResult DownloadReport(string reportFileName, int fileType, int reportType, string currentDateTime)
        {
            string contentType;
            string fileName;

            string path     = GlobalConfigVariable.ReportsFilePath;
            string filePath = Path.Combine(path, reportFileName);

            string fileNameWithoutExtension = string.Format("{0}-{1}.{2}",
                                                            reportType ==
                                                            Constants.ReportLevelClaim
                    ? Constants.ClaimVarianceReportFileBaseName
                    : Constants.ContractVarianceReportFileBaseName, currentDateTime, "{0}");

            if (fileType == Constants.DownloadFileTypeExcel)
            {
                var    fileExtension = Path.GetExtension(reportFileName);
                string newExtenstion = string.Empty;
                if (fileExtension != null)
                {
                    newExtenstion = fileExtension.Replace(".", "");
                }
                contentType = MimeAssistant.GetMimeTypeByExtension(newExtenstion);
                fileName    = string.Format(fileNameWithoutExtension, newExtenstion);
            }
            else
            {
                contentType = MimeAssistant.GetMimeTypeByExtension(Enums.DownloadFileType.Pdf.ToString());
                fileName    = string.Format(fileNameWithoutExtension, Enums.DownloadFileType.Pdf);
            }
            return(File(filePath, contentType, fileName));
        }
Пример #2
0
        /// <summary>
        /// Gets the report file details to download.
        /// </summary>
        /// <param name="reportFileBaseName">Name of the report file base.</param>
        /// <param name="reportFileName">Name of the report file.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="fileContentType">Type of the file content.</param>
        /// <param name="contentType">Type of the content.</param>
        /// <param name="currentDateTime"></param>
        /// <returns></returns>
        public static string GetReportFileDetailsToDownload(string reportFileBaseName, string reportFileName, out string fileName,
                                                            Enums.DownloadFileType fileContentType, out string contentType, string currentDateTime)
        {
            string reportLocation = GlobalConfigVariable.ReportsFilePath;

            string filePath = Path.Combine(reportLocation, reportFileName);
            string fileNameWithoutExtension = string.Format("{0}-{1}.{2}", reportFileBaseName, currentDateTime, "{0}");

            switch (fileContentType)
            {
            case Enums.DownloadFileType.Xls:
                contentType = MimeAssistant.GetMimeTypeByExtension(Enums.DownloadFileType.Xls.ToString());
                fileName    = string.Format(fileNameWithoutExtension, Enums.DownloadFileType.Xls);
                break;

            case Enums.DownloadFileType.Csv:
                contentType = MimeAssistant.GetMimeTypeByExtension(Enums.DownloadFileType.Csv.ToString());
                fileName    = string.Format(fileNameWithoutExtension, Enums.DownloadFileType.Csv);
                break;

            case Enums.DownloadFileType.Rtf:
                contentType = MimeAssistant.GetMimeTypeByExtension(Enums.DownloadFileType.Rtf.ToString());
                fileName    = string.Format(fileNameWithoutExtension, Enums.DownloadFileType.Rtf);
                break;

            default:
                contentType = MimeAssistant.GetMimeTypeByExtension(Enums.DownloadFileType.Pdf.ToString());
                fileName    = string.Format(fileNameWithoutExtension, Enums.DownloadFileType.Pdf);
                break;
            }
            return(filePath);
        }
        /// <summary>
        /// Downloads the user manual.
        /// </summary>
        /// <returns></returns>
        public ActionResult DownloadUserManual()
        {
            string userManualDocumentpath = Server.MapPath(GlobalConfigVariable.UserManualFilePath);
            string fileName = new FileInfo(userManualDocumentpath).Name;

            return(File(userManualDocumentpath, MimeAssistant.GetMimeTypeByExtension(Enums.DownloadFileType.Pdf.ToString()), fileName));
        }
        /// <summary>
        /// Downloads the report.
        /// </summary>
        /// <param name="reportFileName">Name of the report file.</param>
        /// <param name="fileType">Type of the file.</param>
        /// <param name="isActive">if set to <c>true</c> [is active].</param>
        /// <param name="currentDateTime">The time zone information.</param>
        /// <returns></returns>
        public ActionResult DownloadReport(string reportFileName, int?fileType, bool isActive, string currentDateTime)
        {
            string contentType;
            string fileName;

            string path     = GlobalConfigVariable.ReportsFilePath;
            string filePath = Path.Combine(path, reportFileName);
            string fileNameWithoutExtension = string.Format("{0}-{1}{2}.{3}", Constants.ModelingReportFileBaseName,
                                                            isActive ? Constants.ActiveReport : Constants.InActiveReport, currentDateTime, "{0}");

            if (fileType == 1)
            {
                contentType = MimeAssistant.GetMimeTypeByExtension(Enums.DownloadFileType.Pdf.ToString());
                fileName    = string.Format(fileNameWithoutExtension, Enums.DownloadFileType.Pdf);
            }
            else
            {
                contentType = MimeAssistant.GetMimeTypeByExtension(Enums.DownloadFileType.Xls.ToString());
                fileName    = string.Format(fileNameWithoutExtension, Enums.DownloadFileType.Xls);
            }
            return(File(filePath, contentType, fileName));
        }