public JsonResult SaveFileInfo(string data) { data = data == null ? null : HttpUtility.UrlDecode(data); BlueStone.Smoke.Entity.FileInfo fileInfo = data == null ? null : Newtonsoft.Json.JsonConvert.DeserializeObject <BlueStone.Smoke.Entity.FileInfo>(data, new Newtonsoft.Json.JsonSerializerSettings { MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore, DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); if (data == null) { return(new JsonResult() { Data = 0 }); } fileInfo.CreateUserName = CurrUser.UserDisplayName; fileInfo.CreateUserSysNo = CurrUser.UserSysNo; int result = 0; if (fileInfo.IsDeleted) { CommonService.DeleteFileInfo(fileInfo.MasterType.Value, fileInfo.MasterID, fileInfo.CategoryName); } else { result = CommonService.InsertFileInfo(fileInfo); } fileInfo.SysNo = result; return(Json(new AjaxResult { Success = true, Message = "保存成功", Data = result })); }
public ActionResult DownloadRemoteFile(int?sysNo) { if (!sysNo.HasValue || sysNo <= 0) { throw new BusinessException("没有检测到要下载的文件。"); } BlueStone.Smoke.Entity.FileInfo file = CommonService.LoadFileInfoBySysNo(sysNo.Value); if (file == null || file.SysNo <= 0) { throw new BusinessException("没有检测到要下载的文件。"); } string fileHost = BlueStone.Utility.AppSettingManager.GetSetting("base", "ImageStorageServerDomain"); string remoteUrl = fileHost + file.FileRelativePath; byte[] fileData; try { using (WebClient client = new WebClient()) { fileData = client.DownloadData(remoteUrl); return(File(fileData, "text/plain", file.FileName)); } } catch { throw new BusinessException("文件下载失败。"); } }