mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-18 17:47:54 +08:00
Merge branch '1.9.x' into dev
Conflicts: README.md
This commit is contained in:
@@ -23,8 +23,8 @@ Our mission is to empower our users and foster a dedicated and diverse community
|
||||
There are many ways you can [contribute to Orchard](http://orchardproject.net/contribution): you can [fix bugs](https://github.com/OrchardCMS/Orchard/issues), contribute modules and themes to [our gallery](http://gallery.orchardproject.net/), [write documentation](https://github.com/OrchardCMS/OrchardDoc), [translate Orchard](http://orchardproject.net/localize), or answer questions [on our forums](http://orchard.codeplex.com/discussions) and [on Stack Overflow](http://stackoverflow.com/questions/tagged/orchardcms).
|
||||
|
||||
## Project Status
|
||||
Orchard is currently in version 1.9. We invite participation by the developer community in shaping the project’s direction, so that we can publicly validate our designs and development approach.
|
||||
Our 1.9 release is available from [our Downloads page](https://github.com/OrchardCMS/Orchard/releases), and is easy to [Install Orchard using the Web Platform Installer](http://www.orchardproject.net/docs/Installing-Orchard.ashx). We encourage interested developers to check out the source code on the Orchard Github site and get involved with the project.
|
||||
Orchard is currently in version 1.9.1. We invite participation by the developer community in shaping the project’s direction, so that we can publicly validate our designs and development approach.
|
||||
Our 1.9.1 release is available from our Downloads page, and is easy to [Install Orchard using the Web Platform Installer](http://www.orchardproject.net/docs/Installing-Orchard.ashx). We encourage interested developers to check out the source code on the Orchard Github site and get involved with the project.
|
||||
|
||||
* [Download the latest release](https://github.com/OrchardCMS/Orchard/releases)
|
||||
* [Feature roadmap](http://www.orchardproject.net/docs/feature-roadmap.ashx)
|
||||
|
@@ -19,6 +19,7 @@ using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Security;
|
||||
using Orchard.Tests.ContentManagement;
|
||||
using Orchard.Tests.Modules;
|
||||
using Orchard.Tests.Stubs;
|
||||
using Orchard.UI.Notify;
|
||||
@@ -34,7 +35,6 @@ namespace Orchard.Core.Tests.Body {
|
||||
builder.RegisterType<Signals>().As<ISignals>();
|
||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
||||
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
|
||||
builder.RegisterInstance(new Mock<INotifier>().Object);
|
||||
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
|
||||
|
@@ -85,6 +85,7 @@
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\lib\sqlce\System.Data.SqlServerCe.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
@@ -35,7 +35,6 @@ namespace Orchard.Core.Tests.Scheduling {
|
||||
public override void Register(ContainerBuilder builder) {
|
||||
_handler = new StubTaskHandler();
|
||||
builder.RegisterInstance(new Mock<IOrchardServices>().Object);
|
||||
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
|
||||
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
|
||||
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
|
||||
builder.RegisterType<Signals>().As<ISignals>();
|
||||
|
@@ -13,6 +13,7 @@ using Orchard.Core.Settings.Metadata;
|
||||
using Orchard.Core.Settings.Metadata.Records;
|
||||
using Orchard.Data;
|
||||
using Orchard.Tests;
|
||||
using Orchard.Tests.ContentManagement;
|
||||
using Orchard.Tests.Stubs;
|
||||
using Orchard.Tests.Utility;
|
||||
|
||||
@@ -23,6 +24,7 @@ namespace Orchard.Core.Tests.Settings.Metadata {
|
||||
private ISessionFactory _sessionFactory;
|
||||
private ISession _session;
|
||||
private IContainer _container;
|
||||
private ITransactionManager _transactionManager;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void InitFixture() {
|
||||
@@ -39,6 +41,17 @@ namespace Orchard.Core.Tests.Settings.Metadata {
|
||||
|
||||
[SetUp]
|
||||
public void Init() {
|
||||
_session = _sessionFactory.OpenSession();
|
||||
foreach (var killType in new[] { typeof(ContentTypeDefinitionRecord), typeof(ContentPartDefinitionRecord), typeof(ContentFieldDefinitionRecord) }) {
|
||||
foreach (var killRecord in _session.CreateCriteria(killType).List()) {
|
||||
_session.Delete(killRecord);
|
||||
}
|
||||
}
|
||||
_session.Flush();
|
||||
_session.Close();
|
||||
_session.Dispose();
|
||||
_session = _sessionFactory.OpenSession();
|
||||
|
||||
var builder = new ContainerBuilder();
|
||||
builder.RegisterAutoMocking();
|
||||
builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
|
||||
@@ -48,25 +61,15 @@ namespace Orchard.Core.Tests.Settings.Metadata {
|
||||
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
|
||||
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
|
||||
|
||||
_session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(_transactionManager = new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||
|
||||
_container = builder.Build();
|
||||
|
||||
_container.Mock<ISessionLocator>()
|
||||
.Setup(x => x.For(It.IsAny<Type>()))
|
||||
.Returns(() => _session);
|
||||
|
||||
_session = _sessionFactory.OpenSession();
|
||||
foreach (var killType in new[] { typeof(ContentTypeDefinitionRecord), typeof(ContentPartDefinitionRecord), typeof(ContentFieldDefinitionRecord) }) {
|
||||
foreach (var killRecord in _session.CreateCriteria(killType).List()) {
|
||||
_session.Delete(killRecord);
|
||||
}
|
||||
}
|
||||
_session.Flush();
|
||||
}
|
||||
|
||||
void ResetSession() {
|
||||
_session.Flush();
|
||||
_session.Dispose();
|
||||
_session = _sessionFactory.OpenSession();
|
||||
_transactionManager.RequireNew();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
@@ -50,7 +50,6 @@ namespace Orchard.Tests.Modules.Comments.Services {
|
||||
builder.RegisterType<Signals>().As<ISignals>();
|
||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
||||
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
|
||||
builder.RegisterInstance(new Mock<INotifier>().Object);
|
||||
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
|
||||
|
@@ -12,6 +12,7 @@ using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Services;
|
||||
using Orchard.Tests.ContentManagement;
|
||||
using Orchard.Tests.Data;
|
||||
using Orchard.Tests.Stubs;
|
||||
|
||||
@@ -52,6 +53,7 @@ namespace Orchard.Tests.Modules {
|
||||
builder.RegisterInstance(_clock).As<IClock>();
|
||||
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
|
||||
builder.RegisterInstance(new ShellSettings { Name = ShellSettings.DefaultName, DataProvider = "SqlCe" });
|
||||
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||
Register(builder);
|
||||
_container = builder.Build();
|
||||
|
||||
@@ -61,11 +63,6 @@ namespace Orchard.Tests.Modules {
|
||||
public virtual void Cleanup() {
|
||||
if(_container != null)
|
||||
_container.Dispose();
|
||||
|
||||
_transaction.Commit();
|
||||
|
||||
if(_session != null)
|
||||
_session.Close();
|
||||
}
|
||||
|
||||
public abstract void Register(ContainerBuilder builder);
|
||||
|
@@ -74,7 +74,7 @@ namespace Orchard.Tests.Modules.ImportExport.Services {
|
||||
builder.RegisterInstance(new Mock<ISettingsFormatter>().Object);
|
||||
builder.RegisterInstance(new Mock<IRecipeExecuteEventHandler>().Object);
|
||||
_session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
|
||||
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||
|
||||
_container = builder.Build();
|
||||
_importExportService = _container.Resolve<IImportExportService>();
|
||||
|
@@ -75,7 +75,6 @@ namespace Orchard.Tests.Modules.Indexing {
|
||||
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
|
||||
|
||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
||||
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
|
||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
||||
|
||||
|
@@ -94,7 +94,7 @@ namespace Orchard.Tests.Modules.Migrations {
|
||||
builder.RegisterType<StubHostEnvironment>().As<IHostEnvironment>();
|
||||
|
||||
_session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
|
||||
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||
|
||||
builder.RegisterInstance(new ShellBlueprint());
|
||||
|
||||
|
@@ -74,7 +74,7 @@ namespace Orchard.Tests.Modules.Users.Controllers {
|
||||
builder.RegisterType<UserPartHandler>().As<IContentHandler>();
|
||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
||||
|
||||
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ITransactionManager>();
|
||||
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||
builder.RegisterInstance(new Work<IEnumerable<IShapeTableEventHandler>>(resolve => _container.Resolve<IEnumerable<IShapeTableEventHandler>>())).AsSelf();
|
||||
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
||||
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
|
||||
|
@@ -93,7 +93,6 @@ namespace Orchard.Tests.Modules.Widgets.Services {
|
||||
builder.RegisterType<Signals>().As<ISignals>();
|
||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
||||
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
|
||||
builder.RegisterInstance(new Mock<INotifier>().Object);
|
||||
builder.RegisterInstance(mockFeatureManager.Object);
|
||||
|
@@ -29,6 +29,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
private IContentManager _manager;
|
||||
private ISessionFactory _sessionFactory;
|
||||
private ISession _session;
|
||||
private ITransactionManager _transactionManager;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void InitFixture() {
|
||||
@@ -74,7 +75,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();
|
||||
|
||||
_session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
|
||||
builder.RegisterInstance(_transactionManager = new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||
|
||||
_session.Delete(string.Format("from {0}", typeof(GammaRecord).FullName));
|
||||
_session.Delete(string.Format("from {0}", typeof(DeltaRecord).FullName));
|
||||
@@ -82,14 +83,19 @@ namespace Orchard.Tests.ContentManagement {
|
||||
_session.Delete(string.Format("from {0}", typeof(ContentItemVersionRecord).FullName));
|
||||
_session.Delete(string.Format("from {0}", typeof(ContentItemRecord).FullName));
|
||||
_session.Delete(string.Format("from {0}", typeof(ContentTypeRecord).FullName));
|
||||
_session.Flush();
|
||||
_session.Clear();
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
_container = builder.Build();
|
||||
_manager = _container.Resolve<IContentManager>();
|
||||
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Cleanup() {
|
||||
if (_container != null)
|
||||
_container.Dispose();
|
||||
}
|
||||
|
||||
private List<IContent> AddSampleData() {
|
||||
var items = new List<IContent> {
|
||||
_manager.Create<AlphaPart>("alpha", init => { }),
|
||||
@@ -98,7 +104,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
_manager.Create<DeltaPart>("delta", init => { init.Record.Quux = "the quux value"; })
|
||||
};
|
||||
|
||||
_session.Flush();
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
return items;
|
||||
}
|
||||
@@ -212,7 +218,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
var twoId = _manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; }).ContentItem.Id;
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
|
||||
var fourId = _manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; }).ContentItem.Id;
|
||||
_session.Flush();
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
|
||||
var two = _manager.Query()
|
||||
@@ -239,7 +245,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; });
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; });
|
||||
_session.Flush();
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
var twoOrFour = _manager.Query<GammaPart, GammaRecord>()
|
||||
.Where(x => x.Frap == "one" || x.Frap == "four")
|
||||
@@ -271,8 +277,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; });
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; });
|
||||
_session.Flush();
|
||||
_session.Clear();
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
var ascending = _manager.Query("gamma")
|
||||
.OrderBy<GammaRecord>(x => x.Frap)
|
||||
@@ -282,7 +287,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
Assert.That(ascending.First().Record.Frap, Is.EqualTo("four"));
|
||||
Assert.That(ascending.Last().Record.Frap, Is.EqualTo("two"));
|
||||
|
||||
_session.Clear();
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
var descending = _manager.Query<GammaPart, GammaRecord>()
|
||||
.OrderByDescending(x => x.Frap)
|
||||
@@ -300,7 +305,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; });
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; });
|
||||
_session.Flush();
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
var reverseById = _manager.Query()
|
||||
.OrderByDescending<GammaRecord>(x => x.Id)
|
||||
@@ -346,8 +351,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
init.Record.Frap = "four";
|
||||
init.As<EpsilonPart>().Record.Quad = "4";
|
||||
});
|
||||
_session.Flush();
|
||||
_session.Clear();
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
var results = _manager.Query<EpsilonPart, EpsilonRecord>()
|
||||
.Where(x => x.Quad == "2" || x.Quad == "3")
|
||||
@@ -365,21 +369,18 @@ namespace Orchard.Tests.ContentManagement {
|
||||
init.As<GammaPart>().Record.Frap = "one";
|
||||
init.As<EpsilonPart>().Record.Quad = "v1";
|
||||
});
|
||||
_session.Flush();
|
||||
_session.Clear();
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
var gamma2 = _manager.Get(gamma1.Id, VersionOptions.DraftRequired);
|
||||
gamma2.As<GammaPart>().Record.Frap = "two";
|
||||
gamma2.As<EpsilonPart>().Record.Quad = "v2";
|
||||
_session.Flush();
|
||||
_session.Clear();
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
var gamma3 = _manager.Create<ContentItem>("gamma", init => {
|
||||
init.As<GammaPart>().Record.Frap = "three";
|
||||
init.As<EpsilonPart>().Record.Quad = "v3";
|
||||
});
|
||||
_session.Flush();
|
||||
_session.Clear();
|
||||
_transactionManager.RequireNew();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -562,7 +563,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; });
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; });
|
||||
_session.Flush();
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
var result = _manager.Query<GammaPart, GammaRecord>()
|
||||
.Where(x => x.Frap.StartsWith("t"))
|
||||
@@ -579,7 +580,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; });
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; });
|
||||
_session.Flush();
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
var result = _manager.Query<GammaPart, GammaRecord>()
|
||||
.Where(x => x.Frap.EndsWith("e"))
|
||||
@@ -596,7 +597,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; });
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
|
||||
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; });
|
||||
_session.Flush();
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
var result = _manager.Query<GammaPart, GammaRecord>()
|
||||
.Where(x => x.Frap.Contains("o"))
|
||||
|
@@ -86,84 +86,16 @@ namespace Orchard.Tests.ContentManagement {
|
||||
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
|
||||
|
||||
_session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>();
|
||||
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||
|
||||
_container = builder.Build();
|
||||
_manager = _container.Resolve<IContentManager>();
|
||||
}
|
||||
|
||||
public class TestSessionLocator : ISessionLocator, ITransactionManager, IDisposable {
|
||||
private readonly ISession _session;
|
||||
private ITransaction _transaction;
|
||||
private bool _cancelled;
|
||||
|
||||
public TestSessionLocator(ISession session) {
|
||||
_session = session;
|
||||
}
|
||||
|
||||
public ISession For(Type entityType) {
|
||||
return _session;
|
||||
}
|
||||
|
||||
void ITransactionManager.Demand() {
|
||||
EnsureSession();
|
||||
|
||||
if (_transaction == null) {
|
||||
_transaction = _session.BeginTransaction(IsolationLevel.ReadCommitted);
|
||||
}
|
||||
}
|
||||
|
||||
void ITransactionManager.RequireNew() {
|
||||
((ITransactionManager)this).RequireNew(IsolationLevel.ReadCommitted);
|
||||
}
|
||||
|
||||
void ITransactionManager.RequireNew(IsolationLevel level) {
|
||||
EnsureSession();
|
||||
|
||||
if (_cancelled) {
|
||||
_transaction.Rollback();
|
||||
_transaction.Dispose();
|
||||
_transaction = null;
|
||||
}
|
||||
else {
|
||||
if (_transaction != null) {
|
||||
_transaction.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
_transaction = _session.BeginTransaction(level);
|
||||
}
|
||||
|
||||
void ITransactionManager.Cancel() {
|
||||
_cancelled = true;
|
||||
}
|
||||
|
||||
void IDisposable.Dispose() {
|
||||
if (_transaction != null) {
|
||||
try {
|
||||
if (!_cancelled) {
|
||||
_transaction.Commit();
|
||||
}
|
||||
else {
|
||||
_transaction.Rollback();
|
||||
}
|
||||
|
||||
_transaction.Dispose();
|
||||
}
|
||||
catch {
|
||||
}
|
||||
finally {
|
||||
_transaction = null;
|
||||
_cancelled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureSession() {
|
||||
if (_session != null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
[TearDown]
|
||||
public void Cleanup() {
|
||||
if (_container != null)
|
||||
_container.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@@ -72,7 +72,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();
|
||||
|
||||
_session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
|
||||
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||
|
||||
_session.Delete(string.Format("from {0}", typeof(GammaRecord).FullName));
|
||||
_session.Delete(string.Format("from {0}", typeof(DeltaRecord).FullName));
|
||||
@@ -88,6 +88,12 @@ namespace Orchard.Tests.ContentManagement {
|
||||
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Cleanup() {
|
||||
if (_container != null)
|
||||
_container.Dispose();
|
||||
}
|
||||
|
||||
private void AddSampleData() {
|
||||
_manager.Create<AlphaPart>("alpha", init => { });
|
||||
_manager.Create<BetaPart>("beta", init => { });
|
||||
|
@@ -80,7 +80,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();
|
||||
|
||||
_session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
|
||||
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||
|
||||
_session.Delete(string.Format("from {0}", typeof(GammaRecord).FullName));
|
||||
_session.Delete(string.Format("from {0}", typeof(DeltaRecord).FullName));
|
||||
@@ -98,6 +98,12 @@ namespace Orchard.Tests.ContentManagement {
|
||||
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Cleanup() {
|
||||
if (_container != null)
|
||||
_container.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllDataTypesCanBeQueried() {
|
||||
var dt = DateTime.Now;
|
||||
|
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using NHibernate;
|
||||
using Orchard.Data;
|
||||
|
||||
namespace Orchard.Tests.ContentManagement {
|
||||
public class TestTransactionManager : ITransactionManager, IDisposable {
|
||||
private ISession _session;
|
||||
private ITransaction _transaction;
|
||||
private bool _cancelled;
|
||||
|
||||
public TestTransactionManager(ISession session) {
|
||||
_session = session;
|
||||
RequireNew();
|
||||
}
|
||||
|
||||
public void Demand() {
|
||||
EnsureSession();
|
||||
}
|
||||
|
||||
public void RequireNew() {
|
||||
RequireNew(IsolationLevel.ReadCommitted);
|
||||
}
|
||||
|
||||
public void RequireNew(IsolationLevel level) {
|
||||
EnsureSession();
|
||||
|
||||
if (_cancelled) {
|
||||
_transaction.Rollback();
|
||||
_transaction.Dispose();
|
||||
_transaction = null;
|
||||
}
|
||||
else {
|
||||
if (_transaction != null) {
|
||||
_transaction.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
_transaction = _session.BeginTransaction(level);
|
||||
}
|
||||
|
||||
public void Cancel() {
|
||||
_cancelled = true;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
if (_transaction != null) {
|
||||
try {
|
||||
if (!_cancelled) {
|
||||
_transaction.Commit();
|
||||
}
|
||||
else {
|
||||
_transaction.Rollback();
|
||||
}
|
||||
|
||||
_transaction.Dispose();
|
||||
}
|
||||
catch {
|
||||
}
|
||||
finally {
|
||||
_transaction = null;
|
||||
_cancelled = false;
|
||||
}
|
||||
}
|
||||
|
||||
_session.Close();
|
||||
_session.Dispose();
|
||||
_session = null;
|
||||
}
|
||||
|
||||
private void EnsureSession() {
|
||||
if (_session == null) {
|
||||
throw new ArgumentNullException("Session can't be null, ever");
|
||||
}
|
||||
}
|
||||
|
||||
public ISession GetSession() {
|
||||
EnsureSession();
|
||||
|
||||
return _session;
|
||||
}
|
||||
}
|
||||
}
|
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Data;
|
||||
using Orchard.Tests.ContentManagement;
|
||||
using Orchard.Tests.Records;
|
||||
|
||||
namespace Orchard.Tests.Data {
|
||||
@@ -22,7 +23,7 @@ namespace Orchard.Tests.Data {
|
||||
_databaseFilePath = Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(_databaseFilePath, typeof(FooRecord));
|
||||
_session = _sessionFactory.OpenSession();
|
||||
_fooRepos = new Repository<FooRecord>(new StubLocator(_session));
|
||||
_fooRepos = new Repository<FooRecord>(new TestTransactionManager(_session));
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
@@ -45,12 +45,18 @@ namespace Orchard.Tests.DataMigration {
|
||||
typeof(ContentTypeRecord));
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void InitDb() {
|
||||
foreach ( var record in _repository.Fetch(m => m != null) ) {
|
||||
_repository.Delete(record);
|
||||
}
|
||||
_repository.Flush();
|
||||
|
||||
_transactionManager.RequireNew();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void CleanUp() {
|
||||
if (_container != null)
|
||||
_container.Dispose();
|
||||
}
|
||||
|
||||
public void Init(IEnumerable<Type> dataMigrations) {
|
||||
@@ -73,7 +79,7 @@ namespace Orchard.Tests.DataMigration {
|
||||
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
|
||||
builder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>();
|
||||
_session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>().As<ITransactionManager>();
|
||||
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||
foreach(var type in dataMigrations) {
|
||||
builder.RegisterType(type).As<IDataMigration>();
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ namespace Orchard.Tests.DataMigration
|
||||
builder.RegisterType<SessionFactoryHolder>().As<ISessionFactoryHolder>();
|
||||
builder.RegisterType<DefaultDatabaseCacheConfiguration>().As<IDatabaseCacheConfiguration>();
|
||||
builder.RegisterType<StubHostEnvironment>().As<IHostEnvironment>();
|
||||
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
|
||||
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||
builder.RegisterInstance(new ShellBlueprint { Records = Enumerable.Empty<RecordBlueprint>() }).As<ShellBlueprint>();
|
||||
builder.RegisterInstance(new ShellSettings { Name = "temp", DataProvider = "SqlCe", DataTablePrefix = "TEST" }).As<ShellSettings>();
|
||||
builder.RegisterModule(new DataModule());
|
||||
|
@@ -11,6 +11,7 @@ using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Services;
|
||||
using Orchard.Tests.ContentManagement;
|
||||
using Orchard.Tests.Data;
|
||||
using Orchard.Tests.Stubs;
|
||||
|
||||
@@ -48,6 +49,7 @@ namespace Orchard.Tests {
|
||||
builder.RegisterInstance(_clock).As<IClock>();
|
||||
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
|
||||
builder.RegisterInstance(new ShellSettings { Name = ShellSettings.DefaultName, DataProvider = "SqlCe" });
|
||||
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||
|
||||
Register(builder);
|
||||
_container = builder.Build();
|
||||
@@ -57,9 +59,6 @@ namespace Orchard.Tests {
|
||||
public void Cleanup() {
|
||||
if(_container != null)
|
||||
_container.Dispose();
|
||||
|
||||
if(_session != null)
|
||||
_session.Close();
|
||||
}
|
||||
|
||||
public abstract void Register(ContainerBuilder builder);
|
||||
|
@@ -160,6 +160,38 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
||||
public class TestDependency : ITestDependency {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ComponentsImplementingMultipleContractsAreResolvableOnce() {
|
||||
var settings = CreateSettings();
|
||||
var blueprint = CreateBlueprint(
|
||||
WithDependency<MultipleDependency>()
|
||||
);
|
||||
|
||||
var factory = _container.Resolve<IShellContainerFactory>();
|
||||
var shellContainer = factory.CreateContainer(settings, blueprint);
|
||||
|
||||
var multipleDependency1 = shellContainer.Resolve<IMultipleDependency1>();
|
||||
var multipleDependency2 = shellContainer.Resolve<IMultipleDependency2>();
|
||||
|
||||
Assert.That(multipleDependency1, Is.Not.Null);
|
||||
Assert.That(multipleDependency2, Is.Not.Null);
|
||||
|
||||
Assert.That(multipleDependency1, Is.InstanceOf<MultipleDependency>());
|
||||
Assert.That(multipleDependency2, Is.InstanceOf<MultipleDependency>());
|
||||
|
||||
Assert.True(multipleDependency1 == multipleDependency2);
|
||||
}
|
||||
|
||||
public interface IMultipleDependency1 : IDependency {
|
||||
|
||||
}
|
||||
public interface IMultipleDependency2 : IDependency {
|
||||
|
||||
}
|
||||
public class MultipleDependency : IMultipleDependency1, IMultipleDependency2 {
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtraInformationCanDropIntoProperties() {
|
||||
var settings = CreateSettings();
|
||||
|
@@ -46,7 +46,6 @@ namespace Orchard.Tests.Localization {
|
||||
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
||||
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
|
||||
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
|
||||
builder.RegisterInstance(new Mock<INotifier>().Object);
|
||||
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
|
||||
@@ -60,7 +59,7 @@ namespace Orchard.Tests.Localization {
|
||||
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
|
||||
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
|
||||
_session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
|
||||
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||
_container = builder.Build();
|
||||
_cultureManager = _container.Resolve<ICultureManager>();
|
||||
}
|
||||
|
@@ -208,6 +208,7 @@
|
||||
<Compile Include="ContentManagement\Records\GammaRecord.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ContentManagement\TestTransactionManager.cs" />
|
||||
<Compile Include="ContentManagement\XmlHelperTests.cs" />
|
||||
<Compile Include="DatabaseEnabledTestsBase.cs" />
|
||||
<Compile Include="DataMigration\SchemaBuilderTests.cs" />
|
||||
|
@@ -11,11 +11,11 @@ using Orchard.Environment.Extensions;
|
||||
namespace Orchard.AuditTrail.Services {
|
||||
[OrchardFeature("Orchard.AuditTrail.RecycleBin")]
|
||||
public class RecycleBin : IRecycleBin {
|
||||
private readonly ISessionLocator _sessionLocator;
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public RecycleBin(ISessionLocator sessionLocator, IContentManager contentManager) {
|
||||
_sessionLocator = sessionLocator;
|
||||
public RecycleBin(ITransactionManager transactionManager, IContentManager contentManager) {
|
||||
_transactionManager = transactionManager;
|
||||
_contentManager = contentManager;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Orchard.AuditTrail.Services {
|
||||
}
|
||||
|
||||
private IQuery GetDeletedVersionsQuery(IEnumerable<int> contentItemIds = null) {
|
||||
var session = _sessionLocator.For(typeof(ContentItemVersionRecord));
|
||||
var session = _transactionManager.GetSession();
|
||||
|
||||
// Select only the highest versions where both Published and Latest are false.
|
||||
var select =
|
||||
|
@@ -25,7 +25,6 @@ namespace Orchard.Azure.MediaServices.Services.Assets {
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
private readonly IClock _clock;
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
private readonly ISessionLocator _sessionLocator;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IAssetManager _assetManager;
|
||||
private readonly ITempFileManager _fileManager;
|
||||
@@ -35,7 +34,6 @@ namespace Orchard.Azure.MediaServices.Services.Assets {
|
||||
IOrchardServices orchardServices,
|
||||
IClock clock,
|
||||
ITransactionManager transactionManager,
|
||||
ISessionLocator sessionLocator,
|
||||
IContentManager contentManager,
|
||||
IAssetManager assetManager,
|
||||
ITempFileManager fileManager,
|
||||
@@ -44,7 +42,6 @@ namespace Orchard.Azure.MediaServices.Services.Assets {
|
||||
_orchardServices = orchardServices;
|
||||
_clock = clock;
|
||||
_transactionManager = transactionManager;
|
||||
_sessionLocator = sessionLocator;
|
||||
_contentManager = contentManager;
|
||||
_assetManager = assetManager;
|
||||
_fileManager = fileManager;
|
||||
@@ -172,7 +169,7 @@ namespace Orchard.Azure.MediaServices.Services.Assets {
|
||||
|
||||
// Check for cancellation (asset upload status was set to Canceled).
|
||||
if (!cancellationTokenSource.IsCancellationRequested) {
|
||||
var session = _sessionLocator.For(typeof(AssetRecord));
|
||||
var session = _transactionManager.GetSession();
|
||||
session.Refresh(progressAsset.Record, LockMode.None);
|
||||
|
||||
if (progressAsset.UploadState.Status == AssetUploadStatus.Canceled) {
|
||||
|
@@ -1,8 +1,12 @@
|
||||
[
|
||||
{
|
||||
"inputs": [ "Assets/JavaScript/Lib/**/*.js" ],
|
||||
"output": "Scripts/Lib.js"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
"Assets/JavaScript/Lib/jquery.validate.js",
|
||||
"Assets/JavaScript/Lib/jquery.validate.unobtrusive.js",
|
||||
"Assets/JavaScript/Lib/jquery.validate.unobtrusive.additional.js"
|
||||
],
|
||||
"output": "Scripts/Lib.js"
|
||||
},
|
||||
{
|
||||
"inputs": [ "Assets/JavaScript/LayoutEditor/**/*.js" ],
|
||||
"output": "Scripts/LayoutEditor.js"
|
||||
|
@@ -79,19 +79,19 @@
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Assets\CSS\DynamicForms-Admin.css" />
|
||||
<None Include="Assets\CSS\DynamicForms.css" />
|
||||
<Content Include="Assets\CSS\DynamicForms-Admin.css" />
|
||||
<Content Include="Assets\CSS\DynamicForms.css" />
|
||||
<Content Include="Scripts\LayoutEditor.js" />
|
||||
<Content Include="Scripts\LayoutEditor.min.js" />
|
||||
<None Include="Assets\JavaScript\LayoutEditor\Directives\Fieldset.js" />
|
||||
<None Include="Assets\JavaScript\LayoutEditor\Directives\Form.js" />
|
||||
<None Include="Assets\JavaScript\LayoutEditor\Models\Fieldset.js" />
|
||||
<None Include="Assets\JavaScript\LayoutEditor\Models\Form.js" />
|
||||
<Content Include="Assets\JavaScript\LayoutEditor\Directives\Fieldset.js" />
|
||||
<Content Include="Assets\JavaScript\LayoutEditor\Directives\Form.js" />
|
||||
<Content Include="Assets\JavaScript\LayoutEditor\Models\Fieldset.js" />
|
||||
<Content Include="Assets\JavaScript\LayoutEditor\Models\Form.js" />
|
||||
<Content Include="Scripts\Lib.js" />
|
||||
<Content Include="Scripts\Lib.min.js" />
|
||||
<None Include="Assets\JavaScript\Lib\jquery.validate.js" />
|
||||
<None Include="Assets\JavaScript\Lib\jquery.validate.unobtrusive.additional.js" />
|
||||
<None Include="Assets\JavaScript\Lib\jquery.validate.unobtrusive.js" />
|
||||
<Content Include="Assets\JavaScript\Lib\jquery.validate.js" />
|
||||
<Content Include="Assets\JavaScript\Lib\jquery.validate.unobtrusive.additional.js" />
|
||||
<Content Include="Assets\JavaScript\Lib\jquery.validate.unobtrusive.js" />
|
||||
<Content Include="Styles\DynamicForms-Admin.css" />
|
||||
<Content Include="Styles\DynamicForms-Admin.min.css" />
|
||||
<Content Include="Styles\DynamicForms.css" />
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -33,7 +33,7 @@ namespace Orchard.ContentManagement {
|
||||
private readonly ICacheManager _cacheManager;
|
||||
private readonly Func<IContentManagerSession> _contentManagerSession;
|
||||
private readonly Lazy<IContentDisplay> _contentDisplay;
|
||||
private readonly Lazy<ISessionLocator> _sessionLocator;
|
||||
private readonly Lazy<ITransactionManager> _transactionManager;
|
||||
private readonly Lazy<IEnumerable<IContentHandler>> _handlers;
|
||||
private readonly Lazy<IEnumerable<IIdentityResolverSelector>> _identityResolverSelectors;
|
||||
private readonly Lazy<IEnumerable<ISqlStatementProvider>> _sqlStatementProviders;
|
||||
@@ -52,7 +52,7 @@ namespace Orchard.ContentManagement {
|
||||
ICacheManager cacheManager,
|
||||
Func<IContentManagerSession> contentManagerSession,
|
||||
Lazy<IContentDisplay> contentDisplay,
|
||||
Lazy<ISessionLocator> sessionLocator,
|
||||
Lazy<ITransactionManager> transactionManager,
|
||||
Lazy<IEnumerable<IContentHandler>> handlers,
|
||||
Lazy<IEnumerable<IIdentityResolverSelector>> identityResolverSelectors,
|
||||
Lazy<IEnumerable<ISqlStatementProvider>> sqlStatementProviders,
|
||||
@@ -71,7 +71,7 @@ namespace Orchard.ContentManagement {
|
||||
_signals = signals;
|
||||
_handlers = handlers;
|
||||
_contentDisplay = contentDisplay;
|
||||
_sessionLocator = sessionLocator;
|
||||
_transactionManager = transactionManager;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ namespace Orchard.ContentManagement {
|
||||
}
|
||||
|
||||
private IEnumerable<ContentItemVersionRecord> GetManyImplementation(QueryHints hints, Action<ICriteria, ICriteria> predicate) {
|
||||
var session = _sessionLocator.Value.For(typeof (ContentItemRecord));
|
||||
var session = _transactionManager.Value.GetSession();
|
||||
var contentItemVersionCriteria = session.CreateCriteria(typeof (ContentItemVersionRecord));
|
||||
var contentItemCriteria = contentItemVersionCriteria.CreateCriteria("ContentItemRecord");
|
||||
predicate(contentItemCriteria, contentItemVersionCriteria);
|
||||
@@ -443,7 +443,7 @@ namespace Orchard.ContentManagement {
|
||||
}
|
||||
|
||||
public virtual void Destroy(ContentItem contentItem) {
|
||||
var session = _sessionLocator.Value.For(typeof(ContentItemVersionRecord));
|
||||
var session = _transactionManager.Value.GetSession();
|
||||
var context = new DestroyContentContext(contentItem);
|
||||
|
||||
// Give storage filters a chance to delete content part records.
|
||||
@@ -717,7 +717,7 @@ namespace Orchard.ContentManagement {
|
||||
}
|
||||
|
||||
public IHqlQuery HqlQuery() {
|
||||
return new DefaultHqlQuery(this, _sessionLocator.Value.For(typeof(ContentItemVersionRecord)), _sqlStatementProviders.Value, _shellSettings);
|
||||
return new DefaultHqlQuery(this, _transactionManager.Value.GetSession(), _sqlStatementProviders.Value, _shellSettings);
|
||||
}
|
||||
|
||||
// Insert or Update imported data into the content manager.
|
||||
|
@@ -15,7 +15,7 @@ using Orchard.Caching;
|
||||
|
||||
namespace Orchard.ContentManagement {
|
||||
public class DefaultContentQuery : IContentQuery {
|
||||
private readonly ISessionLocator _sessionLocator;
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
private ISession _session;
|
||||
private ICriteria _itemVersionCriteria;
|
||||
private VersionOptions _versionOptions;
|
||||
@@ -25,11 +25,11 @@ namespace Orchard.ContentManagement {
|
||||
|
||||
public DefaultContentQuery(
|
||||
IContentManager contentManager,
|
||||
ISessionLocator sessionLocator,
|
||||
ITransactionManager transactionManager,
|
||||
ICacheManager cacheManager,
|
||||
ISignals signals,
|
||||
IRepository<ContentTypeRecord> contentTypeRepository) {
|
||||
_sessionLocator = sessionLocator;
|
||||
_transactionManager = transactionManager;
|
||||
ContentManager = contentManager;
|
||||
_cacheManager = cacheManager;
|
||||
_signals = signals;
|
||||
@@ -40,7 +40,7 @@ namespace Orchard.ContentManagement {
|
||||
|
||||
ISession BindSession() {
|
||||
if (_session == null)
|
||||
_session = _sessionLocator.For(typeof(ContentItemVersionRecord));
|
||||
_session = _transactionManager.GetSession();
|
||||
return _session;
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,8 @@ using NHibernate;
|
||||
|
||||
namespace Orchard.Data {
|
||||
public interface ISessionLocator : IDependency {
|
||||
|
||||
[Obsolete("Use ITransactionManager.GetSession() instead.")]
|
||||
ISession For(Type entityType);
|
||||
}
|
||||
}
|
@@ -15,7 +15,7 @@ using Orchard.Logging;
|
||||
namespace Orchard.Data.Migration.Interpreters {
|
||||
public class DefaultDataMigrationInterpreter : AbstractDataMigrationInterpreter, IDataMigrationInterpreter {
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly ISessionLocator _sessionLocator;
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
private readonly IEnumerable<ICommandInterpreter> _commandInterpreters;
|
||||
private readonly Lazy<Dialect> _dialectLazy;
|
||||
private readonly List<string> _sqlStatements;
|
||||
@@ -24,11 +24,11 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
|
||||
public DefaultDataMigrationInterpreter(
|
||||
ShellSettings shellSettings,
|
||||
ISessionLocator sessionLocator,
|
||||
ITransactionManager ITransactionManager,
|
||||
IEnumerable<ICommandInterpreter> commandInterpreters,
|
||||
ISessionFactoryHolder sessionFactoryHolder) {
|
||||
_shellSettings = shellSettings;
|
||||
_sessionLocator = sessionLocator;
|
||||
_transactionManager = ITransactionManager;
|
||||
_commandInterpreters = commandInterpreters;
|
||||
_sqlStatements = new List<string>();
|
||||
|
||||
@@ -330,7 +330,7 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities", Justification = "Nothing comes from user input.")]
|
||||
private void RunPendingStatements() {
|
||||
|
||||
var session = _sessionLocator.For(typeof(ContentItemRecord));
|
||||
var session = _transactionManager.GetSession();
|
||||
|
||||
try {
|
||||
foreach (var sqlStatement in _sqlStatements) {
|
||||
|
@@ -10,21 +10,17 @@ using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Data {
|
||||
public class Repository<T> : IRepository<T> where T : class {
|
||||
private readonly ISessionLocator _sessionLocator;
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
|
||||
public Repository(ISessionLocator sessionLocator) {
|
||||
_sessionLocator = sessionLocator;
|
||||
public Repository(ITransactionManager transactionManager) {
|
||||
_transactionManager = transactionManager;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
protected virtual ISessionLocator SessionLocator {
|
||||
get { return _sessionLocator; }
|
||||
}
|
||||
|
||||
protected virtual ISession Session {
|
||||
get { return SessionLocator.For(typeof (T)); }
|
||||
get { return _transactionManager.GetSession(); }
|
||||
}
|
||||
|
||||
public virtual IQueryable<T> Table {
|
||||
|
@@ -12,7 +12,24 @@ using Orchard.Logging;
|
||||
using Orchard.Security;
|
||||
|
||||
namespace Orchard.Data {
|
||||
public class SessionLocator : ISessionLocator, ITransactionManager, IDisposable {
|
||||
|
||||
public class SessionLocator : ISessionLocator {
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
|
||||
public SessionLocator(ITransactionManager transactionManager) {
|
||||
_transactionManager = transactionManager;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public ISession For(Type entityType) {
|
||||
Logger.Debug("Acquiring session for {0}", entityType);
|
||||
return _transactionManager.GetSession();
|
||||
}
|
||||
}
|
||||
|
||||
public class TransactionManager : ITransactionManager, IDisposable {
|
||||
private readonly ISessionFactoryHolder _sessionFactoryHolder;
|
||||
private readonly IEnumerable<ISessionInterceptor> _interceptors;
|
||||
private Func<IContentManagerSession> _contentManagerSessionFactory;
|
||||
@@ -20,7 +37,7 @@ namespace Orchard.Data {
|
||||
private ISession _session;
|
||||
private IContentManagerSession _contentManagerSession;
|
||||
|
||||
public SessionLocator(
|
||||
public TransactionManager(
|
||||
ISessionFactoryHolder sessionFactoryHolder,
|
||||
Func<IContentManagerSession> contentManagerSessionFactory,
|
||||
IEnumerable<ISessionInterceptor> interceptors) {
|
||||
@@ -35,13 +52,10 @@ namespace Orchard.Data {
|
||||
public ILogger Logger { get; set; }
|
||||
public IsolationLevel IsolationLevel { get; set; }
|
||||
|
||||
public ISession For(Type entityType) {
|
||||
Logger.Debug("Acquiring session for {0}", entityType);
|
||||
public ISession GetSession() {
|
||||
Demand();
|
||||
|
||||
return _session;
|
||||
}
|
||||
|
||||
public void Demand() {
|
||||
EnsureSession(IsolationLevel);
|
||||
}
|
||||
@@ -56,7 +70,8 @@ namespace Orchard.Data {
|
||||
}
|
||||
|
||||
public void Cancel() {
|
||||
if (_session!= null && !_session.Transaction.WasRolledBack && _session.Transaction.IsActive) {
|
||||
// IsActive is true if the transaction hasn't been committed or rolled back
|
||||
if (_session != null && _session.Transaction.IsActive) {
|
||||
Logger.Debug("Rolling back transaction");
|
||||
_session.Transaction.Rollback();
|
||||
}
|
||||
@@ -70,7 +85,8 @@ namespace Orchard.Data {
|
||||
if (_session != null) {
|
||||
|
||||
try {
|
||||
if (!_session.Transaction.WasRolledBack && _session.Transaction.IsActive) {
|
||||
// IsActive is true if the transaction hasn't been committed or rolled back
|
||||
if (_session.Transaction.IsActive) {
|
||||
Logger.Debug("Committing transaction");
|
||||
_session.Transaction.Commit();
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System.Data;
|
||||
using System.Web.Mvc;
|
||||
using NHibernate;
|
||||
using Orchard.Mvc.Filters;
|
||||
|
||||
namespace Orchard.Data {
|
||||
@@ -8,6 +9,8 @@ namespace Orchard.Data {
|
||||
void RequireNew();
|
||||
void RequireNew(IsolationLevel level);
|
||||
void Cancel();
|
||||
|
||||
ISession GetSession();
|
||||
}
|
||||
|
||||
public class TransactionFilter : FilterProvider, IExceptionFilter {
|
||||
|
@@ -10,22 +10,27 @@
|
||||
<ToolsOptionsCategory name="Environment">
|
||||
<ToolsOptionsSubCategory name="TaskList">
|
||||
<PropertyValue name="CommentTokens" ArrayType="VT_VARIANT" ArrayElementCount="4">
|
||||
<PropertyValue name="0">TODO:2</PropertyValue>
|
||||
<PropertyValue name="1">HACK:2</PropertyValue>
|
||||
<PropertyValue name="0">HACK:2</PropertyValue>
|
||||
<PropertyValue name="1">TODO:2</PropertyValue>
|
||||
<PropertyValue name="2">UNDONE:2</PropertyValue>
|
||||
<PropertyValue name="3">UnresolvedMergeConflict:3</PropertyValue>
|
||||
</PropertyValue>
|
||||
<PropertyValue name="ConfirmTaskDeletion">true</PropertyValue>
|
||||
<PropertyValue name="DontShowFilePaths">true</PropertyValue>
|
||||
<PropertyValue name="ConfirmTaskDeletion">false</PropertyValue>
|
||||
<PropertyValue name="DontShowFilePaths">false</PropertyValue>
|
||||
<PropertyValue name="WarnOnAddingHiddenItem">false</PropertyValue>
|
||||
</ToolsOptionsSubCategory>
|
||||
</ToolsOptionsCategory>
|
||||
<ToolsOptionsCategory name="TextEditor">
|
||||
<ToolsOptionsSubCategory name="CSharp-Specific">
|
||||
<PropertyValue name="AutoComment">1</PropertyValue>
|
||||
<PropertyValue name="ClosedFileDiagnostics">1</PropertyValue>
|
||||
<PropertyValue name="CodeDefinitionWindow_DocumentationComment_IndentBase">1</PropertyValue>
|
||||
<PropertyValue name="CodeDefinitionWindow_DocumentationComment_IndentOffset">2</PropertyValue>
|
||||
<PropertyValue name="CodeDefinitionWindow_DocumentationComment_WrapLength">80</PropertyValue>
|
||||
<PropertyValue name="DisplayLineSeparators">0</PropertyValue>
|
||||
<PropertyValue name="EnableHighlightRelatedKeywords">1</PropertyValue>
|
||||
<PropertyValue name="ExtractMethod_AllowMovingDeclaration">0</PropertyValue>
|
||||
<PropertyValue name="ExtractMethod_DoNotPutOutOrRefOnStruct">1</PropertyValue>
|
||||
<PropertyValue name="Formatting_TriggerOnBlockCompletion">1</PropertyValue>
|
||||
<PropertyValue name="Formatting_TriggerOnPaste">1</PropertyValue>
|
||||
<PropertyValue name="Formatting_TriggerOnStatementCompletion">1</PropertyValue>
|
||||
@@ -52,6 +57,7 @@
|
||||
<PropertyValue name="NewLines_ObjectInitializer_EachMember">1</PropertyValue>
|
||||
<PropertyValue name="NewLines_QueryExpression_EachClause">1</PropertyValue>
|
||||
<PropertyValue name="RemoveUnusedUsings">1</PropertyValue>
|
||||
<PropertyValue name="RenameTrackingPreview">1</PropertyValue>
|
||||
<PropertyValue name="SortUsings">1</PropertyValue>
|
||||
<PropertyValue name="SortUsings_PlaceSystemFirst">1</PropertyValue>
|
||||
<PropertyValue name="Space_AfterBasesColon">1</PropertyValue>
|
||||
@@ -80,6 +86,10 @@
|
||||
<PropertyValue name="Space_WithinMethodDeclarationParentheses">0</PropertyValue>
|
||||
<PropertyValue name="Space_WithinOtherParentheses">0</PropertyValue>
|
||||
<PropertyValue name="Space_WithinSquares">0</PropertyValue>
|
||||
<PropertyValue name="Style_PreferIntrinsicPredefinedTypeKeywordInDeclaration">1</PropertyValue>
|
||||
<PropertyValue name="Style_PreferIntrinsicPredefinedTypeKeywordInMemberAccess">1</PropertyValue>
|
||||
<PropertyValue name="Style_QualifyMemberAccessWithThisOrMe">0</PropertyValue>
|
||||
<PropertyValue name="Style_UseVarWhenDeclaringLocals">1</PropertyValue>
|
||||
<PropertyValue name="WarnOnBuildErrors">1</PropertyValue>
|
||||
<PropertyValue name="WarnWhenMembersCauseCompilerGeneratedReferences">1</PropertyValue>
|
||||
<PropertyValue name="Wrapping_IgnoreSpacesAroundBinaryOperators">0</PropertyValue>
|
||||
@@ -102,6 +112,7 @@
|
||||
<PropertyValue name="InsertSpaceBeforeAndAfterBinaryOperators">true</PropertyValue>
|
||||
<PropertyValue name="PlaceOpenBraceOnNewLineForControlBlocks">false</PropertyValue>
|
||||
<PropertyValue name="PlaceOpenBraceOnNewLineForFunctions">false</PropertyValue>
|
||||
<PropertyValue name="PlaceOpenBraceOnNewLineForFunctionsAndClasses">false</PropertyValue>
|
||||
<PropertyValue name="ShowErrorsAsWarnings">true</PropertyValue>
|
||||
<PropertyValue name="ShowSyntaxErrors">true</PropertyValue>
|
||||
</ToolsOptionsSubCategory>
|
||||
@@ -112,11 +123,15 @@
|
||||
<PropertyValue name="AutoFormatOnBraceCompletion">true</PropertyValue>
|
||||
<PropertyValue name="AutoFormatOnClosingBrace">true</PropertyValue>
|
||||
<PropertyValue name="AutoFormatOnPaste">true</PropertyValue>
|
||||
<PropertyValue name="AutoFormatOnPaste2">1</PropertyValue>
|
||||
<PropertyValue name="AutoFormatOnSemicolon">true</PropertyValue>
|
||||
<PropertyValue name="AutoIndentOnTab">false</PropertyValue>
|
||||
<PropertyValue name="ColorizeInactiveBlocksDifferently">true</PropertyValue>
|
||||
<PropertyValue name="DisableBrowsingUpToDateCheck">true</PropertyValue>
|
||||
<PropertyValue name="DisableErrorReporting">false</PropertyValue>
|
||||
<PropertyValue name="DisableIntelliSenseErrorsInErrorList">false</PropertyValue>
|
||||
<PropertyValue name="EnableSingleFileISense">true</PropertyValue>
|
||||
<PropertyValue name="EnableSingleFileISenseSquiggles">false</PropertyValue>
|
||||
<PropertyValue name="EnumerateCommentTasks">false</PropertyValue>
|
||||
<PropertyValue name="GroupBrackets">true</PropertyValue>
|
||||
<PropertyValue name="HighlightMatchingTokens">true</PropertyValue>
|
||||
@@ -128,6 +143,8 @@
|
||||
<PropertyValue name="IndentCaseLabels">false</PropertyValue>
|
||||
<PropertyValue name="IndentGotoLabels">1</PropertyValue>
|
||||
<PropertyValue name="IndentNamespaceContents">true</PropertyValue>
|
||||
<PropertyValue name="IndentPreprocessor">2</PropertyValue>
|
||||
<PropertyValue name="IndentationReference">2</PropertyValue>
|
||||
<PropertyValue name="NewlineControlBlockBrace">0</PropertyValue>
|
||||
<PropertyValue name="NewlineEmptyFunctionCloseBrace">true</PropertyValue>
|
||||
<PropertyValue name="NewlineEmptyTypeCloseBrace">true</PropertyValue>
|
||||
@@ -138,22 +155,37 @@
|
||||
<PropertyValue name="NewlineKeywordWhile">false</PropertyValue>
|
||||
<PropertyValue name="NewlineLambdaBrace">0</PropertyValue>
|
||||
<PropertyValue name="NewlineNamespaceBrace">0</PropertyValue>
|
||||
<PropertyValue name="NewlineScopeBrace">false</PropertyValue>
|
||||
<PropertyValue name="NewlineTypeBrace">0</PropertyValue>
|
||||
<PropertyValue name="PreserveBlock">1</PropertyValue>
|
||||
<PropertyValue name="PreserveCommentIndentation">false</PropertyValue>
|
||||
<PropertyValue name="PreserveInitListSpace">true</PropertyValue>
|
||||
<PropertyValue name="PreserveParameterIndentation">false</PropertyValue>
|
||||
<PropertyValue name="RefactorScope">2</PropertyValue>
|
||||
<PropertyValue name="RemoveSpaceBeforeSemicolon">true</PropertyValue>
|
||||
<PropertyValue name="RenameRenameComments">false</PropertyValue>
|
||||
<PropertyValue name="RenameRenameInactive">false</PropertyValue>
|
||||
<PropertyValue name="RenameRenameStrings">false</PropertyValue>
|
||||
<PropertyValue name="RenameRenameUnconfirmed">false</PropertyValue>
|
||||
<PropertyValue name="RenameSearchComments">true</PropertyValue>
|
||||
<PropertyValue name="RenameSearchStrings">true</PropertyValue>
|
||||
<PropertyValue name="RenameShowPreview">false</PropertyValue>
|
||||
<PropertyValue name="RenameSkipPreviewIfConfirmed">false</PropertyValue>
|
||||
<PropertyValue name="ShowSingleFileISenseErrorsInTaskList">false</PropertyValue>
|
||||
<PropertyValue name="SpaceAfterCastParenthesis">false</PropertyValue>
|
||||
<PropertyValue name="SpaceAfterComma">true</PropertyValue>
|
||||
<PropertyValue name="SpaceAfterSemicolon">true</PropertyValue>
|
||||
<PropertyValue name="SpaceAroundAssignmentOperator">2</PropertyValue>
|
||||
<PropertyValue name="SpaceAroundBinaryOperator">2</PropertyValue>
|
||||
<PropertyValue name="SpaceAroundConditionalOperator">2</PropertyValue>
|
||||
<PropertyValue name="SpaceBeforeBlockBrace">true</PropertyValue>
|
||||
<PropertyValue name="SpaceBeforeBracket">false</PropertyValue>
|
||||
<PropertyValue name="SpaceBeforeComma">false</PropertyValue>
|
||||
<PropertyValue name="SpaceBeforeConstructorColon">true</PropertyValue>
|
||||
<PropertyValue name="SpaceBeforeControlBlockParenthesis">true</PropertyValue>
|
||||
<PropertyValue name="SpaceBeforeEmptyBracket">false</PropertyValue>
|
||||
<PropertyValue name="SpaceBeforeFunctionParenthesis">false</PropertyValue>
|
||||
<PropertyValue name="SpaceBeforeFunctionParenthesis2">1</PropertyValue>
|
||||
<PropertyValue name="SpaceBeforeInheritanceColon">true</PropertyValue>
|
||||
<PropertyValue name="SpaceBeforeInitListBrace">false</PropertyValue>
|
||||
<PropertyValue name="SpaceBeforeLambdaParenthesis">false</PropertyValue>
|
||||
@@ -173,6 +205,9 @@
|
||||
</ToolsOptionsSubCategory>
|
||||
<ToolsOptionsSubCategory name="TypeScript Specific">
|
||||
<PropertyValue name="AutomaticallyCompileTypeScriptFilesWhenSavedWhenNoSolution">false</PropertyValue>
|
||||
<PropertyValue name="ES3ForFilesThatAreNotPartOfAProject">false</PropertyValue>
|
||||
<PropertyValue name="ES5ForFilesThatAreNotPartOfAProject">true</PropertyValue>
|
||||
<PropertyValue name="ES6ForFilesThatAreNotPartOfAProject">false</PropertyValue>
|
||||
<PropertyValue name="FormatCompletedBlockOnRightCurlyBrace">true</PropertyValue>
|
||||
<PropertyValue name="FormatCompletedLineOnEnter">true</PropertyValue>
|
||||
<PropertyValue name="FormatCompletedStatementOnSemicolon">true</PropertyValue>
|
||||
@@ -185,12 +220,16 @@
|
||||
<PropertyValue name="InsertSpaceBeforeAndAfterBinaryOperators">true</PropertyValue>
|
||||
<PropertyValue name="PlaceOpenBraceOnNewLineForControlBlocks">false</PropertyValue>
|
||||
<PropertyValue name="PlaceOpenBraceOnNewLineForFunctions">false</PropertyValue>
|
||||
<PropertyValue name="ShowGruntGulpDialogForAspNet">true</PropertyValue>
|
||||
<PropertyValue name="ShowVirtualProjectsInSolutionExplorerWhenNoSolution">true</PropertyValue>
|
||||
<PropertyValue name="ShowVirtualProjectsInSolutionExplorerWhenSolutionOpen">false</PropertyValue>
|
||||
<PropertyValue name="UseAMDCodeGenerationForModulesThatAreNotPartOfAProject">false</PropertyValue>
|
||||
<PropertyValue name="UseCommonJSCodeGenerationForModulesThatAreNotPartOfAProject">false</PropertyValue>
|
||||
<PropertyValue name="UseSystemCodeGenerationForModulesThatAreNotPartOfAProject">false</PropertyValue>
|
||||
<PropertyValue name="UseUMDCodeGenerationForModulesThatAreNotPartOfAProject">false</PropertyValue>
|
||||
</ToolsOptionsSubCategory>
|
||||
<ToolsOptionsSubCategory name="HTMLX Specific">
|
||||
<PropertyValue name="EnableTagNavigator">false</PropertyValue>
|
||||
<PropertyValue name="EnableValidation">true</PropertyValue>
|
||||
<PropertyValue name="ErrorsAsWarnings">true</PropertyValue>
|
||||
<PropertyValue name="FormatOnPaste">true</PropertyValue>
|
||||
|
Reference in New Issue
Block a user