public static void EditLetter(string board_id, string discussion_id, string letter_id, string editor, string words, string delta_flags, HttpFileCollectionBase files) { string partition_key = SandId.CombineId(board_id, discussion_id); TableResult result = Warehouse.DiscussionLoadTable.Execute(TableOperation.Retrieve(partition_key, letter_id)); DynamicTableEntity entity = (DynamicTableEntity)result.Result; GroupStore.CheckEditRight(board_id, discussion_id, entity); HashSet <string> files_set = new HashSet <string>(); words = processUploadFiles(words, files, files_set); words = processWords(words); claimFiles(words, SandId.CombineId(board_id, discussion_id, letter_id), files_set); // if (entity != null) // let it throw null reference exception. int ec = RevisionStore.IncreaseEditCount(entity); RevisionStore.CreateRevision(entity, board_id, discussion_id, letter_id, ec); LetterConverter.EditLetterEntity(entity, editor, words, delta_flags, board_id, discussion_id); Warehouse.DiscussionLoadTable.Execute(TableOperation.Replace(entity)); // Throws StorageException ((412) Precondition Failed) if the entity is modified in between. Warehouse.DiscussionLoadPond.Notify(board_id, discussion_id); Warehouse.DiscussionSummaryPond.Notify(board_id, discussion_id); HttpResponse.RemoveOutputCacheItem("/discussionload/" + board_id + "/" + discussion_id); }
public static ControlHistory ControlLetter(string board_id, string discussion_id, string letter_id, string delta_flags) { string partition_key = SandId.CombineId(board_id, discussion_id); // todo: select only needed properties. TableResult result = Warehouse.DiscussionLoadTable.Execute(TableOperation.Retrieve(partition_key, letter_id)); DynamicTableEntity entity = (DynamicTableEntity)result.Result; // permanent deleting twice is not blocked. GroupStore.CheckControlRight(board_id, discussion_id, letter_id, ref delta_flags, entity); int ec = RevisionStore.IncreaseEditCount(entity); RevisionStore.CreateRevision(entity, board_id, discussion_id, letter_id, ec); int prev_report_cnt = SandFlags.GetNumber(entity.GetFlags(), SandFlags.MT_REPORT); LetterConverter.ModifyLetterFlags(entity, null, delta_flags); int new_report_cnt = SandFlags.GetNumber(entity.GetFlags(), SandFlags.MT_REPORT); Warehouse.DiscussionLoadTable.Execute(TableOperation.Replace(entity)); // Throws StorageException ((412) Precondition Failed) if the entity is modified in between. Warehouse.DiscussionLoadPond.Notify(board_id, discussion_id); Warehouse.DiscussionSummaryPond.Notify(board_id, discussion_id); HttpResponse.RemoveOutputCacheItem("/discussionload/" + board_id + "/" + discussion_id); return(new ControlHistory { ReportCount = new_report_cnt - prev_report_cnt }); }
public static void CheckControlRight(string board_id, string discussion_id, string letter_id, ref string delta_flags, DynamicTableEntity entity) { Subtype subtype = LetterConverter.GetSubtype(entity); if (subtype == Subtype.d) { Util.ThrowUnauthorizedException("不能修改的類型。"); } bool auto_unreport = false; if (SandFlags.Check(delta_flags, SandFlags.MT_PERMANENT_DELETE, 1)) { GroupStore.CheckPermanentDeleteRight(board_id, discussion_id, letter_id, entity); auto_unreport = true; } int delete_num = SandFlags.GetNumber(delta_flags, SandFlags.MT_DELETED); if (delete_num == 1 || delete_num == -1) { //bool is_undelete = SandFlags.Check(delta_flags, SandFlags.DELETED_FLAG_CHAR, -1); int user_level = GroupStore.CheckDeleteRight(board_id, discussion_id, letter_id, entity, delete_num == -1); //delta_flags = SandFlags.DELETED_FLAG_CHAR + (delete_num * user_level).ToString(); //delta_flags = SandFlags.MultiplyNumber(delta_flags, SandFlags.DELETED_FLAG_CHAR, user_level); delta_flags = SandFlags.Operate(delta_flags, new FlagOperation { type = FlagOperation.Type.Multiply, MetaTitle = SandFlags.MT_DELETED, N = user_level }); string current_flags = entity.GetFlags(); SandFlags.CheckLevel(current_flags, SandFlags.MT_DELETED, delta_flags); auto_unreport = true; } if (SandFlags.Check(delta_flags, SandFlags.MT_REPORT, 0)) { GroupStore.CheckUnreportRight(board_id); } else if (SandFlags.Check(delta_flags, SandFlags.MT_REPORT, 1)) { } else { if (auto_unreport) { delta_flags = SandFlags.Add(delta_flags, SandFlags.MT_REPORT, 0); } } }
public BoardSetting(string board_id) { BoardId = board_id; BoardName = Warehouse.BsMapPond.Get().GetBoardName(board_id); string flags = BoardInfoStore.GetBoardFlags(board_id); this.LowKey = SandFlags.Check(flags, SandFlags.MT_LOW_KEY, 1); #if ACCOUNT_USING_SQL g10 = GroupStore.GetBoardGroup(board_id, GroupStore.ChairOwnerGroupName, out g10UserIds); g11 = GroupStore.GetBoardGroup(board_id, GroupStore.ViceOwnerGroupName, out g11UserIds); g12 = GroupStore.GetBoardGroup(board_id, GroupStore.InsiderGroupName, out g12UserIds); #endif // Output = JsonConvert.SerializeObject(this); // the ","Output":null" will also be written into Output. }