/// <summary> /// 作者:Ark /// 时间:2014.09.19 /// 描述:同步测评结果到Eme /// </summary> /// <returns></returns> public string SyncResults(string jsonData) { var result = new SyncExamResult { msg = "success" }; if (string.IsNullOrWhiteSpace(jsonData)) { result.code = 101; result.msg = "json data param empty"; } else { try { var resultList = JsonHelper.FromJson<List<ExamResult>>(jsonData); result = StudentBLL.CreateExamResult(resultList); } catch (Exception ex) { result.code = 103; result.msg = "json param format error"; } } return JsonHelper.ToJson(result); }
/// <summary> /// 作者:Ark /// 时间:2014-09-17 /// 描述:更新User同步状态为true(测评) /// </summary> /// <param name="userNameList">登录名列表</param> /// <returns>同步成功的测评号返回给测评</returns> public static SyncExamResult CreateExamResult(List<ExamResult> examResultList) { // 同步成功的测评号返回给测评 var result = new SyncExamResult { msg = "success", results = new List<string>() }; using (var edb = new EmeEntities()) { foreach (var examResult in examResultList) { try { // 转字符 examResult.ErrMsg1 = examResult.ErrMsg1.FromUtf8(); examResult.ErrMsg2 = examResult.ErrMsg2.FromUtf8(); examResult.ErrMsg3 = examResult.ErrMsg3.FromUtf8(); examResult.ErrMsg4 = examResult.ErrMsg4.FromUtf8(); var emeResult = edb.ExaminationResult.FirstOrDefault(w => w.ExamNo.Trim() == examResult.ExamNo.Trim()); var isAdd = false; if (null == emeResult) { isAdd = true; emeResult = new ExaminationResult(); } emeResult.ExamNo = examResult.ExamNo; emeResult.LoginName = examResult.StudentLoginName; emeResult.Level = examResult.Level; emeResult.Stage = examResult.Stage; emeResult.Score1 = examResult.Score1; emeResult.Score2 = examResult.Score2; emeResult.Score3 = examResult.Score3; emeResult.Score4 = examResult.Score4; emeResult.Score = examResult.Score; emeResult.ErrMsg1 = examResult.ErrMsg1; emeResult.ErrMsg2 = examResult.ErrMsg2; emeResult.ErrMsg3 = examResult.ErrMsg3; emeResult.ErrMsg4 = examResult.ErrMsg4; emeResult.P1 = examResult.P1; emeResult.P2 = examResult.P2; emeResult.P3 = examResult.P3; emeResult.P4 = examResult.P4; emeResult.CreateDate = DateTime.Now; if (isAdd) { edb.ExaminationResult.Add(emeResult); } else { edb.Entry(emeResult).State = EntityState.Modified; } edb.SaveChanges(); result.results.Add(emeResult.ExamNo); result.count += 1; } catch (Exception ex) { // 异常日志消息队列 QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("StudentBLL-CreateExamResult:{0};{1};{2}", ex.Message, ex.InnerException.Message, ex.HelpLink), IsTreat = false, CreateBy = -1, CreateTime = DateTime.Now }); } } if (result.count == 0) { result.code = 102; result.msg = "json data param error or database exception"; } } return result; }