Example #1
0
        /// <summary>
        /// 获取HSE日志信息
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="userId"></param>
        /// <param name="diaryDate"></param>
        /// <returns></returns>
        public static Model.HSEDiaryItem getHSEDiary(string projectId, string userId, string diaryDate)
        {
            DateTime?getDiaryDate = Funs.GetNewDateTime(diaryDate);

            Model.HSEDiaryItem getItem = new Model.HSEDiaryItem();
            if (getDiaryDate.HasValue && !string.IsNullOrEmpty(projectId) && !string.IsNullOrEmpty(userId))
            {
                var getFlowOperteList = ReturnFlowOperteList(projectId, userId, getDiaryDate.Value);
                getItem.ProjectId  = projectId;
                getItem.UserId     = userId;
                getItem.UserName   = UserService.GetUserNameByUserId(userId);
                getItem.DiaryDate  = diaryDate;
                getItem.HSEDiaryId = SQLHelper.GetNewID();
                getItem.Value1     = getValues1(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value2     = getValues2(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value3     = getValues3(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value4     = getValues4(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value5     = getValues5(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value6     = getValues6(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value7     = getValues7(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value8     = getValues8(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value9     = getValues9(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                getItem.Value10    = getValues10(getFlowOperteList, projectId, userId, getDiaryDate.Value);
                var getInfo = Funs.DB.Project_HSEDiary.FirstOrDefault(x => x.UserId == userId && x.DiaryDate == getDiaryDate);
                if (getInfo != null)
                {
                    getItem.HSEDiaryId   = getInfo.HSEDiaryId;
                    getItem.DailySummary = getInfo.DailySummary;
                    getItem.TomorrowPlan = getInfo.TomorrowPlan;
                }
            }
            return(getItem);
        }
Example #2
0
        /// <summary>
        /// 保存Solution_ConstructSolution
        /// </summary>
        /// <param name="newItem">施工方案</param>
        /// <returns></returns>
        public static void SaveConstructSolution(Model.ConstructSolutionItem newItem)
        {
            Model.SUBHSSEDB db = Funs.DB;
            Model.Solution_ConstructSolution newConstructSolution = new Model.Solution_ConstructSolution
            {
                ConstructSolutionId   = newItem.ConstructSolutionId,
                ProjectId             = newItem.ProjectId,
                ConstructSolutionCode = newItem.ConstructSolutionCode,
                ConstructSolutionName = newItem.ConstructSolutionName,
                VersionNo             = newItem.VersionNo,
                UnitId          = newItem.UnitId,
                InvestigateType = newItem.InvestigateType,
                SolutinType     = newItem.SolutinTypeId,
                FileContents    = System.Web.HttpUtility.HtmlEncode(newItem.FileContents),
                CompileMan      = newItem.CompileManId,
                CompileManName  = UserService.GetUserNameByUserId(newItem.CompileManId),
                States          = Const.State_2,
            };
            if (newItem.States != "1")
            {
                newConstructSolution.States = Const.State_0;
            }

            var updateConstructSolution = Funs.DB.Solution_ConstructSolution.FirstOrDefault(x => x.ConstructSolutionId == newItem.ConstructSolutionId);

            if (updateConstructSolution == null)
            {
                newConstructSolution.CompileDate           = DateTime.Now;
                newConstructSolution.ConstructSolutionId   = SQLHelper.GetNewID();
                newConstructSolution.ConstructSolutionCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectConstructSolutionMenuId, newConstructSolution.ProjectId, newConstructSolution.UnitId);
                ConstructSolutionService.AddConstructSolution(newConstructSolution);
            }
            else
            {
                ConstructSolutionService.UpdateConstructSolution(newConstructSolution);
            }
            if (newConstructSolution.States == "1")
            {
                CommonService.btnSaveData(newConstructSolution.ProjectId, Const.ProjectConstructSolutionMenuId, newConstructSolution.ConstructSolutionId, newConstructSolution.CompileMan, true, newConstructSolution.CompileManName, "../Solution/ConstructSolutionView.aspx?ConstructSolutionId={0}");
            }
            if (!string.IsNullOrEmpty(newItem.AttachUrl))
            {
                ////保存附件
                UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(newItem.AttachUrl, 10, null), newItem.AttachUrl, Const.ProjectConstructSolutionMenuId, newConstructSolution.ConstructSolutionId);
            }
            else
            {
                CommonService.DeleteAttachFileById(newConstructSolution.ConstructSolutionId);
            }
        }
Example #3
0
        /// <summary>
        /// 获取用户下拉选项  项目 角色 且可审批
        /// </summary>
        /// <returns></returns>
        public static List <Model.SpSysUserItem> GetProjectRoleUserListByProjectId(string projectId, string unitId)
        {
            IQueryable <Model.SpSysUserItem> users = null;

            if (!string.IsNullOrEmpty(projectId))
            {
                List <Model.SpSysUserItem>       returUsers = new List <Model.SpSysUserItem>();
                List <Model.Project_ProjectUser> getPUser   = new List <Model.Project_ProjectUser>();
                if (!string.IsNullOrEmpty(unitId))
                {
                    getPUser = (from x in Funs.DB.Project_ProjectUser
                                join u in Funs.DB.Project_ProjectUnit on new { x.ProjectId, x.UnitId } equals new { u.ProjectId, u.UnitId }
                                where x.ProjectId == projectId && (u.UnitId == unitId || u.UnitType == BLL.Const.ProjectUnitType_1 || u.UnitType == BLL.Const.ProjectUnitType_3 || u.UnitType == BLL.Const.ProjectUnitType_4)
                                select x).ToList();
                }
                else
                {
                    getPUser = (from x in Funs.DB.Project_ProjectUser
                                where x.ProjectId == projectId
                                select x).ToList();
                }

                if (getPUser.Count() > 0)
                {
                    foreach (var item in getPUser)
                    {
                        List <string> roleIdList = Funs.GetStrListByStr(item.RoleId, ',');
                        var           getRoles   = Funs.DB.Sys_Role.FirstOrDefault(x => x.IsAuditFlow == true && roleIdList.Contains(x.RoleId));
                        if (getRoles != null)
                        {
                            string userName = RoleService.getRoleNamesRoleIds(item.RoleId) + "-" + UserService.GetUserNameByUserId(item.UserId);
                            Model.SpSysUserItem newsysUser = new Model.SpSysUserItem
                            {
                                UserId   = item.UserId,
                                UserName = userName,
                            };
                            returUsers.Add(newsysUser);
                        }
                    }
                }
                return(returUsers);
            }
            else
            {
                if (!string.IsNullOrEmpty(unitId))
                {
                    users = (from x in Funs.DB.Sys_User
                             join z in Funs.DB.Sys_Role on x.RoleId equals z.RoleId
                             where x.IsPost == true && z.IsAuditFlow == true && x.UnitId == unitId
                             orderby x.UserCode
                             select new Model.SpSysUserItem
                    {
                        UserName = z.RoleName + "- " + x.UserName,
                        UserId = x.UserId,
                    });
                }
                else
                {
                    users = (from x in Funs.DB.Sys_User
                             join z in Funs.DB.Sys_Role on x.RoleId equals z.RoleId
                             where x.IsPost == true && z.IsAuditFlow == true
                             orderby x.UserCode
                             select new Model.SpSysUserItem
                    {
                        UserName = z.RoleName + "- " + x.UserName,
                        UserId = x.UserId,
                    });
                }
            }
            return(users.ToList());
        }
Example #4
0
        /// <summary>
        /// 根据考生计划结束时 将相关培训考生内容 写培训记录归档
        /// </summary>
        /// <param name="getTestPlan"></param>

        public static void InsertTrainRecord(Model.Training_TestPlan getTestPlan)
        {
            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                ////获取培训计划
                var getTrainingPlan = db.Training_Plan.FirstOrDefault(e => e.PlanId == getTestPlan.PlanId);
                var getTrainRecord  = db.EduTrain_TrainRecord.FirstOrDefault(x => x.PlanId == getTestPlan.PlanId);
                if (getTrainingPlan != null && getTrainRecord == null)
                {
                    getTrainingPlan.States = "3";
                    db.SubmitChanges();

                    Model.EduTrain_TrainRecord newTrainRecord = new Model.EduTrain_TrainRecord
                    {
                        TrainingId     = SQLHelper.GetNewID(),
                        TrainingCode   = getTrainingPlan.PlanCode,
                        ProjectId      = getTrainingPlan.ProjectId,
                        TrainTitle     = getTrainingPlan.PlanName,
                        TrainContent   = getTrainingPlan.TrainContent,
                        TrainStartDate = getTrainingPlan.TrainStartDate,
                        TeachHour      = getTrainingPlan.TeachHour,
                        TrainEndDate   = getTrainingPlan.TrainEndDate,
                        TeachMan       = getTrainingPlan.TeachMan,
                        TeachAddress   = getTrainingPlan.TeachAddress,
                        Remark         = "来源:培训计划",
                        TrainTypeId    = getTrainingPlan.TrainTypeId,
                        TrainLevelId   = getTrainingPlan.TrainLevelId,
                        UnitIds        = getTrainingPlan.UnitIds,
                        States         = Const.State_2,
                        WorkPostIds    = getTrainingPlan.WorkPostId,
                        PlanId         = getTrainingPlan.PlanId,
                    };
                    newTrainRecord.CompileMan = UserService.GetUserNameByUserId(getTrainingPlan.DesignerId);
                    ///获取培训人员
                    var getTrainingTasks = from x in db.Training_Task where x.PlanId == getTrainingPlan.PlanId
                                           select x;
                    newTrainRecord.TrainPersonNum = getTrainingTasks.Count();
                    ///新增培训记录
                    db.EduTrain_TrainRecord.InsertOnSubmit(newTrainRecord);
                    db.SubmitChanges();

                    ////及格分数
                    int passScore = 80;
                    var testRule  = db.Sys_TestRule.FirstOrDefault();
                    if (testRule != null)
                    {
                        passScore = testRule.PassingScore;
                    }

                    foreach (var item in getTrainingTasks)
                    {
                        decimal gScores = 0;
                        bool    result  = false;
                        ////获取 考生试卷
                        var getTestRecord = db.Training_TestRecord.Where(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == item.UserId);
                        foreach (var itemR in getTestRecord)
                        {
                            if (itemR.TestScores > gScores)
                            {
                                gScores = itemR.TestScores ?? 0;
                            }
                        }

                        if (gScores >= passScore)
                        {
                            result = true;
                        }

                        Model.EduTrain_TrainRecordDetail newDetail = new Model.EduTrain_TrainRecordDetail
                        {
                            TrainDetailId = SQLHelper.GetNewID(),
                            TrainingId    = newTrainRecord.TrainingId,
                            PersonId      = item.UserId,
                            CheckScore    = gScores,
                            CheckResult   = result,
                        };
                        db.EduTrain_TrainRecordDetail.InsertOnSubmit(newDetail);
                        db.SubmitChanges();

                        ///// 培训考试 通过 更新卡号
                        if (result)
                        {
                            var getPerson = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == newDetail.PersonId);
                            if (getPerson != null && string.IsNullOrEmpty(getPerson.CardNo))
                            {
                                getPerson.CardNo = SQLHelper.RunProcNewId("SpGetNewNumber", "SitePerson_Person", "CardNo", getPerson.ProjectId, UnitService.GetUnitCodeByUnitId(getPerson.UnitId));
                                db.SubmitChanges();
                            }
                        }
                    }

                    ////增加一条编码记录
                    CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectTrainRecordMenuId, newTrainRecord.ProjectId, null, newTrainRecord.TrainingId, newTrainRecord.TrainStartDate);
                    CommonService.btnSaveData(newTrainRecord.ProjectId, Const.ProjectTrainRecordMenuId, newTrainRecord.TrainingId, getTrainingPlan.DesignerId, true, newTrainRecord.TrainTitle, "../EduTrain/TrainRecordView.aspx?TrainingId={0}");
                }
            }
        }