Пример #1
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.");
                }
            }
        }
Пример #2
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.");
            }
        }
    }
Пример #3
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.");
                }
            }
        }