示例#1
0
        public async void LoadStories()
        {
            List <Story> st = await StoryPer.LoadSprintBacklog(LeSingleton.SelectedSprint.Sprint_Id);

            if (st != null)
            {
                foreach (Story storey in st)
                {
                    switch (storey.Story_State)
                    {
                    case "ToDo":
                        TodoCollection.Add(storey);
                        break;

                    case "Doing":
                        DoingCollection.Add(storey);
                        break;

                    case "Done":
                        DoneCollection.Add(storey);
                        break;

                    case "DoneDone":
                        DoneDoneCollection.Add(storey);
                        break;
                    }
                }
            }
        }
示例#2
0
        public override DoingCollection GetEveryoneDoingsWithComments(int pageNumber, int pageSize, ref int?totalCount)
        {
            DoingCollection doings = null;

            using (SqlSession db = new SqlSession())
            {
                using (SqlQuery query = new SqlQuery())
                {
                    query.Pager.TableName    = "[bx_Doings]";
                    query.Pager.SortField    = "[DoingID]";
                    query.Pager.PageNumber   = pageNumber;
                    query.Pager.PageSize     = pageSize;
                    query.Pager.TotalRecords = totalCount;
                    query.Pager.IsDesc       = true;
                    query.Pager.SelectCount  = true;

                    using (XSqlDataReader reader = query.ExecuteReader())
                    {
                        doings = new DoingCollection(reader);

                        if (totalCount == null && reader.NextResult() && reader.Read())
                        {
                            totalCount = reader.Get <int>(0);
                        }

                        doings.TotalRecords = totalCount.GetValueOrDefault();
                    }
                }

                FillDoingComments(doings, db);
            }

            return(doings);
        }
示例#3
0
        /// <summary>
        /// 获取大家的记录包含当前页的记录的评论(通过记录的CommentList属性访问)
        /// </summary>
        /// <param name="visitorID">访问者ID</param>
        /// <param name="friendOwnerID">好友所有者ID</param>
        /// <param name="pageNumber">数据分页每页条数</param>
        /// <param name="pageSize">数据分页当前页码</param>
        /// <returns></returns>
        public DoingCollection GetEveryoneDoingsWithComments(int pageNumber, int pageSize)
        {
            pageNumber = pageNumber <= 0 ? 1 : pageNumber;

            pageSize = pageSize <= 0 ? Consts.DefaultPageSize : pageSize;

            DoingCollection doings = null;

            #region 获取Doings缓存

            string doingsCacheKey = GetCacheKeyForEveryoneDoings(pageNumber, pageSize);

            bool doingsNeedCache = pageNumber <= Consts.ListCachePageCount;

            bool doingsCached = doingsNeedCache && CacheUtil.TryGetValue(doingsCacheKey, out doings);

            if (doingsCached)
            {
                return(doings);
            }

            #endregion

            #region 获取TotalCount缓存

            int?totalCount = null;

            string totalCountCacheKey = GetCacheKeyForEveryoneDoingsTotalCount();

            bool totalCountCached = CacheUtil.TryGetValue(totalCountCacheKey, out totalCount);

            #endregion

            doings = DoingDao.Instance.GetEveryoneDoingsWithComments(pageNumber, pageSize, ref totalCount);

            #region 设置TotalCount缓存

            if (totalCountCached == false)
            {
                CacheUtil.Set(totalCountCacheKey, totalCount);
            }

            #endregion

            #region 设置Articles缓存

            if (doingsNeedCache)
            {
                CacheUtil.Set(doingsCacheKey, doings);
            }

            #endregion

            ProcessKeyword(doings, ProcessKeywordMode.TryUpdateKeyword);

            return(doings);
        }
示例#4
0
        public async void ChangeState(string name)
        {
            string removeState = DragStory.Story_State;

            DragStory.Story_State = name;
            bool success = await StoryPer.ChangeState(DragStory.Story_Id, DragStory);

            if (success)
            {
                switch (DragStory.Story_State)
                {
                case "ToDo":
                    TodoCollection.Add(DragStory);
                    break;

                case "Doing":
                    DoingCollection.Add(DragStory);
                    break;

                case "Done":
                    DoneCollection.Add(DragStory);
                    break;

                case "DoneDone":
                    DoneDoneCollection.Add(DragStory);
                    break;
                }

                switch (removeState)
                {
                case "ToDo":
                    TodoCollection.Remove(DragStory);
                    break;

                case "Doing":
                    DoingCollection.Remove(DragStory);
                    break;

                case "Done":
                    DoneCollection.Remove(DragStory);
                    break;

                case "DoneDone":
                    DoneDoneCollection.Remove(DragStory);
                    break;
                }
            }
            else
            {
                DragStory.Story_State = removeState;
            }
        }
示例#5
0
        /// <summary>
        /// 获取记录用于管理
        /// </summary>
        /// <param name="operatorID">操作者ID</param>
        /// <param name="filter">文章搜索条件</param>
        /// <param name="pageNumber">数据分页页码</param>
        /// <returns></returns>
        public DoingCollection GetDoingsForAdmin(int operatorID, AdminDoingFilter filter, int pageNumber)
        {
            if (ValidateDoingAdminPermission(operatorID) == false)
            {
                return(null);
            }

            Guid[] excludeRoleIDs = ManagePermission.GetNoPermissionTargetRoleIds(operatorID, PermissionTargetType.Content);

            DoingCollection doings = DoingDao.Instance.GetDoingsBySearch(excludeRoleIDs, filter, pageNumber);

            ProcessKeyword(doings, ProcessKeywordMode.FillOriginalText);

            return(doings);
        }
示例#6
0
        private void ProcessKeyword(DoingCollection doings, ProcessKeywordMode mode)
        {
            if (doings.Count == 0)
            {
                return;
            }

            KeywordReplaceRegulation keyword = AllSettings.Current.ContentKeywordSettings.ReplaceKeywords;

            bool needProcess = false;

            //更新关键字模式,只在必要的情况下才取恢复信息并处理
            if (mode == ProcessKeywordMode.TryUpdateKeyword)
            {
                needProcess = keyword.NeedUpdate <Doing>(doings);
            }
            //填充原始内容模式,始终都要取恢复信息,但不处理
            else
            {
                needProcess = true;
            }

            if (needProcess)
            {
                RevertableCollection <Doing> doingsWithReverter = DoingDao.Instance.GetDoingsWithReverters(doings.GetKeys());

                if (doingsWithReverter != null)
                {
                    if (keyword.Update(doingsWithReverter))
                    {
                        DoingDao.Instance.UpdateDoingKeywords(doingsWithReverter);
                    }

                    //将新数据填充到旧的列表
                    doingsWithReverter.FillTo(doings);
                }
            }

            if (mode == ProcessKeywordMode.TryUpdateKeyword)
            {
                foreach (Doing doing in doings)
                {
                    CommentBO.Instance.ProcessKeyword(doing.CommentList, mode);
                }
            }
        }
示例#7
0
        private void ProcessKeyword(Doing doing, ProcessKeywordMode mode)
        {
            //更新关键字模式,如果这个记录并不需要处理,直接退出
            if (mode == ProcessKeywordMode.TryUpdateKeyword)
            {
                if (AllSettings.Current.ContentKeywordSettings.ReplaceKeywords.NeedUpdate <Doing>(doing) == false)
                {
                    return;
                }
            }

            DoingCollection doings = new DoingCollection();

            doings.Add(doing);

            ProcessKeyword(doings, mode);
        }
示例#8
0
        public override DoingCollection GetUserDoingsWithComments(int doingOwnerID, DataAccessLevel dataAccessLevel, int pageNumber, int pageSize, ref int?totalCount)
        {
            DoingCollection doings = null;

            using (SqlSession db = new SqlSession())
            {
                using (SqlQuery query = db.CreateQuery())
                {
                    query.Pager.TableName    = "[bx_Doings]";
                    query.Pager.SortField    = "[DoingID]";
                    query.Pager.SelectCount  = true;
                    query.Pager.PageNumber   = pageNumber;
                    query.Pager.PageSize     = pageSize;
                    query.Pager.TotalRecords = totalCount;

                    query.Pager.Condition = "[UserID]=@UserID";
                    query.CreateParameter <int>("@UserID", doingOwnerID, SqlDbType.Int);

                    //if (dataAccessLevel == DataAccessLevel.Normal)
                    //{
                    //    query.Pager.Condition += " AND [PrivacyType] IN (0, 3)";
                    //}
                    //else if (dataAccessLevel == DataAccessLevel.Friend)
                    //{
                    //    query.Pager.Condition += " AND [PrivacyType] IN (0, 1, 3)";
                    //}

                    using (XSqlDataReader reader = query.ExecuteReader())
                    {
                        doings = new DoingCollection(reader);

                        if (totalCount == null && reader.NextResult() && reader.Read())
                        {
                            totalCount = reader.Get <int>(0);
                        }

                        doings.TotalRecords = totalCount.GetValueOrDefault();
                    }
                }

                FillDoingComments(doings, db);
            }

            return(doings);
        }
示例#9
0
        /// <summary>
        /// 获取指定用户评论过的记录包含当前页的记录的评论(通过记录的CommentList属性访问)
        /// </summary>
        /// <param name="userID">评论者ID</param>
        /// <param name="pageNumber">数据分页每页条数</param>
        /// <param name="pageSize">数据分页当前页码</param>
        /// <returns></returns>
        public DoingCollection GetUserCommentedDoingsWithComments(int userID, int pageNumber, int pageSize)
        {
            pageNumber = pageNumber <= 0 ? 1 : pageNumber;

            pageSize = pageSize <= 0 ? Consts.DefaultPageSize : pageSize;

            if (ValidateUserID(userID) == false)
            {
                return(null);
            }

            int?totalCount = null;

            DoingCollection doings = DoingDao.Instance.GetUserCommentedDoingsWithComments(userID, pageNumber, pageSize, ref totalCount);

            ProcessKeyword(doings, ProcessKeywordMode.TryUpdateKeyword);

            return(doings);
        }
示例#10
0
        /// <summary>
        /// 获取用户的记录包含当前页的记录的评论(通过记录的CommentList属性访问)
        /// </summary>
        /// <param name="visitorID">访问者ID</param>
        /// <param name="doingOwnerID">数据所有者ID</param>
        /// <param name="pageNumber">数据分页每页条数</param>
        /// <param name="pageSize">数据分页当前页码</param>
        /// <returns></returns>
        public DoingCollection GetUserDoingsWithComments(int visitorID, int doingOwnerID, int pageNumber, int pageSize)
        {
            pageNumber = pageNumber <= 0 ? 1 : pageNumber;

            pageSize = pageSize <= 0 ? Consts.DefaultPageSize : pageSize;

            if (ValidateUserID(visitorID) == false || ValidateUserID(doingOwnerID) == false)
            {
                return(null);
            }

            DoingCollection doings = null;

            DataAccessLevel dataAccessLevel = GetDataAccessLevel(visitorID, doingOwnerID);

            #region 获取TotalCount缓存

            int?totalCount = null;

            string totalCountCacheKey = GetCacheKeyForUserDoingsTotalCount(doingOwnerID, dataAccessLevel);

            bool totalCountCached = CacheUtil.TryGetValue(totalCountCacheKey, out totalCount);

            #endregion

            doings = DoingDao.Instance.GetUserDoingsWithComments(doingOwnerID, dataAccessLevel, pageNumber, pageSize, ref totalCount);

            #region 设置TotalCount缓存

            if (totalCountCached == false)
            {
                CacheUtil.Set(totalCountCacheKey, totalCount);
            }

            #endregion

            ProcessKeyword(doings, ProcessKeywordMode.TryUpdateKeyword);

            return(doings);
        }
示例#11
0
        public override DoingCollection GetDoingsBySearch(Guid[] excludeRoleIDs, AdminDoingFilter filter, int pageNumber)
        {
            using (SqlQuery query = new SqlQuery())
            {
                string conditions = BuildConditionsByFilter(query, filter, excludeRoleIDs, false);

                query.Pager.TableName = "[bx_Doings]";

                query.Pager.SortField = filter.Order.ToString();

                if (filter.Order != AdminDoingFilter.OrderBy.DoingID)
                {
                    query.Pager.PrimaryKey = "DoingID";
                }

                query.Pager.IsDesc      = filter.IsDesc;
                query.Pager.PageNumber  = pageNumber;
                query.Pager.PageSize    = filter.PageSize;
                query.Pager.SelectCount = true;

                query.Pager.Condition = conditions.ToString();

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    DoingCollection doings = new DoingCollection(reader);

                    if (reader.NextResult())
                    {
                        if (reader.Read())
                        {
                            doings.TotalRecords = reader.Get <int>(0);
                        }
                    }

                    return(doings);
                }
            }
        }
示例#12
0
        public override bool BeforeExecute(int operatorUserID, string param, ref long offset, ref int totalCount, out string title)
        {
            StringList paramData = StringList.Parse(param);

            AdminDoingFilter filter = AdminDoingFilter.Parse(paramData[0]);

            //只取一条数据测试下就可以
            filter.PageSize = 1;

            DoingCollection doings = DoingBO.Instance.GetDoingsForAdmin(operatorUserID, filter, 1);

            if (doings == null || doings.Count == 0)
            {
                title = "没有数据可以删除";
                return(false);
            }

            totalCount = doings.TotalRecords;

            title = "将删除 " + totalCount + " 篇日志";

            return(true);
        }
示例#13
0
        public override DoingCollection GetUserCommentedDoingsWithComments(int userID, int pageNumber, int pageSize, ref int?totalCount)
        {
            DoingCollection doings = null;

            using (SqlSession db = new SqlSession())
            {
                using (SqlQuery query = new SqlQuery())
                {
                    query.Pager.TableName    = "[bx_Doings]";
                    query.Pager.SortField    = "DoingID";
                    query.Pager.PageNumber   = pageNumber;
                    query.Pager.PageSize     = pageSize;
                    query.Pager.TotalRecords = totalCount;
                    query.Pager.IsDesc       = true;
                    query.Pager.SelectCount  = true;
                    query.Pager.Condition    = "[DoingID] IN (SELECT [TargetID] FROM [bx_Comments] WHERE [Type]=3 AND [UserID] = @UserID)";

                    query.CreateParameter <int>("@UserID", userID, SqlDbType.Int);

                    using (XSqlDataReader reader = query.ExecuteReader())
                    {
                        doings = new DoingCollection(reader);

                        if (totalCount == null && reader.NextResult() && reader.Read())
                        {
                            totalCount = reader.Get <int>(0);
                        }

                        doings.TotalRecords = totalCount.GetValueOrDefault();
                    }
                }

                FillDoingComments(doings, db);
            }

            return(doings);
        }
示例#14
0
        public override DoingCollection GetUserDoingsWithComments(int doingOwnerID, DataAccessLevel dataAccessLevel, int pageNumber, int pageSize, ref int? totalCount)
        {
            DoingCollection doings = null;

            using (SqlSession db = new SqlSession())
            {
                using (SqlQuery query = db.CreateQuery())
                {
                    query.Pager.TableName = "[bx_Doings]";
                    query.Pager.SortField = "[DoingID]";
                    query.Pager.SelectCount = true;
                    query.Pager.PageNumber = pageNumber;
                    query.Pager.PageSize = pageSize;
                    query.Pager.TotalRecords = totalCount;

                    query.Pager.Condition = "[UserID]=@UserID";
                    query.CreateParameter<int>("@UserID", doingOwnerID, SqlDbType.Int);

                    //if (dataAccessLevel == DataAccessLevel.Normal)
                    //{
                    //    query.Pager.Condition += " AND [PrivacyType] IN (0, 3)";
                    //}
                    //else if (dataAccessLevel == DataAccessLevel.Friend)
                    //{
                    //    query.Pager.Condition += " AND [PrivacyType] IN (0, 1, 3)";
                    //}

                    using (XSqlDataReader reader = query.ExecuteReader())
                    {
                        doings = new DoingCollection(reader);

                        if (totalCount == null && reader.NextResult() && reader.Read())
                        {
                            totalCount = reader.Get<int>(0);
                        }

                        doings.TotalRecords = totalCount.GetValueOrDefault();
                    }
                }

                FillDoingComments(doings, db);
            }

            return doings;
        }
示例#15
0
        public override DoingCollection GetEveryoneDoingsWithComments(int pageNumber, int pageSize, ref int? totalCount)
        {
            DoingCollection doings = null;

            using (SqlSession db = new SqlSession())
            {
                using (SqlQuery query = new SqlQuery())
                {
                    query.Pager.TableName = "[bx_Doings]";
                    query.Pager.SortField = "[DoingID]";
                    query.Pager.PageNumber = pageNumber;
                    query.Pager.PageSize = pageSize;
                    query.Pager.TotalRecords = totalCount;
                    query.Pager.IsDesc = true;
                    query.Pager.SelectCount = true;

                    using (XSqlDataReader reader = query.ExecuteReader())
                    {
                        doings = new DoingCollection(reader);

                        if (totalCount == null && reader.NextResult() && reader.Read())
                        {
                            totalCount = reader.Get<int>(0);
                        }

                        doings.TotalRecords = totalCount.GetValueOrDefault();
                    }
                }

                FillDoingComments(doings, db);
            }

            return doings;
        }
示例#16
0
        private void FillDoingComments(DoingCollection doings, SqlSession db)
        {
            if (doings.Count == 0)
            {
                return;
            }

            List <int> minIds = new List <int>();
            List <int> maxIds = new List <int>();

            for (int i = 0; i < doings.Count; i++)
            {
                if (doings[i].TotalComments == 0)
                {
                    continue;
                }
                else if (doings[i].TotalComments == 1)
                {
                    minIds.Add(doings[i].DoingID);
                }
                else
                {
                    minIds.Add(doings[i].DoingID);
                    maxIds.Add(doings[i].DoingID);
                }
            }

            if (minIds.Count == 0)
            {
                return;
            }

            using (SqlQuery query = db.CreateQuery())
            {
                query.CommandText = @"
SELECT * FROM bx_Comments WHERE CommentID IN(
    SELECT Min(CommentID) FROM [bx_Comments] WHERE [Type]=3 AND IsApproved = 1 AND [TargetID] IN(@MinTargetIDs) GROUP BY TargetID
);
";
                if (maxIds.Count > 0)
                {
                    query.CommandText += @"
SELECT * FROM bx_Comments WHERE CommentID IN(
    SELECT Max(CommentID) FROM [bx_Comments] WHERE [Type]=3 AND IsApproved = 1 AND [TargetID] IN(@MaxTargetIDs) GROUP BY TargetID
);
";
                }

                query.CreateInParameter <int>("@MinTargetIDs", minIds);
                query.CreateInParameter <int>("@MaxTargetIDs", maxIds);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Comment comment = new Comment(reader);
                        Doing   doing   = doings.GetValue(comment.TargetID);
                        if (doing != null)
                        {
                            if (doing.CommentList.ContainsKey(comment.CommentID) == false)
                            {
                                doing.CommentList.Add(comment);
                            }
                        }
                    }
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            Comment comment = new Comment(reader);
                            Doing   doing   = doings.GetValue(comment.TargetID);
                            if (doing != null)
                            {
                                if (doing.CommentList.ContainsKey(comment.CommentID) == false)
                                {
                                    doing.CommentList.Add(comment);
                                }
                            }
                        }
                    }
                }
            }

            db.Connection.Close();

            //Doing doing = null;
            //int lastDoingID = -1;

            //for (int i = 0; i < comments.Count; i++)
            //{
            //    int doingID = comments[i].TargetID;

            //    if (doingID != lastDoingID)
            //    {
            //        doing = doings.GetValue(doingID);

            //        lastDoingID = doingID;
            //    }

            //    doing.CommentList.Add(comments[i]);
            //}
        }
示例#17
0
        public override DoingCollection GetUserCommentedDoingsWithComments(int userID, int pageNumber, int pageSize, ref int? totalCount)
        {
            DoingCollection doings = null;

            using (SqlSession db = new SqlSession())
            {
                using (SqlQuery query = new SqlQuery())
                {
                    query.Pager.TableName = "[bx_Doings]";
                    query.Pager.SortField = "DoingID";
                    query.Pager.PageNumber = pageNumber;
                    query.Pager.PageSize = pageSize;
                    query.Pager.TotalRecords = totalCount;
                    query.Pager.IsDesc = true;
                    query.Pager.SelectCount = true;
                    query.Pager.Condition = "[DoingID] IN (SELECT [TargetID] FROM [bx_Comments] WHERE [Type]=3 AND [UserID] = @UserID)";

                    query.CreateParameter<int>("@UserID", userID, SqlDbType.Int);

                    using (XSqlDataReader reader = query.ExecuteReader())
                    {
                        doings = new DoingCollection(reader);

                        if (totalCount == null && reader.NextResult() && reader.Read())
                        {
                            totalCount = reader.Get<int>(0);
                        }

                        doings.TotalRecords = totalCount.GetValueOrDefault();
                    }
                }

                FillDoingComments(doings, db);
            }

            return doings;
        }
示例#18
0
        public override DoingCollection GetDoingsBySearch(Guid[] excludeRoleIDs, AdminDoingFilter filter, int pageNumber)
        {
            using (SqlQuery query = new SqlQuery())
            {
                string conditions = BuildConditionsByFilter(query, filter, excludeRoleIDs, false);

                query.Pager.TableName = "[bx_Doings]";

                query.Pager.SortField = filter.Order.ToString();

                if (filter.Order != AdminDoingFilter.OrderBy.DoingID)
                {
                    query.Pager.PrimaryKey = "DoingID";
                }

                query.Pager.IsDesc = filter.IsDesc;
                query.Pager.PageNumber = pageNumber;
                query.Pager.PageSize = filter.PageSize;
                query.Pager.SelectCount = true;

                query.Pager.Condition = conditions.ToString();

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    DoingCollection doings = new DoingCollection(reader);

                    if (reader.NextResult())
                    {
                        if (reader.Read())
                        {
                            doings.TotalRecords = reader.Get<int>(0);
                        }
                    }

                    return doings;
                }
            }
        }
示例#19
0
        private void FillDoingComments(DoingCollection doings, SqlSession db)
        {
            if (doings.Count == 0)
                return;

            List<int> minIds = new List<int>();
            List<int> maxIds = new List<int>();

            for (int i = 0; i < doings.Count; i++)
            {
                if (doings[i].TotalComments == 0)
                    continue;
                else if (doings[i].TotalComments == 1)
                    minIds.Add(doings[i].DoingID);
                else
                {
                    minIds.Add(doings[i].DoingID);
                    maxIds.Add(doings[i].DoingID);
                }
            }

            if (minIds.Count == 0)
                return;

            using (SqlQuery query = db.CreateQuery())
            {

                query.CommandText = @"
SELECT * FROM bx_Comments WHERE CommentID IN(
    SELECT Min(CommentID) FROM [bx_Comments] WHERE [Type]=3 AND IsApproved = 1 AND [TargetID] IN(@MinTargetIDs) GROUP BY TargetID
);
";
                if (maxIds.Count > 0)
                {
                    query.CommandText += @"
SELECT * FROM bx_Comments WHERE CommentID IN(
    SELECT Max(CommentID) FROM [bx_Comments] WHERE [Type]=3 AND IsApproved = 1 AND [TargetID] IN(@MaxTargetIDs) GROUP BY TargetID
);
";
                }

                query.CreateInParameter<int>("@MinTargetIDs", minIds);
                query.CreateInParameter<int>("@MaxTargetIDs", maxIds);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Comment comment = new Comment(reader);
                        Doing doing = doings.GetValue(comment.TargetID);
                        if (doing != null)
                        {
                            if (doing.CommentList.ContainsKey(comment.CommentID) == false)
                                doing.CommentList.Add(comment);
                        }
                    }
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            Comment comment = new Comment(reader);
                            Doing doing = doings.GetValue(comment.TargetID);
                            if (doing != null)
                            {
                                if (doing.CommentList.ContainsKey(comment.CommentID) == false)
                                    doing.CommentList.Add(comment);
                            }
                        }
                    }
                }
            }

            db.Connection.Close();

            //Doing doing = null;
            //int lastDoingID = -1;

            //for (int i = 0; i < comments.Count; i++)
            //{
            //    int doingID = comments[i].TargetID;

            //    if (doingID != lastDoingID)
            //    {
            //        doing = doings.GetValue(doingID);

            //        lastDoingID = doingID;
            //    }

            //    doing.CommentList.Add(comments[i]);
            //}
        }