public void EnableNews(int Level) { if (this.GroupK == 0) { this.IsNews = true; this.NewsLevel = Level; this.NewsModeratedByUsrK = Usr.Current.K; this.NewsModerationDateTime = DateTime.Now; this.NewsStatus = Thread.NewsStatusEnum.Done; this.Update(); this.NewsUsr.NewsPermissionLevel++; this.NewsUsr.Update(); Mailer m = new Mailer(); m.Subject = "Your recent news posting"; m.Body = "<p>Your news posting has been accepted.</p>"; m.Body += "<p>Your news level rises by 1.</p>"; m.Body += "<p>Each time you post news that's accepted, your news level goes up by 1. Posting news that is rejected by our moderators reduces your news level by 1.</p>"; m.Body += "<p>When you reach a news level 10, your news will go live straight away (without waiting for our moderators to check it).</p>"; m.Body += "<p><b>Your current news level is " + this.NewsUsr.NewsPermissionLevel + ".</b></p>"; m.RedirectUrl = this.Url(); m.TemplateType = Mailer.TemplateTypes.AnotherSiteUser; m.UsrRecipient = this.NewsUsr; m.Send(); } else { bool sendAlerts = false; if (this.NewsStatus.Equals(Thread.NewsStatusEnum.Recommended)) sendAlerts = true; this.IsNews = true; this.NewsLevel = 10; this.NewsModeratedByUsrK = Usr.Current.K; this.NewsModerationDateTime = DateTime.Now; this.NewsStatus = Thread.NewsStatusEnum.Done; this.Update(); if (sendAlerts) { Mailer m = new Mailer(); m.Subject = "Your recent group news posting"; m.Body = "<p>Your news group posting has been accepted.</p>"; m.RedirectUrl = this.Url(); m.TemplateType = Mailer.TemplateTypes.AnotherSiteUser; m.UsrRecipient = this.NewsUsr; m.Send(); SendNewsAlertsJob sendNewsAlertsJob = new SendNewsAlertsJob(this); sendNewsAlertsJob.AddJobToRunOnceFinished(new UpdateTotalParticipantsJob(this)); sendNewsAlertsJob.ExecuteAsynchronously(); } } }
private static void ThreadSendNewsAlerts(Thread parentThread) { #region SendNewsAlerts() try { if (parentThread.IsNews && parentThread.GroupK > 0) { SendNewsAlertsJob job = new SendNewsAlertsJob(parentThread); job.ExecuteSynchronously(); } } catch (Exception ex) { Bobs.Global.Log("64f76097-9bc6-4b63-a7a4-b52eb649534c", ex); } #endregion }