Ejemplo n.º 1
0
        /// <summary>
        /// 保存电子文档
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public ActionResult <bool> SaveFiles(AttachFileSave file)
        {
            try
            {
                List <Bll_AttachFile> dbfiles = (from f in file.files
                                                 select new Bll_AttachFile
                {
                    BusinessID = file.BusinessID,
                    FileTitle = f.FileTitle,
                    FileType = f.FileType,
                    FileUrl = f.FileUrl,
                    ID = Guid.NewGuid()
                }).ToList();


                rpsFile.Delete(q => q.BusinessID == file.BusinessID);
                rpsFile.Add(dbfiles);
                //不提交,与业务一起提交
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改人员健康档案
        /// </summary>
        /// <param name="docmentEdit"></param>
        /// <returns></returns>
        public ActionResult <bool> EditHealDocment(HealDocmentEdit docmentEdit)
        {
            try
            {
                var dbhd = _rpshd.GetModel(docmentEdit.ID);
                if (dbhd == null)
                {
                    throw new Exception("未找到所要修改的健康档案!");
                }
                var check = _rpshd.Any(p => p.ID != docmentEdit.ID && p.EmployeeID == docmentEdit.EmployeeID);
                if (check)
                {
                    throw new Exception("该人员的健康档案已存在!");
                }
                dbhd = docmentEdit.CopyTo <Heal_Docment>(dbhd);


                //自定义项
                srvUserDefined.DeleteBusinessValue(dbhd.ID);
                var definedvalue = new UserDefinedBusinessValue
                {
                    BusinessID = dbhd.ID,
                    Values     = docmentEdit.UserDefineds
                };
                var defined = srvUserDefined.SaveBuisnessValue(definedvalue);
                if (defined.state != 200)
                {
                    throw new Exception(defined.msg);
                }

                //电子文档
                srvFile.DelFileByBusinessId(dbhd.ID);
                var files = new AttachFileSave
                {
                    BusinessID = dbhd.ID,
                    files      = from f in docmentEdit.AttachFiles
                                 select new AttachFileNew
                    {
                        FileTitle = f.FileTitle,
                        FileType  = f.FileType,
                        FileUrl   = f.FileUrl
                    }
                };

                var fre = srvFile.SaveFiles(files);
                if (fre.state != 200)
                {
                    throw new Exception(fre.msg);
                }

                _rpshd.Update(dbhd);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 修改安全会议模型
        /// </summary>
        /// <param name="meetingEdit"></param>
        /// <returns></returns>
        public ActionResult <bool> EditDocMeeting(DocMeetingEdit meetingEdit)
        {
            try
            {
                var dbdm = _rpsdm.GetModel(meetingEdit.ID);
                if (dbdm == null)
                {
                    throw new Exception("未找到所要修改的会议!");
                }
                var check = _rpsdm.Any(p => p.ID != meetingEdit.ID && p.Motif == meetingEdit.Motif);
                if (check)
                {
                    throw new Exception("该会议主题已存在!");
                }
                dbdm = meetingEdit.CopyTo <Doc_Meeting>(dbdm);

                //自定义项
                srvUserDefined.DeleteBusinessValue(dbdm.ID);
                var definedvalue = new UserDefinedBusinessValue
                {
                    BusinessID = dbdm.ID,
                    Values     = meetingEdit.UserDefineds
                };
                var defined = srvUserDefined.SaveBuisnessValue(definedvalue);
                if (defined.state != 200)
                {
                    throw new Exception(defined.msg);
                }

                //电子文档
                srvFile.DelFileByBusinessId(dbdm.ID);
                var files = new AttachFileSave
                {
                    BusinessID = dbdm.ID,
                    files      = from f in meetingEdit.AttachFiles
                                 select new AttachFileNew
                    {
                        FileTitle = f.FileTitle,
                        FileType  = f.FileType,
                        FileUrl   = f.FileUrl
                    }
                };

                var fre = srvFile.SaveFiles(files);
                if (fre.state != 200)
                {
                    throw new Exception(fre.msg);
                }
                _rpsdm.Update(dbdm);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 修改体检模型
        /// </summary>
        /// <param name="docmentEdit"></param>
        /// <returns></returns>
        public ActionResult <bool> EditHealRecord(HealRecordsEdit recordsEdit)
        {
            try
            {
                var dbhr = _rpshr.GetModel(recordsEdit.ID);
                if (dbhr == null)
                {
                    throw new Exception("未找到所要修改的体检信息!");
                }
                var check = _rpshr.Any(p => p.ID != recordsEdit.ID && p.RecDate == recordsEdit.RecDate);
                if (check)
                {
                    throw new Exception("该人员的体检信息已存在!");
                }
                dbhr = recordsEdit.CopyTo <Heal_Records>(dbhr);

                //删除自定义项
                srvUserDefined.DeleteBusinessValue(dbhr.ID);
                //自定义项
                var definedvalue = new UserDefinedBusinessValue
                {
                    BusinessID = dbhr.ID,
                    Values     = recordsEdit.UserDefineds
                };
                var defined = srvUserDefined.SaveBuisnessValue(definedvalue);
                if (defined.state != 200)
                {
                    throw new Exception(defined.msg);
                }
                //电子文档
                srvFile.DelFileByBusinessId(dbhr.ID);
                var files = new AttachFileSave
                {
                    BusinessID = dbhr.ID,
                    files      = from f in recordsEdit.AttachFiles
                                 select new AttachFileNew
                    {
                        FileTitle = f.FileTitle,
                        FileType  = f.FileType,
                        FileUrl   = f.FileUrl
                    }
                };
                var fre = srvFile.SaveFiles(files);
                if (fre.state != 200)
                {
                    throw new Exception(fre.msg);
                }

                _rpshr.Update(dbhr);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 修改训练模型
        /// </summary>
        /// <param name="trainingEdit"></param>
        /// <returns></returns>
        public ActionResult <bool> EditTraining(DocTrainingEdit trainingEdit)
        {
            try
            {
                var dbdt = _rpsdt.GetModel(trainingEdit.ID);
                if (dbdt == null)
                {
                    throw new Exception("未找到所需修改的训练项模型");
                }
                var check = _rpsdt.Any(p => p.ID != trainingEdit.ID && p.Motif == trainingEdit.Motif);
                if (check)
                {
                    throw new Exception("该训练项已存在");
                }
                dbdt = trainingEdit.CopyTo <Doc_Training>(dbdt);

                //电子文档
                srvFile.DelFileByBusinessId(dbdt.ID);
                var files = new AttachFileSave
                {
                    BusinessID = dbdt.ID,
                    files      = from f in trainingEdit.AttachFiles
                                 select new AttachFileNew
                    {
                        FileTitle = f.FileTitle,
                        FileType  = f.FileType,
                        FileUrl   = f.FileUrl
                    }
                };

                var fileresult = srvFile.SaveFiles(files);
                if (fileresult.state != 200)
                {
                    throw new Exception(fileresult.msg);
                }

                //培训人员先删除后添加
                _rpsdtemp.Delete(p => p.TrainID == trainingEdit.ID);
                //添加培训人员
                List <Doc_TrainEmpoyees> emps = (from empid in trainingEdit.EmployeeIDs
                                                 select new Doc_TrainEmpoyees
                {
                    EmployeeID = empid,
                    TrainID = dbdt.ID
                }).ToList();

                _rpsdtemp.Add(emps);

                _rpsdt.Update(dbdt);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 新建体检模型
        /// </summary>
        /// <param name="recordsNew"></param>
        /// <returns></returns>
        public ActionResult <bool> AddHealRecord(HealRecordsNew recordsNew)
        {
            try
            {
                if (recordsNew == null)
                {
                    throw new Exception("参数有误");
                }
                var check = _rpshr.Any(p => p.DocmentID == recordsNew.DocmentID && p.RecDate == recordsNew.RecDate);
                if (check)
                {
                    throw new Exception("该体检信息已存在!");
                }
                var dbhr = recordsNew.MAPTO <Heal_Records>();

                //自定义项
                var definedvalue = new UserDefinedBusinessValue
                {
                    BusinessID = dbhr.ID,
                    Values     = recordsNew.UserDefineds
                };
                var defined = srvUserDefined.SaveBuisnessValue(definedvalue);
                if (defined.state != 200)
                {
                    throw new Exception(defined.msg);
                }

                //电子文档
                var files = new AttachFileSave
                {
                    BusinessID = dbhr.ID,
                    files      = from f in recordsNew.AttachFiles
                                 select new AttachFileNew
                    {
                        FileTitle = f.FileTitle,
                        FileType  = f.FileType,
                        FileUrl   = f.FileUrl
                    }
                };

                var fre = srvFile.SaveFiles(files);
                if (fre.state != 200)
                {
                    throw new Exception(fre.msg);
                }

                _rpshr.Add(dbhr);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 新建安全会议模型
        /// </summary>
        /// <param name="meetingNew"></param>
        /// <returns></returns>
        public ActionResult <bool> AddDocMeeting(DocMeetingNew meetingNew)
        {
            try
            {
                if (meetingNew == null)
                {
                    throw new Exception("参数有误");
                }
                var check = _rpsdm.Any(p => p.Motif == meetingNew.Motif);
                if (check)
                {
                    throw new Exception("该会议主题已存在!");
                }
                var dbdm = meetingNew.MAPTO <Doc_Meeting>();

                //自定义项
                var definedvalue = new UserDefinedBusinessValue
                {
                    BusinessID = dbdm.ID,
                    Values     = meetingNew.UserDefineds
                };
                var defined = srvUserDefined.SaveBuisnessValue(definedvalue);
                if (defined.state != 200)
                {
                    throw new Exception(defined.msg);
                }

                //电子文档
                var files = new AttachFileSave
                {
                    BusinessID = dbdm.ID,
                    files      = from f in meetingNew.AttachFiles
                                 select new AttachFileNew
                    {
                        FileTitle = f.FileTitle,
                        FileType  = f.FileType,
                        FileUrl   = f.FileUrl
                    }
                };

                var fileresult = srvFile.SaveFiles(files);
                if (fileresult.state != 200)
                {
                    throw new Exception(fileresult.msg);
                }

                _rpsdm.Add(dbdm);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 新建健康文档
        /// </summary>
        /// <param name="docmentNew"></param>
        /// <returns></returns>
        public ActionResult <bool> AddHealDocment(HealDocmentNew docmentNew)
        {
            try
            {
                if (docmentNew == null)
                {
                    throw new Exception("参数有误");
                }
                var check = _rpshd.Any(p => p.EmployeeID == docmentNew.EmployeeID);
                if (check)
                {
                    throw new Exception("该人员的健康档案已存在!");
                }
                var dbhd = docmentNew.MAPTO <Heal_Docment>();

                //自定义项
                var definedvalue = new UserDefinedBusinessValue
                {
                    BusinessID = dbhd.ID,
                    Values     = docmentNew.UserDefineds
                };
                var defined = srvUserDefined.SaveBuisnessValue(definedvalue);
                if (defined.state != 200)
                {
                    throw new Exception(defined.msg);
                }

                //电子文档
                var files = new AttachFileSave
                {
                    BusinessID = dbhd.ID,
                    files      = from f in docmentNew.AttachFiles
                                 select new AttachFileNew
                    {
                        FileTitle = f.FileTitle,
                        FileType  = f.FileType,
                        FileUrl   = f.FileUrl
                    }
                };

                var fre = srvFile.SaveFiles(files);
                if (fre.state != 200)
                {
                    throw new Exception(fre.msg);
                }
                _rpshd.Add(dbhd);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 修改岗位
        /// </summary>
        /// <param name="post"></param>
        /// <returns></returns>
        public ActionResult <bool> EditPost(PostEdit post)
        {
            try
            {
                var dbpost = _rpspost.GetModel(p => p.ID == post.ID);
                if (dbpost == null)
                {
                    throw new Exception("未找到所需修改的岗位");
                }
                if (post.Org == Guid.Empty || post.Principal == Guid.Empty)
                {
                    throw new Exception("请选择组织架构或负责人!");
                }
                var check = _rpspost.Any(p => p.Name == post.Name && p.ID != post.ID);
                if (check)
                {
                    throw new Exception("该岗位名已存在");
                }
                var _dbpost = post.CopyTo <Basic_Post>(dbpost);

                //自定义项
                usedefinedService.DeleteBusinessValue(_dbpost.ID);
                var definedvalue = new UserDefinedBusinessValue
                {
                    BusinessID = _dbpost.ID,
                    Values     = post.UserDefineds
                };
                var defined = usedefinedService.SaveBuisnessValue(definedvalue);
                if (defined.state != 200)
                {
                    throw new Exception(defined.msg);
                }
                //文件
                srvFile.DelFileByBusinessId(_dbpost.ID);
                var files = new AttachFileSave
                {
                    BusinessID = _dbpost.ID,
                    files      = post.fileNews
                };

                var file = srvFile.SaveFiles(files);
                if (file.state != 200)
                {
                    throw new Exception(file.msg);
                }
                _rpspost.Update(_dbpost);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 添加岗位
        /// </summary>
        /// <param name="post"></param>
        /// <returns></returns>
        public ActionResult <bool> AddPost(PostNew post)
        {
            try
            {
                if (post == null)
                {
                    throw new Exception("参数有误");
                }
                if (post.Org == Guid.Empty || post.Principal == Guid.Empty)
                {
                    throw new Exception("请选择组织架构或负责人!");
                }
                var check = _rpspost.Any(p => p.Name == post.Name);
                if (check)
                {
                    throw new Exception("该岗位已存在");
                }

                var dbpost = post.MAPTO <Basic_Post>();
                //自定义项
                var definedvalue = new UserDefinedBusinessValue
                {
                    BusinessID = dbpost.ID,
                    Values     = post.UserDefineds
                };
                var defined = usedefinedService.SaveBuisnessValue(definedvalue);
                if (defined.state != 200)
                {
                    throw new Exception(defined.msg);
                }
                //文件
                var files = new AttachFileSave
                {
                    BusinessID = dbpost.ID,
                    files      = post.fileNews
                };
                var file = srvFile.SaveFiles(files);
                if (file.state != 200)
                {
                    throw new Exception(file.msg);
                }
                _rpspost.Add(dbpost);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 新建风险点
 /// </summary>
 /// <param name="pointNew"></param>
 /// <returns></returns>
 public ActionResult <bool> AddDangerPoint(DangerPointNew pointNew)
 {
     try
     {
         var check = rpsdp.Any(q => q.Name == pointNew.Name);
         if (check)
         {
             throw new Exception("该风险点已存在");
         }
         if (pointNew.DangerLevel == Guid.Empty)
         {
             throw new Exception("请选择风险等级!");
         }
         if (pointNew.WXYSDictIDs.Count() == 0)
         {
             throw new Exception("请选择危险因素!");
         }
         if (pointNew.OrgID == Guid.Empty)
         {
             throw new Exception("请选责任部门!");
         }
         if (pointNew.Principal == Guid.Empty)
         {
             throw new Exception("请选责任人!");
         }
         var dbdp = pointNew.MAPTO <Basic_DangerPoint>();
         dbdp.WXYSJson    = JsonConvert.SerializeObject(pointNew.WXYSDictIDs);
         dbdp.Code        = Command.CreateCode();
         dbdp.WarningSign = JsonConvert.SerializeObject(pointNew.WarningSigns);
         dbdp.QRCoderUrl  = CreateQRCoder(dbdp.ID);
         //文件
         var files = new AttachFileSave
         {
             BusinessID = dbdp.ID,
             files      = pointNew.fileNews
         };
         var file = srvFile.SaveFiles(files);
         if (file.state != 200)
         {
             throw new Exception(file.msg);
         }
         rpsdp.Add(dbdp);
         work.Commit();
         return(new ActionResult <bool>(true));
     }
     catch (Exception ex)
     {
         return(new ActionResult <bool>(ex));
     }
 }
Ejemplo n.º 12
0
        ///// <summary>
        ///// 新建训练人员模型
        ///// </summary>
        ///// <param name="empoyeesNew"></param>
        ///// <returns></returns>
        //public ActionResult<bool> AddTrainEmployee(DocTrainEmpoyeesNew empoyeesNew)
        //{
        //    try
        //    {
        //        var check = _rpsdtemp.Any(p=>p.TrainID==empoyeesNew.TrainID);
        //        if (!check)
        //        {
        //            throw new Exception("未找到该培训项");
        //        }
        //        check = _rpsdtemp.Any(p => p.TrainID == empoyeesNew.TrainID && p.EmployeeID == empoyeesNew.EmployeeID);
        //        if (check)
        //        {
        //            throw new Exception("该培训项下已存在该人员");
        //        }
        //        var dbdtemp = empoyeesNew.MAPTO<Doc_TrainEmpoyees>();
        //        _rpsdtemp.Add(dbdtemp);
        //        _work.Commit();
        //        return new ActionResult<bool>(true);
        //    }
        //    catch (Exception ex)
        //    {
        //        return new ActionResult<bool>(ex);
        //    }
        //}
        /// <summary>
        /// 新建训练模型
        /// </summary>
        /// <param name="trainingNew"></param>
        /// <returns></returns>
        public ActionResult <bool> AddTraining(DocTrainingNew trainingNew)
        {
            try
            {
                if (trainingNew == null)
                {
                    throw new Exception("参数有误");
                }
                var check = _rpsdt.Any(p => p.Motif == trainingNew.Motif);
                if (check)
                {
                    throw new Exception("该训练项已存在");
                }
                var dbdt = trainingNew.MAPTO <Doc_Training>();
                //电子文档
                var files = new AttachFileSave
                {
                    BusinessID = dbdt.ID,
                    files      = from f in trainingNew.AttachFiles
                                 select new AttachFileNew
                    {
                        FileTitle = f.FileTitle,
                        FileType  = f.FileType,
                        FileUrl   = f.FileUrl
                    }
                };

                var fileresult = srvFile.SaveFiles(files);
                if (fileresult.state != 200)
                {
                    throw new Exception(fileresult.msg);
                }
                //添加培训人员
                List <Doc_TrainEmpoyees> emps = (from empid in trainingNew.EmployeeIDs
                                                 select new Doc_TrainEmpoyees
                {
                    EmployeeID = empid,
                    TrainID = dbdt.ID
                }).ToList();

                _rpsdtemp.Add(emps);
                _rpsdt.Add(dbdt);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 新建设备设施模型
        /// </summary>
        /// <param name="facility"></param>
        /// <returns></returns>
        public ActionResult <bool> AddFacility(FacilityNew facility)
        {
            try
            {
                if (facility == null)
                {
                    throw new Exception("参数错误");
                }
                var check = _rpsfacilities.Any(p => p.SortID == facility.SortID && p.Name == facility.Name);
                if (check)
                {
                    throw new Exception("该设备设施已存在");
                }
                var dbfacility = facility.MAPTO <Basic_Facilities>();

                var definedvalue = new UserDefinedBusinessValue
                {
                    BusinessID = dbfacility.ID,
                    Values     = facility.UserDefineds
                };
                var defined = usedefinedService.SaveBuisnessValue(definedvalue);
                if (defined.state != 200)
                {
                    throw new Exception(defined.msg);
                }
                //文件
                var files = new AttachFileSave
                {
                    BusinessID = dbfacility.ID,
                    files      = facility.fileNews
                };
                var file = srvFile.SaveFiles(files);
                if (file.state != 200)
                {
                    throw new Exception(file.msg);
                }
                _rpsfacilities.Add(dbfacility);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 修改设备设施
        /// </summary>
        /// <param name="facility"></param>
        /// <returns></returns>
        public ActionResult <bool> EditFacility(FacilityEdit facility)
        {
            try
            {
                var dbfacility = _rpsfacilities.GetModel(p => p.ID == facility.ID);
                if (dbfacility == null)
                {
                    throw new Exception("未找到所需修改的设备设施项");
                }
                var _dbfacility = facility.CopyTo <Basic_Facilities>(dbfacility);
                //自定义项
                usedefinedService.DeleteBusinessValue(_dbfacility.ID);
                var definedvalue = new UserDefinedBusinessValue
                {
                    BusinessID = _dbfacility.ID,
                    Values     = facility.UserDefineds
                };
                var defined = usedefinedService.SaveBuisnessValue(definedvalue);
                if (defined.state != 200)
                {
                    throw new Exception(defined.msg);
                }
                //文件
                srvFile.DelFileByBusinessId(_dbfacility.ID);
                var files = new AttachFileSave
                {
                    BusinessID = _dbfacility.ID,
                    files      = facility.fileNews
                };
                var file = srvFile.SaveFiles(files);
                if (file.state != 200)
                {
                    throw new Exception(file.msg);
                }

                _rpsfacilities.Update(_dbfacility);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 修改资质模型
        /// </summary>
        /// <param name="certificateEdit"></param>
        /// <returns></returns>
        public ActionResult <bool> EditDocCertificate(DocCertificateEdit certificateEdit)
        {
            try
            {
                var dbdc = _rpsdc.GetModel(certificateEdit.ID);
                if (dbdc == null)
                {
                    throw new Exception("未找到所需修改的资质模型");
                }
                var check = _rpsdc.Any(p => p.ID != certificateEdit.ID && p.Name == certificateEdit.Name && p.TypeID == certificateEdit.TypeID && p.Owner == certificateEdit.Owner);
                if (check)
                {
                    throw new Exception("该资质类型下已存在该资质");
                }
                dbdc = certificateEdit.CopyTo <Doc_Certificate>(dbdc);

                //电子文档
                srvFile.DelFileByBusinessId(dbdc.ID);
                var files = new AttachFileSave
                {
                    BusinessID = dbdc.ID,
                    files      = from f in certificateEdit.AttachFiles
                                 select new AttachFileNew
                    {
                        FileTitle = f.FileTitle,
                        FileType  = f.FileType,
                        FileUrl   = f.FileUrl
                    }
                };

                var fre = srvFile.SaveFiles(files);
                if (fre.state != 200)
                {
                    throw new Exception(fre.msg);
                }
                _rpsdc.Update(dbdc);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 新建资质模型
        /// </summary>
        /// <param name="certificateNew"></param>
        /// <returns></returns>
        public ActionResult <bool> AddDocCertificate(DocCertificateNew certificateNew)
        {
            try
            {
                if (certificateNew == null)
                {
                    throw new Exception("参数有误");
                }
                var check = _rpsdc.Any(p => p.Name == certificateNew.Name && p.TypeID == certificateNew.TypeID && p.Owner == certificateNew.Owner);
                if (check)
                {
                    throw new Exception("该资质类型下已存在该资质");
                }
                var dbdc = certificateNew.MAPTO <Doc_Certificate>();
                //电子文档
                var files = new AttachFileSave
                {
                    BusinessID = dbdc.ID,
                    files      = from f in certificateNew.AttachFiles
                                 select new AttachFileNew
                    {
                        FileTitle = f.FileTitle,
                        FileType  = f.FileType,
                        FileUrl   = f.FileUrl
                    }
                };

                var fre = srvFile.SaveFiles(files);
                if (fre.state != 200)
                {
                    throw new Exception(fre.msg);
                }
                _rpsdc.Add(dbdc);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 修改风险点
        /// </summary>
        /// <param name="pointEdit"></param>
        /// <returns></returns>
        public ActionResult <bool> EditDangerPoint(DangerPointEdit pointEdit)
        {
            try
            {
                var dbdp = rpsdp.GetModel(pointEdit.ID);
                if (dbdp == null)
                {
                    throw new Exception("未找到所需修改的风险点!");
                }
                if (pointEdit.DangerLevel == Guid.Empty)
                {
                    throw new Exception("请选择风险等级!");
                }
                if (pointEdit.WXYSDictIDs.Count() == 0)
                {
                    throw new Exception("请选择危险因素!");
                }
                if (pointEdit.OrgID == Guid.Empty)
                {
                    throw new Exception("请选责任部门!");
                }
                if (pointEdit.Principal == Guid.Empty)
                {
                    throw new Exception("请选责任人!");
                }
                var check = rpsdp.Any(p => p.Name == pointEdit.Name && p.ID != pointEdit.ID);
                if (check)
                {
                    throw new Exception("该风险点名已存在!");
                }
                //风险点图片
                if (!string.Equals(pointEdit.DangerPointImg, dbdp.DangerPointImg))
                {
                    var dPointImg = HttpContext.Current.Server.MapPath(dbdp.DangerPointImg);
                    if (File.Exists(dPointImg))
                    {
                        File.Delete(dPointImg);
                    }
                }
                //删除警示牌
                foreach (var item in JsonConvert.DeserializeObject <IEnumerable <string> >(dbdp.WarningSign))
                {
                    if (!pointEdit.WarningSigns.Contains(item))
                    {
                        var dPointImg = HttpContext.Current.Server.MapPath(item);
                        if (File.Exists(dPointImg))
                        {
                            File.Delete(dPointImg);
                        }
                    }
                }

                dbdp = pointEdit.CopyTo <Basic_DangerPoint>(dbdp);

                dbdp.WXYSJson    = JsonConvert.SerializeObject(pointEdit.WXYSDictIDs);
                dbdp.WarningSign = JsonConvert.SerializeObject(pointEdit.WarningSigns);
                //文件
                srvFile.DelFileByBusinessId(pointEdit.ID);
                var files = new AttachFileSave
                {
                    BusinessID = dbdp.ID,
                    files      = pointEdit.fileNews
                };
                var file = srvFile.SaveFiles(files);
                if (file.state != 200)
                {
                    throw new Exception(file.msg);
                }
                rpsdp.Update(dbdp);
                work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }