public void DownLoadEmailFiles(string keyvalue, string type) { var data = new EmailApp().Email_Path(keyvalue); string filename = ""; string filepath = ""; if (type == ".zip") { //文件名 filename = Server.UrlDecode(data.PF_Src.Substring(data.PF_Src.LastIndexOf("/") + 1)); //路径 filepath = Server.MapPath(data.PF_Src); } else { filename = Server.UrlDecode(type); filepath = Server.MapPath(data.PF_Src.Replace(data.PF_Src.Substring(data.PF_Src.LastIndexOf("/")), "") + "/" + filename); } filepath = filepath.Replace("\\Email\\DownLoadEmailFiles", ""); // return File(new System.IO.FileStream(filepath, System.IO.FileMode.Open), "application/octet-stream", filename); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
/// <summary> /// 下载 /// </summary> /// <param name="keyValue"></param> /// <param name="filename"></param> /// <param name="recId"></param> public void DownloadFile(string keyValue, string filename, string recId) { var fileFolderBLL = new FileFolderBLL(); var fileInfoBLL = new FileInfoBLL(); if (string.IsNullOrEmpty(keyValue)) { return; } FileInfoEntity data = null; if (!string.IsNullOrEmpty(filename)) { data = fileInfoBLL.GetEntity(recId, Server.UrlDecode(filename)); } else { data = fileInfoBLL.GetEntity(keyValue); } if (data != null) { string name = string.IsNullOrEmpty(filename) ? Server.UrlDecode(data.FileName) : Server.UrlDecode(filename);//返回客户端文件名称 string filepath = this.Server.MapPath(data.FilePath); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, name); } } }
public void DownloadFile(string keyValue, string filename, string recId) { if (string.IsNullOrEmpty(keyValue)) { return; } FileInfoEntity data = null; if (!string.IsNullOrEmpty(filename)) { data = fileInfoBLL.GetEntity(recId, Server.UrlDecode(filename)); } else { data = fileInfoBLL.GetEntity(keyValue); } if (data != null) { string name = string.IsNullOrEmpty(filename) ? Server.UrlDecode(data.FileName) : Server.UrlDecode(filename);//返回客户端文件名称 string filepath = this.Server.MapPath(data.FilePath); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, name); } else { Response.StatusCode = 404; Response.Redirect("../../Error/ErrorPath404", true); return; } } }
public void DownloadFile(string keyValue) { string filePath = Server.MapPath("~/Uploads/Leave/") + keyValue; //文件路径 if (System.IO.File.Exists(filePath)) //判断文件是否存在 { FileDownHelper.DownLoadold(filePath, keyValue); } }
public void DownloadFile(string keyValue) { string filename = Server.UrlDecode("客户导入模板.xls");//返回客户端文件名称 string filepath = this.Server.MapPath("~/Resource/ExcelTemplate/客户导入模板.xls"); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
/// <summary> /// 文件下载 /// </summary> /// <param name="KeyValue">主键</param> /// <returns></returns> public void Download(string KeyValue) { Base_NetworkFile entity = base_networkfilebll.Repository().FindEntity(KeyValue); string filename = Server.UrlDecode(entity.FileName); //返回客户端文件名称 string filepath = Server.UrlDecode(entity.FilePath); //文件虚拟路径 if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public void DownloadBackup(string keyValue) { var data = DbBackupApp.GetForm(keyValue); string filename = System.Web.HttpUtility.UrlDecode(data.FileName); string filepath = FileHelper.MapPath(data.FilePath); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public void DownAnnexesFile(string fileId) { var data = annexesFileIBLL.GetEntity(fileId); string filename = Server.UrlDecode(data.F_FileName);//返回客户端文件名称 string filepath = data.F_FilePath; if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public ActionResult GetUeditorImg(string id) { string path = Config.GetValue("imgPath") + "/ueditor/upload/image" + id; path = System.Text.RegularExpressions.Regex.Replace(path, @"\s", ""); if (FileDownHelper.FileExists(path)) { FileDownHelper.DownLoadold(path, id.Split('/')[2]); } return(Success("获取成功")); }
public void DownloadFile(string keyValue) { var data = fileInfoBLL.GetEntity(keyValue); string filename = Server.UrlDecode(data.F_FileName);//返回客户端文件名称 string filepath = this.Server.MapPath(data.F_FilePath); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public void DownloadBackup(string keyValue) { var data = dbBackupApp.GetForm(keyValue); string filename = Server.UrlDecode(data.F_FileName); string filepath = Server.MapPath(data.F_FilePath); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public void FileDownload(string file) { var data = JObject.Parse(Uri.UnescapeDataString(file)); string filename = data["originalName"].ToString();//返回客户端文件名称 string filepath = this.Server.MapPath(data["path"].ToString()); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } //return Content("下载成功"); }
public void DownLoadBackups(string id) { B_Backups b_backup = new B_Backups(); var data = b_backup.Get(Convert.ToInt32(id)); string filename = Server.UrlDecode(data.fileName); string filepath = Server.MapPath(data.filePath); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public void DownloadBackup(string keyValue) { if ((keyValue != "undefined") && !string.IsNullOrEmpty(keyValue)) { var data = dbBackupApp.GetForm(keyValue); string filename = Server.UrlDecode(data.F_FileName); string filepath = data.F_FilePath; if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } base.OperateLog("据库备份下载", "/SystemSecurity/DbBackup/DownloadBackup", "备份下载", Application.DbLogType.Other); } }
/// <summary> /// 下载文件 /// </summary> /// <param name="pathList">文件路径集合(相对路径)</param> /// <returns></returns> public void DownloadFile(string pathList) { if (!string.IsNullOrEmpty(pathList)) { List <string> lstid = pathList.Split(',').ToList <string>(); if (lstid.Count == 1) { var absolutePath = Server.MapPath(lstid[0]);//转成绝对路径 var fullName = System.IO.Path.GetFileName(absolutePath); if (System.IO.File.Exists(absolutePath)) { FileDownHelper.DownLoadold(absolutePath, fullName); return; } } else if (lstid.Count == 0) { return; } //将文件拷贝至指定临时路径并压缩打包 string newFilename = DateTime.Now.ToString("yyyyMMddHHmmss"); string newFolder = "/Temp/" + newFilename + "/"; string newZip = Server.MapPath("/Temp/" + newFilename + ".zip"); //压缩包 FileHelper.CreateDirectory(Server.MapPath(newFolder)); //创建一个临时文件夹 for (int i = 0; i < lstid.Count; i++) { var filepath = Server.MapPath(lstid[i]); var fullName = System.IO.Path.GetFileName(filepath); if (FileDownHelper.FileExists(filepath)) { FileHelper.Copy(filepath, Server.MapPath(newFolder + fullName));//将文件拷贝到临时文件夹 } } //将文件夹进行GZip压缩 ZipFloClass Zc = new ZipFloClass(); Zc.ZipFile(Server.MapPath(newFolder), newZip);//生成压缩包 if (FileDownHelper.FileExists(newZip)) { FileDownHelper.DownLoadold(newZip, newFilename + ".zip");//下载压缩包 } //删除文件夹 FileHelper.DeleteDirectory(newFolder); //删除文件夹 FileHelper.DeleteFile(newZip); //删除临时压缩包 } return; }
public void DownloadTemplate(string keyValue) { try { string filename = Server.UrlDecode(keyValue); string filepath = Path.Combine(Server.MapPath("/Uploads/Template/"), keyValue); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } } catch (Exception ex) { throw; } }
/// <summary> /// 下载文件 /// </summary> /// <param name="keyValue">主键</param> /// <returns></returns> //[HttpPost] //[HttpGet] //[HandlerAuthorize(PermissionMode.Ignore)] public void DownloadFile(string keyValue, string filename, string recId) { if (string.IsNullOrEmpty(keyValue)) { return; } FileInfoEntity data = null; if (!string.IsNullOrEmpty(filename)) { data = fileInfoBLL.GetEntity(recId, Server.UrlDecode(filename)); } else { data = fileInfoBLL.GetEntity(keyValue); } if (data != null) { string name = string.IsNullOrEmpty(filename) ? Server.UrlDecode(data.FileName) : Server.UrlDecode(filename);//返回客户端文件名称 string filepath = this.Server.MapPath(data.FilePath); if (name.ToLower().Contains(".gw")) { name = name.ToLower().Replace(".gw", ".pdf"); } if (filepath.ToUpper().LastIndexOf(".GW") > 0) { filepath = filepath.ToUpper().Replace(".GW", ".pdf"); } if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, name); } else { if (this.Server.MapPath(data.FilePath).ToUpper().LastIndexOf(".GW") > 0) { HttpContext.Response.Write("GW文件未找到或正在转换成PDF文件"); } else { HttpContext.Response.Write("文件未找到"); } } } }
public void DownloadProposal(string keyValue) { try { string filename = Server.UrlDecode(keyValue); string filepath = Path.Combine(Server.MapPath("/Uploads/Proposal/"), keyValue); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } } catch (Exception ex) { new ErrorLogApp().SubmitForm(ex); throw; } }
public void DownAnnexesFileNew(string fileId) { var data = annexesFileIBLL.GetEntity(fileId); string filename = Server.UrlDecode(data.F_FileName);//返回客户端文件名称 string filepath = data.F_FilePath; var redPrintPath = data.F_FilePath.Replace(data.F_FileExtensions, "") + "_s" + data.F_FileExtensions; if (FileDownHelper.FileExists(redPrintPath)) { FileDownHelper.DownLoadold(redPrintPath, filename); } else { if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } } }
public void DownloadBackup(string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { List <string> lstid = StringHelper.GetStrArray(keyValue, ',', false); if (lstid.Count == 1) { var data = pictureApp.GetForm(lstid[0]); //将压缩包下载 FileDownHelper.DownLoadold(Server.MapPath(data.F_FilePath), data.F_FullName);//单个图片直接下载 return; } //将图片拷贝至指定临时路径并压缩打包 string newFilename = DateTime.Now.ToString("yyyyMMddHHmmss"); string newFolder = "/Temp/" + newFilename + "/"; string newZip = Server.MapPath("/Temp/" + newFilename + ".zip"); //压缩包 FileHelper.CreateDirectory(Server.MapPath(newFolder)); //创建一个临时文件夹 for (int i = 0; i < lstid.Count; i++) { var data = pictureApp.GetForm(lstid[i]); string filename = Server.UrlDecode(data.F_FullName); string filepath = Server.MapPath(data.F_FilePath); if (FileDownHelper.FileExists(filepath)) { FileHelper.Copy(filepath, Server.MapPath(newFolder + data.F_FullName));//将文件拷贝到临时文件夹 } } //将文件夹进行GZip压缩 ZipFloClass Zc = new ZipFloClass(); Zc.ZipFile(Server.MapPath(newFolder), newZip);//生成压缩包 if (FileDownHelper.FileExists(newZip)) { FileDownHelper.DownLoadold(newZip, newFilename + ".zip");//下载压缩包 } //删除文件夹 FileHelper.DeleteDirectory(newFolder); //删除文件夹 FileHelper.DeleteFile(newZip); //删除临时压缩包 } }
public void DownloadFileForKeyValue(string keyValue) { FileInfoBLL fileInfoBLL = new FileInfoBLL(); if (string.IsNullOrEmpty(keyValue)) { return; } DataTable data = null; data = fileInfoBLL.GetFiles(keyValue); if (data != null && data.Rows.Count > 0) { string name = string.IsNullOrEmpty(data.Rows[0]["FileName"].ToString()) ? Server.UrlDecode(data.Rows[0]["FileName"].ToString()) : Server.UrlDecode(data.Rows[0]["FileName"].ToString());//返回客户端文件名称 string filepath = this.Server.MapPath(data.Rows[0]["FilePath"].ToString()); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, name); } } }
public void Export() { try { //总人数,单程人数,双程人数 var ToPosition = HttpUtility.UrlDecode(Request["ToPosition"]); string sql = GetGridOrderSql(null, true); var dataTable = Db.MySqlContext.FromSql(sql).ToDataTable(); NPOIExcel nPOIExcel = new NPOIExcel(); string baseDictioneryPath = AppDomain.CurrentDomain.BaseDirectory + "\\Excel"; if (!Directory.Exists(baseDictioneryPath)) { Directory.CreateDirectory(baseDictioneryPath); } string fileName = "订单列表" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; string excelFilePath = baseDictioneryPath + "\\" + fileName; string CarNumber = HttpUtility.UrlDecode(Request["CarNumber"]); string DepartureTimeStart = Request["DepartureTimeStart"]; string DepartureTimeEnd = Request["DepartureTimeEnd"]; bool r = nPOIExcel.ToExcel(dataTable, "订单列表", "订单列表", excelFilePath, (workBook, sheet) => { //自定义行 object TotalAmountSum = dataTable.Compute("sum(车费)", "TRUE"); IRow row = sheet.CreateRow(0); var _DepartureTimeStart = DepartureTimeStart.ToDate().ToString("yyyy年MM月dd日"); var _DepartureTimeEnd = DepartureTimeEnd.ToDate().ToString("yyyy年MM月dd日"); var DepartureTimeStr = string.Empty; if (_DepartureTimeStart == _DepartureTimeEnd) { DepartureTimeStr = _DepartureTimeStart; } else { DepartureTimeStr = $"{ _DepartureTimeStart}-{ _DepartureTimeEnd}"; } int totalCount = dataTable.Rows.Count; //总人数 int singleCount = dataTable.Select("单程='是'").Count(); //单程 int doubleCount = totalCount - singleCount; //双程 row.CreateCell(0).SetCellValue($"目的地:{ToPosition} 车号:{CarNumber} 发车时间:{DepartureTimeStr} 合计:{TotalAmountSum} 总人数:{totalCount} 单程:{singleCount} 双程:{doubleCount} "); sheet.AddMergedRegion(new CellRangeAddress(0, 0, 0, dataTable.Columns.Count - 1)); row.Height = 500; ICellStyle cellStyle = workBook.CreateCellStyle(); IFont font = workBook.CreateFont(); font.FontName = "微软雅黑"; font.FontHeightInPoints = 17; cellStyle.SetFont(font); cellStyle.VerticalAlignment = VerticalAlignment.Center; cellStyle.Alignment = HorizontalAlignment.Left; row.Cells[0].CellStyle = cellStyle; return(1); }); FileDownHelper.DownLoadold(excelFilePath, fileName); } catch (Exception ex) { LogApp(f_ModuleName, DbLogType.Exception, ex.Message); } }