/// <summary>
        /// Custom Staging Task generation
        /// </summary>
        /// <param name="RelationshipSiteObj"></param>
        /// <param name="TaskType"></param>
        private void RelationshipNameSite_CreateStagingTask(RelationshipNameSiteInfo RelationshipSiteObj, TaskTypeEnum TaskType)
        {
            List <ServerInfo>    ActiveServers   = ServerInfo.Provider.Get().WhereEquals("ServerSiteID", SiteContext.CurrentSiteID).WhereEquals("ServerEnabled", true).ToList();
            RelationshipNameInfo RelationshipObj = RelationshipNameInfo.Provider.Get(RelationshipSiteObj.RelationshipNameID);

            // If relationship obj is already gone, then the Site deletion thing is already handled with the deletion of the relationship name.
            if (RelationshipObj == null)
            {
                return;
            }

            if (IsCustomAdhocRelationshipName(RelationshipObj) && ActiveServers.Count > 0)
            {
                string Data         = "<NewDataSet>" + RelationshipObj.ToXML("CMS_RelationshipName", false) + "</NewDataSet>";
                string TaskTitle    = "";
                string TaskTitleEnd = "";
                switch (TaskType)
                {
                case TaskTypeEnum.AddToSite:
                    TaskTitle    = "Add";
                    TaskTitleEnd = "to";
                    break;

                case TaskTypeEnum.RemoveFromSite:
                    TaskTitle    = "Remove";
                    TaskTitleEnd = "from";
                    break;
                }
                StagingTaskInfo SiteTask = new CMS.Synchronization.StagingTaskInfo()
                {
                    TaskTitle      = string.Format("{0} Relationship name '{1}' {2} site", TaskTitle, RelationshipObj.RelationshipDisplayName, TaskTitleEnd),
                    TaskType       = TaskType,
                    TaskObjectType = RelationshipNameInfo.OBJECT_TYPE,
                    TaskObjectID   = RelationshipObj.RelationshipNameId,
                    TaskData       = Data,
                    TaskTime       = DateTime.Now,
                    TaskSiteID     = SiteContext.CurrentSiteID
                };
                StagingTaskInfo.Provider.Set(SiteTask);

                foreach (ServerInfo ServerObj in ActiveServers)
                {
                    // Create synchronization
                    SynchronizationInfo SyncSiteInfo = new SynchronizationInfo()
                    {
                        SynchronizationTaskID   = SiteTask.TaskID,
                        SynchronizationServerID = ServerObj.ServerID
                    };
                    SynchronizationInfo.Provider.Set(SyncSiteInfo);
                }

                TaskGroupInfo TaskGroup = TaskGroupInfoProvider.GetUserTaskGroupInfo(MembershipContext.AuthenticatedUser.UserID);
                if (TaskGroup != null)
                {
                    TaskGroupTaskInfo.Provider.Add(TaskGroup.TaskGroupID, SiteTask.TaskID);
                }
            }
        }
Esempio n. 2
0
    /// <summary>
    /// Removes relationship name from site. Called when the "Remove name from site" button is pressed.
    /// Expects the AddRelationshipNameToSite method to be run first.
    /// </summary>
    private bool RemoveRelationshipNameFromSite()
    {
        // Get the relationship name
        RelationshipNameInfo removeName = RelationshipNameInfoProvider.GetRelationshipNameInfo("MyNewRelationshipName");

        if (removeName != null)
        {
            int siteId = SiteContext.CurrentSiteID;

            // Get the binding
            RelationshipNameSiteInfo nameSite = RelationshipNameSiteInfoProvider.GetRelationshipNameSiteInfo(removeName.RelationshipNameId, siteId);

            // Delete the binding
            RelationshipNameSiteInfoProvider.DeleteRelationshipNameSiteInfo(nameSite);

            return(true);
        }

        return(false);
    }