private decimal CalculateScore(IEnumerable <decimal> scores, ReviewMethodSetting setting) { var score = scores.Average(); //仅当去掉最高最低分且打分数大于2 if (setting.CutOff && scores.Count() > 2) { var max = scores.Max(); var min = scores.Min(); score = (scores.Sum() - max - min) / (scores.Count() - 2); } return(score); }
/// <summary> /// 添加评审活动,并建立第一轮第一次评审 /// </summary> /// <param name="review"></param> /// <param name="reviewdetail"></param> /// <param name="reviewmethodsetting"></param> /// <param name="isPublish"></param> public static void AddReview(Review review, ReviewDetail reviewdetail, ReviewMethodSetting reviewmethodsetting, bool isPublish = false) { using (var trans = Config.Helper.UseTransaction()) { try { if (isPublish) { review.ReviewStatus = ReviewStatus.Reviewing; reviewdetail.ReviewStatus = ReviewStatus.Reviewing; review.StartTime = DateTime.Now; } else { review.ReviewStatus = ReviewStatus.BeforePublish; } Config.Helper.Save(review); reviewdetail.ReviewID = review.ID; reviewdetail.ReviewMethodSetting = reviewmethodsetting; if (reviewdetail.Round == 0) { reviewdetail.Round = 1; } if (reviewdetail.Turn == 0) { reviewdetail.Turn = 1; } if (reviewdetail.SourceProjectIDs.IsNullOrEmpty()) { reviewdetail.SourceProjectIDs = review.Award.Projects.Select(o => o.ID).Join(","); } Config.Helper.Save(reviewdetail); } catch (Exception ex) { trans.Abort(); throw new Exception(ex.Message); } } }
/// <summary> /// 修改评审轮次 /// </summary> /// <param name="reviewdetail"></param> /// <param name="reviewmethodsetting"></param> /// <param name="isPublish"></param> public static void EditDetail(ReviewDetail reviewdetail, ReviewMethodSetting reviewmethodsetting, bool isPublish = false) { using (var trans = Config.Helper.UseTransaction()) { try { var review = Config.Helper.SingleById <Review>(reviewdetail.ReviewID); if (isPublish) { review.ReviewStatus = ReviewStatus.Reviewing; reviewdetail.ReviewStatus = ReviewStatus.Reviewing; review.StartTime = DateTime.Now; } Config.Helper.Save(review); reviewdetail.ReviewMethodSetting = reviewmethodsetting; Config.Helper.Save(reviewdetail); } catch (Exception ex) { trans.Abort(); throw new Exception(ex.Message); } } }