Exemplo n.º 1
0
        public ActionResult addRecordInfo(string userId, string classId, int scoType, string recordData, string timestamp)
        {
            int result;
            string msg;

            #region 验证参数
            string teacherNo = ApiTools.Decrypt(HttpUtility.UrlDecode(userId), aesKey, aesIV).Replace("\0", "");
            //userId = Dianda.Common.StringSecurity.DES.Decrypt(HttpUtility.UrlDecode(userId));
            if (string.IsNullOrEmpty(teacherNo))
            {
                result = 0;
                msg = "参数:userId的加密格式错误";
                return Json(new { Result = result, Msg = msg });
            }

            classId = ApiTools.Decrypt(HttpUtility.UrlDecode(classId), aesKey, aesIV);
            //classId = Dianda.Common.StringSecurity.DES.Decrypt(HttpUtility.UrlDecode(classId));
            if (string.IsNullOrEmpty(classId))
            {
                result = 0;
                msg = "参数:classId的加密格式错误";
                return Json(new { Result = result, Msg = msg });
            }
            int trainingId;
            if (!int.TryParse(classId.Replace("\0", ""), out trainingId))
            {
                result = 0;
                msg = "参数:classId不是合法的整数类型";
                return Json(new { Result = result, Msg = msg });
            }

            if (scoType < 1 || scoType > 7)
            {
                result = 0;
                msg = "参数:scoType不合法";
                return Json(new { Result = result, Msg = msg });
            }

            recordData = ApiTools.Decrypt(HttpUtility.UrlDecode(recordData), aesKey, aesIV);
            //recordData = Dianda.Common.StringSecurity.DES.Decrypt(HttpUtility.UrlDecode(recordData));
            if (string.IsNullOrEmpty(recordData))
            {
                result = 0;
                msg = "参数:recordData的加密格式错误";
                return Json(new { Result = result, Msg = msg });
            }
            JavaScriptSerializer jss = new JavaScriptSerializer();
            OutCourse outcourse;
            try
            {
                outcourse = jss.Deserialize<OutCourse>(recordData.Replace("\0", ""));
            }
            catch (Exception)
            {
                result = 0;
                msg = "参数:recordData不是合法的Json格式";
                return Json(new { Result = result, Msg = msg });
            }

            if (!Dianda.Common.StringSecurity.MD5Lib.Encrypt(
                DateTime.Now.ToString("yyyyMMddHH") + teacherNo + trainingId).Equals(timestamp, StringComparison.CurrentCultureIgnoreCase))
            {
                result = 0;
                msg = "参数:timestamp验证不通过";
                return Json(new { Result = result, Msg = msg });
            }
            #endregion

            Member_ClassRegisterBLL mcBLL = new Member_ClassRegisterBLL();
            Member_ClassRegister mcModel = mcBLL.GetModel("Delflag=0 and TrainingId=" + this.ConvertTrainingId(trainingId)
                + " and AccountId=(select top 1.AccountId from Member_BaseInfo where Delflag=0 and TeacherNo='" + teacherNo + "') and PlanId=" + Code.SiteCache.Instance.PlanId);
            if (mcModel == null)
            {
                result = 0;
                msg = "学员班级信息不存在";
                return Json(new { Result = result, Msg = msg });
            }

            switch (scoType)
            {
                case 1:
                    if (mcModel.ReadingScore == null)
                        mcModel.ReadingScore = 1;
                    else
                        mcModel.ReadingScore += 1;
                    break;

                case 2:
                    if (mcModel.ReadingScore == null)
                        mcModel.ReadingScore = 1;
                    else
                        mcModel.ReadingScore += 1;
                    break;

                case 3:
                    if (mcModel.TestingScore == null)
                        mcModel.TestingScore = 1;
                    else
                        mcModel.TestingScore += 1;
                    break;

                case 4:
                    if (mcModel.DiscussScore == null)
                        mcModel.DiscussScore = 1;
                    else
                        mcModel.DiscussScore += 1;
                    break;

                case 5:
                    if (mcModel.HomeWorkScore == null)
                        mcModel.HomeWorkScore = 1;
                    else
                        mcModel.HomeWorkScore += 1;
                    break;

                case 6:
                    if (mcModel.ExaminationScore == null)
                        mcModel.ExaminationScore = 1;
                    else
                        mcModel.ExaminationScore += 1;
                    break;

                case 7:
                    if (mcModel.OtherScore == null)
                        mcModel.OtherScore = 1;
                    else
                        mcModel.OtherScore += 1;
                    break;
            }

            Course_OutCourseRecordBLL bll = new Course_OutCourseRecordBLL();
            Course_OutCourseRecord model = new Course_OutCourseRecord();
            model.ClassId = mcModel.ClassId;
            model.TrainingId = mcModel.TrainingId;
            model.AccountId = mcModel.AccountId;
            model.DataType = scoType;
            model.Status = true;
            model.Delflag = false;
            ConvertModel(outcourse, model);

            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    bll.Add(model);
                    mcBLL.Update(mcModel);
                    trans.Complete();
                    result = 1;
                    msg = "新增学习记录成功";
                    ApiTools.WriteLog(TraceEventType.Information, 1, "新增学习活动记录");
                    return Json(new { Result = result, Msg = msg });
                }
            }
            catch (Exception e)
            {
                ApiTools.WriteLog(TraceEventType.Error, 0, e.ToString());
                result = 0;
                msg = "新增学习记录失败";
                return Json(new { Result = result, Msg = msg });
            }
        }
Exemplo n.º 2
0
 //获取学员外部活动列表
 public JsonResult GetOutCourseRecord(int classId, int traningId, int accountId, int type)
 {
     try
     {
         var recordList = new Course_OutCourseRecordBLL()
             .GetList(" Delflag=0 and ClassId=" + classId + " and TrainingId=" + traningId + " and AccountId=" + accountId + " and DataType in (" + (type == 1 ? "1,2" : type.ToString()) + ")", "");
         return Json(recordList, JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex)
     {
         return Json(new { Code = -1, Msg = ex.Message }, JsonRequestBehavior.AllowGet);
     }
 }
Exemplo n.º 3
0
        public ActionResult setEvaluation(string userId, string classId, int isPassed, string assessmentName, string remark, string timestamp)
        {
            int result;
            string msg;

            #region 验证参数
            string teacherNo = ApiTools.Decrypt(HttpUtility.UrlDecode(userId), aesKey, aesIV).Replace("\0", "");
            //userId = Dianda.Common.StringSecurity.DES.Decrypt(HttpUtility.UrlDecode(userId));
            if (string.IsNullOrEmpty(userId))
            {
                result = 0;
                msg = "参数:userId的加密格式错误";
                return Json(new { Result = result, Msg = msg });
            }

            classId = ApiTools.Decrypt(HttpUtility.UrlDecode(classId), aesKey, aesIV);
            //classId = Dianda.Common.StringSecurity.DES.Decrypt(HttpUtility.UrlDecode(classId));
            if (string.IsNullOrEmpty(classId))
            {
                result = 0;
                msg = "参数:classId的加密格式错误";
                return Json(new { Result = result, Msg = msg });
            }
            int trainingId;
            if (!int.TryParse(classId.Replace("\0", ""), out trainingId))
            {
                result = 0;
                msg = "参数:classId不是合法的整数类型";
                return Json(new { Result = result, Msg = msg });
            }

            if (!Dianda.Common.StringSecurity.MD5Lib.Encrypt(
                DateTime.Now.ToString("yyyyMMddHH") + teacherNo + trainingId).Equals(timestamp, StringComparison.CurrentCultureIgnoreCase))
            {
                result = 0;
                msg = "参数:timestamp验证不通过";
                return Json(new { Result = result, Msg = msg });
            }
            #endregion

            Member_ClassRegisterBLL mcBLL = new Member_ClassRegisterBLL();
            Member_ClassRegister mcModel = mcBLL.GetModel("Delflag=0 and TrainingId=" + this.ConvertTrainingId(trainingId)
                + " and AccountId=(select top 1.AccountId from Member_BaseInfo where Delflag=0 and TeacherNo='" + teacherNo + "') and PlanId=" + Code.SiteCache.Instance.PlanId);
            if (mcModel == null)
            {
                result = 0;
                msg = "学员班级信息不存在";
                return Json(new { Result = result, Msg = msg });
            }

            if (isPassed == 1)
                mcModel.Result = 1;
            else
                mcModel.Result = 0;

            Course_OutCourseRecordBLL bll = new Course_OutCourseRecordBLL();
            Course_OutCourseRecord model = new Course_OutCourseRecord();
            model.AssessmentName = assessmentName;
            model.ClassId = mcModel.ClassId;
            model.TrainingId = mcModel.TrainingId;
            model.AccountId = mcModel.AccountId;
            model.DataType = 0;
            if (isPassed == 1)
                model.IsPassed = true;
            else
                model.IsPassed = false;
            model.Remark = remark;
            model.Status = true;
            model.Delflag = false;
            model.CreateDate = DateTime.Now;

            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    bll.Add(model);
                    mcBLL.Update(mcModel);
                    trans.Complete();
                    result = 1;
                    msg = "结业评定操作成功";
                    ApiTools.WriteLog(TraceEventType.Information, 1, "结业评定");
                    return Json(new { Result = result, Msg = msg });
                }
            }
            catch (Exception e)
            {
                ApiTools.WriteLog(TraceEventType.Error, 0, e.ToString());
                result = 0;
                msg = "结业评定操作失败";
                return Json(new { Result = result, Msg = msg });
            }
        }