private void Document_Update_After(object sender, DocumentEventArgs e) { // Update the document itself, only if there is no workflow try { if (e.Node.WorkflowStep == null) { DynamicRouteEventHelper.DocumentInsertUpdated(e.Node.NodeID); } else { if (e.Node.WorkflowStep.StepIsPublished && DynamicRouteInternalHelper.ErrorOnConflict()) { DynamicRouteEventHelper.DocumentInsertUpdated_CheckOnly(e.Node.NodeID); } } } catch (UrlSlugCollisionException ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "UrlSlugConflict", $"Occurred on Document Update After for ${e.Node.NodeAlias}."); e.Cancel(); } catch (Exception ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "Error", $"Occurred on Document Update After for ${e.Node.NodeAlias}."); e.Cancel(); } }
private void Document_Move_After(object sender, DocumentEventArgs e) { // Update on the Node itself, this will rebuild itself and it's children DynamicRouteInternalHelper.CommitTransaction(true); try { DynamicRouteEventHelper.DocumentInsertUpdated(e.Node.NodeID); var PreviousParentNodeID = Thread.GetData(Thread.GetNamedDataSlot("PreviousParentIDForNode_" + e.Node.NodeID)); if (PreviousParentNodeID != null && (int)PreviousParentNodeID != e.TargetParentNodeID) { // If differnet node IDs, it moved to another parent, so also run Document Moved check on both new and old parent DynamicRouteEventHelper.DocumentMoved((int)PreviousParentNodeID, e.TargetParentNodeID); } } catch (UrlSlugCollisionException ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "UrlSlugConflict", $"Occurred on Document After Before for Node {e.Node.NodeAliasPath}"); e.Cancel(); } catch (Exception ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "Error", $"Occurred on Document Move After for Node {e.Node.NodeAliasPath}"); } }
private void EnsureSeoUrlUnique(DocumentEventArgs eventArgs) { var seoUrl = ValidationHelper.GetString(eventArgs.Node[Constants.DynamicRouting.SeoUrlFieldName], String.Empty); var foundNodes = SeoUrlService.GetAllDocumentsBySeoUrl(seoUrl); if (foundNodes.Count == 0 || foundNodes.All(x => x.DocumentID == eventArgs.Node.DocumentID)) { return; } eventArgs.Cancel(); throw new Exception( $"URL '{seoUrl}' is in conflict with another URL used for the page '{foundNodes.FirstOrDefault()?.DocumentNamePath ?? String.Empty}' ({foundNodes.FirstOrDefault()?.DocumentCulture ?? String.Empty}) page."); }
private void Document_Copy_After(object sender, DocumentEventArgs e) { try { DynamicRouteEventHelper.DocumentInsertUpdated(e.Node.NodeID); } catch (UrlSlugCollisionException ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "UrlSlugConflict", $"Occurred on Document Copy for Node {e.Node.NodeAliasPath}"); e.Cancel(); } catch (Exception ex) { LogErrorsInSeparateThread(ex, "DynamicRouting", "Error", $"Occurred on Document Copy 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}"); } } }