Merge remote-tracking branch 'origin/1.9.x' into feature/deployment

Conflicts:
	src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs
This commit is contained in:
Bertrand Le Roy
2015-06-01 12:21:45 -07:00
23 changed files with 195 additions and 138 deletions

View File

@@ -42,7 +42,7 @@
// display a message on leave if changes have been made
window.onbeforeunload = function (e) {
return leaveConfirmation;
return $("<div/>").html(leaveConfirmation).text();
};
// cancel leaving message on save

View File

@@ -22,7 +22,7 @@
<label for="menuId">@T("Current Menu:")</label>
<select id="menuId" name="menuId">
@foreach (var menu in Model.Menus) {
@Html.SelectOption(Model.CurrentMenu.Id, menu.Id, Convert.ToString(Html.ItemDisplayText(menu)))
@Html.SelectOption(Model.CurrentMenu.Id, menu.Id, Convert.ToString(Html.ItemDisplayText(menu, false)))
}
</select>
@if (hasPermission) {
@@ -134,12 +134,12 @@
@using (Script.Foot()) {
<script type="text/javascript">
//<![CDATA[
var leaveConfirmation = '@T("Some items where not saved.")';
//<![CDATA[
var leaveConfirmation = '@HttpUtility.JavaScriptStringEncode(T("Some items where not saved.").Text)';
$('#menuId').change(function () {
$(this).parents('form').submit();
});
//]]>
//]]>
</script>
}

View File

@@ -6,7 +6,7 @@
@Html.LabelFor(m => m.CurrentMenuId, T("For Menu"))
<select id="@Html.FieldIdFor(m => m.CurrentMenuId)" name="@Html.FieldNameFor(m => m.CurrentMenuId)">
@foreach(ContentItem menu in Model.Menus) {
@Html.SelectOption(Model.CurrentMenuId, menu.Id, Html.ItemDisplayText(menu).ToString())
@Html.SelectOption(Model.CurrentMenuId, menu.Id, Html.ItemDisplayText(menu, false).ToString())
}
</select>
<span class="hint">@T("Select which menu you want to display")</span>

View File

@@ -11,7 +11,7 @@
<div data-controllerid="@Html.FieldIdFor(m => m.OnMenu)" class="">
<select id="@Html.FieldIdFor(m => m.CurrentMenuId)" name="@Html.FieldNameFor(m => m.CurrentMenuId)">
@foreach (ContentItem menu in Model.Menus) {
@Html.SelectOption(Model.CurrentMenuId, menu.Id, Html.ItemDisplayText(menu).ToString())
@Html.SelectOption(Model.CurrentMenuId, menu.Id, Html.ItemDisplayText(menu, false).ToString())
}
</select>
<span class="hint">@T("Select which menu you want the content item to be displayed on.")</span>

View File

@@ -29,7 +29,7 @@
<div data-controllerid="@Html.FieldIdFor(m => m.AddMenuItem)">
<select id="@Html.FieldIdFor(m => m.CurrentMenuId)" name="@Html.FieldNameFor(m => m.CurrentMenuId)">
@foreach (ContentItem menu in Model.Menus) {
@Html.SelectOption(Model.CurrentMenuId, menu.Id, Html.ItemDisplayText(menu).ToString())
@Html.SelectOption(Model.CurrentMenuId, menu.Id, Html.ItemDisplayText(menu, false).ToString())
}
</select>
<span class="hint">@T("Select which menu you want the content item to be added on.")</span>

View File

@@ -1,16 +1,17 @@
using System.Web;
using System.Web.Mvc;
using Orchard.Layouts.Filters;
using Orchard.Mvc;
namespace Orchard.Layouts.Services {
public class CurrentControllerAccessor : ICurrentControllerAccessor {
private readonly IHttpContextAccessor _httpContextAccessor;
public CurrentControllerAccessor(IHttpContextAccessor httpContextAccessor) {
_httpContextAccessor = httpContextAccessor;
private readonly HttpContextBase _httpContext;
public CurrentControllerAccessor(HttpContextBase httpContext) {
_httpContext = httpContext;
}
public Controller CurrentController {
get { return (Controller) _httpContextAccessor.Current().Items[ControllerAccessorFilter.CurrentControllerKey]; }
get { return (Controller) _httpContext.Items[ControllerAccessorFilter.CurrentControllerKey]; }
}
}
}

View File

@@ -43,7 +43,7 @@
var force = actionLink.data("feature-force");
var dependants = actionLink.data("feature-dependants");
if (!dependants || /^\s*$/.test(dependants) || confirm(confirmDisableMessage + "\n\n" + dependants)) {
if (!dependants || /^\s*$/.test(dependants) || confirm($("<div/>").html(confirmDisableMessage + "\n\n" + dependants).text())) {
$("[name='submit.BulkExecute']").val("yes");
$("[name='featureIds']").val(featureId);

View File

@@ -1,4 +1 @@
$(function(){var n=function(){var n=$(".bulk-actions-wrapper").addClass("visible"),t=$(".switch-for-switchable");t.prepend(n);$("#search-box").focus().keyup(function(){var n=$(this).val(),t;if(n==""){$("li.category").show();$("li.feature:hidden").show();return}$("li.feature").each(function(){var t=$(this),i=t.find("h3:first").text();i.toLowerCase().indexOf(n.toLowerCase())>=0?t.show():t.hide()});$("li.category:hidden").show();t=$("li.category:not(:has(li.feature:visible))").hide()})},t=function(){$("li.feature h3").on("change","input[type='checkbox']",function(){var n=$(this).is(":checked"),t=$(this).parents("li.feature:first");t.toggleClass("selected",n)})},i=function(){$("li.feature .actions").on("click","a[data-feature-action]",function(n){var t=$(this),r=t.data("feature-id"),u=t.data("feature-action"),f=t.data("feature-force"),i=t.data("feature-dependants");(!i||/^\s*$/.test(i)||confirm(confirmDisableMessage+"\n\n"+i))&&($("[name='submit.BulkExecute']").val("yes"),$("[name='featureIds']").val(r),$("[name='bulkAction']").val(u),$("[name='force']").val(f),t.parents("form:first").submit());n.preventDefault()})};n();t();i()});
/*
//# sourceMappingURL=features.admin.min.js.map
*/
$(function(){var n=function(){var n=$(".bulk-actions-wrapper").addClass("visible"),t=$(".switch-for-switchable");t.prepend(n);$("#search-box").keyup(function(){var n=$(this).val(),t;if(n==""){$("li.category").show();$("li.feature:hidden").show();return}$("li.feature").each(function(){var t=$(this),i=t.find("h3:first").text();i.toLowerCase().indexOf(n.toLowerCase())>=0?t.show():t.hide()});$("li.category:hidden").show();t=$("li.category:not(:has(li.feature:visible))").hide()})},t=function(){$("li.feature h3").on("change","input[type='checkbox']",function(){var n=$(this).is(":checked"),t=$(this).parents("li.feature:first");t.toggleClass("selected",n)})},i=function(){$("li.feature .actions").on("click","a[data-feature-action]",function(n){var t=$(this),r=t.data("feature-id"),u=t.data("feature-action"),f=t.data("feature-force"),i=t.data("feature-dependants");(!i||/^\s*$/.test(i)||confirm($("<div/>").html(confirmDisableMessage+"\n\n"+i).text()))&&($("[name='submit.BulkExecute']").val("yes"),$("[name='featureIds']").val(r),$("[name='bulkAction']").val(u),$("[name='force']").val(f),t.parents("form:first").submit());n.preventDefault()})};n();t();i()});

View File

@@ -16,29 +16,29 @@
@if (Model.Features.Any()) {
using (Html.BeginFormAntiForgeryPost()) {
@Html.Hidden("submit.BulkExecute")
@Html.Hidden("force", true)
@Html.Hidden("featureIds")
<div class="bulk-actions-wrapper">
<fieldset class="bulk-actions">
<label for="search-box">@T("Filter:")</label>
<input id="search-box" class="text" type="text" autofocus="autofocus" />
</fieldset>
<fieldset class="bulk-actions">
<label for="publishActions">@T("Actions:")</label>
<select id="publishActions" name="bulkAction">
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.None, T("Choose action...").ToString())
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.Enable, T("Enable").ToString())
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.Disable, T("Disable").ToString())
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.Update, T("Update").ToString())
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.Toggle, T("Toggle").ToString())
</select>
<button type="submit" name="submit.BulkExecute" value="yes">@T("Execute")</button>
</fieldset>
</div>
@Html.Hidden("submit.BulkExecute")
@Html.Hidden("force", true)
@Html.Hidden("featureIds")
<div class="bulk-actions-wrapper">
<fieldset class="bulk-actions">
<label for="search-box">@T("Filter:")</label>
<input id="search-box" class="text" type="text" autofocus="autofocus" />
</fieldset>
<fieldset class="bulk-actions">
<label for="publishActions">@T("Actions:")</label>
<select id="publishActions" name="bulkAction">
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.None, T("Choose action...").ToString())
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.Enable, T("Enable").ToString())
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.Disable, T("Disable").ToString())
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.Update, T("Update").ToString())
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.Toggle, T("Toggle").ToString())
</select>
<button type="submit" name="submit.BulkExecute" value="yes">@T("Execute")</button>
</fieldset>
</div>
<ul class="features summary-view switchable">
@{
<ul class="features summary-view switchable">
@{
var featureGroups = Model.Features.OrderBy(f => f.Descriptor.Category, new DoghouseComparer("Core")).GroupBy(f => f.Descriptor.Category).ToList();
foreach (var featureGroup in featureGroups) {
if (!featureGroup.Any(x => Model.IsAllowed(x.Descriptor.Extension))) {
@@ -98,8 +98,7 @@
<input type="checkbox" name="featureIds" value="@feature.Descriptor.Id" />
@featureName
</label>
}
else {
} else {
@featureName
}
</h3>
@@ -138,14 +137,14 @@
}
</ul>
</li>}
}
</ul>}
}
</ul>}
using (Script.Foot()) {
<script type="text/javascript">
//<![CDATA[
var confirmDisableMessage = '@T("Disabling this feature will also disable the following dependent features. Are you sure you want to continue?")';
//]]>
//<![CDATA[
var confirmDisableMessage = '@HttpUtility.JavaScriptStringEncode(T("Disabling this feature will also disable the following dependent features. Are you sure you want to continue?").Text)';
//]]>
</script>
}
}

View File

@@ -213,30 +213,39 @@ namespace Orchard.OutputCache.Filters {
response.Filter = captureStream;
captureStream.Captured += (output) => {
try {
var cacheItem = new CacheItem() {
CachedOnUtc = _now,
Duration = cacheDuration,
GraceTime = cacheGraceTime,
Output = output,
ContentType = response.ContentType,
QueryString = filterContext.HttpContext.Request.Url.Query,
CacheKey = _cacheKey,
InvariantCacheKey = _invariantCacheKey,
Url = filterContext.HttpContext.Request.Url.AbsolutePath,
Tenant = _shellSettings.Name,
StatusCode = response.StatusCode,
Tags = new[] { _invariantCacheKey }.Union(contentItemIds).ToArray()
};
// Since this is a callback any call to injected dependencies can result in an Autofac exception: "Instances
// cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed."
// To prevent access to the original lifetime scope a new work context scope should be created here and dependencies
// should be resolved from it.
// Write the rendered item to the cache.
_cacheStorageProvider.Remove(_cacheKey);
_cacheStorageProvider.Set(_cacheKey, cacheItem);
using (var scope = _workContextAccessor.CreateWorkContextScope()) {
var cacheItem = new CacheItem() {
CachedOnUtc = _now,
Duration = cacheDuration,
GraceTime = cacheGraceTime,
Output = output,
ContentType = response.ContentType,
QueryString = filterContext.HttpContext.Request.Url.Query,
CacheKey = _cacheKey,
InvariantCacheKey = _invariantCacheKey,
Url = filterContext.HttpContext.Request.Url.AbsolutePath,
Tenant = scope.Resolve<ShellSettings>().Name,
StatusCode = response.StatusCode,
Tags = new[] { _invariantCacheKey }.Union(contentItemIds).ToArray()
};
Logger.Debug("Item '{0}' was written to cache.", _cacheKey);
// Write the rendered item to the cache.
var cacheStorageProvider = scope.Resolve<IOutputCacheStorageProvider>();
cacheStorageProvider.Remove(_cacheKey);
cacheStorageProvider.Set(_cacheKey, cacheItem);
// Also add the item tags to the tag cache.
foreach (var tag in cacheItem.Tags) {
_tagCache.Tag(tag, _cacheKey);
Logger.Debug("Item '{0}' was written to cache.", _cacheKey);
// Also add the item tags to the tag cache.
var tagCache = scope.Resolve<ITagCache>();
foreach (var tag in cacheItem.Tags) {
tagCache.Tag(tag, _cacheKey);
}
}
}
finally {
@@ -447,6 +456,9 @@ namespace Orchard.OutputCache.Filters {
private void ServeCachedItem(ActionExecutingContext filterContext, CacheItem cacheItem) {
var response = filterContext.HttpContext.Response;
// Fix for missing charset in response headers
response.Charset = response.Charset;
// Adds some caching information to the output if requested.
if (CacheSettings.DebugMode) {
response.AddHeader("X-Cached-On", cacheItem.CachedOnUtc.ToString("r"));

View File

@@ -1,14 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<httpHandlers>
<!-- iis6 - for any request in this location, return via managed static file handler -->
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
</httpHandlers>
</system.web>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />

View File

@@ -59,10 +59,11 @@ namespace Orchard.Search.Controllers {
var viewModel = new MediaManagerMediaItemsViewModel {
MediaItems = mediaItems,
MediaItemsCount = mediaPartsCount
MediaItemsCount = mediaPartsCount,
FolderPath = folderPath
};
return View(viewModel);
}
}
}
}

View File

@@ -17,8 +17,9 @@
mimeTypeClass = x.MediaPart.MimeType.HtmlClassify(),
thumbnail = Display(x.Shape).ToString(),
editLink = Url.ItemEditUrl(x.MediaPart)
}).ToArray()
}).ToArray(),
folderPath = Model.FolderPath
}))
}

View File

@@ -36,25 +36,8 @@ namespace Orchard.SecureSocketsLayer.Drivers {
}
protected override void Importing(SslSettingsPart part, ImportContentContext context) {
var elementName = part.PartDefinition.Name;
part.Enabled = bool.Parse(context.Attribute(elementName, "Enabled") ?? "false");
part.SecureEverything = bool.Parse(context.Attribute(elementName, "SecureEverything") ?? "true");
part.CustomEnabled = bool.Parse(context.Attribute(elementName, "CustomEnabled") ?? "false");
part.Urls = context.Attribute(elementName, "Urls") ?? "";
part.InsecureHostName = context.Attribute(elementName, "InsecureHostName") ?? "";
part.SecureHostName = context.Attribute(elementName, "SecureHostName") ?? "";
base.Importing(part, context);
_signals.Trigger(SslSettingsPart.CacheKey);
}
protected override void Exporting(SslSettingsPart part, ExportContentContext context) {
var el = context.Element(part.PartDefinition.Name);
el.SetAttributeValue("Enabled", part.Enabled);
el.SetAttributeValue("SecureEverything", part.SecureEverything);
el.SetAttributeValue("CustomEnabled", part.CustomEnabled);
el.SetAttributeValue("Urls", part.Urls);
el.SetAttributeValue("InsecureHostName", part.InsecureHostName);
el.SetAttributeValue("SecureHostName", part.SecureHostName);
}
}
}
}

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Web.Routing;
using Autofac;
using JetBrains.Annotations;
using Orchard.Caching;
using Orchard.Commands;
using Orchard.Commands.Builtin;
@@ -66,6 +67,7 @@ namespace Orchard.Setup {
builder.RegisterType<ResourceFilter>().As<IFilterProvider>().InstancePerLifetimeScope();
builder.RegisterType<DefaultOrchardShell>().As<IOrchardShell>().InstancePerMatchingLifetimeScope("shell");
builder.RegisterType<SweepGenerator>().As<ISweepGenerator>().SingleInstance();
builder.RegisterType<SetupBackgroundService>().As<IBackgroundService>().InstancePerLifetimeScope();
// setup mode specific implementations of needed service interfaces
builder.RegisterType<SafeModeThemeService>().As<IThemeManager>().InstancePerLifetimeScope();
@@ -100,6 +102,13 @@ namespace Orchard.Setup {
}
internal class SetupBackgroundService : IBackgroundService {
public void Sweep() {
// Don't run any background service in setup mode.
}
}
[UsedImplicitly]
class SafeModeText : IText {
public LocalizedString Get(string textHint, params object[] args) {
if (args == null || args.Length == 0) {
@@ -109,6 +118,7 @@ namespace Orchard.Setup {
}
}
[UsedImplicitly]
class SafeModeThemeService : IThemeManager {
private readonly ExtensionDescriptor _theme = new ExtensionDescriptor {
Id = "SafeMode",
@@ -119,6 +129,7 @@ namespace Orchard.Setup {
public ExtensionDescriptor GetRequestTheme(RequestContext requestContext) { return _theme; }
}
[UsedImplicitly]
class SafeModeSiteWorkContextProvider : IWorkContextStateProvider {
public Func<WorkContext, T> Get<T>(string name) {
if (name == "CurrentSite") {
@@ -129,6 +140,7 @@ namespace Orchard.Setup {
}
}
[UsedImplicitly]
class SafeModeSiteService : ISiteService {
public ISite GetSiteSettings() {
var siteType = new ContentTypeDefinitionBuilder().Named("Site").Build();

View File

@@ -0,0 +1,33 @@
using System.IO;
using System.Web;
using Orchard.Settings;
namespace Orchard {
/// <summary>
/// A factory class that creates an HttpContext instance and initializes the HttpContext.Current property with that instance.
/// This is useful when rendering views from a background thread, as some Html Helpers access HttpContext.Current directly, thus preventing a NullReferenceException.
/// </summary>
public class BackgroundHttpContextFactory : IBackgroundHttpContextFactory {
public const string IsBackgroundHttpContextKey = "IsBackgroundHttpContext";
private readonly ISiteService _siteService;
public BackgroundHttpContextFactory(ISiteService siteService) {
_siteService = siteService;
}
public HttpContext CreateHttpContext() {
var url = _siteService.GetSiteSettings().BaseUrl;
var httpContext = new HttpContext(new HttpRequest("", url, ""), new HttpResponse(new StringWriter()));
httpContext.Items[IsBackgroundHttpContextKey] = true;
return httpContext;
}
public void InitializeHttpContext() {
if (HttpContext.Current != null)
return;
HttpContext.Current = CreateHttpContext();
}
}
}

View File

@@ -0,0 +1,8 @@
using System.Web;
namespace Orchard {
public interface IBackgroundHttpContextFactory : IDependency {
HttpContext CreateHttpContext();
void InitializeHttpContext();
}
}

View File

@@ -7,11 +7,15 @@ using Orchard.Utility.Extensions;
namespace Orchard.Mvc.Html {
public static class ContentItemExtensions {
public static MvcHtmlString ItemDisplayText(this HtmlHelper html, IContent content) {
public static MvcHtmlString ItemDisplayText(this HtmlHelper html, IContent content, bool encode = true) {
var metadata = content.ContentItem.ContentManager.GetItemMetadata(content);
if (metadata.DisplayText == null)
return null;
return MvcHtmlString.Create(html.Encode(metadata.DisplayText));
if (encode) {
return MvcHtmlString.Create(html.Encode(metadata.DisplayText));
} else {
return MvcHtmlString.Create(metadata.DisplayText);
}
}
public static MvcHtmlString ItemDisplayLink(this HtmlHelper html, IContent content) {

View File

@@ -0,0 +1,39 @@
using System;
using System.Web;
namespace Orchard.Mvc {
public class HttpContextAccessor : IHttpContextAccessor {
private HttpContextBase _httpContext;
public HttpContextBase Current() {
var httpContext = GetStaticProperty();
return !IsBackgroundHttpContext(httpContext) ? new HttpContextWrapper(httpContext) : _httpContext;
}
public void Set(HttpContextBase httpContext) {
_httpContext = httpContext;
}
private static bool IsBackgroundHttpContext(HttpContext httpContext) {
return httpContext == null || httpContext.Items.Contains(BackgroundHttpContextFactory.IsBackgroundHttpContextKey);
}
private static HttpContext GetStaticProperty() {
var httpContext = HttpContext.Current;
if (httpContext == null) {
return null;
}
try {
// The "Request" property throws at application startup on IIS integrated pipeline mode.
if (httpContext.Request == null) {
return null;
}
}
catch (Exception) {
return null;
}
return httpContext;
}
}
}

View File

@@ -1,39 +1,8 @@
using System;
using System.Web;
using System.Web;
namespace Orchard.Mvc {
public interface IHttpContextAccessor {
HttpContextBase Current();
void Set(HttpContextBase httpContext);
}
public class HttpContextAccessor : IHttpContextAccessor {
private HttpContextBase _httpContext;
public HttpContextBase Current() {
var httpContext = GetStaticProperty();
return httpContext != null ? new HttpContextWrapper(httpContext) : _httpContext;
}
public void Set(HttpContextBase httpContext) {
_httpContext = httpContext;
}
private HttpContext GetStaticProperty() {
var httpContext = HttpContext.Current;
if (httpContext == null) {
return null;
}
try {
if (httpContext.Request == null) {
return null;
}
}
catch (Exception) {
return null;
}
return httpContext;
}
}
}

View File

@@ -28,7 +28,7 @@ namespace Orchard.Mvc {
return false;
try {
// The "Request" property throws at application startup on IIS integrated pipeline mode
// The "Request" property throws at application startup on IIS integrated pipeline mode.
var req = HttpContext.Current.Request;
}
catch (Exception) {

View File

@@ -149,6 +149,7 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="BackgroundHttpContextFactory.cs" />
<Compile Include="Caching\DefaultCacheContextAccessor.cs" />
<Compile Include="Caching\DefaultParallelCacheContext.cs" />
<Compile Include="Caching\ICacheContextAccessor.cs" />
@@ -320,6 +321,7 @@
<Compile Include="Mvc\DataAnnotations\LocalizedRequiredAttribute.cs" />
<Compile Include="Mvc\Extensions\RouteExtension.cs" />
<Compile Include="Mvc\FormValueRequiredAttribute.cs" />
<Compile Include="Mvc\HttpContextAccessor.cs" />
<Compile Include="Mvc\HttpContextWorkContext.cs" />
<Compile Include="Mvc\Extensions\ControllerExtensions.cs" />
<Compile Include="Mvc\IOrchardViewPage.cs" />
@@ -647,6 +649,7 @@
<Compile Include="WebApi\Filters\OrchardApiActionFilterDispatcher.cs" />
<Compile Include="WebApi\Routes\IHttpRouteProvider.cs" />
<Compile Include="WebApi\Routes\StandardExtensionHttpRouteProvider.cs" />
<Compile Include="IBackgroundHttpContextFactory.cs" />
<Compile Include="WorkContextExtensions.cs" />
<Compile Include="Mvc\ViewEngines\Razor\RazorCompilationEventsShim.cs" />
<Compile Include="Mvc\ViewEngines\Razor\RazorViewEngineProvider.cs" />

View File

@@ -14,24 +14,28 @@ namespace Orchard.Tasks {
public class BackgroundService : IBackgroundService {
private readonly IEnumerable<IBackgroundTask> _tasks;
private readonly ITransactionManager _transactionManager;
private readonly IBackgroundHttpContextFactory _backgroundHttpContextFactory;
private readonly string _shellName;
private readonly IContentManager _contentManager;
public BackgroundService(
IEnumerable<IBackgroundTask> tasks,
ITransactionManager transactionManager,
ShellSettings shellSettings,
IContentManager contentManager) {
IContentManager contentManager,
IBackgroundHttpContextFactory backgroundHttpContextFactory) {
_tasks = tasks;
_transactionManager = transactionManager;
_backgroundHttpContextFactory = backgroundHttpContextFactory;
_shellName = shellSettings.Name;
_contentManager = contentManager;
Logger = NullLogger.Instance;
}
public ILogger Logger { get; set; }
public void Sweep() {
_backgroundHttpContextFactory.InitializeHttpContext();
foreach(var task in _tasks) {
var taskName = task.GetType().FullName;