mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-29 19:14:22 +08:00
Removed cache from data migration notifier
--HG-- branch : dev
This commit is contained in:
parent
b3b48fa3df
commit
b86d3e20ed
src/Orchard/Data/Migration
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Orchard.Caching;
|
|
||||||
using Orchard.Data.Migration.Interpreters;
|
using Orchard.Data.Migration.Interpreters;
|
||||||
using Orchard.Data.Migration.Records;
|
using Orchard.Data.Migration.Records;
|
||||||
using Orchard.Data.Migration.Schema;
|
using Orchard.Data.Migration.Schema;
|
||||||
@ -20,20 +19,17 @@ namespace Orchard.Data.Migration {
|
|||||||
private readonly IRepository<DataMigrationRecord> _dataMigrationRepository;
|
private readonly IRepository<DataMigrationRecord> _dataMigrationRepository;
|
||||||
private readonly IExtensionManager _extensionManager;
|
private readonly IExtensionManager _extensionManager;
|
||||||
private readonly IDataMigrationInterpreter _interpreter;
|
private readonly IDataMigrationInterpreter _interpreter;
|
||||||
private readonly ISignals _signals;
|
|
||||||
|
|
||||||
public DataMigrationManager(
|
public DataMigrationManager(
|
||||||
IEnumerable<IDataMigration> dataMigrations,
|
IEnumerable<IDataMigration> dataMigrations,
|
||||||
IRepository<DataMigrationRecord> dataMigrationRepository,
|
IRepository<DataMigrationRecord> dataMigrationRepository,
|
||||||
IExtensionManager extensionManager,
|
IExtensionManager extensionManager,
|
||||||
IDataMigrationInterpreter interpreter,
|
IDataMigrationInterpreter interpreter
|
||||||
ISignals signals
|
|
||||||
) {
|
) {
|
||||||
_dataMigrations = dataMigrations;
|
_dataMigrations = dataMigrations;
|
||||||
_dataMigrationRepository = dataMigrationRepository;
|
_dataMigrationRepository = dataMigrationRepository;
|
||||||
_extensionManager = extensionManager;
|
_extensionManager = extensionManager;
|
||||||
_interpreter = interpreter;
|
_interpreter = interpreter;
|
||||||
_signals = signals;
|
|
||||||
|
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
}
|
}
|
||||||
@ -82,9 +78,6 @@ namespace Orchard.Data.Migration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Update(string feature){
|
public void Update(string feature){
|
||||||
// invalidate the notifications cache
|
|
||||||
_signals.Trigger(DataMigrationNotificationProvider.SignalKey);
|
|
||||||
|
|
||||||
Logger.Information("Updating {0}", feature);
|
Logger.Information("Updating {0}", feature);
|
||||||
|
|
||||||
// proceed with dependent features first, whatever the module it's in
|
// proceed with dependent features first, whatever the module it's in
|
||||||
@ -152,9 +145,6 @@ namespace Orchard.Data.Migration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Uninstall(string feature) {
|
public void Uninstall(string feature) {
|
||||||
// invalidate the notifications cache
|
|
||||||
_signals.Trigger(DataMigrationNotificationProvider.SignalKey);
|
|
||||||
|
|
||||||
var migrations = GetDataMigrations(feature);
|
var migrations = GetDataMigrations(feature);
|
||||||
|
|
||||||
// apply update methods to each migration class for the module
|
// apply update methods to each migration class for the module
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Orchard.Caching;
|
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.UI.Admin.Notification;
|
using Orchard.UI.Admin.Notification;
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
@ -9,25 +8,16 @@ using Orchard.UI.Notify;
|
|||||||
namespace Orchard.Data.Migration {
|
namespace Orchard.Data.Migration {
|
||||||
public class DataMigrationNotificationProvider: INotificationProvider {
|
public class DataMigrationNotificationProvider: INotificationProvider {
|
||||||
private readonly IDataMigrationManager _dataMigrationManager;
|
private readonly IDataMigrationManager _dataMigrationManager;
|
||||||
private readonly ICacheManager _cacheManager;
|
|
||||||
private readonly ISignals _signals;
|
|
||||||
public const string CacheKey = "DataMigrationNotifications";
|
|
||||||
public const string SignalKey = "DataMigrationNotificationsChanged";
|
|
||||||
|
|
||||||
public DataMigrationNotificationProvider(IDataMigrationManager dataMigrationManager, ICacheManager cacheManager, ISignals signals) {
|
public DataMigrationNotificationProvider(IDataMigrationManager dataMigrationManager) {
|
||||||
_dataMigrationManager = dataMigrationManager;
|
_dataMigrationManager = dataMigrationManager;
|
||||||
_cacheManager = cacheManager;
|
|
||||||
_signals = signals;
|
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
public IEnumerable<NotifyEntry> GetNotifications() {
|
public IEnumerable<NotifyEntry> GetNotifications() {
|
||||||
var features = _cacheManager.Get(CacheKey, ctx => {
|
var features = _dataMigrationManager.GetFeaturesThatNeedUpdate();
|
||||||
ctx.Monitor(_signals.When(SignalKey));
|
|
||||||
return _dataMigrationManager.GetFeaturesThatNeedUpdate();
|
|
||||||
});
|
|
||||||
|
|
||||||
if(features.Any()) {
|
if(features.Any()) {
|
||||||
yield return new NotifyEntry { Message = T("Some features need to be upgraded: {0}", String.Join(", ", features)), Type = NotifyType.Warning};
|
yield return new NotifyEntry { Message = T("Some features need to be upgraded: {0}", String.Join(", ", features)), Type = NotifyType.Warning};
|
||||||
|
Loading…
Reference in New Issue
Block a user