private void DataClass_Update_Before(object sender, ObjectEventArgs e) { // Check if the Url Pattern is changing DataClassInfo Class = (DataClassInfo)e.Object; if (!Class.ClassURLPattern.Equals(ValidationHelper.GetString(e.Object.GetOriginalValue("ClassURLPattern"), ""))) { // Add key that the "After" will check, if the Continue is "False" then this was hit, so we actually want to continue. RecursionControl TriggerClassUpdateAfter = new RecursionControl("TriggerClassUpdateAfter_" + Class.ClassName); var Trigger = TriggerClassUpdateAfter.Continue; } }
private void UrlSlug_Update_Before_IsCustomRebuild(object sender, ObjectEventArgs e) { UrlSlugInfo UrlSlug = (UrlSlugInfo)e.Object; // If the Url Slug is custom or was custom, then need to rebuild after. if (UrlSlug.UrlSlugIsCustom || ValidationHelper.GetBoolean(UrlSlug.GetOriginalValue("UrlSlugIsCustom"), UrlSlug.UrlSlugIsCustom)) { // Add hook so the Url Slug will be re-rendered after it's updated RecursionControl Trigger = new RecursionControl("UrlSlugNoLongerCustom_" + UrlSlug.UrlSlugGuid); var Triggered = Trigger.Continue; } }
/// <summary> /// True iff the two objects are equal Layers. /// </summary> public bool Equals(GreLayer other) { return(other != null && Version.Equals(other.Version) && ProtocolType.Equals(other.ProtocolType) && RecursionControl.Equals(other.RecursionControl) && FutureUseBits.Equals(other.FutureUseBits) && ChecksumPresent.Equals(other.ChecksumPresent) && (Checksum == null ? other.Checksum == null : Checksum.Equals(other.Checksum)) && (Key == null ? other.Key == null : Key.Equals(other.Key)) && (SequenceNumber == null ? other.SequenceNumber == null : SequenceNumber.Equals(other.SequenceNumber)) && (AcknowledgmentSequenceNumber == null ? other.AcknowledgmentSequenceNumber == null : AcknowledgmentSequenceNumber.Equals(other.AcknowledgmentSequenceNumber)) && (RoutingOffset == null ? other.RoutingOffset == null : RoutingOffset.Equals(other.RoutingOffset)) && (Routing == null ? other.Routing == null : Routing.SequenceEqual(other.Routing)) && StrictSourceRoute.Equals(other.StrictSourceRoute)); }
private void Document_ChangeOrder_After(object sender, DocumentChangeOrderEventArgs e) { // Sometimes ChangeOrder is triggered before the insert (if it inserts before other records), // So will use recursion helper to prevent this from running on the insert as well. RecursionControl PreventInsertAfter = new RecursionControl("PreventInsertAfter" + e.Node.NodeID); var Trigger = PreventInsertAfter.Continue; try { DynamicRouteEventHelper.DocumentInsertUpdated(e.Node.NodeID); } catch (UrlSlugCollisionException ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "UrlSlugConflict", $"Occurred on Document Change Order for Node {e.Node.NodeAliasPath}"); e.Cancel(); } catch (Exception ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "Error", $"Occurred on Document Change Order for Node {e.Node.NodeAliasPath}"); } }
private void Document_Insert_After(object sender, DocumentEventArgs e) { // Prevents the CHangeOrderAfter which may trigger before this from creating a double queue item. RecursionControl PreventInsertAfter = new RecursionControl("PreventInsertAfter" + e.Node.NodeID); if (PreventInsertAfter.Continue) { try { DynamicRouteEventHelper.DocumentInsertUpdated(e.Node.NodeID); } catch (UrlSlugCollisionException ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "UrlSlugConflict", $"Occurred on Document Insert After for Node {e.Node.NodeAliasPath}"); e.Cancel(); } catch (Exception ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "Error", $"Occurred on Document Insert After for Node {e.Node.NodeAliasPath}"); } } }
private void UrlSlug_Update_After_IsCustomRebuild(object sender, ObjectEventArgs e) { UrlSlugInfo UrlSlug = (UrlSlugInfo)e.Object; RecursionControl Trigger = new RecursionControl("UrlSlugNoLongerCustom_" + UrlSlug.UrlSlugGuid); if (!Trigger.Continue) { try { // If Continue is false, then the Before update shows this needs to be rebuilt. DynamicRouteInternalHelper.RebuildRoutesByNode(UrlSlug.UrlSlugNodeID); } catch (UrlSlugCollisionException ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "UrlSlugConflict", $"Occurred on Url Slug {UrlSlug.UrlSlugID}"); e.Cancel(); } catch (Exception ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "Error", $"Occurred on Url Slug {UrlSlug.UrlSlugID}"); } } }
private void DataClass_Update_After(object sender, ObjectEventArgs e) { DataClassInfo Class = (DataClassInfo)e.Object; RecursionControl PreventDoubleClassUpdateTrigger = new RecursionControl("PreventDoubleClassUpdateTrigger_" + Class.ClassName); // If the "Continue" is false, it means that a DataClass_Update_Before found that the UrlPattern was changed // Otherwise the "Continue" will be true that this is the first time triggering it. if (!new RecursionControl("TriggerClassUpdateAfter_" + Class.ClassName).Continue&& PreventDoubleClassUpdateTrigger.Continue) { try { DynamicRouteEventHelper.ClassUrlPatternChanged(Class.ClassName); } catch (UrlSlugCollisionException ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "UrlSlugConflict", $"Occurred on Class Update After for class {Class.ClassName}"); e.Cancel(); } catch (Exception ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "Error", $"Occurred on Class Update After for class {Class.ClassName}"); } } }
private void UrlSlug_Update_Before_IsCustomRebuild(object sender, ObjectEventArgs e) { UrlSlugInfo UrlSlug = (UrlSlugInfo)e.Object; TreeNode Node = new DocumentQuery() .WhereEquals("NodeID", UrlSlug.UrlSlugNodeID) .Columns("NodeSiteID, NodeAliasPath, NodeGuid, NodeAlias") .FirstOrDefault(); // First check if there is already a custom URL slug, if so cancel if (UrlSlug.UrlSlugIsCustom) { var ExistingMatchingSlug = UrlSlugInfoProvider.GetUrlSlugs() .WhereNotEquals("UrlSlugNodeID", UrlSlug.UrlSlugNodeID) .WhereEquals("UrlSlug", UrlSlug.UrlSlug) .Where($"UrlSlugNodeID in (Select NodeID from CMS_Tree where NodeSiteID = {Node.NodeSiteID})") .Columns("UrlSlugNodeID") .FirstOrDefault(); if (ExistingMatchingSlug != null) { TreeNode ConflictNode = new DocumentQuery() .WhereEquals("NodeID", ExistingMatchingSlug.UrlSlugNodeID) .Columns("NodeSiteID, NodeAliasPath") .FirstOrDefault(); var Error = new NotSupportedException($"This custom URL Slug '{UrlSlug.UrlSlug}' on {Node.NodeAliasPath} is already the pattern of an existing document ({ConflictNode.NodeAliasPath}). Operation aborted."); EventLogProvider.LogException("DynamicRouting", "CustomUrlSlugConflict", Error, Node.NodeSiteID); throw Error; } } // This prevents the recursive url slug updates from the first update from removing the "Ignore" on this item. RecursionControl AlreadyDeterminedIfShouldIgnore = new RecursionControl("AlreadyDeterminedIfShouldIgnore_" + UrlSlug.UrlSlugGuid); if (CMSActionContext.CurrentLogSynchronization && AlreadyDeterminedIfShouldIgnore.Continue) { // Delete existing ignore records DynamicRouteInternalHelper.RemoveIgnoreStagingTaskOfUrlSlug(UrlSlug.UrlSlugID); // If the staging task Should be created if ( (UrlSlug.UrlSlugIsCustom && !ValidationHelper.GetBoolean(UrlSlug.GetOriginalValue("UrlSlugIsCustom"), true)) || (!UrlSlug.UrlSlugIsCustom && ValidationHelper.GetBoolean(UrlSlug.GetOriginalValue("UrlSlugIsCustom"), false)) || (UrlSlug.UrlSlugIsCustom && ValidationHelper.GetBoolean(UrlSlug.GetOriginalValue("UrlSlugIsCustom"), false) && UrlSlug.UrlSlug != ValidationHelper.GetString(UrlSlug.GetOriginalValue("UrlSlug"), UrlSlug.UrlSlug)) ) { // Staging task should be created, so proceed as normal } else { // Staging task should not be created, add entry so this task won't be generated UrlSlugStagingTaskIgnoreInfoProvider.SetUrlSlugStagingTaskIgnoreInfo(new UrlSlugStagingTaskIgnoreInfo() { UrlSlugStagingTaskIgnoreUrlSlugID = UrlSlug.UrlSlugID }); } } // If the Url Slug is custom or was custom, then need to rebuild after. if (UrlSlug.UrlSlugIsCustom || ValidationHelper.GetBoolean(UrlSlug.GetOriginalValue("UrlSlugIsCustom"), UrlSlug.UrlSlugIsCustom)) { // Add hook so the Url Slug will be re-rendered after it's updated RecursionControl Trigger = new RecursionControl("UrlSlugNoLongerCustom_" + UrlSlug.UrlSlugGuid); var Triggered = Trigger.Continue; } }