public ActionResult Score(ScoreRequire score) { string message; if (_scoreTaskService.Score(score, currentAccount, out message)) { return(StandardJson()); } else { return(StandardJson(message)); } }
public bool Score(ScoreRequire score, CustomerAccount currentAccount, out string message) { var scoreTask = this.GetByID(score.ScoreTaskID); if (scoreTask != null) { var fileResults = this._fileResultService.GetEffectiveRecords(scoreTask.ItemID, currentAccount.CustomerCompanyID); if (fileResults.Where(o => o.Status != FileStatus.Audit).Count() > 0) { message = "只有所有文件审核完毕才可评分"; return(false); } if (scoreTask.ScorePersonID != currentAccount.Id) { message = "只有评分人才可进行评分"; return(false); } using (var tran = this.BeginTransaction()) { try { var dt = DateTime.Now; StringBuilder sb = new StringBuilder(); scoreTask.Score = score.Score; scoreTask.ScoreTime = dt; this.Update(scoreTask); if (score.Score == ScoreLevel.PartiallyCompliant || score.Score == ScoreLevel.Substandard) { var fileResultIDs = score.Argument.Select(oi => oi.FileResultID).ToList(); var rejectFileResults = this._fileResultService.Query.Where(o => fileResultIDs.Contains(o.Id)); foreach (var item in rejectFileResults) { item.Status = FileStatus.Reject; this._fileResultService.Update(item); string cause = score.Argument.First(o => o.FileResultID == item.Id).Cause; this._fileOperationNoteService.Add(new FileOperationNote() { FileRequire = item.FileRequire, Operationer = currentAccount, Description = string.Format("评分:{0},原因:{1}", GetScoreLevelDescription(score.Score), cause), CreateTime = DateTime.Now }); sb.AppendLine(string.Format("{0}:{1}", item.FileRequire.SuggestFileName, cause)); var fileSchedule = _fileScheduleService.Query.Where(o => o.Id == item.FileRequireID).FirstOrDefault(); fileSchedule.FinishTime = null; this._fileScheduleService.Update(fileSchedule); } } this._scoreOperationNoteService.Add(new ScoreOperationNote() { ScoreTask = scoreTask, Operationer = currentAccount, Score = score.Score, Description = sb.ToString(), CreateTime = dt }); tran.Commit(); message = ""; return(true); } catch (Exception ex) { message = ex.Message; tran.Rollback(); return(false); } } } else { message = "该数据不存在"; } return(false); }