public void RegisterUpdateEvents() { EventHandler <BlogEventArgs> addOrUpdate = (s, e) => _taskQueue.QueueBackgroundWorkItem(Job.AddOrUpdateBlog(e)); ReplyController.OnAddPost += (s, e) => _taskQueue.QueueBackgroundWorkItem(Job.UpdatePostCount(e)); Controllers.App.ReplyController.OnAddPost += (s, e) => _taskQueue.QueueBackgroundWorkItem(Job.UpdatePostCount(e)); ReplyController.OnDeletePost += (s, e) => _taskQueue.QueueBackgroundWorkItem(Job.UpdatePostCount(e)); Controllers.App.ReplyController.OnDeletePost += (s, e) => _taskQueue.QueueBackgroundWorkItem(Job.UpdatePostCount(e)); AuditController.OnApproveBlog += addOrUpdate; AuditController.OnDenyBlog += addOrUpdate; BlogController.OnNewBlog += addOrUpdate; BlogController.OnDeleteBlog += (s, e) => { if (e.Deleted) { _taskQueue.QueueBackgroundWorkItem(Job.RemoveBlog(e)); } else { _taskQueue.QueueBackgroundWorkItem(Job.AddOrUpdateBlog(e)); } }; BlogController.OnEditBlog += addOrUpdate; BlogController.OnEditTags += (s, e) => _taskQueue.QueueBackgroundWorkItem(Job.UpdateBlogTag(e)); RatingUtil.OnRateBlog += (s, e) => _taskQueue.QueueBackgroundWorkItem(Job.UpdateBlogRate(e)); }
public void SendNoticeMsg(string noticeuser, NoticeType type, string actor, string content = null, string url = null) { if (noticeuser == actor) { return; } _taskQueue.QueueBackgroundWorkItem(Job.CreateJob(new SendNoticeArgs { Actor = actor, Content = content, NoticeUser = noticeuser, Type = type, Url = url })); _cache.Remove("unreadmsg" + noticeuser.ToLower()); }
public void log(string actor, string action, string target, string reason = null) { if (reason != null) { var pos = reason.IndexOf("原因:"); if (pos >= 0) { reason = reason.Substring(pos); } if (reason.Length > 100) { reason = reason.Substring(0, 100); } } if (target.Length > 100) { target = target.Substring(0, 100); } var log = new AdminLog { Action = action, Actor = actor, Target = target, Reason = reason, LogTime = DateTime.Now }; _taskQueue.QueueBackgroundWorkItem(Job.CreateJob(log)); }