Example #1
0
        private UserPostAbilityExam GetExam(int examId, int reId, int userId)
        {
            var exampaperDB   = new RetechWing.Exam.DataAgent.ExampaperDb();
            var examinationDB = new RetechWing.Exam.DataAgent.ExaminationDb();
            var exam          = exampaperDB.GetSingleById <tbExampaperRedundancy>(examId);
            var examuser      = examinationDB.GetExamSendStudentWithByRelationIdAndUserIdAndExampaperId(reId, 2, examId, userId);

            var result = new UserPostAbilityExam();

            if (examuser == null)
            {
                //没参加考试
                result.ExamCount  = -1;
                result.ExamStatus = "未参加";
                result.GetScore   = -1;
                result.IsPassed   = "--";
            }
            else
            {
                result.ExamCount  = examuser.TestTimes;
                result.ExamStatus = "已参加";
                result.GetScore   = examuser.Score;
                result.IsPassed   = examuser.IsPass == 0 ? "未通过" : "已通过";
            }
            result.ExanName       = exam.ExampaperTitle;
            result.AllowCount     = 100;
            result.ExamTimeLength = 100;
            //result.PassScore=exam.ExampaperScore*
            result.TotalScore = exam.ExampaperScore;
            return(result);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="applyId"></param>
        /// <returns></returns>
        public List <PromotionStageUserStatus> GetPromotionUserDetail(int applyId)
        {
            var list  = new List <PromotionStageUserStatus>();
            var apply = _dataAccess.Get <PromotionApply>(applyId);

            if (apply.ApproveStatus == 3)
            {
                return(list);
            }

            var stage = _dataAccess.Get <PromotionStage>(apply.CurrentStageId);

            if (apply.ApproveStatus == 0 || apply.ApproveStatus == 1)
            {
                var model = new PromotionStageUserStatus()
                {
                    ApproveStatus = apply.ApproveStatus,
                    PostName      = stage.PostName,
                    StageDesc     = stage.Description,
                    Reason        = apply.Reason,
                    OrderNum      = 0
                };
                list.Add(model);
                return(list);
            }
            list =
                _dataAccess.FetchListBySql <PromotionStageUserStatus>(@"SELECT pslr.RecordId,pst.PromotionId,pst.StageId,pst.ExamId,p.PostId,p.PostName,pslr.EndTime  PromotionSuccessTime,pst.Description StageDesc,pst.OrderNum,pst.Period,pslr.StartTime
FROM Ab_PromotionStageLenRecord pslr
JOIN Ab_PromotionStage pst ON pst.StageId = pslr.Stageid
JOIN Sys_Posts p ON p.PostId = pst.PostId
WHERE ApplyId=" + applyId).ToList();
            foreach (var way in list)
            {
                if (way.PromotionSuccessTime.HasValue)
                {
                    way.ApproveStatus = 4;
                }
                else
                {
                    if (way.Period == 0)
                    {
                        way.ApproveStatus = 2;
                    }
                    else
                    {
                        if (way.StartTime.AddDays(way.Period) > DateTime.Now)
                        {
                            way.ApproveStatus = 2;
                        }
                        else
                        {
                            way.ApproveStatus = 3;
                        }
                    }
                }
                if (way.ApproveStatus == 2)
                {
                    int completeCount = (int)_dataAccess.ExecuteScalar(string.Format(@"select count(0) from Len_LearningRecord
where LearnProcess = 2 and LearnPath = 3 
and SourceId in (select RecordId from Ab_LearningRecord where StageId = {0} and ApplyId in (select ApplyId from Ab_PromotionApply where UserId = {1} and PromotionId = {2} and ApproveStatus = 2 and IsDelete = 0))
and UserId = {1}", way.StageId, apply.UserId, apply.PromotionId));
                    int allCount      = (int)_dataAccess.ExecuteScalar(string.Format(@"select count(0) from Ab_AbilityResource
where Ab_AbilityResource.IsDelete = 0 and Ab_AbilityResource.ResourceType = 0 
and Ab_AbilityResource.AbilityId in (
	select AbilityId from Ab_PostAbility where IsDelete = 0 and PostId = {0}
)", way.PostId));
                    if (stage.ExamId > 0)
                    {
                        allCount++;
                        var examuser = new RetechWing.Exam.DataAgent.ExaminationDb().GetExamSendStudentWithByRelationIdAndUserId(way.StageId, 2, apply.UserId).FirstOrDefault();
                        if (examuser != null && examuser.ExamPaperID == stage.ExamId && examuser.IsPass == 1)
                        {
                            completeCount++;
                        }
                    }
                    way.PromotionProcess = allCount == 0 ? 0 : completeCount * 100 / allCount;
                }
                else if (way.ApproveStatus == 3)
                {
                    way.CourseName = _dataAccess.FetchListBySql <string>(string.Format(@"select CourseName from Res_Course
where CourseId in (
	select ResourceId from Ab_AbilityResource
	where Ab_AbilityResource.IsDelete = 0 and Ab_AbilityResource.ResourceType = 0 
	and Ab_AbilityResource.AbilityId in (
		select AbilityId from Ab_PostAbility where IsDelete = 0 and PostId = {0}
	)
)
and CourseId not in (
	select CourseId from Len_LearningRecord
	where LearnProcess = 2 and LearnPath = 3 
	and SourceId in (select RecordId from Ab_LearningRecord where StageId = {1} and ApplyId = {4})
	and UserId = {2} and EndTime <= '{3}'
)", way.PostId
                                                                                       , way.StageId
                                                                                       , apply.UserId
                                                                                       , way.StartTime.AddDays(way.Period).ToString("yyyy-MM-dd HH:mm:ss")
                                                                                       , applyId)).ToList();
                    if (way.ExamId > 0)
                    {
                        var examuser =
                            new RetechWing.Exam.DataAgent.ExaminationDb().GetExamSendStudentWithByRelationIdAndUserId(
                                way.RecordId, 2, apply.UserId).FirstOrDefault();
                        if (!(examuser != null && examuser.ExamPaperID == stage.ExamId && examuser.IsPass == 1))
                        {
                            var paper = new RetechWing.Exam.DataAgent.ExampaperDb().GetSingleById <tbExampaperRedundancy>(stage.ExamId);
                            if (paper != null)
                            {
                                way.ExamName = paper.ExampaperTitle;
                            }
                        }
                    }
                }
            }
            if (list.Count == 0 || apply.CurrentStageId != list.OrderByDescending(p => p.OrderNum).First().StageId)
            {
                list.Add(new PromotionStageUserStatus()
                {
                    PostName         = stage.PostName,
                    ApproveStatus    = 2,
                    PromotionProcess = 0,
                    StageDesc        = stage.Description
                });
            }

            return(list);
        }