mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Shifting WarmupSettingsPart
This commit is contained in:
@@ -102,7 +102,6 @@ namespace Orchard.Tests.Modules.Users.Controllers {
|
||||
protected override IEnumerable<Type> DatabaseTypes {
|
||||
get {
|
||||
return new[] { typeof(UserPartRecord),
|
||||
typeof(RegistrationSettingsPartRecord),
|
||||
typeof(ContentTypeRecord),
|
||||
typeof(ContentItemRecord),
|
||||
typeof(ContentItemVersionRecord),
|
||||
|
@@ -54,7 +54,7 @@ namespace Orchard.Tests.Modules.Warmup {
|
||||
_orchardServices = new StubOrchardServices();
|
||||
((StubWorkContextAccessor.WorkContextImpl.StubSite) _orchardServices.WorkContext.CurrentSite).BaseUrl = "http://orchardproject.net";
|
||||
|
||||
_settings = new WarmupSettingsPart { Record = new WarmupSettingsPartRecord() };
|
||||
_settings = new WarmupSettingsPart();
|
||||
_orchardServices.WorkContext.CurrentSite.ContentItem.Weld(_settings);
|
||||
|
||||
var builder = new ContainerBuilder();
|
||||
|
@@ -1,14 +1,16 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Data;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Warmup.Models;
|
||||
|
||||
namespace Orchard.Warmup.Handlers {
|
||||
[UsedImplicitly]
|
||||
public class WarmupSettingsPartHandler : ContentHandler {
|
||||
public WarmupSettingsPartHandler(IRepository<WarmupSettingsPartRecord> repository) {
|
||||
public WarmupSettingsPartHandler() {
|
||||
Filters.Add(new ActivatingFilter<WarmupSettingsPart>("Site"));
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
|
||||
OnInitializing<WarmupSettingsPart>((context, part) => {
|
||||
part.Delay = 90;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,15 +3,7 @@
|
||||
namespace Orchard.Warmup {
|
||||
public class Migrations : DataMigrationImpl {
|
||||
public int Create() {
|
||||
SchemaBuilder.CreateTable("WarmupSettingsPartRecord",
|
||||
table => table
|
||||
.ContentPartRecord()
|
||||
.Column<string>("Urls", column => column.Unlimited())
|
||||
.Column<bool>("Scheduled")
|
||||
.Column<int>("Delay")
|
||||
.Column<bool>("OnPublish")
|
||||
);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@@ -1,26 +1,26 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Warmup.Models {
|
||||
public class WarmupSettingsPart : ContentPart<WarmupSettingsPartRecord> {
|
||||
public class WarmupSettingsPart : ContentPart {
|
||||
|
||||
public string Urls {
|
||||
get { return Record.Urls; }
|
||||
set { Record.Urls = value; }
|
||||
get { return this.Retrieve(x => x.Urls); }
|
||||
set { this.Store(x => x.Urls, value); }
|
||||
}
|
||||
|
||||
public bool Scheduled {
|
||||
get { return Record.Scheduled; }
|
||||
set { Record.Scheduled = value; }
|
||||
get { return this.Retrieve(x => x.Scheduled); }
|
||||
set { this.Store(x => x.Scheduled, value); }
|
||||
}
|
||||
|
||||
public int Delay {
|
||||
get { return Record.Delay; }
|
||||
set { Record.Delay = value; }
|
||||
get { return this.Retrieve(x => x.Delay); }
|
||||
set { this.Store(x => x.Delay, value); }
|
||||
}
|
||||
|
||||
public bool OnPublish {
|
||||
get { return Record.OnPublish; }
|
||||
set { Record.OnPublish = value; }
|
||||
get { return this.Retrieve(x => x.OnPublish); }
|
||||
set { this.Store(x => x.OnPublish, value); }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Data.Conventions;
|
||||
|
||||
namespace Orchard.Warmup.Models {
|
||||
public class WarmupSettingsPartRecord : ContentPartRecord {
|
||||
public WarmupSettingsPartRecord() {
|
||||
Delay = 90;
|
||||
}
|
||||
|
||||
[StringLengthMax]
|
||||
public virtual string Urls { get; set; }
|
||||
public virtual bool Scheduled { get; set; }
|
||||
public virtual int Delay { get; set; }
|
||||
public virtual bool OnPublish { get; set; }
|
||||
}
|
||||
}
|
@@ -100,7 +100,6 @@
|
||||
<Compile Include="Migrations.cs" />
|
||||
<Compile Include="Models\ReportEntry.cs" />
|
||||
<Compile Include="Models\WarmupSettingsPart.cs" />
|
||||
<Compile Include="Models\WarmupSettingsPartRecord.cs" />
|
||||
<Compile Include="Services\WarmupReportManager.cs" />
|
||||
<Compile Include="Services\IWarmupReportManager.cs" />
|
||||
<Compile Include="Services\IWarmupScheduler.cs" />
|
||||
|
@@ -175,6 +175,17 @@ namespace Upgrade.Controllers {
|
||||
});
|
||||
|
||||
_upgradeService.ExecuteReader("DROP TABLE " + _upgradeService.GetPrefixedTableName("Orchard_Email_SmtpSettingsPartRecord"), null);
|
||||
|
||||
// WarmupSettingsPartRecord
|
||||
_upgradeService.ExecuteReader("SELECT * FROM " + _upgradeService.GetPrefixedTableName("Orchard_Warmup_WarmupSettingsPartRecord"),
|
||||
(reader, connection) => {
|
||||
site.As<InfosetPart>().Store("WarmupSettingsPart", "Urls", (string)reader["Urls"]);
|
||||
site.As<InfosetPart>().Store("WarmupSettingsPart", "Scheduled", (bool)reader["Scheduled"]);
|
||||
site.As<InfosetPart>().Store("WarmupSettingsPart", "Delay", (int)reader["Delay"]);
|
||||
site.As<InfosetPart>().Store("WarmupSettingsPart", "OnPublish", (bool)reader["OnPublish"]);
|
||||
});
|
||||
|
||||
_upgradeService.ExecuteReader("DROP TABLE " + _upgradeService.GetPrefixedTableName("Orchard_Warmup_WarmupSettingsPartRecord"), null);
|
||||
|
||||
_orchardServices.Notifier.Information(T("Site Settings migrated successfully"));
|
||||
|
||||
|
Reference in New Issue
Block a user