Merge
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
public class PublishEventArgs<TEntity> : CancellableObjectEventArgs<IEnumerable<TEntity>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor accepting multiple entities that are used in the publish operation
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
/// <param name="canCancel"></param>
|
||||
/// <param name="isAllPublished"></param>
|
||||
public PublishEventArgs(IEnumerable<TEntity> eventObject, bool canCancel, bool isAllPublished)
|
||||
: base(eventObject, canCancel)
|
||||
{
|
||||
IsAllRepublished = isAllPublished;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting multiple entities that are used in the publish operation
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
public PublishEventArgs(IEnumerable<TEntity> eventObject)
|
||||
: base(eventObject)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting a single entity instance
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
public PublishEventArgs(TEntity eventObject)
|
||||
: base(new List<TEntity> { eventObject })
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting a single entity instance
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
/// <param name="canCancel"></param>
|
||||
/// <param name="isAllPublished"></param>
|
||||
public PublishEventArgs(TEntity eventObject, bool canCancel, bool isAllPublished)
|
||||
: base(new List<TEntity> { eventObject }, canCancel)
|
||||
{
|
||||
IsAllRepublished = isAllPublished;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all entities that were published during the operation
|
||||
/// </summary>
|
||||
public IEnumerable<TEntity> PublishedEntities
|
||||
{
|
||||
get { return EventObject; }
|
||||
}
|
||||
|
||||
public bool IsAllRepublished { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
public class PublishingEventArgs : System.ComponentModel.CancelEventArgs
|
||||
{
|
||||
public PublishingEventArgs()
|
||||
{
|
||||
IsAllRepublished = false;
|
||||
}
|
||||
|
||||
public PublishingEventArgs(bool isAllPublished)
|
||||
{
|
||||
IsAllRepublished = isAllPublished;
|
||||
}
|
||||
|
||||
public bool IsAllRepublished { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
@@ -44,7 +43,7 @@ namespace Umbraco.Core.Events
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all entities that were deleted during the operation
|
||||
/// Returns all entities that were saved during the operation
|
||||
/// </summary>
|
||||
public IEnumerable<TEntity> SavedEntities
|
||||
{
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
public class UnPublishEventArgs<TEntity> : CancellableObjectEventArgs<IEnumerable<TEntity>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor accepting multiple entities that are used in the unpublish operation
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
/// <param name="canCancel"></param>
|
||||
public UnPublishEventArgs(IEnumerable<TEntity> eventObject, bool canCancel)
|
||||
: base(eventObject, canCancel)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting multiple entities that are used in the unpublish operation
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
public UnPublishEventArgs(IEnumerable<TEntity> eventObject)
|
||||
: base(eventObject)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting a single entity instance
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
public UnPublishEventArgs(TEntity eventObject)
|
||||
: base(new List<TEntity> { eventObject })
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting a single entity instance
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
/// <param name="canCancel"></param>
|
||||
public UnPublishEventArgs(TEntity eventObject, bool canCancel)
|
||||
: base(new List<TEntity> { eventObject }, canCancel)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all entities that were unpublished during the operation
|
||||
/// </summary>
|
||||
public IEnumerable<TEntity> UnPublishedEntities
|
||||
{
|
||||
get { return EventObject; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,6 @@ namespace Umbraco.Core.Models
|
||||
Mandate.ParameterNotNull(contentType, "contentType");
|
||||
Mandate.ParameterNotNull(properties, "properties");
|
||||
|
||||
//_parentId = parentId;
|
||||
_parentId = new Lazy<int>(() => parentId);
|
||||
|
||||
_contentTypeId = int.Parse(contentType.Id.ToString(CultureInfo.InvariantCulture));
|
||||
@@ -74,7 +73,6 @@ namespace Umbraco.Core.Models
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the Parent entity
|
||||
/// </summary>
|
||||
/// <remarks>Might not be necessary if handled as a relation?</remarks>
|
||||
[DataMember]
|
||||
public virtual int ParentId
|
||||
{
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace Umbraco.Core.Models.EntityBase
|
||||
{
|
||||
internal interface IUmbracoEntity : IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the Parent entity
|
||||
/// </summary>
|
||||
int ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the sort order of the Entity
|
||||
/// </summary>
|
||||
int SortOrder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the level of the Entity
|
||||
/// </summary>
|
||||
int Level { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the path to the Entity
|
||||
/// </summary>
|
||||
string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Profile of the user who created this Entity
|
||||
/// </summary>
|
||||
int CreatorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Boolean indicating whether this Entity is Trashed or not.
|
||||
/// If an Entity is Trashed it will be located in the Recyclebin.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When content is trashed it should be unpublished.
|
||||
/// Not all entities support being trashed, they'll always return false.
|
||||
/// </remarks>
|
||||
bool Trashed { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Core.Publishing
|
||||
@@ -15,92 +13,6 @@ namespace Umbraco.Core.Publishing
|
||||
public abstract bool UnPublish(IContent content, int userId);
|
||||
public abstract bool UnPublish(IEnumerable<IContent> content, int userId);
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before publish
|
||||
/// </summary>
|
||||
public static event EventHandler<PublishingEventArgs> Publishing;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="Publishing"/> event
|
||||
/// </summary>
|
||||
/// <param name="content"> </param>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void OnPublish(IContent content, PublishingEventArgs e)
|
||||
{
|
||||
if (Publishing != null)
|
||||
Publishing(content, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after publish
|
||||
/// </summary>
|
||||
public static event EventHandler<PublishingEventArgs> Published;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="Published"/> event
|
||||
/// </summary>
|
||||
/// <param name="content"> </param>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void OnPublished(IContent content, PublishingEventArgs e)
|
||||
{
|
||||
if (Published != null)
|
||||
Published(content, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="Published"/> event
|
||||
/// </summary>
|
||||
/// <param name="content"> </param>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void OnPublished(IEnumerable<IContent> content, PublishingEventArgs e)
|
||||
{
|
||||
if (Published != null)
|
||||
Published(content, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before unpublish
|
||||
/// </summary>
|
||||
public static event EventHandler<PublishingEventArgs> UnPublishing;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="UnPublishing"/> event
|
||||
/// </summary>
|
||||
/// <param name="content"> </param>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void OnUnPublish(IContent content, PublishingEventArgs e)
|
||||
{
|
||||
if (UnPublishing != null)
|
||||
UnPublishing(content, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after unpublish
|
||||
/// </summary>
|
||||
public static event EventHandler<PublishingEventArgs> UnPublished;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="UnPublished"/> event
|
||||
/// </summary>
|
||||
/// <param name="content"> </param>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void OnUnPublished(IContent content, PublishingEventArgs e)
|
||||
{
|
||||
if (UnPublished != null)
|
||||
UnPublished(content, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="UnPublished"/> event
|
||||
/// </summary>
|
||||
/// <param name="content"> </param>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void OnUnPublished(IEnumerable<IContent> content, PublishingEventArgs e)
|
||||
{
|
||||
if (UnPublished != null)
|
||||
UnPublished(content, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call to fire event that updating the published content has finalized.
|
||||
/// </summary>
|
||||
|
||||
@@ -10,9 +10,9 @@ namespace Umbraco.Core.Publishing
|
||||
/// <summary>
|
||||
/// Currently acts as an interconnection between the new public api and the legacy api for publishing
|
||||
/// </summary>
|
||||
internal class PublishingStrategy : BasePublishingStrategy
|
||||
public class PublishingStrategy : BasePublishingStrategy
|
||||
{
|
||||
internal PublishingStrategy()
|
||||
public PublishingStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,49 +24,43 @@ namespace Umbraco.Core.Publishing
|
||||
/// <returns>True if the publish operation was successfull and not cancelled, otherwise false</returns>
|
||||
public override bool Publish(IContent content, int userId)
|
||||
{
|
||||
var e = new PublishingEventArgs();
|
||||
//Fire Publishing event
|
||||
OnPublish(content, e);
|
||||
if (Publishing.IsRaisedEventCancelled(new PublishEventArgs<IContent>(content), this))
|
||||
return false;
|
||||
|
||||
if (!e.Cancel)
|
||||
//Check if the Content is Expired to verify that it can in fact be published
|
||||
if (content.Status == ContentStatus.Expired)
|
||||
{
|
||||
//Check if the Content is Expired to verify that it can in fact be published
|
||||
if (content.Status == ContentStatus.Expired)
|
||||
{
|
||||
LogHelper.Info<PublishingStrategy>(
|
||||
string.Format("Content '{0}' with Id '{1}' has expired and could not be published.",
|
||||
content.Name, content.Id));
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check if the Content is Awaiting Release to verify that it can in fact be published
|
||||
if (content.Status == ContentStatus.AwaitingRelease)
|
||||
{
|
||||
LogHelper.Info<PublishingStrategy>(
|
||||
string.Format("Content '{0}' with Id '{1}' is awaiting release and could not be published.",
|
||||
content.Name, content.Id));
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check if the Content is Trashed to verify that it can in fact be published
|
||||
if (content.Status == ContentStatus.Trashed)
|
||||
{
|
||||
LogHelper.Info<PublishingStrategy>(
|
||||
string.Format("Content '{0}' with Id '{1}' is trashed and could not be published.",
|
||||
content.Name, content.Id));
|
||||
return false;
|
||||
}
|
||||
|
||||
content.ChangePublishedState(true);
|
||||
|
||||
LogHelper.Info<PublishingStrategy>(
|
||||
string.Format("Content '{0}' with Id '{1}' has been published.",
|
||||
string.Format("Content '{0}' with Id '{1}' has expired and could not be published.",
|
||||
content.Name, content.Id));
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
//Check if the Content is Awaiting Release to verify that it can in fact be published
|
||||
if (content.Status == ContentStatus.AwaitingRelease)
|
||||
{
|
||||
LogHelper.Info<PublishingStrategy>(
|
||||
string.Format("Content '{0}' with Id '{1}' is awaiting release and could not be published.",
|
||||
content.Name, content.Id));
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check if the Content is Trashed to verify that it can in fact be published
|
||||
if (content.Status == ContentStatus.Trashed)
|
||||
{
|
||||
LogHelper.Info<PublishingStrategy>(
|
||||
string.Format("Content '{0}' with Id '{1}' is trashed and could not be published.",
|
||||
content.Name, content.Id));
|
||||
return false;
|
||||
}
|
||||
|
||||
content.ChangePublishedState(true);
|
||||
|
||||
LogHelper.Info<PublishingStrategy>(
|
||||
string.Format("Content '{0}' with Id '{1}' has been published.",
|
||||
content.Name, content.Id));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -77,17 +71,13 @@ namespace Umbraco.Core.Publishing
|
||||
/// <returns>True if the publish operation was successfull and not cancelled, otherwise false</returns>
|
||||
public override bool PublishWithChildren(IEnumerable<IContent> content, int userId)
|
||||
{
|
||||
var e = new PublishingEventArgs();
|
||||
|
||||
/* Only update content thats not already been published - we want to loop through
|
||||
* all unpublished content to write skipped content (expired and awaiting release) to log.
|
||||
*/
|
||||
foreach (var item in content.Where(x => x.Published == false))
|
||||
{
|
||||
//Fire Publishing event
|
||||
OnPublish(item, e);
|
||||
if (e.Cancel)
|
||||
return false;
|
||||
if (Publishing.IsRaisedEventCancelled(new PublishEventArgs<IContent>(item), this))
|
||||
|
||||
//Check if the Content is Expired to verify that it can in fact be published
|
||||
if (item.Status == ContentStatus.Expired)
|
||||
@@ -134,33 +124,27 @@ namespace Umbraco.Core.Publishing
|
||||
/// <returns>True if the unpublish operation was successfull and not cancelled, otherwise false</returns>
|
||||
public override bool UnPublish(IContent content, int userId)
|
||||
{
|
||||
var e = new PublishingEventArgs();
|
||||
//Fire BeforeUnPublish event
|
||||
OnUnPublish(content, e);
|
||||
if (UnPublishing.IsRaisedEventCancelled(new UnPublishEventArgs<IContent>(content), this))
|
||||
return false;
|
||||
|
||||
if (!e.Cancel)
|
||||
//If Content has a release date set to before now, it should be removed so it doesn't interrupt an unpublish
|
||||
//Otherwise it would remain released == published
|
||||
if (content.ReleaseDate.HasValue && content.ReleaseDate.Value <= DateTime.Now)
|
||||
{
|
||||
//If Content has a release date set to before now, it should be removed so it doesn't interrupt an unpublish
|
||||
//Otherwise it would remain released == published
|
||||
if (content.ReleaseDate.HasValue && content.ReleaseDate.Value <= DateTime.Now)
|
||||
{
|
||||
content.ReleaseDate = null;
|
||||
|
||||
LogHelper.Info<PublishingStrategy>(
|
||||
string.Format(
|
||||
"Content '{0}' with Id '{1}' had its release date removed, because it was unpublished.",
|
||||
content.Name, content.Id));
|
||||
}
|
||||
|
||||
content.ChangePublishedState(false);
|
||||
content.ReleaseDate = null;
|
||||
|
||||
LogHelper.Info<PublishingStrategy>(
|
||||
string.Format("Content '{0}' with Id '{1}' has been unpublished.",
|
||||
content.Name, content.Id));
|
||||
return true;
|
||||
string.Format(
|
||||
"Content '{0}' with Id '{1}' had its release date removed, because it was unpublished.",
|
||||
content.Name, content.Id));
|
||||
}
|
||||
|
||||
return false;
|
||||
content.ChangePublishedState(false);
|
||||
|
||||
LogHelper.Info<PublishingStrategy>(
|
||||
string.Format("Content '{0}' with Id '{1}' has been unpublished.",
|
||||
content.Name, content.Id));
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -171,14 +155,11 @@ namespace Umbraco.Core.Publishing
|
||||
/// <returns>True if the unpublish operation was successfull and not cancelled, otherwise false</returns>
|
||||
public override bool UnPublish(IEnumerable<IContent> content, int userId)
|
||||
{
|
||||
var e = new PublishingEventArgs();
|
||||
|
||||
//Only update content thats already been published
|
||||
foreach (var item in content.Where(x => x.Published == true))
|
||||
{
|
||||
//Fire UnPublished event
|
||||
OnUnPublish(item, e);
|
||||
if (e.Cancel)
|
||||
//Fire UnPublishing event
|
||||
if (UnPublishing.IsRaisedEventCancelled(new UnPublishEventArgs<IContent>(item), this))
|
||||
return false;
|
||||
|
||||
//If Content has a release date set to before now, it should be removed so it doesn't interrupt an unpublish
|
||||
@@ -212,7 +193,7 @@ namespace Umbraco.Core.Publishing
|
||||
/// <param name="content"><see cref="IContent"/> thats being published</param>
|
||||
public override void PublishingFinalized(IContent content)
|
||||
{
|
||||
OnPublished(content, new PublishingEventArgs());
|
||||
Published.RaiseEvent(new PublishEventArgs<IContent>(content, false, false), this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -222,7 +203,8 @@ namespace Umbraco.Core.Publishing
|
||||
/// <param name="isAllRepublished">Boolean indicating whether its all content that is republished</param>
|
||||
public override void PublishingFinalized(IEnumerable<IContent> content, bool isAllRepublished)
|
||||
{
|
||||
OnPublished(content, new PublishingEventArgs(isAllRepublished));
|
||||
Published.RaiseEvent(new PublishEventArgs<IContent>(content, false, isAllRepublished), this);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -231,7 +213,7 @@ namespace Umbraco.Core.Publishing
|
||||
/// <param name="content"><see cref="IContent"/> thats being unpublished</param>
|
||||
public override void UnPublishingFinalized(IContent content)
|
||||
{
|
||||
OnUnPublished(content, new PublishingEventArgs());
|
||||
UnPublished.RaiseEvent(new UnPublishEventArgs<IContent>(content, false), this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -240,7 +222,29 @@ namespace Umbraco.Core.Publishing
|
||||
/// <param name="content">An enumerable list of <see cref="IContent"/> thats being unpublished</param>
|
||||
public override void UnPublishingFinalized(IEnumerable<IContent> content)
|
||||
{
|
||||
OnUnPublished(content, new PublishingEventArgs());
|
||||
UnPublished.RaiseEvent(new UnPublishEventArgs<IContent>(content, false), this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before publish
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IPublishingStrategy, PublishEventArgs<IContent>> Publishing;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after publish
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IPublishingStrategy, PublishEventArgs<IContent>> Published;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before unpublish
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IPublishingStrategy, UnPublishEventArgs<IContent>> UnPublishing;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after unpublish
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IPublishingStrategy, UnPublishEventArgs<IContent>> UnPublished;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1268,12 +1268,12 @@ namespace Umbraco.Core.Services
|
||||
public static event TypedEventHandler<IContentService, DeleteEventArgs<IContent>> Deleted;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before Delete
|
||||
/// Occurs before Delete Versions
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IContentService, DeleteRevisionsEventArgs> DeletingVersions;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after Delete
|
||||
/// Occurs after Delete Versions
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IContentService, DeleteRevisionsEventArgs> DeletedVersions;
|
||||
|
||||
|
||||
@@ -125,14 +125,15 @@
|
||||
<Compile Include="Events\CancellableObjectEventArgs.cs" />
|
||||
<Compile Include="Events\DeleteRevisionsEventArgs.cs" />
|
||||
<Compile Include="Events\EventExtensions.cs" />
|
||||
<Compile Include="Events\PublishEventArgs.cs" />
|
||||
<Compile Include="Events\TypedEventHandler.cs" />
|
||||
<Compile Include="Events\PublishingEventArgs.cs" />
|
||||
<Compile Include="Events\MoveEventArgs.cs" />
|
||||
<Compile Include="Events\NewEventArgs.cs" />
|
||||
<Compile Include="Events\RefreshContentEventArgs.cs" />
|
||||
<Compile Include="Events\RollbackEventArgs.cs" />
|
||||
<Compile Include="Events\SaveEventArgs.cs" />
|
||||
<Compile Include="Events\SendToPublishEventArgs.cs" />
|
||||
<Compile Include="Events\UnPublishEventArgs.cs" />
|
||||
<Compile Include="MacroPropertyTypeResolver.cs" />
|
||||
<Compile Include="Models\ContentBase.cs" />
|
||||
<Compile Include="Models\ContentExtensions.cs" />
|
||||
@@ -153,6 +154,7 @@
|
||||
<Compile Include="Models\Css\TrieNode.cs" />
|
||||
<Compile Include="Models\DictionaryItem.cs" />
|
||||
<Compile Include="Models\DictionaryTranslation.cs" />
|
||||
<Compile Include="Models\EntityBase\IUmbracoEntity.cs" />
|
||||
<Compile Include="Models\File.cs" />
|
||||
<Compile Include="Models\IDataTypeDefinition.cs" />
|
||||
<Compile Include="Models\IDictionaryItem.cs" />
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Umbraco.Web.Strategies
|
||||
/// <remarks>
|
||||
/// This implementation is meant as a seperation of the cache refresh from the ContentService
|
||||
/// and PublishingStrategy.
|
||||
/// This event subscriber will only be relevant as long as there is an xml cache.
|
||||
/// </remarks>
|
||||
public class UpdateCacheAfterPublish : IApplicationStartupHandler
|
||||
{
|
||||
@@ -27,23 +28,24 @@ namespace Umbraco.Web.Strategies
|
||||
PublishingStrategy.Published += PublishingStrategy_Published;
|
||||
}
|
||||
|
||||
void PublishingStrategy_Published(object sender, PublishingEventArgs e)
|
||||
void PublishingStrategy_Published(IPublishingStrategy sender, PublishEventArgs<IContent> e)
|
||||
{
|
||||
if (sender is IContent)
|
||||
{
|
||||
var content = sender as IContent;
|
||||
UpdateSingleContentCache(content);
|
||||
}
|
||||
else if (sender is IEnumerable<IContent>)
|
||||
if (e.PublishedEntities.Any())
|
||||
{
|
||||
if (e.IsAllRepublished)
|
||||
{
|
||||
var content = sender as IEnumerable<IContent>;
|
||||
UpdateMultipleContentCache(content);
|
||||
UpdateEntireCache();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.PublishedEntities.Count() > 1)
|
||||
{
|
||||
UpdateMultipleContentCache(e.PublishedEntities);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateEntireCache();
|
||||
var content = e.PublishedEntities.FirstOrDefault();
|
||||
UpdateSingleContentCache(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Publishing;
|
||||
@@ -17,6 +18,7 @@ namespace Umbraco.Web.Strategies
|
||||
/// <remarks>
|
||||
/// This implementation is meant as a seperation of the cache refresh from the ContentService
|
||||
/// and PublishingStrategy.
|
||||
/// This event subscriber will only be relevant as long as there is an xml cache.
|
||||
/// </remarks>
|
||||
public class UpdateCacheAfterUnPublish : IApplicationStartupHandler
|
||||
{
|
||||
@@ -25,19 +27,21 @@ namespace Umbraco.Web.Strategies
|
||||
PublishingStrategy.UnPublished += PublishingStrategy_UnPublished;
|
||||
}
|
||||
|
||||
void PublishingStrategy_UnPublished(object sender, PublishingEventArgs e)
|
||||
void PublishingStrategy_UnPublished(IPublishingStrategy sender, UnPublishEventArgs<IContent> e)
|
||||
{
|
||||
if (sender is IContent)
|
||||
if (e.UnPublishedEntities.Any())
|
||||
{
|
||||
var content = sender as IContent;
|
||||
UnPublishSingle(content);
|
||||
}
|
||||
else if (sender is IEnumerable<IContent>)
|
||||
{
|
||||
var content = sender as IEnumerable<IContent>;
|
||||
foreach (var c in content)
|
||||
if (e.UnPublishedEntities.Count() > 1)
|
||||
{
|
||||
UnPublishSingle(c);
|
||||
foreach (var c in e.UnPublishedEntities)
|
||||
{
|
||||
UnPublishSingle(c);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var content = e.UnPublishedEntities.FirstOrDefault();
|
||||
UnPublishSingle(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user