Scope - forgot to complete some scopes

This commit is contained in:
Stephan
2017-02-14 09:17:24 +01:00
parent 55c5b41693
commit 507d7dd4f0
6 changed files with 21 additions and 12 deletions

View File

@@ -1604,7 +1604,6 @@ namespace Umbraco.Core.Services
// fixme mess!
using (var scope = UowProvider.ScopeProvider.CreateScope())
{
using (var uow = UowProvider.GetUnitOfWork())
{
if (uow.Events.DispatchCancelable(Copying, this, new CopyEventArgs<IContent>(content, copy, parentId)))

View File

@@ -756,6 +756,7 @@ namespace Umbraco.Core.Services
using (var scope = UowProvider.ScopeProvider.CreateScope()) // fixme what a mess
{
scope.Events.Dispatch(SavedContentType, this, new SaveEventArgs<IContentType>(contentType, false));
scope.Complete();
}
Audit(AuditType.Save, "Save ContentType performed by user", userId, contentType.Id);
}
@@ -800,8 +801,9 @@ namespace Umbraco.Core.Services
using (var scope = UowProvider.ScopeProvider.CreateScope()) // fixme what a mess
{
scope.Events.Dispatch(SavedContentType, this, new SaveEventArgs<IContentType>(asArray, false));
scope.Complete();
}
Audit(AuditType.Save, "Save ContentTypes performed by user", userId, -1);
Audit(AuditType.Save, "Save ContentTypes performed by user", userId, -1);
}
/// <summary>
@@ -1211,6 +1213,7 @@ namespace Umbraco.Core.Services
using (var scope = UowProvider.ScopeProvider.CreateScope()) // fixme what a mess
{
scope.Events.Dispatch(SavedMediaType, this, new SaveEventArgs<IMediaType>(mediaType, false));
scope.Complete();
}
Audit(AuditType.Save, "Save MediaType performed by user", userId, mediaType.Id);
}
@@ -1255,6 +1258,7 @@ namespace Umbraco.Core.Services
using (var scope = UowProvider.ScopeProvider.CreateScope()) // fixme what a mess
{
scope.Events.Dispatch(SavedMediaType, this, new SaveEventArgs<IMediaType>(asArray, false));
scope.Complete();
}
Audit(AuditType.Save, "Save MediaTypes performed by user", userId, -1);
}

View File

@@ -17,7 +17,7 @@ namespace Umbraco.Core.Services
private readonly IMemberService _memberService;
private static readonly ReaderWriterLockSlim Locker = new ReaderWriterLockSlim();
public MemberTypeService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, ILogger logger, IEventMessagesFactory eventMessagesFactory, IMemberService memberService)
: base(provider, repositoryFactory, logger, eventMessagesFactory)
@@ -110,7 +110,7 @@ namespace Umbraco.Core.Services
public void Save(IEnumerable<IMemberType> memberTypes, int userId = 0)
{
var asArray = memberTypes.ToArray();
using (new WriteLock(Locker))
{
using (var uow = UowProvider.GetUnitOfWork())
@@ -137,7 +137,7 @@ namespace Umbraco.Core.Services
uow.Events.Dispatch(Saved, this, new SaveEventArgs<IMemberType>(asArray, false));
}
}
}
public void Delete(IMemberType memberType, int userId = 0)
@@ -167,7 +167,7 @@ namespace Umbraco.Core.Services
public void Delete(IEnumerable<IMemberType> memberTypes, int userId = 0)
{
var asArray = memberTypes.ToArray();
using (new WriteLock(Locker))
{
using (var scope = UowProvider.ScopeProvider.CreateScope())

View File

@@ -79,10 +79,11 @@ namespace Umbraco.Web.Scheduling
// running on a background task, and Log.CleanLogs uses the old SqlHelper,
// better wrap in a scope and ensure it's all cleaned up and nothing leaks
using (ApplicationContext.Current.ScopeProvider.CreateScope())
using (var scope = ApplicationContext.Current.ScopeProvider.CreateScope())
using (DisposableTimer.DebugDuration<LogScrubber>("Log scrubbing executing", "Log scrubbing complete"))
{
Log.CleanLogs(GetLogScrubbingMaximumAge(_settings));
scope.Complete();
}
return true; // repeat

View File

@@ -85,10 +85,11 @@ namespace Umbraco.Web.Scheduling
// running on a background task, requires its own (safe) scope
// (GetAuthenticationHeaderValue uses UserService to load the current user, hence requires a database)
// (might not need a scope but we don't know really)
using (ApplicationContext.Current.ScopeProvider.CreateScope())
using (var scope = ApplicationContext.Current.ScopeProvider.CreateScope())
{
//pass custom the authorization header
request.Headers.Authorization = AdminTokenAuthorizeAttribute.GetAuthenticationHeaderValue(_appContext);
scope.Complete();
}
var result = await wc.SendAsync(request, token);

View File

@@ -57,7 +57,7 @@ namespace UmbracoExamine.DataServices
[Obsolete("This should no longer be used, latest content will be indexed by using the IContentService directly")]
public XDocument GetLatestContentByXPath(string xpath)
{
using (ApplicationContext.Current.ScopeProvider.CreateScope())
using (var scope = ApplicationContext.Current.ScopeProvider.CreateScope())
{
var xmlContent = XDocument.Parse("<content></content>");
var rootContent = _applicationContext.Services.ContentService.GetRootContent();
@@ -67,6 +67,7 @@ namespace UmbracoExamine.DataServices
xmlContent.Root.Add(c.ToDeepXml(_applicationContext.Services.PackagingService));
}
var result = ((IEnumerable)xmlContent.XPathEvaluate(xpath)).Cast<XElement>();
scope.Complete();
return result.ToXDocument();
}
}
@@ -79,9 +80,11 @@ namespace UmbracoExamine.DataServices
/// <returns></returns>
public bool IsProtected(int nodeId, string path)
{
using (ApplicationContext.Current.ScopeProvider.CreateScope())
using (var scope = ApplicationContext.Current.ScopeProvider.CreateScope())
{
return _applicationContext.Services.PublicAccessService.IsProtected(path.EnsureEndsWith("," + nodeId));
var ret = _applicationContext.Services.PublicAccessService.IsProtected(path.EnsureEndsWith("," + nodeId));
scope.Complete();
return ret;
}
}
@@ -92,11 +95,12 @@ namespace UmbracoExamine.DataServices
public IEnumerable<string> GetAllUserPropertyNames()
{
using (ApplicationContext.Current.ScopeProvider.CreateScope())
using (var scope = ApplicationContext.Current.ScopeProvider.CreateScope())
{
try
{
var result = _applicationContext.DatabaseContext.Database.Fetch<string>("select distinct alias from cmsPropertyType order by alias");
scope.Complete();
return result;
}
catch (Exception ex)