public ResponseBase UploadSecondlevelSafetyAssessmentReport(ManualInspectionSafetyAssementReportUploadRequest req)
        {
            ResponseBase resp = new ResponseBase();

            try
            {
                var uploadReport = new ManualInspectionSafetyAssessmentReportTable()
                {
                    AssessmentResultStateId = req.ReportGradeId,
                    ReportPeriods           = req.ReportName,
                    ReportTime = req.uploadDate,
                    ReprotPath = req.ReportPath,
                };
                _getManualInspectionSafetyAssessmentReportDAL.Add(uploadReport);
                resp.Succeed = true;
                resp.Message = "文件上传成功!";
            }
            catch (Exception ex)
            {
                resp.Succeed = false;
                resp.Message = "文件上传失败!";
                Log(ex);
            }
            return(resp);
        }
コード例 #2
0
        /// <summary>
        /// 下载报告
        /// </summary>
        /// <param name="ReportPath">本地上传报告的路径</param>
        /// <param name="ReportName">报告名字</param>
        /// <returns></returns>
        public ActionResult DownloadManualInspectionSafetyAssessmentReport(string ReportPath, string ReportName)
        {
            var req = new ManualInspectionSafetyAssementReportUploadRequest()
            {
                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));
        }
コード例 #3
0
        public ActionResult DeleteManualInspectionSafetyAssessmentReport(string ReportPath)
        {
            var req = new ManualInspectionSafetyAssementReportUploadRequest()
            {
                ReportPath = ReportPath,
            };
            var GetManualInspectionSafetyAssessmentReportService = new GetManualInspectionSafetyAssessmentReportService();
            var resp = GetManualInspectionSafetyAssessmentReportService.DeleteSecondLevelSafetyAssessmentReport(req);

            if (resp.Succeed == true)
            {
                System.IO.File.Delete(ReportPath);
            }
            return(Json(resp.Message, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        /// <summary>
        /// 上传评估报告
        /// </summary>
        /// <param name="conditions"></param>
        /// <returns></returns>
        public ActionResult UploadManualInspectionSafetyAssessmentReport(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    GetManualInspectionSafetyAssessmentReportService = new GetManualInspectionSafetyAssessmentReportService();
            bool   reportresp = GetManualInspectionSafetyAssessmentReportService.GetReportNameIsNotHas(ReportName);

            if (reportresp == true)
            {
                files[0].SaveAs(ReprotPath); //保存文件
                DateTime uploadDate = DateTime.Now;
                var      req        = new ManualInspectionSafetyAssementReportUploadRequest()
                {
                    ReportGradeId = reportGradeId,
                    ReportPath    = ReprotPath,
                    uploadDate    = uploadDate,
                    ReportName    = ReportName,
                };
                var resp = GetManualInspectionSafetyAssessmentReportService.UploadSecondlevelSafetyAssessmentReport(req);
                return(Json(resp.Message, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("该文件名已存在,请重新选择文件或重命名上传文件!", JsonRequestBehavior.AllowGet));
            }
        }
        public ResponseBase DeleteSecondLevelSafetyAssessmentReport(ManualInspectionSafetyAssementReportUploadRequest req)
        {
            ResponseBase resp = new ResponseBase();
            IList <Func <ManualInspectionSafetyAssessmentReportTable, bool> > ps = new List <Func <ManualInspectionSafetyAssessmentReportTable, bool> >();

            DealWithDeleteConditon(req, ps);

            try
            {
                var source = _getManualInspectionSafetyAssessmentReportDAL.FindBy(ps).SingleOrDefault();
                _getManualInspectionSafetyAssessmentReportDAL.Remove(source);
                resp.Succeed = true;
                resp.Message = "删除报告成功";
            }
            catch (Exception ex)
            {
                resp.Succeed = false;
                resp.Message = "删除报告失败!";
                Log(ex);
            }
            return(resp);
        }
 void DealWithDeleteConditon(ManualInspectionSafetyAssementReportUploadRequest req, IList <Func <ManualInspectionSafetyAssessmentReportTable, bool> > ps)
 {
     ps.Add(m => m.ReprotPath == req.ReportPath);
 }