public ActionResult Download(string id) { var FilesPath = HelpAnswerGroup.GetList().FirstOrDefault(u => u.id == id).Answer; if (FilesPath != null) { JObject jo = (JObject)JsonConvert.DeserializeObject(FilesPath); foreach (var path in jo["Values"]) { ///判断是否为路径格式,如果存在就直接显示下载 if (path.ToString().IndexOf("/") > -1) { try { // var wwwroot = _hostingEnvironment.ContentRootPath + path; //判断该文件是否存在????? //if (System.IO.File.Exists(path.ToString())) //{ /// 虚拟文件地址输出下载 //} //return Content("<script>alert('该文件已丢失,请重试');window.history.back(-1); </script>"); return(File(path.ToString(), "application/vnd.android.package-archive", Path.GetFileName(path.ToString()))); } catch (Exception el) { return(Content("<script>alert('文件下载失败,请重试');window.history.back(-1); </script>")); } } } } return(Content("<script>alert('文件下载失败,请重试');window.history.back(-1); </script>")); }
public ActionResult Details(string id) { var entity = HelpAnswerGroup.GetList().FirstOrDefault(u => u.id == id); if (entity != null) { return(View("Details", entity)); } return(RedirectToAction("Exhibition")); }
public IActionResult Index(IFormCollection model, List <IFormFile> files) { //在文件上传的时候, 只能采用表单的提交后台才能够获取到文件?? 而Ajax的方式不行? string paths = FileSave(files); Dictionary <string, string> keyValuePairs = new Dictionary <string, string>() { }; foreach (var item in model) { // 去掉莫名上传的Cookies防伪标志 if (item.Key.IndexOf("_") != 0) { //前端会上传类型路径的字符串,如果存在就替换成上传路径! if (item.Value.ToString().IndexOf("\\") > -1) { keyValuePairs.Add(item.Key, paths); } else { string Value = item.Value.ToString() == "" ? "..." : item.Value.ToString(); //keyValuePairs.Add(item.Key, item.Value); keyValuePairs.Add(item.Key, Value); } } } AnswerGroup InsertModel = new AnswerGroup() { id = Guid.NewGuid().ToString(), FromID = Seesion.FromIds, Answer = JObject.FromObject(new { FormName = keyValuePairs.Keys, Values = keyValuePairs.Values }).ToString() }; try { int flage = HelpAnswerGroup.Insert(InsertModel); if (flage > 0) { //RedirectToAction 只能够在本页面跳转 return(RedirectToAction("Succeed")); } return(Json("插入失败")); } catch (Exception el) { return(Json(ResultMsg.FormatResult(el))); } }
public ActionResult Delete(string id) { // ???? 所有的Js 都没有弹出 var entity = HelpAnswerGroup.GetList().FirstOrDefault(u => u.id == id); if (entity != null) { if (HelpAnswerGroup.Delete(id)) { return(RedirectToAction("Exhibition")); } return(Content("<script>alert('删除失败 ,请重试');window.history.back(-1); </script>")); // 删除信息同时是否删除文件夹??? } else { return(Content("<script>alert('删除失败,请重试');window.history.back(-1); </script>")); } }
/// <summary> /// 显示数据 /// </summary> /// <returns></returns> public ActionResult Exhibition(string fid) { ViewData["theader"] = HelpTopicgroup.GetList("FromID='" + fid + "'"); return(View(HelpAnswerGroup.GetList("FromID='" + fid + "'").ToList())); }