/// <summary>
 /// Handle the Removal of Node Categories when not bound to the document, since binding to the Nodes don't seem to operate right.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void NonBindingNodeDocument_ProcessTask_After(object sender, StagingSynchronizationEventArgs e)
 {
     if (e.TaskType == TaskTypeEnum.DeleteObject)
     {
         // Don't want to trigger updates as we set the data in the database, so we won't log synchronziations
         using (new CMSActionContext()
         {
             LogSynchronization = false,
             LogIntegration = false
         })
         {
             if (e.ObjectType.ToLower() == "cms.treecategory")
             {
                 DataTable NodeCategoryTable = e.TaskData.Tables[0];
                 // Translate tables
                 int NodeID     = RelHelper.TranslateBindingTranslateID((int)NodeCategoryTable.Rows[0]["NodeID"], e.TaskData, "cms.node");
                 int CategoryID = RelHelper.TranslateBindingTranslateID((int)NodeCategoryTable.Rows[0]["CategoryID"], e.TaskData, "cms.category");
                 if (NodeID > 0 && CategoryID > 0)
                 {
                     TreeCategoryInfo.Provider.Remove(NodeID, CategoryID);
                 }
             }
         }
     }
 }
Beispiel #2
0
        private void ProcessTask_After(object sender, StagingSynchronizationEventArgs e)
        {
            List <TaskTypeEnum> DocumentTaskTypes = new List <TaskTypeEnum>()
            {
                TaskTypeEnum.CreateDocument,
                TaskTypeEnum.UpdateDocument
            };

            if (DocumentTaskTypes.Contains(e.TaskType))
            {
                // First table is the Node Data
                DataTable NodeTable = e.TaskData.Tables[0];

                if (NodeTable != null && NodeTable.Columns.Contains("NodeGuid"))
                {
                    // Get node ID
                    TreeNode NodeObj = new DocumentQuery().WhereEquals("NodeGUID", NodeTable.Rows[0]["NodeGuid"]).FirstOrDefault();

                    // Don't want to trigger updates as we set the data in the database, so we won't log synchronziations
                    using (new CMSActionContext()
                    {
                        LogSynchronization = false,
                        LogIntegration = false
                    })
                    {
                        #region "Node Baz (Node object w/out Ordering)"

                        // Get NodeBaz and Handle
                        List <int> BazIDs = RelHelper.NewBoundObjectIDs(e, NodeBazInfo.OBJECT_TYPE, nameof(NodeBazInfo.NodeBazNodeID), nameof(NodeBazInfo.NodeBazBazID), BazInfo.TYPEINFO);

                        // Delete Ones not found
                        NodeBazInfo.Provider.Get().WhereEquals("NodeID", NodeObj.NodeID).WhereNotIn("BazID", BazIDs).ForEachObject(x => x.Delete());

                        // Find ones that need to be added and add
                        List <int> CurrentBazIDs = NodeBazInfo.Provider.Get().WhereEquals(nameof(NodeBazInfo.NodeBazNodeID), NodeObj.NodeID).Select(x => x.NodeBazBazID).ToList();
                        foreach (int NewBazID in BazIDs.Except(CurrentBazIDs))
                        {
                            NodeBazInfo.Provider.Add(NodeObj.NodeID, NewBazID);
                        }

                        #endregion
                    }
                    if (RelHelper.IsStagingEnabled(NodeObj.NodeSiteID))
                    {
                        // Check if we need to generate a task for a server that isn't the origin server
                        RelHelper.CheckIfTaskCreationShouldOccur(NodeObj.NodeGUID);
                    }
                }
                else if (NodeTable == null || !NodeTable.Columns.Contains("NodeGuid"))
                {
                    Service.Resolve <IEventLogService>().LogEvent(EventTypeEnum.Error, "DemoProcessTask", "No Node Table Found", eventDescription: "First Table in the incoming Staging Task did not contain the Node GUID, could not processes.");
                }
            }
        }
        private void ProcessTask_After(object sender, StagingSynchronizationEventArgs e)
        {
            if (e.TaskType == TaskTypeEnum.UpdateDocument || e.TaskType == TaskTypeEnum.CreateDocument || e.TaskType == TaskTypeEnum.MoveDocument || e.TaskType == TaskTypeEnum.PublishDocument || e.TaskType == TaskTypeEnum.ArchiveDocument)
            {
                // Seems the first table is always the node's table, the table name dose change by the document page type.
                DataTable NodeTable = e.TaskData.Tables[0];
                if (NodeTable != null && NodeTable.Columns.Contains("NodeGuid"))
                {
                    // Don't want to trigger updates as we set the data in the database, so we won't log synchronziations
                    TreeNode NodeObj = new DocumentQuery().WhereEquals("NodeGUID", NodeTable.Rows[0]["NodeGuid"]).FirstOrDefault();

                    using (new CMSActionContext()
                    {
                        LogSynchronization = false,
                        LogIntegration = false
                    })
                    {
                        List <int> NewNodeCategoryIDs = RelHelper.NewBoundObjectIDs(e, TreeCategoryInfo.OBJECT_TYPE, "NodeID", "CategoryID", CategoryInfo.TYPEINFO);

                        // Now handle categories, deleting categories not found, and adding ones that are not set yet.
                        TreeCategoryInfo.Provider.Get().WhereEquals("NodeID", NodeObj.NodeID).WhereNotIn("CategoryID", NewNodeCategoryIDs).ForEachObject(x => x.Delete());
                        List <int> CurrentCategories = TreeCategoryInfo.Provider.Get().WhereEquals("NodeID", NodeObj.NodeID).Select(x => x.CategoryID).ToList();
                        foreach (int NewCategoryID in NewNodeCategoryIDs.Except(CurrentCategories))
                        {
                            TreeCategoryInfo.Provider.Add(NodeObj.NodeID, NewCategoryID);
                        }
                    }
                    if (RelHelper.IsStagingEnabled(NodeObj.NodeSiteID))
                    {
                        TaskTypeEnum TaskTypeToUse = e.TaskType;
                        switch (e.TaskType)
                        {
                        case TaskTypeEnum.MoveDocument:
                            TaskTypeToUse = TaskTypeEnum.UpdateDocument;
                            break;
                        }
                        // Check if we need to generate a task for a server that isn't the origin server
                        RelHelper.CheckIfTaskCreationShouldOccur(NodeObj.NodeGUID, TaskTypeToUse);
                    }
                }
                else
                {
                    Service.Resolve <IEventLogService>().LogEvent(EventTypeEnum.Error, "RelationshipExended", "No Node Table Found", eventDescription: "First Table in the incoming Staging Task did not contain the Node GUID, could not processes.");
                }
            }
        }
Beispiel #4
0
        private void StagingTask_ProcessTask_Before(object sender, StagingSynchronizationEventArgs e)
        {
            if (e.ObjectType.Equals(UrlSlugInfo.OBJECT_TYPE, StringComparison.InvariantCultureIgnoreCase))
            {
                // Get the URL slug itself
                UrlSlugInfo UrlSlug   = new UrlSlugInfo(e.TaskData.Tables[0].Rows[0]);
                int         NewNodeID = TranslateBindingTranslateID(UrlSlug.UrlSlugNodeID, e.TaskData, "cms.node");
                // Get the Site's current Url Slug
                UrlSlugInfo CurrentUrlSlug = UrlSlugInfoProvider.GetUrlSlugs()
                                             .WhereEquals("UrlSlugNodeID", NewNodeID)
                                             .WhereEquals("UrlSlugCultureCode", UrlSlug.UrlSlugCultureCode)
                                             .FirstOrDefault();

                bool UpdateCurrentUrlSlug = false;
                if (UrlSlug.UrlSlugIsCustom)
                {
                    if (!CurrentUrlSlug.UrlSlugIsCustom)
                    {
                        CurrentUrlSlug.UrlSlugIsCustom = true;
                        UpdateCurrentUrlSlug           = true;
                    }
                    if (CurrentUrlSlug.UrlSlug != UrlSlug.UrlSlug)
                    {
                        CurrentUrlSlug.UrlSlug = UrlSlug.UrlSlug;
                        UpdateCurrentUrlSlug   = true;
                    }
                }
                else
                {
                    if (CurrentUrlSlug.UrlSlugIsCustom)
                    {
                        CurrentUrlSlug.UrlSlugIsCustom = false;
                        UpdateCurrentUrlSlug           = true;
                    }
                }
                if (UpdateCurrentUrlSlug)
                {
                    UrlSlugInfoProvider.SetUrlSlugInfo(CurrentUrlSlug);
                }
                e.TaskHandled = true;
            }
        }
Beispiel #5
0
    private void ProcessTask_After(object sender, StagingSynchronizationEventArgs e)
    {
        if (e.TaskType == TaskTypeEnum.UpdateDocument)
        {
            // First table is the Node Data
            DataTable NodeTable = e.TaskData.Tables[0];

            if (NodeTable != null && NodeTable.Columns.Contains("NodeGuid"))
            {
                // Get node ID
                TreeNode NodeObj = new DocumentQuery().WhereEquals("NodeGUID", NodeTable.Rows[0]["NodeGuid"]).FirstOrDefault();

                // Don't want to trigger updates as we set the data in the database, so we won't log synchronziations
                using (new CMSActionContext()
                {
                    LogSynchronization = false,
                    LogIntegration = false
                })
                {
                    #region "Node Baz (Node object w/out Ordering)"
                    // Get NodeBaz and Handle
                    List <int> BazIDs = RelHelper.NewBoundObjectIDs(e, "demo.nodebaz", "NodeID", "BazID", BazInfo.TYPEINFO);
                    NodeBazInfoProvider.GetNodeBazes().WhereEquals("NodeID", NodeObj.NodeID).WhereNotIn("BazID", BazIDs).ForEachObject(x => x.Delete());
                    List <int> CurrentBazIDs = NodeBazInfoProvider.GetNodeBazes().WhereEquals("NodeID", NodeObj.NodeID).Select(x => x.BazID).ToList();
                    foreach (int NewBazID in BazIDs.Except(CurrentBazIDs))
                    {
                        NodeBazInfoProvider.AddTreeToBaz(NodeObj.NodeID, NewBazID);
                    }
                    #endregion

                    #region "Node Region (Node object w/out Ordering)"
                    // Get NodeRegion and Handle
                    List <int> RegionCategoryIDs = RelHelper.NewBoundObjectIDs(e, "demo.nodeRegion", "NodeID", "RegionCategoryID", CategoryInfo.TYPEINFO);
                    NodeRegionInfoProvider.GetNodeRegions().WhereEquals("NodeID", NodeObj.NodeID).WhereNotIn("RegionCategoryID", RegionCategoryIDs).ForEachObject(x => x.Delete());
                    List <int> CurrentRegionCategoryIDs = NodeRegionInfoProvider.GetNodeRegions().WhereEquals("NodeID", NodeObj.NodeID).Select(x => x.RegionCategoryID).ToList();
                    foreach (int NewRegionCategoryID in RegionCategoryIDs.Except(CurrentRegionCategoryIDs))
                    {
                        NodeRegionInfoProvider.AddTreeToCategory(NodeObj.NodeID, NewRegionCategoryID);
                    }
                    #endregion

                    #region "Node Foo  (Node object with Ordering)"

                    // Get NodeFoo and Handle
                    List <int> FooIDInOrders = RelHelper.NewOrderedBoundObjectIDs(e, "demo.nodeFoo", "NodeID", "FooID", "NodeFooOrder", FooInfo.TYPEINFO);
                    NodeFooInfoProvider.GetNodeFoos().WhereEquals("NodeID", NodeObj.NodeID).WhereNotIn("FooID", FooIDInOrders).ForEachObject(x => x.Delete());
                    List <int> CurrentFooIDs = NodeFooInfoProvider.GetNodeFoos().WhereEquals("NodeID", NodeObj.NodeID).Select(x => x.FooID).ToList();
                    foreach (int NewFooID in FooIDInOrders.Except(CurrentFooIDs))
                    {
                        NodeFooInfoProvider.AddTreeToFoo(NodeObj.NodeID, NewFooID);
                    }
                    // Now handle the ordering
                    for (int FooIndex = 0; FooIndex < FooIDInOrders.Count; FooIndex++)
                    {
                        int         FooID      = FooIDInOrders[FooIndex];
                        NodeFooInfo CurrentObj = NodeFooInfoProvider.GetNodeFooInfo(NodeObj.NodeID, FooID);
                        if (CurrentObj != null && CurrentObj.NodeFooOrder != (FooIndex + 1))
                        {
                            CurrentObj.SetObjectOrder(FooIndex + 1);
                        }
                    }
                    #endregion
                }
                if (RelHelper.IsStagingEnabled(NodeObj.NodeSiteID))
                {
                    // Check if we need to generate a task for a server that isn't the origin server
                    RelHelper.CheckIfTaskCreationShouldOccur(NodeObj.NodeGUID);
                }
            }
            else if (NodeTable == null || !NodeTable.Columns.Contains("NodeGuid"))
            {
                EventLogProvider.LogEvent("E", "DemoProcessTask", "No Node Table Found", eventDescription: "First Table in the incoming Staging Task did not contain the Node GUID, could not processes.");
            }
        }
    }
Beispiel #6
0
        private void ProcessTask_After(object sender, StagingSynchronizationEventArgs e)
        {
            List <TaskTypeEnum> DocumentTaskTypes = new List <TaskTypeEnum>()
            {
                TaskTypeEnum.CreateDocument,
                TaskTypeEnum.UpdateDocument
            };

            if (DocumentTaskTypes.Contains(e.TaskType))
            {
                // First table is the Node Data
                DataTable NodeTable = e.TaskData.Tables[0];

                if (NodeTable != null && NodeTable.Columns.Contains("NodeGuid"))
                {
                    // Get node ID
                    TreeNode NodeObj = new DocumentQuery().WhereEquals("NodeGUID", NodeTable.Rows[0]["NodeGuid"]).FirstOrDefault();

                    // Don't want to trigger updates as we set the data in the database, so we won't log synchronziations
                    using (new CMSActionContext()
                    {
                        LogSynchronization = false,
                        LogIntegration = false
                    })
                    {
                        #region "Node Foo  (Node object with Ordering)"

                        // Get NodeFoo and Handle
                        List <int> FooIDInOrders = RelHelper.NewOrderedBoundObjectIDs(e, NodeFooInfo.OBJECT_TYPE, nameof(NodeFooInfo.NodeFooNodeID), nameof(NodeFooInfo.NodeFooFooID), nameof(NodeFooInfo.NodeFooOrder), FooInfo.TYPEINFO);

                        // Delete those not found
                        NodeFooInfo.Provider.Get().WhereEquals(nameof(NodeFooInfo.NodeFooNodeID), NodeObj.NodeID).WhereNotIn(nameof(NodeFooInfo.NodeFooFooID), FooIDInOrders).ForEachObject(x => x.Delete());

                        // Get a list of the Current Foos, add missing
                        List <int> CurrentFooIDs = NodeFooInfo.Provider.Get().WhereEquals(nameof(NodeFooInfo.NodeFooNodeID), NodeObj.NodeID).Select(x => x.NodeFooFooID).ToList();
                        foreach (int NewFooID in FooIDInOrders.Except(CurrentFooIDs))
                        {
                            NodeFooInfo.Provider.Add(NodeObj.NodeID, NewFooID);
                        }
                        // Now handle the ordering
                        for (int FooIndex = 0; FooIndex < FooIDInOrders.Count; FooIndex++)
                        {
                            int         FooID      = FooIDInOrders[FooIndex];
                            NodeFooInfo CurrentObj = NodeFooInfo.Provider.Get(NodeObj.NodeID, FooID);
                            if (CurrentObj != null && CurrentObj.NodeFooOrder != (FooIndex + 1))
                            {
                                CurrentObj.SetObjectOrder(FooIndex + 1);
                            }
                        }

                        #endregion
                    }
                    if (RelHelper.IsStagingEnabled(NodeObj.NodeSiteID))
                    {
                        // Check if we need to generate a task for a server that isn't the origin server
                        RelHelper.CheckIfTaskCreationShouldOccur(NodeObj.NodeGUID);
                    }
                }
                else if (NodeTable == null || !NodeTable.Columns.Contains("NodeGuid"))
                {
                    Service.Resolve <IEventLogService>().LogEvent(EventTypeEnum.Error, "DemoProcessTask", "No Node Table Found", eventDescription: "First Table in the incoming Staging Task did not contain the Node GUID, could not processes.");
                }
            }
        }