Exemple #1
0
        /// <summary>
        /// 添加一个帖子
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        public int AddTopic(Topic topic)
        {
            var result = _dataAccess.AddEntity(topic);

            //冗余字段
            _dataAccess.UpdateFieldCalc("bbs_SubSection", "TopicCount", "TopicCount+1", "SubSectionId=" + topic.SubSectionId);
            IndexTopic(topic.TopicId);
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 赞某一动态
        /// </summary>
        /// <param name="activityId"></param>
        /// <param name="userId"></param>
        /// <param name="operSuccess">是否成功:如果是false,则表明用户已经赞过了,不能重复赞</param>
        /// <returns></returns>
        public int PraiseActivity(int activityId, int userId, out bool operSuccess)
        {
            var sqlwhere = string.Format("Int_ActivityPraise.ActivityId={0} AND Int_ActivityPraise.UserId={1}",
                                         activityId, userId);
            var model = _dataAccess.GetList <ActivityPraise>(sqlwhere).FirstOrDefault();

            if (model == null)
            {
                model            = new ActivityPraise();
                model.ActivityId = activityId;
                model.UserId     = userId;
                model.PraiseTime = DateTime.Now;
                _dataAccess.AddEntity(model);
                //更新冗余
                _dataAccess.UpdateFieldCalc("Int_UserActivity", "PraiseCount", "PraiseCount+1", "ActivityId=" + activityId);
                operSuccess = true;
            }
            else
            {
                operSuccess = false;
            }

            return
                ((int)_dataAccess.ExecuteScalar(
                     "SELECT PraiseCount FROM Int_UserActivity WHERE ActivityId=" + activityId));
        }
Exemple #3
0
        /// <summary>
        /// 学习指派
        /// </summary>
        /// <param name="designateUser">指派者ID</param>
        /// <param name="userId">被指派者id</param>
        /// <returns></returns>
        public void GetDesignateDetail(int designateUser, int userId)
        {
            var userCourseListSql = string.Format(@"SELECT distinct u.UserId,u.Username,u.Realname,u.Sex,u.UserCode,dp.LevelPath,p.PostName,d.CourseId FROM Len_DesignateCourse d LEFT JOIN Sys_Users u
ON u.UserId=d.UserId
LEFT JOIN Sys_Department dp ON u.DeptId=dp.DeptId
LEFT JOIN Sys_Posts p ON u.PostId=p.PostId
WHERE   DesignateUser={0} AND d.InfoType IN(0) and u.UserId={1}", designateUser, userId);
            var userCourseList    = _dataAccess.FetchListBySql <DesignateUserList>(userCourseListSql);
            var courseIds         = userCourseList.Select(p => p.CourseId).Distinct().GetString();

            string[] courseId = courseIds.Split(',');
            //更新学习记录
            if (userCourseList.Any())
            {
//                var sql = string.Format(@"DELETE FROM dbo.Len_LearningRecord WHERE UserId = {0} AND CourseId IN ({1})
//AND LearnPath=0 AND SourceId=0 ", userId, courseIds);
//                var DeletelearnRecords = _dataAccess.ExecuteSql(sql);
                List <LenLearningRecord> learnRecords = new List <LenLearningRecord>();
                foreach (var item in courseId)
                {
                    var learnRecord = _dataAccess.GetList <LenLearningRecord>(string.Format(@"WHERE UserId = ({0}) AND CourseId = ({1})
AND LearnPath=0 AND SourceId=0 ", userId, Convert.ToInt32(item)));
                    if (learnRecord.Count > 0)
                    {
                        _dataAccess.UpdateFieldCalc("dbo.Len_LearningRecord", "LearnProcess", "2", "where RecordId=" + learnRecord[0].RecordId);
                    }
                    else
                    {
                        LenLearningRecord lr = new LenLearningRecord();
                        lr.CourseId      = Convert.ToInt32(item);
                        lr.UserId        = userId;
                        lr.LearnProcess  = 2;
                        lr.LearnPath     = 0;
                        lr.SourceId      = 0;
                        lr.StartTime     = DateTime.Now;
                        lr.EndTime       = DateTime.Now;
                        lr.LastLearnTime = DateTime.Now;
                        _dataAccess.AddEntity(lr);
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 新增问题
        /// </summary>
        /// <param name="question"></param>
        /// <returns></returns>
        public int AddQuestion(IntQuestion question)
        {
            if (question.SortId != 0)
            {
                var allsorts = GetAllSorts(question.TenantId);

                QuestionSort sort = allsorts.First(p => p.SortId == question.SortId);
                while (sort.ParentId != 0)
                {
                    sort = allsorts.First(p => p.SortId == sort.ParentId);
                }
                _dataAccess.UpdateFieldCalc("Int_QuestionSort", "QuestionCount", "QuestionCount+1", "SortId=" + sort.SortId);
            }
            var id = _dataAccess.AddEntity(question);

            //全文检索
            SetQuestionFullSearch(question.QuestionId);

            return(id);
        }