Clearing IContentManagerSession in SessionLocator

This commit is contained in:
Sebastien Ros
2014-09-18 15:38:42 -07:00
parent 65abba550f
commit a0e8fda8a2
7 changed files with 9 additions and 11 deletions

View File

@@ -42,7 +42,6 @@ namespace Orchard.Core.Scheduling.Services {
foreach (var taskEntry in taskEntries) {
_transactionManager.RequireNew();
_contentManager.Clear();
try {
// fetch the task

View File

@@ -89,7 +89,6 @@ namespace Orchard.Azure.MediaServices.Services.Assets {
pendingAsset.UploadState.BytesComplete = 0;
pendingAsset.UploadState.CompletedUtc = null;
_transactionManager.RequireNew();
_contentManager.Clear();
var assetProgressMoniker = Guid.NewGuid();
var assetCancellationTokenSource = new CancellationTokenSource();
@@ -186,7 +185,6 @@ namespace Orchard.Azure.MediaServices.Services.Assets {
if ((_clock.UtcNow - lastUpdateUtc).Seconds >= 5) {
progressAsset.UploadState.BytesComplete = progressInfo.Data.BytesTransferred;
_transactionManager.RequireNew();
_contentManager.Clear();
lastUpdateUtc = _clock.UtcNow;
}

View File

@@ -196,8 +196,7 @@ namespace Orchard.Indexing.Services {
}
else {
_transactionManager.RequireNew();
_contentManager.Clear();
}
}
} while (loop);
@@ -251,7 +250,6 @@ namespace Orchard.Indexing.Services {
}
else {
_transactionManager.RequireNew();
_contentManager.Clear();
}
}
while (loop);

View File

@@ -63,7 +63,6 @@ namespace Orchard.Recipes.RecipeHandlers {
//Create a new transaction for each batch
if (startIndex < elementDictionary.Count) {
_transactionManager.RequireNew();
_orchardServices.ContentManager.Clear();
}
}
}

View File

@@ -649,9 +649,6 @@ namespace Orchard.ContentManagement {
}
public void Clear() {
var session = _sessionLocator.Value.For(typeof(ContentItemRecord));
session.Clear();
_contentManagerSession().Clear();
}
public IContentQuery<ContentItem> Query() {

View File

@@ -6,6 +6,7 @@ using System.Linq;
using NHibernate;
using NHibernate.SqlCommand;
using NHibernate.Type;
using Orchard.ContentManagement;
using Orchard.Exceptions;
using Orchard.Logging;
using Orchard.Security;
@@ -14,13 +15,18 @@ namespace Orchard.Data {
public class SessionLocator : ISessionLocator, ITransactionManager, IDisposable {
private readonly ISessionFactoryHolder _sessionFactoryHolder;
private readonly IEnumerable<ISessionInterceptor> _interceptors;
private Func<IContentManagerSession> _contentManagerSession;
private ISession _session;
public SessionLocator(
ISessionFactoryHolder sessionFactoryHolder,
Func<IContentManagerSession> contentManagerSession,
IEnumerable<ISessionInterceptor> interceptors) {
_sessionFactoryHolder = sessionFactoryHolder;
_interceptors = interceptors;
_contentManagerSession = contentManagerSession;
Logger = NullLogger.Instance;
IsolationLevel = IsolationLevel.ReadCommitted;
}
@@ -73,6 +79,8 @@ namespace Orchard.Data {
_session.Close();
_session.Dispose();
_session = null;
_contentManagerSession().Clear();
}
}
}

View File

@@ -36,7 +36,6 @@ namespace Orchard.Tasks {
public void Sweep() {
foreach(var task in _tasks) {
try {
_contentManager.Clear();
_transactionManager.RequireNew();
task.Sweep();
}