public virtual ActionResult DownloadReportHtml(string fileId) { if (_memoryCache.Get(fileId) != null) { string htmlBody = _memoryCache.Get(fileId) as string; string html = RPCSHtmlHelper.GetSimpleUTF8HtmlPage("Отчет", htmlBody); byte[] binData = System.Text.Encoding.UTF8.GetBytes(html); _memoryCache.Remove(fileId); return(File(binData, "text/HTML", "Report" + DateTime.Now.ToString("ddMMyyHHmmss") + ".html")); } else { string html = RPCSHtmlHelper.GetSimpleUTF8HtmlPage("Ошибка", "Произошла ошибка при выполнении операции."); byte[] binData = System.Text.Encoding.UTF8.GetBytes(html); _memoryCache.Remove(fileId); return(File(binData, "text/HTML", "Error" + DateTime.Now.ToString("ddMMyyHHmmss") + ".html")); } }
public virtual ActionResult DownloadExcel(string fileId) { if (_memoryCache.Get(fileId) != null) { byte[] binData = (_memoryCache.Get(fileId) as byte[]).ToArray(); _memoryCache.Remove(fileId); return(File(binData, ExcelHelper.ExcelContentType, "Report" + DateTime.Now.ToString("ddMMyyHHmmss") + ".xlsx")); } else { string html = RPCSHtmlHelper.GetSimpleUTF8HtmlPage("Ошибка", "Произошла ошибка при выполнении операции."); if (_memoryCache.Get(fileId + ErrorReportIDPostfix) != null) { html = RPCSHtmlHelper.GetSimpleUTF8HtmlPage("Ошибка", "Произошла ошибка при выполнении операции." + _memoryCache.Get(fileId + ErrorReportIDPostfix)); _memoryCache.Remove(fileId + ErrorReportIDPostfix); } byte[] binData = System.Text.Encoding.UTF8.GetBytes(html); _memoryCache.Remove(fileId); return(File(binData, "text/HTML", "Error" + DateTime.Now.ToString("ddMMyyHHmmss") + ".html")); } }