Exemple #1
0
        /// <summary>
        /// 获取用户单个单元完成详情
        /// </summary>
        /// <param name="doId"></param>
        /// <returns></returns>
        public UnitWorksContract GetUserUnitWork(long doId)
        {
            string sql = "SELECT * FROM unitworks WHERE DoId = @DoId";

            UnitWorksContract model = null;

            using (var dr = MySqlHelper.ExecuteReader(ReadConnectionString, sql, new MySqlParameter("@DoId", doId)))
            {
                if (dr.Read())
                {
                    model = new UnitWorksContract()
                    {
                        DoId           = dr.GetInt64("DoId"),
                        ContentId      = dr.GetInt64("ContentId"),
                        RecordId       = dr.GetInt64("RecordId"),
                        WorkId         = dr.GetInt64("WorkId"),
                        DoWorkId       = dr.GetInt64("DoWorkId"),
                        SubmitUserId   = dr.GetInt32("SubmitUserId"),
                        SubmitUserName = dr.GetString("SubmitUserName"),
                        WorkScore      = dr.GetDecimal("WorkScore"),
                        ActualScore    = dr.GetDecimal("ActualScore"),
                        CorrectRate    = dr.GetDecimal("CorrectRate"),
                        WorkLong       = dr.GetInt32("WorkLong"),
                        SubmitDate     = dr.GetDateTime("SubmitDate"),
                        IsTimeOut      = dr.GetBoolean("IsTimeOut"),
                        SubmitCount    = dr.GetInt32("SubmitCount"),
                        Comment        = dr.GetString("Comment"),
                        CommentType    = dr.GetInt32("CommentType"),
                        Status         = dr.GetInt32("Status")
                    };
                }
            }
            return(model);
        }
Exemple #2
0
 /// <summary>
 /// 批改作业答案
 /// </summary>
 /// <param name="workAnswer"></param>
 /// <returns></returns>
 public bool CorrectAnswer(UnitWorksContract unitWork, WorkAnswerContract workAnswer)
 {
     using (var trans = new TransactionScope())
     {
         _workAnserManager.CorrectAnswer(workAnswer);
         _unitWorksManager.Update(unitWork);
         trans.Complete();
     }
     return(true);
 }
Exemple #3
0
        /// <summary>
        /// 提交单元作业
        /// </summary>
        public long DoUnitWorks(UnitWorksContract model, IEnumerable <WorkAnswerContract> userAnswer = null, int totalNum = 0)
        {
            if (model == null)
            {
                throw new ArgumentNullException("参数model为null");
            }
            using (var trans = new TransactionScope())
            {
                model.SubmitDate = DateTime.Now;
                if (model.DoId == 0)
                {
                    _unitWorksManager.Insert(model);
                }
                else
                {
                    _unitWorksManager.Update(model);
                }
                _workAnserManager.Insert(model.DoId, 1, userAnswer);
                trans.Complete();
            }

            if (model.DoId > 0)
            {
                if (totalNum < 1)
                {
                    var workInfo = _workBaseManager.GetWorkBase(model.WorkId);
                    if (workInfo != null)
                    {
                        totalNum = workInfo.TotalNum;
                    }
                }
                //异步更新统计数据
                System.Threading.Tasks.Task.Factory.StartNew(() => _unitWorksManager.SetUnitSummary(model.ContentId, model.WorkId, model.RecordId, totalNum));
                System.Threading.Tasks.Task.Factory.StartNew(() => this.UpdateDoWorkInfo(model.DoWorkId, model.RecordId, model.SubmitDate));
            }

            return(model.DoId);
        }
Exemple #4
0
        /// <summary>
        /// 更新记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Update(UnitWorksContract model)
        {
            var bulider = new UpdateBuilder("unitworks")
                          .RegisterField("ContentId", model.ContentId)
                          .RegisterField("RecordId", model.RecordId)
                          .RegisterField("WorkId", model.WorkId)
                          .RegisterField("DoWorkId", model.DoWorkId)
                          .RegisterField("SubmitUserId", model.SubmitUserId)
                          .RegisterField("SubmitUserName", model.SubmitUserName)
                          .RegisterField("WorkScore", model.WorkScore)
                          .RegisterField("ActualScore", model.ActualScore)
                          .RegisterField("CorrectRate", model.CorrectRate)
                          .RegisterField("WorkLong", model.WorkLong)
                          .RegisterField("SubmitDate", model.SubmitDate)
                          .RegisterField("IsTimeOut", model.IsTimeOut)
                          .RegisterField("SubmitCount", model.SubmitCount)
                          .RegisterField("Comment", model.Comment)
                          .RegisterField("CommentType", model.CommentType)
                          .RegisterField("Status", model.Status)
                          .RegisterClause(new EqualBuilder <long>("DoId", model.DoId));

            return(AdoProvide.ExecuteNonQuery(WriteConnectionString, bulider) > 0);
        }
Exemple #5
0
        /// <summary>
        /// 添加单元作业完成记录,返回自增id
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public long Insert(UnitWorksContract model)
        {
            var bulider = new InsertBuilder("unitworks")
                          .RegisterField("ContentId", model.ContentId)
                          .RegisterField("RecordId", model.RecordId)
                          .RegisterField("WorkId", model.WorkId)
                          .RegisterField("DoWorkId", model.DoWorkId)
                          .RegisterField("SubmitUserId", model.SubmitUserId)
                          .RegisterField("SubmitUserName", model.SubmitUserName ?? string.Empty)
                          .RegisterField("WorkScore", model.WorkScore)
                          .RegisterField("ActualScore", model.ActualScore)
                          .RegisterField("CorrectRate", model.CorrectRate)
                          .RegisterField("WorkLong", model.WorkLong)
                          .RegisterField("SubmitDate", model.SubmitDate)
                          .RegisterField("IsTimeOut", model.IsTimeOut)
                          .RegisterField("SubmitCount", model.SubmitCount)
                          .RegisterField("Comment", model.Comment ?? string.Empty)
                          .RegisterField("CommentType", model.CommentType)
                          .RegisterField("Status", model.Status);

            model.DoId = AdoProvide.ExecuteScalar <long>(WriteConnectionString, bulider);

            return(model.DoId);
        }
Exemple #6
0
        public JsonResult CreateWork(WorkParam baseParam, long contentId, long doWorkId)
        {
            if (baseParam.workStatus == 2 || baseParam.workStatus == 3)
            {
                return(Json(new ReturnResult(1, "作业已经完成啦,刷新页面试一试哦!")));
            }
            if (baseParam.UnitWork != null)
            {
                return(Json(baseParam.UnitWork.DoId));
            }

            var unitWorks = new UnitWorksContract();

            unitWorks.ContentId      = contentId;
            unitWorks.RecordId       = baseParam.WorkResource.RecordId;
            unitWorks.WorkId         = baseParam.DoWorkBase.WorkID;
            unitWorks.DoWorkId       = baseParam.DoWorkBase.DoWorkID;
            unitWorks.SubmitUserId   = baseParam.DoWorkBase.SubmitUserID;
            unitWorks.SubmitUserName = baseParam.DoWorkBase.SubmitUserName;
            unitWorks.SubmitDate     = DateTime.Now;
            unitWorks.IsTimeOut      = unitWorks.SubmitDate > baseParam.DoWorkBase.EffectiveDate;

            return(Json(workService.CreateUnitWork(unitWorks)));
        }
Exemple #7
0
 public long CreateUnitWork(UnitWorksContract unitwork)
 {
     return(_unitWorksManager.Insert(unitwork));
 }