示例#1
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));
            }
        }
示例#2
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));
            }
        }
示例#3
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));
            }
        }
示例#4
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));
     }
 }
示例#5
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));
            }
        }
示例#6
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));
            }
        }
示例#7
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));
            }
        }
示例#8
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));
            }
        }