Exemplo n.º 1
0
 /// <summary>
 /// 新建风险点配置
 /// </summary>
 /// <param name="dangerRelation"></param>
 /// <returns></returns>
 public ActionResult<bool> AddDangerRelation(DangerRelationNew dangerRelation)
 {
     try
     {
         if (dangerRelation.DangerID.Count()==0)
         {
             throw new Exception("参数有误");
         }
         var check = _rpsdangerrelation.Any(p=>p.SubjectID==dangerRelation.SubjectID&&dangerRelation.DangerID.Contains(p.DangerID));
         if (check)
         {
             throw new Exception("已存在该风险点配置");
         }
         var dbdangerrelation = from d in dangerRelation.DangerID
                                select new Basic_DangerRelation
                                {
                                    ID=Guid.NewGuid(),
                                    DangerID=d,
                                    SubjectID=dangerRelation.SubjectID
                                };
         _rpsdangerrelation.Add(dbdangerrelation);
         _work.Commit();
         return new ActionResult<bool>(true);
     }
     catch (Exception ex)
     {
         return new ActionResult<bool>(ex);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 新建设备设施类别
        /// </summary>
        /// <param name="facilitiesSort"></param>
        /// <returns></returns>
        public ActionResult <bool> AddFacilitiesSort(FacilitiesSortNew facilitiesSort)
        {
            try
            {
                if (facilitiesSort == null)
                {
                    throw new Exception("参数有误");
                }
                var check = _rpsfacilitiessort.Any(p => p.ParentID == facilitiesSort.ParentID && p.SortName == facilitiesSort.SortName);
                if (check)
                {
                    throw new Exception("该设备设施类别已存在!");
                }
                var dbfacilitiessort = facilitiesSort.MAPTO <Basic_FacilitiesSort>();
                var parent           = _rpsfacilitiessort.GetModel(facilitiesSort.ParentID);


                //根据上级设置Level
                dbfacilitiessort.Level = parent == null ? 1 : parent.Level + 1;
                _rpsfacilitiessort.Add(dbfacilitiessort);
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 新建视频监控
 /// </summary>
 /// <param name="videoNew"></param>
 /// <returns></returns>
 public ActionResult <bool> AddVideo(VideoNew videoNew)
 {
     try
     {
         if (videoNew == null)
         {
             throw new Exception("参数类型错误");
         }
         var check = _rpsv.Any(p => p.Code == videoNew.Code);
         if (check)
         {
             throw new Exception("该摄像头已存在");
         }
         var dbv  = videoNew.MAPTO <Basic_Vedio>();
         var lsvs = (from vs in videoNew.Subjects
                     select new Basic_VedioSubject
         {
             ID = Guid.NewGuid(),
             SubjectID = vs.SubjectID,
             SubjectType = vs.SubjectType,
             VedioID = dbv.ID
         }).ToList();
         _rpsv.Add(dbv);
         _rpsvs.Add(lsvs);
         _work.Commit();
         return(new ActionResult <bool>(true));
     }
     catch (Exception ex)
     {
         return(new ActionResult <bool>(ex));
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 添加安全标准
 /// </summary>
 /// <param name="safetystandard"></param>
 /// <returns></returns>
 public ActionResult <bool> AddSafetyStandard(SafetyStandardNew safetystandard)
 {
     try
     {
         if (safetystandard == null)
         {
             throw new Exception("参数有误");
         }
         if (safetystandard.DangerSortID == Guid.Empty)
         {
             throw new Exception("请选择则风控项类别!");
         }
         var check = _rpssafetystandard.Any(p => p.DangerSortID == safetystandard.DangerSortID && p.Code == safetystandard.Code);
         if (check)
         {
             throw new Exception("该风险点下已存在该编号的风险安全标准");
         }
         var dbsafetystandard = safetystandard.MAPTO <Basic_SafetyStandard>();
         _rpssafetystandard.Add(dbsafetystandard);
         _work.Commit();
         return(new ActionResult <bool>(true));
     }
     catch (Exception ex)
     {
         return(new ActionResult <bool>(ex));
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 新建作业模型
        /// </summary>
        /// <param name="opreation"></param>
        /// <returns></returns>
        public ActionResult <bool> AddOpreation(OpreationNew opreation)
        {
            try
            {
                if (opreation == null)
                {
                    throw new Exception("参数有误");
                }
                var check = _rpsopreation.Any(q => q.Name == opreation.Name);
                if (check)
                {
                    throw new Exception("已经存在相同的操作 :" + opreation.Name);
                }
                var _opreation   = opreation.MAPTO <Basic_Opreation>();
                var definedvalue = new UserDefinedBusinessValue
                {
                    BusinessID = _opreation.ID,
                    Values     = opreation.UserDefineds
                };
                var defined = usedefinedService.SaveBuisnessValue(definedvalue);
                if (defined.state != 200)
                {
                    throw new Exception(defined.msg);
                }
                _rpsopreation.Add(_opreation);

                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// 新建安全制度模型
 /// </summary>
 /// <param name="institutionNew"></param>
 /// <returns></returns>
 public ActionResult <bool> AddDocInstitution(DocInstitutionNew institutionNew)
 {
     try
     {
         if (institutionNew == null)
         {
             throw new Exception("参数有误");
         }
         var check = _rpsin.Any(p => p.Name == institutionNew.Name && p.TypeID == institutionNew.TypeID);
         if (check)
         {
             throw new Exception("该类型下已存在该安全制度模型");
         }
         var dbin = institutionNew.MAPTO <Doc_Institution>();
         //自定义项
         var definedvalue = new UserDefinedBusinessValue
         {
             BusinessID = dbin.ID,
             Values     = institutionNew.UserDefineds
         };
         var defined = srvUserDefined.SaveBuisnessValue(definedvalue);
         if (defined.state != 200)
         {
             throw new Exception(defined.msg);
         }
         _rpsin.Add(dbin);
         _work.Commit();
         return(new ActionResult <bool>(true));
     }
     catch (Exception ex)
     {
         return(new ActionResult <bool>(ex));
     }
 }
Exemplo n.º 7
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));
            }
        }
Exemplo n.º 8
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));
            }
        }
Exemplo n.º 9
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));
            }
        }
Exemplo 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));
            }
        }
Exemplo n.º 11
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));
            }
        }
Exemplo n.º 12
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));
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// 微信解绑
        /// </summary>
        /// <param name="openid"></param>
        /// <returns></returns>
        public override ActionResult <bool> UserWxUnBind(string openid)
        {
            var rpsbinds = _work.Repository <Core.Model.DB.Platform.Auth_WxBinds>();
            var wxbind   = rpsbinds.GetModel(q => q.openID == openid);

            if (wxbind == null)
            {
                throw new Exception("该用户尚未绑定微信");
            }
            var rpsact = _work.Repository <AccountInfo>();

            var act = rpsact.GetModel(q => q.AccountCode == wxbind.AccountCode);

            if (act == null)
            {
                throw new Exception("账套数据有误");
            }
            if (act.State == (int)PublicEnum.AccountState.Closed || act.ValidDate <= DateTime.Now)
            {
                throw new Exception("账套已经过期或已关闭");
            }
            //rpsbinds.Delete(wxbind);
            //_work.Commit();

            Core.Model.AppUserDB userdb = new AppUserDB()
            {
                DBName   = act.DBName,
                DBPwd    = act.DBPwd,
                DBServer = act.DBServer,
                DBUid    = act.DBUid
            };
            Unitwork.SetUserDB(userdb);

            var rpsuser = _work.Repository <Core.Model.DB.Auth_User>();
            var user    = rpsuser.GetModel(q => q.openID == openid);

            if (user == null)
            {
                throw new Exception("用户未绑定微信");
            }
            user.openID = "";
            rpsuser.Update(user);
            _work.Commit();

            return(base.UserWxUnBind(openid));
        }
Exemplo n.º 14
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));
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// 新建风险信息
 /// </summary>
 /// <param name="danger"></param>
 /// <returns></returns>
 public ActionResult <bool> AddDanger(DangerNew danger)
 {
     try
     {
         if (danger == null)
         {
             throw new Exception("参数有误");
         }
         var DangerNames = danger.Dangers.Select(s => s.Name);
         var DangerCodes = danger.Dangers.Select(s => s.Code);
         var check       = _rpsdanger.Any(p => p.DangerSortID == danger.DangerSortID && (DangerNames.Contains(p.Name) || DangerCodes.Contains(p.Code)));
         if (check)
         {
             throw new Exception("集合中已存在配置的项!");
         }
         var _danger = from d in danger.Dangers
                       select new Basic_Danger
         {
             Code         = d.Code,
             DangerLevel  = d.DangerLevel,
             DangerSortID = danger.DangerSortID,
             Name         = d.Name
         };
         _rpsdanger.Add(_danger);
         _work.Commit();
         return(new ActionResult <bool>(true));
     }
     catch (Exception ex)
     {
         return(new ActionResult <bool>(ex));
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// 新建紧急预案模型
 /// </summary>
 /// <param name="solutionNew"></param>
 /// <returns></returns>
 public ActionResult <bool> AddDocSolution(DocSolutionNew solutionNew)
 {
     try
     {
         if (solutionNew == null)
         {
             throw new Exception("参数有误");
         }
         var check = _rpsds.Any(p => p.Name == solutionNew.Name && p.TypeID == solutionNew.TypeID);
         if (check)
         {
             throw new Exception("该类型下已存在该紧急预案");
         }
         var dbds = solutionNew.MAPTO <Doc_Solution>();
         _rpsds.Add(dbds);
         _work.Commit();
         return(new ActionResult <bool>(true));
     }
     catch (Exception ex)
     {
         return(new ActionResult <bool>(ex));
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult <bool> DelFile(Guid id)
        {
            try
            {
                var file = rpsFile.GetModel(id);
                if (file == null)
                {
                    throw new Exception("文件不存在");
                }
                rpsFile.Delete(q => q.ID == id);

                var filepath = HttpContext.Current.Server.MapPath(file.FileUrl);
                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                _work.Commit();
                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// 新建作业申请单
        /// </summary>
        /// <param name="bill"></param>
        /// <returns></returns>
        public ActionResult <bool> AddNew(OperateBillNew bill)
        {
            try
            {
                var opreationmodel = _work.Repository <Core.Model.DB.Account.Basic_Opreation>().GetModel(bill.OpreationID);
                if (opreationmodel == null)
                {
                    throw new Exception("作业流程未找到");
                }

                var flows = _work.Repository <Core.Model.DB.Account.Basic_OpreationFlow>().Queryable(q => q.OpreationID == opreationmodel.ID).OrderBy(o => o.PointIndex).ToList();
                if (flows.Count() == 0)
                {
                    throw new Exception("该作业流程未配置流程节点,请配置!");
                }
                if (bill.PrincipalEmployeeID == Guid.Empty)
                {
                    throw new Exception("请选择作业流程负责人!");
                }
                var billdb = bill.MAPTO <Core.Model.DB.Account.Bll_OpreationBill>();
                billdb.BillCode      = Command.CreateCode();
                billdb.FlowsJson     = JsonConvert.SerializeObject(flows);
                billdb.OpreationJSON = JsonConvert.SerializeObject(opreationmodel);
                billdb.State         = (int)PublicEnum.BillFlowState.normal;
                billdb.CreateMan     = AppUser.EmployeeInfo.CNName;

                _work.Repository <Core.Model.DB.Account.Bll_OpreationBill>().Add(billdb);
                _work.Commit();

                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }