public NoteRoll(string room_name) { DateTime date = DateTime.Now; #if OLD for (int i = 4; i >= 0; i--) { NoteStore.GetNotes(room_name, date.AddDays(-i), addNote /*entity => addNote(entity)*/); } #else int remaining = 100; int[] counts = new int[5]; int[] starts = new int[counts.Length]; for (int i = 0; i < counts.Length; i++) { int cnt = NoteStore.GetNumberOfNotes(room_name, date.AddDays(-i)); counts[i] = Math.Min(cnt, remaining); starts[i] = cnt - counts[i]; remaining -= counts[i]; } for (int i = counts.Length - 1; i >= 0; i--) { if (counts[i] > 0) { NoteStore.GetLastNotes(room_name, date.AddDays(-i), starts[i], counts[i], AddNote); } } #endif }
public static void AddNote(string room_name, NoteInfo info) { NoteStore.AddNote(room_name, info); NoteRoll obj = (NoteRoll)HttpRuntime.Cache.Get(key(room_name)); if (obj != null) { obj.AddNote(info); } }