public ResponseBase UploadSecondlevelSafetyAssessmentReport(SecondLevelSafetyAssementReportUploadRequest req) { ResponseBase resp = new ResponseBase(); try { var uploadReport = new SecondAssessment_SecondLevelSafetyAssessmentReportTable() { AssessmentResultStateId = req.ReportGradeId, ReportPeriods = req.ReportName, ReportTime = req.uploadDate, ReprotPath = req.ReportPath, }; _getSecondLevelSafetyAssessmentReportDAL.Add(uploadReport); resp.Succeed = true; resp.Message = "文件上传成功!"; } catch (Exception ex) { resp.Succeed = false; resp.Message = "文件上传失败!"; Log(ex); } return(resp); }
/// <summary> /// 下载报告 /// </summary> /// <param name="ReportPath">本地上传报告的路径</param> /// <param name="ReportName">报告名字</param> /// <returns></returns> public ActionResult DownloadSecondLevelSafetyAssessmentReport(string ReportPath, string ReportName) { var req = new SecondLevelSafetyAssementReportUploadRequest() { 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 DeleteSecondLevelSafetyAssessmentReport(string ReportPath) { var req = new SecondLevelSafetyAssementReportUploadRequest() { ReportPath = ReportPath, }; var GetSecondLevelSafetyAssessmentReportListService = new GetSecondLevelSafetyAssessmentReportService(); var resp = GetSecondLevelSafetyAssessmentReportListService.DeleteSecondLevelSafetyAssessmentReport(req); if (resp.Succeed == true) { System.IO.File.Delete(ReportPath); } return(Json(resp.Message, JsonRequestBehavior.AllowGet)); }
public ResponseBase DeleteSecondLevelSafetyAssessmentReport(SecondLevelSafetyAssementReportUploadRequest req) { ResponseBase resp = new ResponseBase(); IList <Func <SecondAssessment_SecondLevelSafetyAssessmentReportTable, bool> > ps = new List <Func <SecondAssessment_SecondLevelSafetyAssessmentReportTable, bool> >(); DealWithDeleteConditon(req, ps); try { var source = _getSecondLevelSafetyAssessmentReportDAL.FindBy(ps).SingleOrDefault(); _getSecondLevelSafetyAssessmentReportDAL.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 UploadSecondLevelSafetyAssessmentReport(int reportGradeId) { 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 GetSecondLevelSafetyAssessmentReportListService = new GetSecondLevelSafetyAssessmentReportService(); bool reportresp = GetSecondLevelSafetyAssessmentReportListService.GetReportNameIsNotHas(ReportName); if (reportresp == true) { files[0].SaveAs(ReprotPath); //保存文件 DateTime uploadDate = DateTime.Now; var req = new SecondLevelSafetyAssementReportUploadRequest() { ReportGradeId = reportGradeId, ReportPath = ReprotPath, uploadDate = uploadDate, ReportName = ReportName, }; var resp = GetSecondLevelSafetyAssessmentReportListService.UploadSecondlevelSafetyAssessmentReport(req); return(Json(resp.Message, JsonRequestBehavior.AllowGet)); } else { return(Json("该文件名已存在,请重新选择文件或重命名上传文件!", JsonRequestBehavior.AllowGet)); } }
public SecondLevelSafetyAssessmentReportDownloadResponse GetSecondLevelSafetyAssessmentReportByReportName(SecondLevelSafetyAssementReportUploadRequest req) { var resp = new SecondLevelSafetyAssessmentReportDownloadResponse(); try { resp.ReprotPath = _getManualInspectionSafetyAssessmentReportDAL.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); }
void DealWithDeleteConditon(SecondLevelSafetyAssementReportUploadRequest req, IList <Func <SecondAssessment_SecondLevelSafetyAssessmentReportTable, bool> > ps) { ps.Add(m => m.ReprotPath == req.ReportPath); }