Replace all UmbracoContext.Current.Application with ApplicationContext.Current
UmbracoContext.Current == is based on a web request, if any code executes on a background thread or non-request thread then UmbracoContext.Current is null!
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
if (string.IsNullOrWhiteSpace(memberGuid) == false)
|
||||
{
|
||||
var memberService = UmbracoContext.Current.Application.Services.MemberService;
|
||||
var memberService = ApplicationContext.Current.Services.MemberService;
|
||||
var member = memberService.GetByKey(new Guid(memberGuid));
|
||||
|
||||
if (member == null)
|
||||
|
||||
@@ -15,7 +15,6 @@ using OurUmbraco.Forum.Services;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace OurUmbraco.Forum.AntiSpam
|
||||
{
|
||||
@@ -39,7 +38,7 @@ namespace OurUmbraco.Forum.AntiSpam
|
||||
var reputationCurrent = member.GetValue<int>("reputationCurrent");
|
||||
member.SetValue("reputationCurrent", reputationCurrent >= 0 ? reputationCurrent - 1 : 0);
|
||||
|
||||
var memberService = UmbracoContext.Current.Application.Services.MemberService;
|
||||
var memberService = ApplicationContext.Current.Services.MemberService;
|
||||
memberService.Save(member);
|
||||
memberService.AssignRole(member.Id, "potentialspam");
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ namespace OurUmbraco.Forum.Api
|
||||
|
||||
if (memberId != 0)
|
||||
{
|
||||
var member = global::Umbraco.Web.UmbracoContext.Current.Application.Services.MemberService.GetById(memberId);
|
||||
var member = ApplicationContext.Current.Services.MemberService.GetById(memberId);
|
||||
|
||||
if (member != null)
|
||||
{
|
||||
@@ -502,7 +502,7 @@ namespace OurUmbraco.Forum.Api
|
||||
|
||||
if (memberId != 0)
|
||||
{
|
||||
var member = global::Umbraco.Web.UmbracoContext.Current.Application.Services.MemberService.GetById(memberId);
|
||||
var member = ApplicationContext.Current.Services.MemberService.GetById(memberId);
|
||||
|
||||
if (member != null)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OurUmbraco.Forum.EventHandlers
|
||||
&& member.Properties.Contains(Constants.Conventions.Member.IsApproved)
|
||||
&& member.IsApproved == false);
|
||||
|
||||
var memberService = UmbracoContext.Current.Application.Services.MemberService;
|
||||
var memberService = ApplicationContext.Current.Services.MemberService;
|
||||
foreach (var member in nonApprovedMembers)
|
||||
{
|
||||
// Adds test for member having an Id, if they don't then it's a NEW member,
|
||||
|
||||
@@ -11,6 +11,7 @@ using MarkdownSharp;
|
||||
using OurUmbraco.Forum.AntiSpam;
|
||||
using OurUmbraco.Forum.Library;
|
||||
using OurUmbraco.Forum.Models;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web;
|
||||
|
||||
@@ -143,14 +144,14 @@ namespace OurUmbraco.Forum.Extensions
|
||||
|
||||
public static bool DetectSpam(this Comment comment)
|
||||
{
|
||||
var member = UmbracoContext.Current.Application.Services.MemberService.GetById(comment.MemberId);
|
||||
var member = ApplicationContext.Current.Services.MemberService.GetById(comment.MemberId);
|
||||
comment.IsSpam = SpamChecker.IsSpam(member, comment.Body);
|
||||
return comment.IsSpam;
|
||||
}
|
||||
|
||||
public static bool DetectSpam(this Topic topic)
|
||||
{
|
||||
var member = UmbracoContext.Current.Application.Services.MemberService.GetById(topic.MemberId);
|
||||
var member = ApplicationContext.Current.Services.MemberService.GetById(topic.MemberId);
|
||||
topic.IsSpam = SpamChecker.IsSpam(member, string.Format("{0} {1}", topic.Title, topic.Body));
|
||||
return topic.IsSpam;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ using System.Web.Security;
|
||||
using RestSharp;
|
||||
using RestSharp.Deserializers;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web;
|
||||
@@ -183,7 +184,7 @@ namespace OurUmbraco.Forum.Library
|
||||
|
||||
if (spammer != null && spammer.TotalScore > PotentialSpammerThreshold)
|
||||
{
|
||||
var memberService = UmbracoContext.Current.Application.Services.MemberService;
|
||||
var memberService = ApplicationContext.Current.Services.MemberService;
|
||||
memberService.AssignRole(member.Id, SpamMemberGroupName);
|
||||
|
||||
spammer.MemberId = member.Id;
|
||||
|
||||
@@ -9,6 +9,7 @@ using OurUmbraco.Our;
|
||||
using OurUmbraco.Wiki.Extensions;
|
||||
using umbraco;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web;
|
||||
|
||||
@@ -134,7 +135,7 @@ namespace OurUmbraco.MarketPlace.NodeListing
|
||||
/// <param name="listingItem"></param>
|
||||
public void SaveOrUpdate(IListingItem listingItem)
|
||||
{
|
||||
var contentService = UmbracoContext.Current.Application.Services.ContentService;
|
||||
var contentService = ApplicationContext.Current.Services.ContentService;
|
||||
//check if this is a new listing or an existing one.
|
||||
var isUpdate = listingItem.Id != 0;
|
||||
var content = (isUpdate)
|
||||
@@ -261,7 +262,7 @@ namespace OurUmbraco.MarketPlace.NodeListing
|
||||
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
|
||||
var contribProjects = new List<IPublishedContent>();
|
||||
const string sql = @"SELECT * FROM projectContributors WHERE memberId=@memberId";
|
||||
var contribPackageIds = UmbracoContext.Current.Application.DatabaseContext.Database.Fetch<int>(sql, new { memberId });
|
||||
var contribPackageIds = ApplicationContext.Current.DatabaseContext.Database.Fetch<int>(sql, new { memberId });
|
||||
|
||||
foreach (var contribPackageId in contribPackageIds)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using OurUmbraco.MarketPlace.Interfaces;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace OurUmbraco.MarketPlace.Providers
|
||||
{
|
||||
@@ -10,7 +10,7 @@ namespace OurUmbraco.MarketPlace.Providers
|
||||
{
|
||||
public int GetProjectKarma(int projectId)
|
||||
{
|
||||
var db = UmbracoContext.Current.Application.DatabaseContext.Database;
|
||||
var db = ApplicationContext.Current.DatabaseContext.Database;
|
||||
var result = db.ExecuteScalar<int>("SELECT SUM(points) karma FROM powersProject WHERE id = @projectId", new { projectId = projectId });
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OurUmbraco.NotificationsWeb.EventHandlers
|
||||
|
||||
void ForumService_Created(object sender, ForumEventArgs e)
|
||||
{
|
||||
var content = Umbraco.Web.UmbracoContext.Current.Application.Services.ContentService.GetById(e.Forum.ParentId);
|
||||
var content = ApplicationContext.Current.Services.ContentService.GetById(e.Forum.ParentId);
|
||||
if (content.ContentType.Alias == "Project")
|
||||
{
|
||||
var owner = content.GetValue<int>("owner");
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace OurUmbraco.Our.Controllers
|
||||
memberService.AssignRole(member.Id, "newaccount");
|
||||
|
||||
var redirectPage = "/";
|
||||
var contentService = UmbracoContext.Current.Application.Services.ContentService;
|
||||
var contentService = ApplicationContext.Current.Services.ContentService;
|
||||
var rootNode = contentService.GetRootContent().OrderBy(x => x.SortOrder).First(x => x.ContentType.Alias == "Community");
|
||||
|
||||
var memberNode = rootNode.Children().FirstOrDefault(x => x.Name == "Member");
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OurUmbraco.Our.CustomHandlers {
|
||||
{
|
||||
if (e.Comment != null && e.Comment.MemberId > 0)
|
||||
{
|
||||
var ms = UmbracoContext.Current.Application.Services.MemberService;
|
||||
var ms = ApplicationContext.Current.Services.MemberService;
|
||||
var member = ms.GetById(e.Comment.MemberId);
|
||||
member.IncreaseForumPostCount();
|
||||
ms.Save(member);
|
||||
@@ -36,7 +36,7 @@ namespace OurUmbraco.Our.CustomHandlers {
|
||||
{
|
||||
if (e.Topic != null && e.Topic.MemberId > 0)
|
||||
{
|
||||
var ms = UmbracoContext.Current.Application.Services.MemberService;
|
||||
var ms = ApplicationContext.Current.Services.MemberService;
|
||||
var member = ms.GetById(e.Topic.MemberId);
|
||||
member.IncreaseForumPostCount();
|
||||
ms.Save(member);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OurUmbraco.Our.CustomHandlers
|
||||
|
||||
if (a.Alias == "ProjectUp")
|
||||
{
|
||||
var contentService = UmbracoContext.Current.Application.Services.ContentService;
|
||||
var contentService = ApplicationContext.Current.Services.ContentService;
|
||||
var content = contentService.GetById(e.ItemId);
|
||||
if (content.GetValue<bool>("approved") == false &&
|
||||
Xslt.Score(content.Id, "powersProject") >= 15)
|
||||
@@ -39,7 +39,7 @@ namespace OurUmbraco.Our.CustomHandlers
|
||||
|
||||
if (a.Alias == "ProjectUp" || a.Alias == "ProjectDown")
|
||||
{
|
||||
var contentService = UmbracoContext.Current.Application.Services.ContentService;
|
||||
var contentService = ApplicationContext.Current.Services.ContentService;
|
||||
var content = contentService.GetById(e.ItemId);
|
||||
|
||||
e.ReceiverId = content.GetValue<int>("owner");
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var macroService = UmbracoContext.Current.Application.Services.MacroService;
|
||||
var macroService = ApplicationContext.Current.Services.MacroService;
|
||||
var macroAlias = "MembersActivate";
|
||||
if (macroService.GetByAlias(macroAlias) == null)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ namespace OurUmbraco.Our
|
||||
macro.Save();
|
||||
}
|
||||
|
||||
var contentService = UmbracoContext.Current.Application.Services.ContentService;
|
||||
var contentService = ApplicationContext.Current.Services.ContentService;
|
||||
var rootNode = contentService.GetRootContent().OrderBy(x => x.SortOrder).First(x => x.ContentType.Alias == "Community");
|
||||
|
||||
var memberNode = rootNode.Children().FirstOrDefault(x => x.Name == "Member");
|
||||
@@ -110,7 +110,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var macroService = UmbracoContext.Current.Application.Services.MacroService;
|
||||
var macroService = ApplicationContext.Current.Services.MacroService;
|
||||
var macroAlias = "AntiSpam";
|
||||
if (macroService.GetByAlias(macroAlias) == null)
|
||||
{
|
||||
@@ -126,7 +126,7 @@ namespace OurUmbraco.Our
|
||||
macro.Save();
|
||||
}
|
||||
|
||||
var contentService = UmbracoContext.Current.Application.Services.ContentService;
|
||||
var contentService = ApplicationContext.Current.Services.ContentService;
|
||||
var rootNode = contentService.GetRootContent().OrderBy(x => x.SortOrder).First(x => x.ContentType.Alias == "Community");
|
||||
|
||||
var antiSpamPageName = "AntiSpam";
|
||||
@@ -156,7 +156,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var macroService = UmbracoContext.Current.Application.Services.MacroService;
|
||||
var macroService = ApplicationContext.Current.Services.MacroService;
|
||||
var macroAlias = "CommunityHome";
|
||||
if (macroService.GetByAlias(macroAlias) == null)
|
||||
{
|
||||
@@ -191,7 +191,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var contentTypeService = UmbracoContext.Current.Application.Services.ContentTypeService;
|
||||
var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
|
||||
var releaseContentType = contentTypeService.GetContentType("Release");
|
||||
var propertyTypeAlias = "overrideYouTrackDescription";
|
||||
if (releaseContentType.PropertyTypeExists(propertyTypeAlias) == false)
|
||||
@@ -230,7 +230,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var contentTypeService = UmbracoContext.Current.Application.Services.ContentTypeService;
|
||||
var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
|
||||
var projectContentType = contentTypeService.GetContentType("Project");
|
||||
var propertyTypeAlias = "worksOnUaaS";
|
||||
if (projectContentType.PropertyTypeExists(propertyTypeAlias) == false)
|
||||
@@ -260,7 +260,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var contentTypeService = UmbracoContext.Current.Application.Services.ContentTypeService;
|
||||
var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
|
||||
var projectContentType = contentTypeService.GetContentType("Forum");
|
||||
var propertyTypeAlias = "archived";
|
||||
if (projectContentType.PropertyTypeExists(propertyTypeAlias) == false)
|
||||
@@ -290,7 +290,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var contentTypeService = UmbracoContext.Current.Application.Services.ContentTypeService;
|
||||
var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
|
||||
var communityContentType = contentTypeService.GetContentType("Community");
|
||||
var propertyTypeAlias = "homeOnlyBanner";
|
||||
if (communityContentType.PropertyTypeExists(propertyTypeAlias) == false)
|
||||
@@ -321,7 +321,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var userService = UmbracoContext.Current.Application.Services.UserService;
|
||||
var userService = ApplicationContext.Current.Services.UserService;
|
||||
var rootUser = userService.GetUserById(0);
|
||||
if (rootUser == null)
|
||||
return;
|
||||
@@ -330,7 +330,7 @@ namespace OurUmbraco.Our
|
||||
if (rootUser.Email == "pph@umrbaco.org")
|
||||
return;
|
||||
|
||||
var db = UmbracoContext.Current.Application.DatabaseContext.Database;
|
||||
var db = ApplicationContext.Current.DatabaseContext.Database;
|
||||
db.Execute("DELETE FROM [umbracoUser] WHERE id != 0");
|
||||
db.Execute("DELETE FROM [umbracoUser2app] WHERE [user] != 0");
|
||||
db.Execute("DBCC CHECKIDENT ('dbo.umbracoUser');");
|
||||
@@ -363,7 +363,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var contentTypeService = UmbracoContext.Current.Application.Services.ContentTypeService;
|
||||
var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
|
||||
var releaseCompareAlias = "ReleaseCompare";
|
||||
var compareContentType = contentTypeService.GetContentType(releaseCompareAlias);
|
||||
if (compareContentType == null)
|
||||
@@ -393,7 +393,7 @@ namespace OurUmbraco.Our
|
||||
Content = templateContent
|
||||
};
|
||||
|
||||
var fileService = UmbracoContext.Current.Application.Services.FileService;
|
||||
var fileService = ApplicationContext.Current.Services.FileService;
|
||||
|
||||
var masterTemplate = fileService.GetTemplate("Master");
|
||||
releaseCompareTemplate.SetMasterTemplate(masterTemplate);
|
||||
@@ -406,7 +406,7 @@ namespace OurUmbraco.Our
|
||||
|
||||
contentTypeService.Save(compareContentType);
|
||||
|
||||
var contentService = UmbracoContext.Current.Application.Services.ContentService;
|
||||
var contentService = ApplicationContext.Current.Services.ContentService;
|
||||
var rootNode = contentService.GetRootContent().OrderBy(x => x.SortOrder).First(x => x.ContentType.Alias == "Community");
|
||||
if (rootNode == null)
|
||||
return;
|
||||
@@ -424,7 +424,7 @@ namespace OurUmbraco.Our
|
||||
compareContent.Template = releaseCompareTemplate;
|
||||
contentService.SaveAndPublishWithStatus(compareContent);
|
||||
|
||||
var macroService = UmbracoContext.Current.Application.Services.MacroService;
|
||||
var macroService = ApplicationContext.Current.Services.MacroService;
|
||||
const string macroAlias = "ReleasesDropdown";
|
||||
if (macroService.GetByAlias(macroAlias) == null)
|
||||
{
|
||||
@@ -458,7 +458,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var contentService = UmbracoContext.Current.Application.Services.ContentService;
|
||||
var contentService = ApplicationContext.Current.Services.ContentService;
|
||||
var rootContent = contentService.GetRootContent().FirstOrDefault();
|
||||
if (rootContent != null)
|
||||
{
|
||||
@@ -490,7 +490,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var macroService = UmbracoContext.Current.Application.Services.MacroService;
|
||||
var macroService = ApplicationContext.Current.Services.MacroService;
|
||||
var macro = macroService.GetByAlias("MemberSignup");
|
||||
macro.ControlType = "";
|
||||
macro.ScriptPath = "~/Views/MacroPartials/Members/Register.cshtml";
|
||||
@@ -515,7 +515,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var db = UmbracoContext.Current.Application.DatabaseContext.Database;
|
||||
var db = ApplicationContext.Current.DatabaseContext.Database;
|
||||
db.Execute("ALTER TABLE [wikiFiles] ADD [minimumVersionStrict] VARCHAR(50)");
|
||||
|
||||
string[] lines = { "" };
|
||||
@@ -537,7 +537,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var contentService = UmbracoContext.Current.Application.Services.ContentService;
|
||||
var contentService = ApplicationContext.Current.Services.ContentService;
|
||||
var rootContent = contentService.GetRootContent().FirstOrDefault();
|
||||
if (rootContent != null)
|
||||
{
|
||||
@@ -574,7 +574,7 @@ namespace OurUmbraco.Our
|
||||
if (File.Exists(path))
|
||||
return;
|
||||
|
||||
var db = UmbracoContext.Current.Application.DatabaseContext.Database;
|
||||
var db = ApplicationContext.Current.DatabaseContext.Database;
|
||||
db.Execute("ALTER TABLE [forumTopics] ADD [markAsSolutionReminderSent] [BIT] NULL DEFAULT ((0))");
|
||||
|
||||
string[] lines = { "" };
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace OurUmbraco.Our.usercontrols
|
||||
memberService.AssignRole(member.Id, "newaccount");
|
||||
|
||||
var redirectPage = "/";
|
||||
var contentService = UmbracoContext.Current.Application.Services.ContentService;
|
||||
var contentService = ApplicationContext.Current.Services.ContentService;
|
||||
var rootNode = contentService.GetRootContent().OrderBy(x => x.SortOrder).First(x => x.ContentType.Alias == "Community");
|
||||
|
||||
var memberNode = rootNode.Children().FirstOrDefault(x => x.Name == "Member");
|
||||
|
||||
@@ -5,6 +5,7 @@ using OurUmbraco.MarketPlace.Interfaces;
|
||||
using OurUmbraco.Our;
|
||||
using OurUmbraco.Wiki.BusinessLogic;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Web;
|
||||
|
||||
@@ -61,7 +62,7 @@ namespace OurUmbraco.Project
|
||||
|
||||
var packageFileType = (FileType)Enum.Parse(typeof(FileType), (string)fileType , true);
|
||||
// TODO: Don't know how else to get the bloody version
|
||||
var version = UmbracoContext.Current.Application.Services.ContentService.GetById(p.Id).Version;
|
||||
var version = ApplicationContext.Current.Services.ContentService.GetById(p.Id).Version;
|
||||
mediaProvider.CreateFile(fileName, version, mem.UniqueId, file, packageFileType, v, dotNetVersion, trust);
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user