mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Fixing autoroute migrations
--HG-- branch : autoroute
This commit is contained in:
@@ -72,20 +72,16 @@ namespace UpgradeTo14.Controllers {
|
|||||||
|
|
||||||
foreach (var contentType in contentTypesToMigrate) {
|
foreach (var contentType in contentTypesToMigrate) {
|
||||||
|
|
||||||
if (_orchardServices.ContentManager.HqlQuery().ForType(contentType).Count() > 0 &&
|
|
||||||
_orchardServices.ContentManager.HqlQuery().ForType(contentType).Slice(0, 1).FirstOrDefault() == null) {
|
|
||||||
// can't load a content item, ignore the type
|
|
||||||
_orchardServices.Notifier.Information(T("Could not process {0}. Some parts might not be compatible with Orchard 1.4, please update your modules.", contentType));
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// migrating parts
|
// migrating parts
|
||||||
_contentDefinitionManager.AlterTypeDefinition(contentType,
|
_contentDefinitionManager.AlterTypeDefinition(contentType,
|
||||||
builder => builder
|
builder => builder
|
||||||
.WithPart("AutoroutePart")
|
.WithPart("AutoroutePart")
|
||||||
.WithPart("TitlePart"));
|
.WithPart("TitlePart"));
|
||||||
|
|
||||||
|
// force the first object to be reloaded in order to get a valid AutoroutePart
|
||||||
|
_orchardServices.ContentManager.Flush();
|
||||||
|
_orchardServices.ContentManager.Clear();
|
||||||
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
var isContainable = false;
|
var isContainable = false;
|
||||||
IEnumerable<ContentItem> contents;
|
IEnumerable<ContentItem> contents;
|
||||||
@@ -102,7 +98,7 @@ namespace UpgradeTo14.Controllers {
|
|||||||
isContainable = true;
|
isContainable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (new TransactionScope(TransactionScopeOption.Suppress)) {
|
using (new TransactionScope(TransactionScopeOption.RequiresNew)) {
|
||||||
var command = session.Connection.CreateCommand();
|
var command = session.Connection.CreateCommand();
|
||||||
command.CommandText = string.Format("SELECT Title, Path FROM {0} WHERE ContentItemRecord_Id = {1}", GetPrefixedTableName("Routable_RoutePartRecord"), autoroutePart.ContentItem.Id);
|
command.CommandText = string.Format("SELECT Title, Path FROM {0} WHERE ContentItemRecord_Id = {1}", GetPrefixedTableName("Routable_RoutePartRecord"), autoroutePart.ContentItem.Id);
|
||||||
var reader = command.ExecuteReader();
|
var reader = command.ExecuteReader();
|
||||||
@@ -120,7 +116,7 @@ namespace UpgradeTo14.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_orchardServices.ContentManager.Flush();
|
_orchardServices.ContentManager.Flush();
|
||||||
// todo: _orchardServices.ContentManager.Clear();
|
_orchardServices.ContentManager.Clear();
|
||||||
|
|
||||||
} while (contents.Any());
|
} while (contents.Any());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user