private void FillForumsTree() { using (var dbMgr = _serviceProvider.CreateDBContext()) using (_forumsTree.UpdateScope(true)) { var forums = dbMgr .ServerForums() .Select(frm => new { frm.ID, frm.Name, frm.Descript }); foreach (var f in forums) { if (_excludeHash.Contains(f.ID)) { continue; } var tn = new TreeNode(ForumHelper.GetDisplayName(f.Name, f.Descript), 0, 0) { Tag = f.ID }; _forumsTree.Nodes.Add(tn); } } }
public void ExecuteSetMessagesRepliesAutoReadMark( ICommandContext context, int[] messageIds, bool isEnabled) { ForumHelper.SetMessageRepliesAutoReadMark( context, ForumMessageCommandHelper.GetMessages(context, messageIds).Cast <MsgBase>(), isEnabled); }
public void ExecuteSetMessagesReadMarkByDate(ICommandContext context) { using (var mmrf = new MarkMsgReadForm(context)) { var owner = context .GetRequiredService <IUIShell>() .GetMainWindowParent(); if (mmrf.ShowDialog(owner) != DialogResult.OK) { return; } var msgText = SR.Forum.MarkMessageCaption; var resText = string.Empty; // Заносим данные в замыкание, так как после диспоза формы часть // данный теряется. var forumIds = mmrf.MarkAllForums ? Enumerable.Empty <int>() : mmrf.ForumsIdsForMark; ProgressWorker.Run(context, false, pi => { pi.SetProgressText(msgText); context.LogInfo(msgText); var markCount = ForumHelper.MarkMessagesByDate( context, forumIds, mmrf.MarkAsRead, mmrf.BeforeDate, mmrf.AfterDate, mmrf.ExceptAnswersMe); resText = SR.Forum.MarkMessageResult.FormatStr( markCount, markCount.GetDeclension( SR.Forum.Message1, SR.Forum.Message2, SR.Forum.Message5)); context.LogInfo(resText); }, () => MessageBox.Show( owner, resText, ApplicationInfo.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information)); } }
public void ExecuteSetMessageReadMark( ICommandContext context, int[] messageIds, bool isRead, bool markChilds) { if (Features.Instance.ActiveFeature is Forum) { ForumDummyForm.Instance.StopMarkTimer(); } ForumHelper.MarkMsgRead( context, ForumMessageCommandHelper.GetMessages(context, messageIds).Cast <MsgBase>(), isRead, markChilds); }
public void ExecuteSetTopicReadMark(ICommandContext context, int[] messageIds, bool isRead) { if (Features.Instance.ActiveFeature is Forum) { ForumDummyForm.Instance.StopMarkTimer(); } ForumHelper.MarkMsgRead( context, ForumMessageCommandHelper .GetMessages(context, messageIds) .Select(msg => msg.Topic) .Cast <MsgBase>(), isRead, true); }
/// <summary> /// Восстанавливает избранное, прочитанное и маркеры... /// </summary> /// <param name="options">Опции восстановления.</param> public void RestoreState(RestoreStateOptions options) { const RestoreStateOptions noOptions = RestoreStateOptions.None; if (options == noOptions) { return; } var state = Deserialize(); // Восстанавливаем пометки... if ((options & RestoreStateOptions.Markers) != noOptions) { var clear = (options & RestoreStateOptions.ClearMarkers) != noOptions; RestoreMarkers( _serviceProvider, state.MarkedMessages, state.MarkedTopics, state.MaxMessageId, clear); } // Восстанавливаем Избранное if ((options & RestoreStateOptions.Favorites) != noOptions) { if ((options & RestoreStateOptions.ClearFavorites) != noOptions) { ClearFavorites(); } RestoreFavorites( _favManager.RootFolder, state.Favorites.Folders, state.Favorites.Links); } // Прочитанные сообщения if ((options & RestoreStateOptions.ReadedMessages) != noOptions) { if (state.UnreadMessages != null) { ForumHelper.MarkMessagesById(_serviceProvider, state.UnreadMessages, state.MaxMessageId); } } }
public void ExecuteSetAllMessagesInForumReadMark( ICommandContext context, int[] forumIds, bool isRead) { if (Config.Instance.ConfirmationConfig.ConfirmMarkAll && MessageBox.Show( context.GetRequiredService <IUIShell>().GetMainWindowParent(), SR.Forum.PromptMarkAll.FormatStr( isRead ? SR.Forum.PromptRead : SR.Forum.PromptUnread), ApplicationInfo.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { return; } ProgressWorker.Run( context, false, info => ForumHelper.SetForumsReadMark(context, GetForums(context, forumIds), isRead)); }
private void _markTimer_Elapsed(object sender, ElapsedEventArgs e) { _markTimer.Enabled = false; try { var msg = _tgMsgs.ActiveNode as IMsg; if (msg != null && msg.IsUnread) { if (_tgMsgs.SelectedNodes.Count == 1) { ForumHelper.MarkMsgRead( _serviceManager, _tgMsgs.SelectedNodes.Cast <MsgBase>(), true, false); } } } catch { // Если не сложилось, пробуем отложить операцию до лучших времен. _markTimer.Enabled = true; } }