void CommentScoring(object sender, ActionEventArgs e) { Action a = (Action)sender; if (a.Alias == "LikeComment" || a.Alias == "DisLikeComment" || a.Alias == "TopicSolved") { int score = Xslt.Score(e.ItemId, a.DataBaseTable); //we then add the sum of the total score to the Data.SqlHelper.ExecuteNonQuery("UPDATE forumComments SET score = @score WHERE id = @id", Data.SqlHelper.CreateParameter("@id", e.ItemId), Data.SqlHelper.CreateParameter("@score", score)); } }
void TopicScoring(object sender, ActionEventArgs e) { if (!e.Cancel) { Action a = (Action)sender; if (a.Alias == "LikeTopic" || a.Alias == "DisLikeTopic") { int topicScore = Xslt.Score(e.ItemId, a.DataBaseTable); //this uses a non-standard coloumn in the forum schema, so this is added manually.. Data.SqlHelper.ExecuteNonQuery("UPDATE forumTopics SET score = @score WHERE id = @id", Data.SqlHelper.CreateParameter("@id", e.ItemId), Data.SqlHelper.CreateParameter("@score", topicScore)); } } }
void Action_AfterPerform(object sender, ActionEventArgs e) { Action a = (Action)sender; if (a.Alias == "ProjectUp") { var contentService = ApplicationContext.Current.Services.ContentService; var content = contentService.GetById(e.ItemId); if (content.GetValue <bool>("approved") == false && Xslt.Score(content.Id, "powersProject") >= 15) { content.SetValue("approved", true); contentService.SaveAndPublishWithStatus(content); } } }
void CommentScoring(object sender, ActionEventArgs e) { var action = (Action)sender; if (action.Alias != "LikeComment" && action.Alias != "DisLikeComment" && action.Alias != "TopicSolved") { return; } var score = Xslt.Score(e.ItemId, action.DataBaseTable); //we then add the sum of the total score to the using (var sqlHelper = Application.SqlHelper) { sqlHelper.ExecuteNonQuery("UPDATE forumComments SET score = @score WHERE id = @id", sqlHelper.CreateParameter("@id", e.ItemId), sqlHelper.CreateParameter("@score", score)); } }
void Document_BeforePublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e) { if (sender.ContentType.Alias == "Project") { //ensure that packages have a guid if (sender.getProperty("packageGuid") != null && String.IsNullOrEmpty(sender.getProperty("packageGuid").Value.ToString())) { sender.getProperty("packageGuid").Value = Guid.NewGuid().ToString(); sender.Save(); } //if the score is above the minimum, set the approved variable int score = Xslt.Score(sender.Id, "powersProject"); if (score >= 15) { sender.getProperty("approved").Value = true; sender.Save(); } //this ensures the package stores it's compatible versions on the node itself, so we save a ton of sql calls if (sender.getProperty("compatibleVersions") != null) { List <string> compatibleVersions = new List <string>(); foreach (WikiFile wf in WikiFile.CurrentFiles(sender.Id)) { if (wf.FileType == "package") { foreach (var ver in wf.Versions) { if (!compatibleVersions.Contains(ver.Version)) { compatibleVersions.Add(ver.Version); } } } } string _compatibleVersions = string.Join(",", compatibleVersions.ToArray()); sender.getProperty("compatibleVersions").Value = "saved," + _compatibleVersions; } } }
void TopicScoring(object sender, ActionEventArgs e) { if (e.Cancel) { return; } var action = (Action)sender; if (action.Alias != "LikeTopic" && action.Alias != "DisLikeTopic") { return; } var topicScore = Xslt.Score(e.ItemId, action.DataBaseTable); using (var sqlHelper = Application.SqlHelper) { //this uses a non-standard coloumn in the forum schema, so this is added manually.. sqlHelper.ExecuteNonQuery("UPDATE forumTopics SET score = @score WHERE id = @id", sqlHelper.CreateParameter("@id", e.ItemId), sqlHelper.CreateParameter("@score", topicScore)); } }