public void SetMessageMarked(bool isMarked) { using (_dbManager.GetLock().GetWriterLock()) { DatabaseManager.SetMessageMarked(ServiceProvider, this, isMarked); SetMarked(isMarked); } }
// TODO: Intensive refactoring required! private void LoadData() //FillForums { using (_dbManager.GetLock().GetWriterLock()) using (var db = _dbManager.CreateDBContext()) { if (BeforeLoadData != null) { BeforeLoadData(this, EventArgs.Empty); } var newLiveBehs = new List <IDisposable>(); var newIdHash = new Dictionary <int, Forum>(); //var forums = _dbManager.GetAccessor<IForumDataAccessor>().GetSubscribedForumList(); var forums = LoadSubscribedForums(db); foreach (var forum in forums) { forum._parent = this; newLiveBehs.Add(forum.ActivateLiveBehavior()); newIdHash[forum.ID] = forum; } var list = LoadServerForums(db); var unsubscribedForums = new List <Forum>(); foreach (var forum in list) { if (newIdHash.ContainsKey(forum.ID)) { continue; } newLiveBehs.Add(forum.ActivateLiveBehavior()); unsubscribedForums.Add(forum); newIdHash.Add(forum.ID, forum); } var oldForums = new List <Forum>(_unsubscribedFolder.Cast <Forum>()); if (ForumList != null) { oldForums.AddRange(ForumList); } ForumList = forums.ToArray(); _unsubscribedFolder.Clear(); foreach (var forum in unsubscribedForums) { _unsubscribedFolder.Add(forum); } _forumsIdHash = newIdHash; if (_forumLiveBehaviors != null) { _forumLiveBehaviors.DisposeAll(); } _forumLiveBehaviors = newLiveBehs; } }