Exemplo n.º 1
0
        public static string /*board id*/ CreateBoard(string board_name)
        {
            int    next_id  = NextIdStore.Next(Warehouse.BoardListTable, null);
            string board_id = SandId.MakeBoardId(next_id);

            DynamicTableEntity entity = new DynamicTableEntity(board_id, EMPTY_ROW_KEY);

            entity["boardname"] = new EntityProperty(board_name);
            entity.OperateFlags(new FlagMergeOperation(SandFlags.MT_LOW_KEY + "1"));
#if OLD
            entity["createtime"] = new EntityProperty(DateTime.Now);

            entity["creatoruid"] = new EntityProperty(WebSecurity.CurrentUserId);
            entity["creatormid"] = new EntityProperty(UserStore.CurrentUserMId);
#else
            CreatorConverter.FillEntity(entity, CreatorConverter.Status.Editor, null);
#endif
            Warehouse.BoardListTable.Execute(TableOperation.Insert(entity));

            DiscussionListStore.CreateSkeleton(board_id);
            //don't work for child action. //HttpResponse.RemoveOutputCacheItem("/boardlist");
            Warehouse.BsMapPond.Notify();

            return(board_id);
        }
Exemplo n.º 2
0
        private static string /*letter id*/ CreateLetterInternal(string board_id, string discussion_id,
                                                                 string creator, string words, Subtype subtype, string delta_flags)
        {
            string partition_key = SandId.CombineId(board_id, discussion_id);

            if (NextIdStore.GetLastId(Warehouse.DiscussionLoadTable, partition_key) >= HeartsConfiguration.MAX_NUM_OF_LETTERS_IN_A_DISCUSSION)
            {
                Util.ThrowBadRequestException("留言數超過上限(" + HeartsConfiguration.MAX_NUM_OF_LETTERS_IN_A_DISCUSSION + ")則。");
            }

            int    next_id   = NextIdStore.Next(Warehouse.DiscussionLoadTable, partition_key);                  // null reference exception for nonexistent board id.
            string letter_id = SandId.MakeLetterId(next_id);
            // if exception is thrown after getting id, the id is lost.

            DynamicTableEntity entity = new DynamicTableEntity(partition_key, letter_id);

            LetterConverter.CreateLetterEntity(entity, creator, words, subtype, delta_flags, board_id, discussion_id);
            //
            Warehouse.DiscussionLoadPond.Get(board_id, discussion_id).AddLetter(entity);
            Warehouse.DiscussionSummaryPond.Get(board_id, discussion_id).AddLetter(entity);

            Warehouse.DiscussionLoadTable.Execute(TableOperation.Insert(entity));
            //
            return(letter_id);
        }
Exemplo n.º 3
0
        public static void GetLastLetters(string board_id, string discussion_id, int cnt, Action <DynamicTableEntity> act)
        {
            string partition_key = SandId.CombineId(board_id, discussion_id);

            int last_id = NextIdStore.GetLastId(Warehouse.DiscussionLoadTable, partition_key);

            if (last_id != -1)
            {
                Warehouse.DiscussionLoadTable.EnumerateRowRange(partition_key, SandId.LETTER_ID_PREFIX, last_id - cnt + 1, cnt, act);
            }
        }
Exemplo n.º 4
0
        public static void GetLastDiscussions(string board_id, int cnt, Action <DynamicTableEntity> act)
        {
            string partition_key = board_id;

            int last_id = NextIdStore.GetLastId(Warehouse.DiscussionListTable, partition_key);

            if (last_id != -1)
            {
                Warehouse.DiscussionListTable.EnumerateRowRange(partition_key, SandId.DISCUSSION_ID_PREFIX, last_id - cnt + 1, cnt, act);
            }
        }
Exemplo n.º 5
0
        public static string /*selection id*/ CreateSelection(string selection_name)
        {
            int    next_id      = NextIdStore.Next(Warehouse.SelectionListTable, null);
            string selection_id = SandId.MakeSelectionId(next_id);

            DynamicTableEntity entity = new DynamicTableEntity(selection_id, EMPTY_ROW_KEY);

            entity["selectionname"] = new EntityProperty(selection_name);
            entity["boardlist"]     = new EntityProperty(string.Empty);

            CreatorConverter.FillEntity(entity, CreatorConverter.Status.Editor, null);

            Warehouse.SelectionListTable.Execute(TableOperation.Insert(entity));

            //don't work for child action. //HttpResponse.RemoveOutputCacheItem("/boardlist");
            Warehouse.BsMapPond.Notify();

            return(selection_id);
        }
Exemplo n.º 6
0
        public static string /*discussion id*/ CreateDiscussion(string board_id, string creator, string words, string heading,
                                                                string delta_flags, HttpFileCollectionBase files, string heading_delta_flags)
        {
            string partition_key = board_id;

            int    next_id       = NextIdStore.Next(Warehouse.DiscussionListTable, partition_key);
            string discussion_id = SandId.MakeDiscussionId(next_id);

            DynamicTableEntity entity = new DynamicTableEntity(partition_key, discussion_id);

            entity["heading"] = new EntityProperty(/*DiscussionLoadRoll.RemoveForeMeta*/ (heading));
            entity.OperateFlags(new FlagMergeOperation(heading_delta_flags));

            Warehouse.DiscussionListTable.Execute(TableOperation.Insert(entity));

            DiscussionLoadStore.CreateSkeleton(board_id, discussion_id);
            DiscussionLoadStore.CreateLetter(board_id, discussion_id, creator, heading, Subtype.h, heading_delta_flags, null);
            DiscussionLoadStore.CreateLetter(board_id, discussion_id, creator, words, Subtype.s, delta_flags, files);

            Warehouse.DiscussionListPond.Get(board_id).AddDiscussion(entity);

            return(discussion_id);
        }
Exemplo n.º 7
0
        public static void CreateSkeleton(string board_id, string discussion_id)
        {
            string partition_key = SandId.CombineId(board_id, discussion_id);

            NextIdStore.Create(Warehouse.DiscussionLoadTable, partition_key, 0);
        }
Exemplo n.º 8
0
        public static void CreateSkeleton(string board_id)
        {
            string partition_key = board_id;

            NextIdStore.Create(Warehouse.DiscussionListTable, partition_key, HeartsConfiguration.NEXT_ID_INITIAL_VALUE);
        }
Exemplo n.º 9
0
 public static void CreateSkeleton()
 {
     NextIdStore.CreateIfNotExists(Warehouse.SelectionListTable, null, HeartsConfiguration.NEXT_ID_INITIAL_VALUE);
 }