public ActionResult SeeProject(long?id, string action) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var test = from ad in db.vw_projectProfile where (ad.projectID == id) select ad; vw_projectProfile projectProfile = test.First(); List <SelectListItem> list = new List <SelectListItem> { new SelectListItem { Text = "是", Value = "1" }, new SelectListItem { Text = "否", Value = "0" }, }; if (test.First().isYD == true) { ViewBag.isYD = new SelectList(list, "Value", "Text", 1); } else { ViewBag.isYD = new SelectList(list, "Value", "Text", 0); } if (action == "返回") { return(RedirectToAction("MeterialsSend")); } if (projectProfile == null) { return(HttpNotFound()); } return(View(projectProfile)); }
public ActionResult SeeReceive(long?id, string action, string id2) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var test = from ad in db.vw_projectProfile where (ad.projectID == id) select ad; vw_projectProfile projectProfile = test.First(); if (action == "返回") { if (id2 == "2") { return(RedirectToAction("AllArchives")); } else { return(RedirectToAction("StatisticalAndAnalysis")); } } if (action == "文件下载") { //if (string.IsNullOrEmpty(id)) //{ // throw new ArgumentNullException("fileId is errror"); //} int Id = Convert.ToInt32(id); var findFile = db.ProjectInfo.Where(a => a.projectID == Id).First(); if (findFile.storagePath == null) { Response.Write("<script >alert('该工程未上传文件!');window.history.back();</script>"); } else { string filePath = Request.MapPath("~/files/jungongWord"); string path = filePath + "/" + findFile.storagePath; //以字符流的形式下载文件 FileStream fs = new FileStream(path, FileMode.Open); byte[] bytes = new byte[(int)fs.Length]; fs.Read(bytes, 0, bytes.Length); fs.Close(); Response.ContentType = "application/octet-stream"; //通知浏览器下载文件而不是打开 Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(findFile.storagePath, System.Text.Encoding.UTF8)); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); } } List <SelectListItem> list = new List <SelectListItem> { new SelectListItem { Text = "是", Value = "1" }, new SelectListItem { Text = "否", Value = "0" }, }; if (test.First().isYD == true) { ViewBag.isYD = new SelectList(list, "Value", "Text", 1); } else { ViewBag.isYD = new SelectList(list, "Value", "Text", 0); } if (projectProfile == null) { return(HttpNotFound()); } return(View(projectProfile)); }