/// <summary> /// 下载报告 /// </summary> /// <param name="ReportPath">本地上传报告的路径</param> /// <param name="ReportName">报告名字</param> /// <returns></returns> public ActionResult DownloadSpecialSafetyAssessmentReport(string ReportPath, string ReportName) { var req = new SpecialSafetyAssementReportUploadRequest() { ReportPath = ReportPath, ReportName = ReportName }; FileStream fileStream = new FileStream(ReportPath, FileMode.Open); var guid = ""; guid = Guid.NewGuid().ToString(); CacheHelper.SetCache(guid, fileStream); return(Json(guid, JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteSpecialSafetyAssessmentReport(string ReportPath) { var req = new SpecialSafetyAssementReportUploadRequest() { ReportPath = ReportPath, }; var _getSpecialSafetyAssessmentReportService = new GetSpecialSafetyAssessmentReportService(); var resp = _getSpecialSafetyAssessmentReportService.DeleteSpecialSafetyAssessmentReport(req); if (resp.Succeed == true) { System.IO.File.Delete(ReportPath); } return(Json(resp.Message, JsonRequestBehavior.AllowGet)); }
public ResponseBase DeleteSpecialSafetyAssessmentReport(SpecialSafetyAssementReportUploadRequest req) { ResponseBase resp = new ResponseBase(); IList <Func <SpecialAssessment_SpecialSafetyAssessmentReportTable, bool> > ps = new List <Func <SpecialAssessment_SpecialSafetyAssessmentReportTable, bool> >(); DealWithDeleteConditon(req, ps); try { var source = _getSpecialSafetyAssessmentReportDAL.FindBy(ps).SingleOrDefault(); _getSpecialSafetyAssessmentReportDAL.Remove(source); resp.Succeed = true; resp.Message = "删除报告成功"; } catch (Exception ex) { resp.Succeed = false; resp.Message = "删除报告失败"; Log(ex); } return(resp); }
/// <summary> /// 上传专项评估报告 /// </summary> /// <param name="conditions"></param> /// <returns></returns> public ActionResult UploadSpecialSafetyAssessmentReport() { HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; if (files.Count == 0) { return(Json("未选择文件!", JsonRequestBehavior.AllowGet)); } HttpPostedFile fileSave = files[0]; //转换文件类型 string ReportName = fileSave.FileName; //获得服务端上传文件的文件名 string path = System.Web.HttpContext.Current.Server.MapPath(StyleConstants.SecondLevelSafetyAssessmentReportUploasPath); if (System.IO.Directory.Exists(path) == false) { System.IO.Directory.CreateDirectory(path); } string ReprotPath = string.Concat(path, ReportName);//拼接上传文件的保存路径 var _getSpecialSafetyAssessmentReportService = new GetSpecialSafetyAssessmentReportService(); bool reportresp = _getSpecialSafetyAssessmentReportService.GetReportNameIsNotHas(ReportName); if (reportresp == true) { files[0].SaveAs(ReprotPath); //保存文件 DateTime uploadDate = DateTime.Now; var req = new SpecialSafetyAssementReportUploadRequest() { ReportPath = ReprotPath, uploadDate = uploadDate, ReportName = ReportName, }; var resp = _getSpecialSafetyAssessmentReportService.UploadSpecialSafetyAssessmentReport(req); return(Json(resp.Message, JsonRequestBehavior.AllowGet)); } else { return(Json("该文件名已存在,请重新选择文件或重命名上传文件!", JsonRequestBehavior.AllowGet)); } }
public ResponseBase UploadSpecialSafetyAssessmentReport(SpecialSafetyAssementReportUploadRequest req) { ResponseBase resp = new ResponseBase(); try { var uploadReport = new SpecialAssessment_SpecialSafetyAssessmentReportTable() { ReportPeriods = req.ReportName, ReportTime = req.uploadDate, ReprotPath = req.ReportPath, }; _getSpecialSafetyAssessmentReportDAL.Add(uploadReport); resp.Succeed = true; resp.Message = "文件上传成功"; } catch (Exception ex) { resp.Succeed = false; resp.Message = "文件上传失败"; Log(ex); } return(resp); }
void DealWithDeleteConditon(SpecialSafetyAssementReportUploadRequest req, IList <Func <SpecialAssessment_SpecialSafetyAssessmentReportTable, bool> > ps) { ps.Add(m => m.ReprotPath == req.ReportPath); }
public SpecialSafetyAssessmentReportDownloadResponse GetSpecialSafetyAssessmentReportByReportName(SpecialSafetyAssementReportUploadRequest req) { var resp = new SpecialSafetyAssessmentReportDownloadResponse(); try { resp.ReprotPath = _getSpecialSafetyAssessmentReportDAL.FindBy(m => m.ReprotPath == req.ReportPath).SingleOrDefault().ReprotPath; resp.Message = "下载成功"; resp.Succeed = true; } catch (Exception ex) { resp.Succeed = false; resp.Message = "下载失败"; Log(ex); } return(resp); }