An attempt to speed up sorting a large set of nodes when a large set of users exist. Our sorts were failing in azure because the user notifications were taking long enough that azure would kill the thread.
This commit is contained in:
@@ -9,6 +9,7 @@ using Umbraco.Core.Services;
|
||||
using umbraco;
|
||||
using umbraco.BusinessLogic.Actions;
|
||||
using umbraco.interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
@@ -27,6 +28,16 @@ namespace Umbraco.Web
|
||||
service.SendNotification(entity, action, UmbracoContext.Current);
|
||||
}
|
||||
|
||||
internal static void SendNotification(this INotificationService service, IEnumerable<IUmbracoEntity> entities, IAction action, ApplicationContext applicationContext)
|
||||
{
|
||||
if (UmbracoContext.Current == null)
|
||||
{
|
||||
LogHelper.Warn(typeof(NotificationServiceExtensions), "Cannot send notifications, there is no current UmbracoContext");
|
||||
return;
|
||||
}
|
||||
service.SendNotification(entities, action, UmbracoContext.Current);
|
||||
}
|
||||
|
||||
internal static void SendNotification(this INotificationService service, IUmbracoEntity entity, IAction action, UmbracoContext umbracoContext)
|
||||
{
|
||||
if (umbracoContext == null)
|
||||
@@ -37,6 +48,16 @@ namespace Umbraco.Web
|
||||
service.SendNotification(entity, action, umbracoContext, umbracoContext.Application);
|
||||
}
|
||||
|
||||
internal static void SendNotification(this INotificationService service, IEnumerable<IUmbracoEntity> entities, IAction action, UmbracoContext umbracoContext)
|
||||
{
|
||||
if (umbracoContext == null)
|
||||
{
|
||||
LogHelper.Warn(typeof(NotificationServiceExtensions), "Cannot send notifications, there is no current UmbracoContext");
|
||||
return;
|
||||
}
|
||||
service.SendNotification(entities, action, umbracoContext, umbracoContext.Application);
|
||||
}
|
||||
|
||||
internal static void SendNotification(this INotificationService service, IUmbracoEntity entity, IAction action, UmbracoContext umbracoContext, ApplicationContext applicationContext)
|
||||
{
|
||||
if (umbracoContext == null)
|
||||
@@ -61,6 +82,30 @@ namespace Umbraco.Web
|
||||
service.SendNotification(user, entity, action, umbracoContext, applicationContext);
|
||||
}
|
||||
|
||||
internal static void SendNotification(this INotificationService service, IEnumerable<IUmbracoEntity> entities, IAction action, UmbracoContext umbracoContext, ApplicationContext applicationContext)
|
||||
{
|
||||
if (umbracoContext == null)
|
||||
{
|
||||
LogHelper.Warn(typeof(NotificationServiceExtensions), "Cannot send notifications, there is no current UmbracoContext");
|
||||
return;
|
||||
}
|
||||
|
||||
var user = umbracoContext.Security.CurrentUser;
|
||||
|
||||
//if there is no current user, then use the admin
|
||||
if (user == null)
|
||||
{
|
||||
LogHelper.Debug(typeof(NotificationServiceExtensions), "There is no current Umbraco user logged in, the notifications will be sent from the administrator");
|
||||
user = applicationContext.Services.UserService.GetUserById(0);
|
||||
if (user == null)
|
||||
{
|
||||
LogHelper.Warn(typeof(NotificationServiceExtensions), "Noticiations can not be sent, no admin user with id 0 could be resolved");
|
||||
return;
|
||||
}
|
||||
}
|
||||
service.SendNotification(user, entities, action, umbracoContext, applicationContext);
|
||||
}
|
||||
|
||||
internal static void SendNotification(this INotificationService service, IUser sender, IUmbracoEntity entity, IAction action, UmbracoContext umbracoContext, ApplicationContext applicationContext)
|
||||
{
|
||||
if (sender == null) throw new ArgumentNullException("sender");
|
||||
@@ -79,5 +124,24 @@ namespace Umbraco.Web
|
||||
? ui.Text("notifications", "mailBody", strings, mailingUser)
|
||||
: ui.Text("notifications", "mailBodyHtml", strings, mailingUser));
|
||||
}
|
||||
|
||||
internal static void SendNotification(this INotificationService service, IUser sender, IEnumerable<IUmbracoEntity> entities, IAction action, UmbracoContext umbracoContext, ApplicationContext applicationContext)
|
||||
{
|
||||
if (sender == null) throw new ArgumentNullException("sender");
|
||||
if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
|
||||
if (applicationContext == null) throw new ArgumentNullException("applicationContext");
|
||||
|
||||
|
||||
applicationContext.Services.NotificationService.SendNotifications(
|
||||
sender,
|
||||
entities,
|
||||
action.Letter.ToString(CultureInfo.InvariantCulture),
|
||||
ui.Text("actions", action.Alias),
|
||||
umbracoContext.HttpContext,
|
||||
(mailingUser, strings) => ui.Text("notifications", "mailSubject", strings, mailingUser),
|
||||
(mailingUser, strings) => UmbracoConfig.For.UmbracoSettings().Content.DisableHtmlEmail
|
||||
? ui.Text("notifications", "mailBody", strings, mailingUser)
|
||||
: ui.Text("notifications", "mailBodyHtml", strings, mailingUser));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user