Exemplo n.º 1
0
        public ActionResult Add(Epm_DangerousWork model)
        {
            ResultView <int> view = new ResultView <int>();

            //表单校验
            if (!model.ProjectId.HasValue || model.ProjectId.Value == 0 || string.IsNullOrWhiteSpace(model.ProjectName))
            {
                view.Flag    = false;
                view.Message = "项目名称不能为空";
                return(Json(view));
            }
            //if (string.IsNullOrEmpty(model.TaskName))
            //{
            //    view.Flag = false;
            //    view.Message = "作业名称不能为空";
            //    return Json(view);
            //}
            if (!model.StartTime.HasValue || model.StartTime.Value == DateTime.MinValue)
            {
                view.Flag    = false;
                view.Message = "开始时间不能为空";
                return(Json(view));
            }
            //if (!model.EndTime.HasValue || model.EndTime.Value == DateTime.MinValue)
            //{
            //    view.Flag = false;
            //    view.Message = "结束时间不能为空";
            //    return Json(view);
            //}
            //if (model.StartTime.Value > model.EndTime.Value)
            //{
            //    view.Flag = false;
            //    view.Message = "开始时间不能大于结束时间";
            //    return Json(view);
            //}
            //if (model.StartTime.Value > model.EndTime.Value)
            //{
            //    view.Flag = false;
            //    view.Message = "开始时间不能大于结束时间";
            //    return Json(view);
            //}
            if (string.IsNullOrEmpty(model.TaskTypeNo) || string.IsNullOrEmpty(model.TaskTypeName))
            {
                view.Flag    = false;
                view.Message = "作业分类不能为空";
                return(Json(view));
            }
            if (string.IsNullOrEmpty(model.TaskContent))
            {
                view.Flag    = false;
                view.Message = "作业内容不能为空";
                return(Json(view));
            }

            //上传附件
            string            fileDataJsonFile = Request.Form["fileDataJsonFile"];                                     //获取上传文件json字符串
            List <Base_Files> files            = JsonConvert.DeserializeObject <List <Base_Files> >(fileDataJsonFile); //将文件信息json字符

            Result <int> result = new Result <int>();

            using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(Request)))
            {
                result = proxy.AddDangerousWork(model, files);
            }
            return(Json(result.ToResultView()));
        }