public override void Remove(OrganizationServiceCachePluginMessage message) { message.ThrowOnNull("message"); if (message is OrganizationServiceCacheBatchedPluginMessage) { Remove((OrganizationServiceCacheBatchedPluginMessage)message); } else { base.Remove(message); if (message.Target != null && message.Relationship == null) { var entity = message.Target.ToEntityReference(); Refresh(entity); } if (message.Target != null && message.Relationship != null && message.RelatedEntities != null) { var target = message.Target.ToEntityReference(); var relationship = message.Relationship.ToRelationship(); var relatedEntities = message.RelatedEntities.ToEntityReferenceCollection(); if (message.MessageName == "Associate") { Associate(target, relationship, relatedEntities); } if (message.MessageName == "Disassociate") { Disassociate(target, relationship, relatedEntities); } } if (message.Category != null && message.Category.Value.HasFlag(CacheItemCategory.Content)) { var contentMapProvider = GetContentMapProvider(); if (contentMapProvider != null) { contentMapProvider.Clear(); } } } }
public override void Remove(OrganizationServiceCachePluginMessage message) { message.ThrowOnNull("message"); ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Begin"); IOwinContext context = null; if (HttpContext.Current != null) { try { context = HttpContext.Current.GetOwinContext(); } catch (Exception) { ADXTrace.Instance.TraceInfo(TraceCategory.Application, "No owin.Environment item was found in the context"); return; } } var portalBusMessage = new CacheInvalidationPortalBusMessage { Message = message }; if (this._syncRemoveEnabled) { ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Sending messages syncronously"); var task = PortalBusManager <CacheInvalidationPortalBusMessage> .SendAsync(context, portalBusMessage).WithCurrentCulture(); task.GetAwaiter().GetResult(); } else { this.RemoveLocal(message); ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Sending messages asyncronously"); HostingEnvironment.QueueBackgroundWorkItem(ct => PortalBusManager <CacheInvalidationPortalBusMessage> .SendAsync(context, portalBusMessage)); } ADXTrace.Instance.TraceInfo(TraceCategory.Application, "End"); }
public virtual void Remove(OrganizationServiceCachePluginMessage message) { try { message.ThrowOnNull("message"); ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("MessageName={0}, ServiceCacheName={1}, ConnectionStringName={2}", message.MessageName, message.ServiceCacheName, message.ConnectionStringName)); if (message.Target != null && message.Relationship == null) { var entity = message.Target.ToEntityReference(); ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Id={0}, LogicalName={1}", entity.Id, EntityNamePrivacy.GetEntityName(entity.LogicalName))); } if (message.Category != null) { var category = message.Category.Value; ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("category={0}", category)); } if (message.Target != null && message.Relationship != null && message.RelatedEntities != null) { var target = message.Target.ToEntityReference(); var relationship = message.Relationship.ToRelationship(); var relatedEntities = message.RelatedEntities.ToEntityReferenceCollection(); ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Target: Id={0}, LogicalName={1}", target.Id, EntityNamePrivacy.GetEntityName(target.LogicalName))); foreach (var entity in relatedEntities) { ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Related: Id={0}, LogicalName={1}", entity.Id, EntityNamePrivacy.GetEntityName(entity.LogicalName))); } } _cache.ExtendedRemoveLocal(message); } catch (Exception error) { ADXTrace.Instance.TraceError(TraceCategory.Application, error.ToString()); } }
public override void RemoveLocal(OrganizationServiceCachePluginMessage message) { message.ThrowOnNull("message"); base.Remove(message); }