Removes scheduled tasks
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
{
|
||||
public interface IScheduledTask
|
||||
{
|
||||
string Alias { get; }
|
||||
|
||||
bool Log { get; }
|
||||
|
||||
int Interval { get; }
|
||||
|
||||
string Url { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
{
|
||||
public interface IScheduledTasksSection : IUmbracoConfigurationSection
|
||||
{
|
||||
IEnumerable<IScheduledTask> Tasks { get; }
|
||||
|
||||
string BaseUrl { get; }
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
|
||||
ILoggingSection Logging { get; }
|
||||
|
||||
IScheduledTasksSection ScheduledTasks { get; }
|
||||
|
||||
IProvidersSection Providers { get; }
|
||||
|
||||
IWebRoutingSection WebRouting { get; }
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
using System.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
{
|
||||
internal class ScheduledTaskElement : ConfigurationElement, IScheduledTask
|
||||
{
|
||||
[ConfigurationProperty("alias")]
|
||||
public string Alias
|
||||
{
|
||||
get { return (string)base["alias"]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("log")]
|
||||
public bool Log
|
||||
{
|
||||
get { return (bool)base["log"]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("interval")]
|
||||
public int Interval
|
||||
{
|
||||
get { return (int)base["interval"]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("url")]
|
||||
public string Url
|
||||
{
|
||||
get { return (string)base["url"]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
{
|
||||
internal class ScheduledTasksCollection : ConfigurationElementCollection, IEnumerable<IScheduledTask>
|
||||
{
|
||||
protected override ConfigurationElement CreateNewElement()
|
||||
{
|
||||
return new ScheduledTaskElement();
|
||||
}
|
||||
|
||||
protected override object GetElementKey(ConfigurationElement element)
|
||||
{
|
||||
return ((ScheduledTaskElement)element).Alias;
|
||||
}
|
||||
|
||||
IEnumerator<IScheduledTask> IEnumerable<IScheduledTask>.GetEnumerator()
|
||||
{
|
||||
for (var i = 0; i < Count; i++)
|
||||
{
|
||||
yield return BaseGet(i) as IScheduledTask;
|
||||
}
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
{
|
||||
internal class ScheduledTasksElement : ConfigurationElement, IScheduledTasksSection
|
||||
{
|
||||
[ConfigurationCollection(typeof(ScheduledTasksCollection), AddItemName = "task")]
|
||||
[ConfigurationProperty("", IsDefaultCollection = true)]
|
||||
internal ScheduledTasksCollection Tasks
|
||||
{
|
||||
get { return (ScheduledTasksCollection)base[""]; }
|
||||
}
|
||||
|
||||
IEnumerable<IScheduledTask> IScheduledTasksSection.Tasks
|
||||
{
|
||||
get { return Tasks; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("baseUrl", IsRequired = false, DefaultValue = null)]
|
||||
public string BaseUrl
|
||||
{
|
||||
get { return (string)base["baseUrl"]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,12 +34,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
get { return (LoggingElement)this["logging"]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("scheduledTasks")]
|
||||
internal ScheduledTasksElement ScheduledTasks
|
||||
{
|
||||
get { return (ScheduledTasksElement)this["scheduledTasks"]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("providers")]
|
||||
internal ProvidersElement Providers
|
||||
{
|
||||
@@ -77,11 +71,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
get { return Logging; }
|
||||
}
|
||||
|
||||
IScheduledTasksSection IUmbracoSettingsSection.ScheduledTasks
|
||||
{
|
||||
get { return ScheduledTasks; }
|
||||
}
|
||||
|
||||
IProvidersSection IUmbracoSettingsSection.Providers
|
||||
{
|
||||
get { return Providers; }
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
[ConfigurationProperty("disableRedirectUrlTracking", DefaultValue = "false")]
|
||||
public bool DisableRedirectUrlTracking => (bool) base["disableRedirectUrlTracking"];
|
||||
|
||||
[ConfigurationProperty("urlProviderMode", DefaultValue = "AutoLegacy")]
|
||||
[ConfigurationProperty("urlProviderMode", DefaultValue = "Auto")]
|
||||
public string UrlProviderMode => (string) base["urlProviderMode"];
|
||||
|
||||
[ConfigurationProperty("umbracoApplicationUrl", DefaultValue = null)]
|
||||
|
||||
@@ -66,22 +66,6 @@ namespace Umbraco.Core.Sync
|
||||
return umbracoApplicationUrl;
|
||||
}
|
||||
|
||||
// try umbracoSettings:settings/scheduledTasks/@baseUrl
|
||||
// which is assumed to:
|
||||
// - end with SystemDirectories.Umbraco
|
||||
// - NOT contain any scheme (because, legacy)
|
||||
// - end or not with a slash, it will be taken care of
|
||||
// eg "mysite.com/umbraco"
|
||||
url = settings.ScheduledTasks.BaseUrl;
|
||||
if (url.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
var ssl = globalSettings.UseHttps ? "s" : "";
|
||||
url = "http" + ssl + "://" + url;
|
||||
var umbracoApplicationUrl = url.TrimEnd('/');
|
||||
logger.Info(TypeOfApplicationUrlHelper, "ApplicationUrl: {UmbracoAppUrl} (using scheduledTasks/@baseUrl)", umbracoApplicationUrl);
|
||||
return umbracoApplicationUrl;
|
||||
}
|
||||
|
||||
// try the server registrar
|
||||
// which is assumed to return a url that:
|
||||
// - end with SystemDirectories.Umbraco
|
||||
|
||||
@@ -265,8 +265,6 @@
|
||||
<Compile Include="Configuration\UmbracoSettings\ImagingAutoFillUploadFieldElement.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\IProvidersSection.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\IRequestHandlerSection.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\IScheduledTask.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\IScheduledTasksSection.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\ISecuritySection.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\ITourSection.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\IUmbracoSettingsSection.cs" />
|
||||
@@ -276,9 +274,6 @@
|
||||
<Compile Include="Configuration\UmbracoSettings\NotificationsElement.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\ProvidersElement.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\RequestHandlerElement.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\ScheduledTaskElement.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\ScheduledTasksCollection.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\ScheduledTasksElement.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\SecurityElement.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\TourConfigElement.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\UmbracoConfigurationElement.cs" />
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
{
|
||||
[TestFixture]
|
||||
public class ScheduledTasksElementDefaultTests : ScheduledTasksElementTests
|
||||
{
|
||||
protected override bool TestingDefaults
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public override void Tasks()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.ScheduledTasks.Tasks.Any() == false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
{
|
||||
[TestFixture]
|
||||
public class ScheduledTasksElementTests : UmbracoSettingsTests
|
||||
{
|
||||
[Test]
|
||||
public virtual void Tasks()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.ScheduledTasks.Tasks.Count() == 2);
|
||||
Assert.IsTrue(SettingsSection.ScheduledTasks.Tasks.ElementAt(0).Alias == "test60");
|
||||
Assert.IsTrue(SettingsSection.ScheduledTasks.Tasks.ElementAt(0).Log == true);
|
||||
Assert.IsTrue(SettingsSection.ScheduledTasks.Tasks.ElementAt(0).Interval == 60);
|
||||
Assert.IsTrue(SettingsSection.ScheduledTasks.Tasks.ElementAt(0).Url == "http://localhost/umbraco/test.aspx");
|
||||
Assert.IsTrue(SettingsSection.ScheduledTasks.Tasks.ElementAt(1).Alias == "testtest");
|
||||
Assert.IsTrue(SettingsSection.ScheduledTasks.Tasks.ElementAt(1).Log == false);
|
||||
Assert.IsTrue(SettingsSection.ScheduledTasks.Tasks.ElementAt(1).Interval == 61);
|
||||
Assert.IsTrue(SettingsSection.ScheduledTasks.Tasks.ElementAt(1).Url == "http://localhost/umbraco/test1.aspx");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
[Test]
|
||||
public override void UrlProviderMode()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.WebRouting.UrlProviderMode == "AutoLegacy");
|
||||
Assert.IsTrue(SettingsSection.WebRouting.UrlProviderMode == "Auto");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
[Test]
|
||||
public virtual void UrlProviderMode()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.WebRouting.UrlProviderMode == "AutoLegacy");
|
||||
Assert.IsTrue(SettingsSection.WebRouting.UrlProviderMode == "Auto");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,12 +119,6 @@
|
||||
<externalLogger assembly="~/bin/assemblyFileName.dll" type="fully.qualified.namespace.and.type" logAuditTrail="false" />
|
||||
</logging>
|
||||
|
||||
<scheduledTasks>
|
||||
<!-- add tasks that should be called with an interval (seconds) -->
|
||||
<task log="true" alias="test60" interval="60" url="http://localhost/umbraco/test.aspx"/>
|
||||
<task log="false" alias="testtest" interval="61" url="http://localhost/umbraco/test1.aspx"/>
|
||||
</scheduledTasks>
|
||||
|
||||
<providers>
|
||||
<users>
|
||||
<!-- if you wish to use your own membershipprovider for authenticating to the umbraco back office -->
|
||||
|
||||
@@ -37,9 +37,6 @@
|
||||
<!-- https://our.umbraco.com/documentation/using-umbraco/config-files/umbracoSettings/#Logging -->
|
||||
<logging/>
|
||||
|
||||
<!-- https://our.umbraco.com/documentation/using-umbraco/config-files/umbracoSettings/#ScheduledTasks -->
|
||||
<scheduledTasks/>
|
||||
|
||||
<!-- https://our.umbraco.com/documentation/using-umbraco/config-files/umbracoSettings/#Providers -->
|
||||
<providers/>
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@ namespace Umbraco.Tests.Misc
|
||||
// no applicable settings, but a provider
|
||||
|
||||
var settings = Mock.Of<IUmbracoSettingsSection>(section =>
|
||||
section.WebRouting == Mock.Of<IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == (string)null)
|
||||
&& section.ScheduledTasks == Mock.Of<IScheduledTasksSection>());
|
||||
section.WebRouting == Mock.Of<IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == (string)null));
|
||||
|
||||
var globalConfig = Mock.Get(SettingsForTests.GenerateMockGlobalSettings());
|
||||
globalConfig.Setup(x => x.UseHttps).Returns(true);
|
||||
@@ -59,8 +58,7 @@ namespace Umbraco.Tests.Misc
|
||||
// no applicable settings, but a provider
|
||||
|
||||
var settings = Mock.Of<IUmbracoSettingsSection>(section =>
|
||||
section.WebRouting == Mock.Of<IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == (string) null)
|
||||
&& section.ScheduledTasks == Mock.Of<IScheduledTasksSection>());
|
||||
section.WebRouting == Mock.Of<IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == (string) null));
|
||||
|
||||
var globalConfig = Mock.Get(SettingsForTests.GenerateMockGlobalSettings());
|
||||
globalConfig.Setup(x => x.UseHttps).Returns(true);
|
||||
@@ -82,8 +80,7 @@ namespace Umbraco.Tests.Misc
|
||||
// no applicable settings, cannot set url
|
||||
|
||||
var settings = Mock.Of<IUmbracoSettingsSection>(section =>
|
||||
section.WebRouting == Mock.Of<IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == (string) null)
|
||||
&& section.ScheduledTasks == Mock.Of<IScheduledTasksSection>());
|
||||
section.WebRouting == Mock.Of<IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == (string) null));
|
||||
|
||||
var globalConfig = Mock.Get(SettingsForTests.GenerateMockGlobalSettings());
|
||||
globalConfig.Setup(x => x.UseHttps).Returns(true);
|
||||
@@ -93,47 +90,12 @@ namespace Umbraco.Tests.Misc
|
||||
// still NOT set
|
||||
Assert.IsNull(url);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetApplicationUrlFromStSettingsNoSsl()
|
||||
{
|
||||
var settings = Mock.Of<IUmbracoSettingsSection>(section =>
|
||||
section.WebRouting == Mock.Of<IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == (string) null)
|
||||
&& section.ScheduledTasks == Mock.Of<IScheduledTasksSection>(tasksSection => tasksSection.BaseUrl == "mycoolhost.com/umbraco"));
|
||||
|
||||
var globalConfig = Mock.Get(SettingsForTests.GenerateMockGlobalSettings());
|
||||
globalConfig.Setup(x => x.UseHttps).Returns(false);
|
||||
|
||||
|
||||
|
||||
var url = ApplicationUrlHelper.TryGetApplicationUrl(settings, Mock.Of<ILogger>(), globalConfig.Object, Mock.Of<IServerRegistrar>());
|
||||
|
||||
Assert.AreEqual("http://mycoolhost.com/umbraco", url);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetApplicationUrlFromStSettingsSsl()
|
||||
{
|
||||
var settings = Mock.Of<IUmbracoSettingsSection>(section =>
|
||||
section.WebRouting == Mock.Of<IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == (string) null)
|
||||
&& section.ScheduledTasks == Mock.Of<IScheduledTasksSection>(tasksSection => tasksSection.BaseUrl == "mycoolhost.com/umbraco/"));
|
||||
|
||||
var globalConfig = Mock.Get(SettingsForTests.GenerateMockGlobalSettings());
|
||||
globalConfig.Setup(x => x.UseHttps).Returns(true);
|
||||
|
||||
|
||||
|
||||
var url = ApplicationUrlHelper.TryGetApplicationUrl(settings, Mock.Of<ILogger>(), globalConfig.Object, Mock.Of<IServerRegistrar>());
|
||||
|
||||
Assert.AreEqual("https://mycoolhost.com/umbraco", url);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void SetApplicationUrlFromWrSettingsSsl()
|
||||
{
|
||||
var settings = Mock.Of<IUmbracoSettingsSection>(section =>
|
||||
section.WebRouting == Mock.Of<IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == "httpx://whatever.com/umbraco/")
|
||||
&& section.ScheduledTasks == Mock.Of<IScheduledTasksSection>(tasksSection => tasksSection.BaseUrl == "mycoolhost.com/umbraco"));
|
||||
section.WebRouting == Mock.Of<IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == "httpx://whatever.com/umbraco/"));
|
||||
|
||||
var globalConfig = Mock.Get(SettingsForTests.GenerateMockGlobalSettings());
|
||||
globalConfig.Setup(x => x.UseHttps).Returns(true);
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace Umbraco.Tests.TestHelpers
|
||||
var security = new Mock<ISecuritySection>();
|
||||
var requestHandler = new Mock<IRequestHandlerSection>();
|
||||
var logging = new Mock<ILoggingSection>();
|
||||
var tasks = new Mock<IScheduledTasksSection>();
|
||||
var providers = new Mock<IProvidersSection>();
|
||||
var routing = new Mock<IWebRoutingSection>();
|
||||
|
||||
@@ -46,7 +45,6 @@ namespace Umbraco.Tests.TestHelpers
|
||||
settings.Setup(x => x.Security).Returns(security.Object);
|
||||
settings.Setup(x => x.RequestHandler).Returns(requestHandler.Object);
|
||||
settings.Setup(x => x.Logging).Returns(logging.Object);
|
||||
settings.Setup(x => x.ScheduledTasks).Returns(tasks.Object);
|
||||
settings.Setup(x => x.Providers).Returns(providers.Object);
|
||||
settings.Setup(x => x.WebRouting).Returns(routing.Object);
|
||||
|
||||
@@ -55,7 +53,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
settings.Setup(x => x.Content.ImageFileTypes).Returns(ContentImagingElement.GetDefaultImageFileTypes());
|
||||
settings.Setup(x => x.RequestHandler.AddTrailingSlash).Returns(true);
|
||||
settings.Setup(x => x.RequestHandler.CharCollection).Returns(RequestHandlerElement.GetDefaultCharReplacements());
|
||||
settings.Setup(x => x.WebRouting.UrlProviderMode).Returns("AutoLegacy");
|
||||
settings.Setup(x => x.WebRouting.UrlProviderMode).Returns("Auto");
|
||||
settings.Setup(x => x.Providers.DefaultBackOfficeUserProvider).Returns("UsersMembershipProvider");
|
||||
|
||||
return settings.Object;
|
||||
|
||||
@@ -302,8 +302,6 @@
|
||||
<Compile Include="Configurations\UmbracoSettings\ProvidersElementTests.cs" />
|
||||
<Compile Include="Configurations\UmbracoSettings\RequestHandlerElementDefaultTests.cs" />
|
||||
<Compile Include="Configurations\UmbracoSettings\RequestHandlerElementTests.cs" />
|
||||
<Compile Include="Configurations\UmbracoSettings\ScheduledTasksElementDefaultTests.cs" />
|
||||
<Compile Include="Configurations\UmbracoSettings\ScheduledTasksElementTests.cs" />
|
||||
<Compile Include="Configurations\UmbracoSettings\SecurityElementDefaultTests.cs" />
|
||||
<Compile Include="Configurations\UmbracoSettings\SecurityElementTests.cs" />
|
||||
<Compile Include="Configurations\UmbracoSettings\UmbracoSettingsTests.cs" />
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
new Mock<HttpContextBase>().Object,
|
||||
publishedSnapshotService.Object,
|
||||
new Mock<WebSecurity>(null, null, globalSettings).Object,
|
||||
Mock.Of<IUmbracoSettingsSection>(section => section.WebRouting == Mock.Of<IWebRoutingSection>(routingSection => routingSection.UrlProviderMode == "AutoLegacy")),
|
||||
Mock.Of<IUmbracoSettingsSection>(section => section.WebRouting == Mock.Of<IWebRoutingSection>(routingSection => routingSection.UrlProviderMode == "Auto")),
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestVariationContextAccessor(),
|
||||
@@ -145,7 +145,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
[Test]
|
||||
public void Mock_Current_Page()
|
||||
{
|
||||
var webRoutingSettings = Mock.Of<IWebRoutingSection>(section => section.UrlProviderMode == "AutoLegacy");
|
||||
var webRoutingSettings = Mock.Of<IWebRoutingSection>(section => section.UrlProviderMode == "Auto");
|
||||
var globalSettings = TestObjects.GetGlobalSettings();
|
||||
|
||||
var umbracoContext = UmbracoContext.EnsureContext(
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Umbraco.Tests.Web
|
||||
snapshotService,
|
||||
new Mock<WebSecurity>(null, null, globalSettings).Object,
|
||||
//setup a quick mock of the WebRouting section
|
||||
Mock.Of<IUmbracoSettingsSection>(section => section.WebRouting == Mock.Of<IWebRoutingSection>(routingSection => routingSection.UrlProviderMode == "AutoLegacy")),
|
||||
Mock.Of<IUmbracoSettingsSection>(section => section.WebRouting == Mock.Of<IWebRoutingSection>(routingSection => routingSection.UrlProviderMode == "Auto")),
|
||||
//pass in the custom url provider
|
||||
new[]{ testUrlProvider.Object },
|
||||
globalSettings,
|
||||
|
||||
@@ -74,17 +74,10 @@
|
||||
</security>
|
||||
|
||||
<requestHandler>
|
||||
<!-- this will add a trailing slash (/) to urls when in directory url mode -->
|
||||
<addTrailingSlash>true</addTrailingSlash>
|
||||
<!-- this ensures that all url segments are turned to ASCII as much as we can -->
|
||||
<urlReplacing toAscii="try" />
|
||||
</requestHandler>
|
||||
|
||||
<scheduledTasks>
|
||||
<!-- add tasks that should be called with an interval (seconds) -->
|
||||
<!-- <task log="true" alias="test60" interval="60" url="http://localhost/umbraco/test.aspx"/>-->
|
||||
</scheduledTasks>
|
||||
|
||||
<!--
|
||||
web.routing
|
||||
@trySkipIisCustomErrors
|
||||
|
||||
@@ -133,11 +133,6 @@
|
||||
<!--<externalLogger assembly="~/bin/assemblyFileName.dll" type="fully.qualified.namespace.and.type" logAuditTrail="false" /> -->
|
||||
</logging>
|
||||
|
||||
<scheduledTasks>
|
||||
<!-- add tasks that should be called with an interval (seconds) -->
|
||||
<!-- <task log="true" alias="test60" interval="60" url="http://localhost/umbraco/test.aspx"/>-->
|
||||
</scheduledTasks>
|
||||
|
||||
<providers>
|
||||
<users>
|
||||
<!-- if you wish to use your own membershipprovider for authenticating to the umbraco back office -->
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
namespace Umbraco.Web.Routing
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the type of urls that the url provider should produce.
|
||||
/// Specifies the type of urls that the url provider should produce, Auto is the default
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>The <c>AutoLegacy</c> option is equivalent to <c>Auto</c> but it also respects the legacy <c>useDomainPrefixes</c> setting.
|
||||
/// When that setting is true, then all urls are absolute. Otherwise, urls will be relative or absolute, depending on hostnames.</para>
|
||||
/// <para>The <c>Relative</c> option can lead to invalid results when combined with hostnames, but it is the only way to reproduce
|
||||
/// the true, pre-4.10, always-relative behavior of Umbraco.</para>
|
||||
/// <para>For the time being, the default option is <c>AutoLegacy</c> although in the future it will be <c>Auto</c>.</para>
|
||||
/// </remarks>
|
||||
public enum UrlProviderMode
|
||||
{
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Sync;
|
||||
|
||||
namespace Umbraco.Web.Scheduling
|
||||
{
|
||||
// TODO: No scheduled task (i.e. URL) would be secured, so if people are actually using these each task
|
||||
// would need to be a publicly available task (URL) which isn't really very good :(
|
||||
// We should really be using the AdminTokenAuthorizeAttribute for this stuff
|
||||
|
||||
internal class ScheduledTasks : RecurringTaskBase
|
||||
{
|
||||
private static HttpClient _httpClient;
|
||||
private readonly IRuntimeState _runtime;
|
||||
private readonly IUmbracoSettingsSection _settings;
|
||||
private readonly IProfilingLogger _logger;
|
||||
private static readonly Hashtable ScheduledTaskTimes = new Hashtable();
|
||||
|
||||
public ScheduledTasks(IBackgroundTaskRunner<RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
|
||||
IRuntimeState runtime, IUmbracoSettingsSection settings, IProfilingLogger logger)
|
||||
: base(runner, delayMilliseconds, periodMilliseconds)
|
||||
{
|
||||
_runtime = runtime;
|
||||
_settings = settings;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
private async Task ProcessTasksAsync(CancellationToken token)
|
||||
{
|
||||
var scheduledTasks = _settings.ScheduledTasks.Tasks;
|
||||
foreach (var t in scheduledTasks)
|
||||
{
|
||||
var runTask = false;
|
||||
if (ScheduledTaskTimes.ContainsKey(t.Alias) == false)
|
||||
{
|
||||
runTask = true;
|
||||
ScheduledTaskTimes.Add(t.Alias, DateTime.Now);
|
||||
}
|
||||
|
||||
// Add 1 second to timespan to compensate for differences in timer
|
||||
else if (
|
||||
new TimeSpan(
|
||||
DateTime.Now.Ticks - ((DateTime)ScheduledTaskTimes[t.Alias]).Ticks).TotalSeconds + 1 >= t.Interval)
|
||||
{
|
||||
runTask = true;
|
||||
ScheduledTaskTimes[t.Alias] = DateTime.Now;
|
||||
}
|
||||
|
||||
if (runTask)
|
||||
{
|
||||
var taskResult = await GetTaskByHttpAync(t.Url, token);
|
||||
if (t.Log)
|
||||
_logger.Info<ScheduledTasks>("{TaskAlias} has been called with response: {TaskResult}", t.Alias, taskResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> GetTaskByHttpAync(string url, CancellationToken token)
|
||||
{
|
||||
if (_httpClient == null)
|
||||
_httpClient = new HttpClient
|
||||
{
|
||||
BaseAddress = _runtime.ApplicationUrl
|
||||
};
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
|
||||
// TODO: pass custom the authorization header, currently these aren't really secured!
|
||||
//request.Headers.Authorization = AdminTokenAuthorizeAttribute.GetAuthenticationHeaderValue(_appContext);
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _httpClient.SendAsync(request, token).ConfigureAwait(false); // ConfigureAwait(false) is recommended? http://blog.stephencleary.com/2012/07/dont-block-on-async-code.html
|
||||
return result.StatusCode == HttpStatusCode.OK;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error<ScheduledTasks>(ex, "An error occurred calling web task for url: {Url}", url);
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override async Task<bool> PerformRunAsync(CancellationToken token)
|
||||
{
|
||||
switch (_runtime.ServerRole)
|
||||
{
|
||||
case ServerRole.Replica:
|
||||
_logger.Debug<ScheduledTasks>("Does not run on replica servers.");
|
||||
return true; // DO repeat, server role can change
|
||||
case ServerRole.Unknown:
|
||||
_logger.Debug<ScheduledTasks>("Does not run on servers with unknown role.");
|
||||
return true; // DO repeat, server role can change
|
||||
}
|
||||
|
||||
// ensure we do not run if not main domain, but do NOT lock it
|
||||
if (_runtime.IsMainDom == false)
|
||||
{
|
||||
_logger.Debug<ScheduledTasks>("Does not run if not MainDom.");
|
||||
return false; // do NOT repeat, going down
|
||||
}
|
||||
|
||||
using (_logger.DebugDuration<ScheduledTasks>("Scheduled tasks executing", "Scheduled tasks complete"))
|
||||
{
|
||||
try
|
||||
{
|
||||
await ProcessTasksAsync(token);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error<ScheduledTasks>(ex, "Error executing scheduled task");
|
||||
}
|
||||
}
|
||||
|
||||
return true; // repeat
|
||||
}
|
||||
|
||||
public override bool IsAsync => true;
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,6 @@ namespace Umbraco.Web.Scheduling
|
||||
|
||||
tasks.Add(RegisterKeepAlive());
|
||||
tasks.Add(RegisterScheduledPublishing());
|
||||
tasks.Add(RegisterTaskRunner(settings));
|
||||
tasks.Add(RegisterLogScrubber(settings));
|
||||
|
||||
var healthCheckConfig = Current.Configs.HealthChecks();
|
||||
@@ -119,14 +118,7 @@ namespace Umbraco.Web.Scheduling
|
||||
_publishingRunner.TryAdd(task);
|
||||
return task;
|
||||
}
|
||||
|
||||
private IBackgroundTask RegisterTaskRunner(IUmbracoSettingsSection settings)
|
||||
{
|
||||
var task = new ScheduledTasks(_tasksRunner, 60000, 60000, _runtime, settings, _logger);
|
||||
_tasksRunner.TryAdd(task);
|
||||
return task;
|
||||
}
|
||||
|
||||
|
||||
private IBackgroundTask RegisterHealthCheckNotifier(IHealthChecks healthCheckConfig,
|
||||
HealthCheckCollection healthChecks, HealthCheckNotificationMethodCollection notifications,
|
||||
IProfilingLogger logger)
|
||||
|
||||
@@ -924,7 +924,6 @@
|
||||
<Compile Include="Scheduling\KeepAlive.cs" />
|
||||
<Compile Include="Scheduling\LogScrubber.cs" />
|
||||
<Compile Include="Scheduling\ScheduledPublishing.cs" />
|
||||
<Compile Include="Scheduling\ScheduledTasks.cs" />
|
||||
<Compile Include="Scheduling\TaskEventArgs.cs" />
|
||||
<Compile Include="Security\MembershipHelper.cs" />
|
||||
<Compile Include="Editors\SectionController.cs" />
|
||||
|
||||
Reference in New Issue
Block a user