/// <summary>
 /// 新增一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Add(Course_OutCourseRecord model)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("insert into [dbo].[Course_OutCourseRecord] ([ClassId],[TrainingId],[AccountId],[DataType],[learningTime],[Role],[IsPassed],[Remark],[Score],[Status],[Delflag],[CreateDate],[Title],[AssessmentName])");
     sql.Append(" values (@ClassId,@TrainingId,@AccountId,@DataType,@learningTime,@Role,@IsPassed,@Remark,@Score,@Status,@Delflag,@CreateDate,@Title,@AssessmentName)");
     sql.Append(" set @Id=@@IDENTITY");
     SqlParameter[] cmdParams = new SqlParameter[]{
         new SqlParameter("@Id", SqlDbType.Int, 4) { Value = model.Id, Direction = ParameterDirection.Output },
         new SqlParameter("@ClassId", SqlDbType.Int, 4) { Value = model.ClassId },
         new SqlParameter("@TrainingId", SqlDbType.Int, 4) { Value = model.TrainingId },
         new SqlParameter("@AccountId", SqlDbType.Int, 4) { Value = model.AccountId },
         new SqlParameter("@DataType", SqlDbType.Int, 4) { Value = model.DataType },
         new SqlParameter("@learningTime", SqlDbType.Float, 8) { Value = model.learningTime },
         new SqlParameter("@Role", SqlDbType.Int, 4) { Value = model.Role },
         new SqlParameter("@IsPassed", SqlDbType.Bit, 1) { Value = model.IsPassed },
         new SqlParameter("@Remark", SqlDbType.VarChar, 500) { Value = model.Remark },
         new SqlParameter("@Score", SqlDbType.Float, 8) { Value = model.Score },
         new SqlParameter("@Status", SqlDbType.Bit, 1) { Value = model.Status },
         new SqlParameter("@Delflag", SqlDbType.Bit, 1) { Value = model.Delflag },
         new SqlParameter("@CreateDate", SqlDbType.DateTime, 8) { Value = model.CreateDate },
         new SqlParameter("@Title", SqlDbType.VarChar, 500) { Value = model.Title },
         new SqlParameter("@AssessmentName", SqlDbType.VarChar, 50) { Value = model.AssessmentName }
     };
     int result = Convert.ToInt32(MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), cmdParams));
     model.Id = Convert.ToInt32(cmdParams[0].Value);
     return result;
 }
 /// <summary>
 /// 获取数据集
 /// </summary>
 /// <param name="where"></param>
 /// <param name="orderBy"></param>
 /// <returns></returns>
 public List<Course_OutCourseRecord> GetList(string where, string orderBy)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("select * from [dbo].[Course_OutCourseRecord]");
     if (!string.IsNullOrEmpty(where))
         sql.Append(" where " + where);
     if (!string.IsNullOrEmpty(orderBy))
         sql.Append(" order by " + orderBy);
     List<Course_OutCourseRecord> list = new List<Course_OutCourseRecord>();
     using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString()))
     {
         while (reader.Read())
         {
             Course_OutCourseRecord model = new Course_OutCourseRecord();
             ConvertToModel(reader, model);
             list.Add(model);
         }
     }
     return list;
 }
 /// <summary>
 /// 获取分页数据集
 /// </summary>
 /// <param name="pageSize"></param>
 /// <param name="pageIndex"></param>
 /// <param name="where"></param>
 /// <param name="orderBy"></param>
 /// <returns></returns>
 public List<Course_OutCourseRecord> GetList(int pageSize, int pageIndex, string where, string orderBy)
 {
     if (string.IsNullOrEmpty(orderBy))
         throw new ArgumentNullException();
     int start = (pageIndex - 1) * pageSize + 1;
     int end = pageIndex * pageSize;
     StringBuilder sql = new StringBuilder();
     sql.Append("select * from (select *,ROW_NUMBER() over (order by " + orderBy + ") as [RowNum] from [dbo].[Course_OutCourseRecord]");
     if (!string.IsNullOrEmpty(where))
         sql.Append(" where " + where);
     sql.Append(") as T where [RowNum] between " + start + " and " + end);
     List<Course_OutCourseRecord> list = new List<Course_OutCourseRecord>();
     using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString()))
     {
         while (reader.Read())
         {
             Course_OutCourseRecord model = new Course_OutCourseRecord();
             ConvertToModel(reader, model);
             list.Add(model);
         }
     }
     return list;
 }
 private void ConvertToModel(IDataReader reader, Course_OutCourseRecord model)
 {
     if (reader["Id"] != DBNull.Value)
         model.Id = Convert.ToInt32(reader["Id"]);
     if (reader["ClassId"] != DBNull.Value)
         model.ClassId = Convert.ToInt32(reader["ClassId"]);
     if (reader["TrainingId"] != DBNull.Value)
         model.TrainingId = Convert.ToInt32(reader["TrainingId"]);
     if (reader["AccountId"] != DBNull.Value)
         model.AccountId = Convert.ToInt32(reader["AccountId"]);
     if (reader["DataType"] != DBNull.Value)
         model.DataType = Convert.ToInt32(reader["DataType"]);
     if (reader["learningTime"] != DBNull.Value)
         model.learningTime = Convert.ToDouble(reader["learningTime"]);
     if (reader["Role"] != DBNull.Value)
         model.Role = Convert.ToInt32(reader["Role"]);
     if (reader["IsPassed"] != DBNull.Value)
         model.IsPassed = Convert.ToBoolean(reader["IsPassed"]);
     if (reader["Remark"] != DBNull.Value)
         model.Remark = reader["Remark"].ToString();
     if (reader["Score"] != DBNull.Value)
         model.Score = Convert.ToDouble(reader["Score"]);
     if (reader["Status"] != DBNull.Value)
         model.Status = Convert.ToBoolean(reader["Status"]);
     if (reader["Delflag"] != DBNull.Value)
         model.Delflag = Convert.ToBoolean(reader["Delflag"]);
     if (reader["CreateDate"] != DBNull.Value)
         model.CreateDate = Convert.ToDateTime(reader["CreateDate"]);
     if (reader["Title"] != DBNull.Value)
         model.Title = reader["Title"].ToString();
     if (reader["AssessmentName"] != DBNull.Value)
         model.AssessmentName = reader["AssessmentName"].ToString();
 }
 /// <summary>
 /// 更新一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(Course_OutCourseRecord model)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("update [dbo].[Course_OutCourseRecord] set ");
     sql.Append("[ClassId]=@ClassId,[TrainingId]=@TrainingId,[AccountId]=@AccountId,[DataType]=@DataType,[learningTime]=@learningTime,[Role]=@Role,[IsPassed]=@IsPassed,[Remark]=@Remark,[Score]=@Score,[Status]=@Status,[Delflag]=@Delflag,[CreateDate]=@CreateDate,[Title]=@Title,[AssessmentName]=@AssessmentName");
     sql.Append(" where [Id]=@Id");
     SqlParameter[] cmdParams = new SqlParameter[] {
         new SqlParameter("@Id", SqlDbType.Int, 4) { Value = model.Id },
         new SqlParameter("@ClassId", SqlDbType.Int, 4) { Value = model.ClassId },
         new SqlParameter("@TrainingId", SqlDbType.Int, 4) { Value = model.TrainingId },
         new SqlParameter("@AccountId", SqlDbType.Int, 4) { Value = model.AccountId },
         new SqlParameter("@DataType", SqlDbType.Int, 4) { Value = model.DataType },
         new SqlParameter("@learningTime", SqlDbType.Float, 8) { Value = model.learningTime },
         new SqlParameter("@Role", SqlDbType.Int, 4) { Value = model.Role },
         new SqlParameter("@IsPassed", SqlDbType.Bit, 1) { Value = model.IsPassed },
         new SqlParameter("@Remark", SqlDbType.VarChar, 500) { Value = model.Remark },
         new SqlParameter("@Score", SqlDbType.Float, 8) { Value = model.Score },
         new SqlParameter("@Status", SqlDbType.Bit, 1) { Value = model.Status },
         new SqlParameter("@Delflag", SqlDbType.Bit, 1) { Value = model.Delflag },
         new SqlParameter("@CreateDate", SqlDbType.DateTime, 8) { Value = model.CreateDate },
         new SqlParameter("@Title", SqlDbType.VarChar, 500) { Value = model.Title },
         new SqlParameter("@AssessmentName", SqlDbType.VarChar, 50) { Value = model.AssessmentName }
     };
     return MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), cmdParams);
 }
 /// <summary>
 /// 取得一条记录
 /// </summary>
 /// <param name="id"></param>
 /// <param name="where"></param>
 /// <returns></returns>
 public Course_OutCourseRecord GetModel(int id, string where)
 {
     string sql = "select * from [dbo].[Course_OutCourseRecord] where [Id]=@Id";
     if (!string.IsNullOrEmpty(where))
         sql += " and " + where;
     SqlParameter[] cmdParams = new SqlParameter[]{
         new SqlParameter("@Id", SqlDbType.Int, 4) { Value = id }
     };
     using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql, cmdParams))
     {
         if (reader.Read())
         {
             Course_OutCourseRecord model = new Course_OutCourseRecord();
             ConvertToModel(reader, model);
             return model;
         }
         else
         {
             return null;
         }
     }
 }
Exemplo n.º 7
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.º 8
0
        private void ConvertModel(OutCourse input, Course_OutCourseRecord output)
        {
            output.Title = input.title;

            double learningTime;
            if (double.TryParse(input.learningTime, out learningTime))
                output.learningTime = learningTime;

            output.Remark = input.remark;

            DateTime recordTime;
            if (DateTime.TryParse(input.recordTime, out recordTime))
                output.CreateDate = recordTime;
            else
                output.CreateDate = DateTime.Now;

            double score;
            if (double.TryParse(input.score, out score))
                output.Score = score;

            if (input.isPassed == "1")
                output.IsPassed = true;
            else
                output.IsPassed = false;

            int role;
            if (int.TryParse(input.role, out role))
                output.Role = role;
        }
Exemplo n.º 9
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 });
            }
        }
 /// <summary>
 /// 新增一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Add(Course_OutCourseRecord model)
 {
     return dal.Add(model) > 0;
 }
 /// <summary>
 /// 更新一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Update(Course_OutCourseRecord model)
 {
     return dal.Update(model) > 0;
 }