/// <summary> /// 作者:Vincen /// 时间:2014.04.14 /// 描述:创建课程点评(学员对教师) /// </summary> /// <param name="arrangeCourseId"></param> /// <param name="studentId"></param> /// <param name="teacherId"></param> /// <param name="totalScore"></param> /// <param name="itemsInfo"></param> /// <param name="comments"></param> /// <param name="batchNo"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static string CreateCourseRateByStudentUserId(int arrangeCourseId, int userId, float totalScore, string itemsInfo, string comments, Guid batchNo, int loginUserId) { var edb = new EmeEntities(); try { var queryTeacherItem = (from q in edb.TeachRecord where q.ArrangeCourseId == arrangeCourseId && q.Status == ConvertEnum.StatusTypeForActive select new { q.TeacherId }).FirstOrDefault(); var queryStudentItem = (from q in edb.Student where q.UserId == userId && q.Status == ConvertEnum.StatusTypeForActive select new { studentId = q.Id }).FirstOrDefault(); if (null == queryTeacherItem) { return "000001"; } if (queryStudentItem == null) { return "000002"; } var queryCorseRateItem = (from q in edb.CourseRate where q.ArrangeCourseId == arrangeCourseId && q.Status == ConvertEnum.StatusTypeForActive && q.StudentId == queryStudentItem.studentId && q.TeacherId == queryTeacherItem.TeacherId select q).FirstOrDefault(); if (null != queryCorseRateItem) { queryCorseRateItem.StudentId = queryStudentItem.studentId; queryCorseRateItem.StudentIsRate = true; queryCorseRateItem.StudentRateScore = totalScore; queryCorseRateItem.StudentRateBatchNo = batchNo; queryCorseRateItem.StudentRateTime = DateTime.Now; if (comments != null) { queryCorseRateItem.Remark = comments; } edb.Entry(queryCorseRateItem).State = EntityState.Modified; } else { var model = new CourseRate() { ArrangeCourseId = arrangeCourseId, StudentId = queryStudentItem.studentId, StudentIsRate = true, StudentRateBatchNo = batchNo, StudentRateScore = totalScore, StudentRateTime = DateTime.Now, TeacherId = queryTeacherItem.TeacherId, TeacherIsRate = false, Status = ConvertEnum.StatusTypeForActive, CreateTime = DateTime.Now, Remark = comments }; edb.Entry(model).State = EntityState.Added; } //Step2. 新增点评日志信息 foreach (var item in itemsInfo.Trim().Trim(',').Split(',')) { var rateId = item.Split('|')[0]; var rateScore = item.Split('|')[1]; var rate = new RateDetail() { BatchNO = batchNo, RateId = CommonHelper.To<int>(rateId), Score = CommonHelper.To<float>(rateScore), Status = ConvertEnum.StatusTypeForActive, Comment = comments, CreateTime = DateTime.Now }; edb.Entry(rate).State = EntityState.Added; } var result = edb.SaveChanges() > 0 ? "000000" : "000003"; return result; } catch (Exception e) { //// 异常日志消息队列 //Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() //{ // ExceptionType = CommonHelper.To<int>(ExceptionType.Function), // Message = string.Format("RateBLL-CreateCourseRateByStudentId:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), // IsTreat = false, // CreateBy = loginUserId, // CreateTime = DateTime.Now //}); throw e; } }
/// <summary> /// 作者:Vincen /// 时间:2014.04.14 /// 描述:创建课程点评(学员对教师) /// </summary> /// <param name="arrangeCourseId"></param> /// <param name="studentId"></param> /// <param name="teacherId"></param> /// <param name="totalScore"></param> /// <param name="itemsInfo"></param> /// <param name="comments"></param> /// <param name="batchNo"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool CreateCourseRateByStudentId(int arrangeCourseId, int studentId, int teacherId, float totalScore, string itemsInfo, string comments, Guid batchNo, int loginUserId) { using (var edb = new EmeEntities()) { try { // Step1.课程点评信息 var crate = edb.CourseRate.FirstOrDefault(p => p.ArrangeCourseId == arrangeCourseId && p.StudentId == studentId && p.TeacherId == teacherId && p.Status == ConvertEnum.StatusTypeForActive); if (null != crate) { crate.StudentId = studentId; crate.StudentIsRate = true; crate.StudentRateScore = totalScore; crate.StudentRateBatchNo = batchNo; crate.StudentRateTime = DateTime.Now; if (comments != null) { crate.Remark = comments; } edb.Entry(crate).State = EntityState.Modified; } else { var model = new CourseRate() { ArrangeCourseId = arrangeCourseId, StudentId = studentId, StudentIsRate = true, StudentRateBatchNo = batchNo, StudentRateScore = totalScore, StudentRateTime = DateTime.Now, TeacherId = teacherId, TeacherIsRate = false, Status = ConvertEnum.StatusTypeForActive, CreateTime = DateTime.Now, Remark = comments }; edb.Entry(model).State = EntityState.Added; } //Step2. 新增点评日志信息 foreach (var item in itemsInfo.Trim().Trim(',').Split(',')) { var rateId = item.Split('|')[0]; var rateScore = item.Split('|')[1]; var rate = new RateDetail() { BatchNO = batchNo, RateId = CommonHelper.To<int>(rateId), Score = CommonHelper.To<float>(rateScore), Status = ConvertEnum.StatusTypeForActive, Comment = comments, CreateTime = DateTime.Now }; edb.Entry(rate).State = EntityState.Added; } var result = edb.SaveChanges() > 0; return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("RateBLL-CreateCourseRateByStudentId:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:beta /// 时间:2015.08.19 /// 描述:更新评分信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool UpdateCousreRate(CourseRate model) { using (var edb = new EmeEntities()) { var courseRate = edb.CourseRate.FirstOrDefault(p => p.Id == model.Id); if (null == courseRate) return false; courseRate.TeacherRateInfo = model.TeacherRateInfo; courseRate.StudentRateInfo = model.StudentRateInfo; courseRate.Remark = model.Remark; courseRate.StudentRateScore = model.StudentRateScore; courseRate.TeacherRateScore = model.TeacherRateScore; courseRate.Status = model.Status; courseRate.UpdateBy = model.UpdateBy; courseRate.UpdateTime = DateTime.Now; edb.Entry(courseRate).State = EntityState.Modified; return edb.SaveChanges() > 0; } }