/// <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 = ServerInfoProvider.GetServers().WhereEquals("ServerSiteID", SiteContext.CurrentSiteID).WhereEquals("ServerEnabled", true).ToList(); RelationshipNameInfo RelationshipObj = RelationshipNameInfoProvider.GetRelationshipNameInfo(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 }; StagingTaskInfoProvider.SetTaskInfo(SiteTask); foreach (ServerInfo ServerObj in ActiveServers) { // Create synchronization SynchronizationInfo SyncSiteInfo = new SynchronizationInfo() { SynchronizationTaskID = SiteTask.TaskID, SynchronizationServerID = ServerObj.ServerID }; SynchronizationInfoProvider.SetSynchronizationInfo(SyncSiteInfo); } TaskGroupInfo TaskGroup = TaskGroupInfoProvider.GetUserTaskGroupInfo(MembershipContext.AuthenticatedUser.UserID); if (TaskGroup != null) { TaskGroupTaskInfoProvider.AddTaskGroupToTask(TaskGroup.TaskGroupID, SiteTask.TaskID); } } }
/// <summary> /// Creates the Staging Task manually /// </summary> /// <param name="RelationshipObj"></param> /// <param name="TaskType"></param> private void RelationshipName_CreateStagingTask(RelationshipNameInfo RelationshipObj, TaskTypeEnum TaskType) { List <ServerInfo> ActiveServers = ServerInfoProvider.GetServers().WhereEquals("ServerSiteID", SiteContext.CurrentSiteID).WhereEquals("ServerEnabled", true).ToList(); if (IsCustomAdhocRelationshipName(RelationshipObj) && ActiveServers.Count > 0) { string Data = "<NewDataSet>" + RelationshipObj.ToXML("CMS_RelationshipName", false) + "</NewDataSet>"; string TaskTitle = ""; switch (TaskType) { case TaskTypeEnum.CreateObject: TaskTitle = "Create"; break; case TaskTypeEnum.UpdateObject: TaskTitle = "Update"; break; case TaskTypeEnum.DeleteObject: TaskTitle = "Delete"; break; } StagingTaskInfo Task = new StagingTaskInfo() { TaskTitle = string.Format("{0} Relationship name '{1}'", TaskTitle, RelationshipObj.RelationshipDisplayName), TaskType = TaskType, TaskObjectType = RelationshipNameInfo.OBJECT_TYPE, TaskObjectID = RelationshipObj.RelationshipNameId, TaskData = Data, TaskTime = DateTime.Now }; StagingTaskInfoProvider.SetTaskInfo(Task); foreach (ServerInfo ServerObj in ActiveServers) { // Create synchronization SynchronizationInfo SyncInfo = new SynchronizationInfo() { SynchronizationTaskID = Task.TaskID, SynchronizationServerID = ServerObj.ServerID }; SynchronizationInfoProvider.SetSynchronizationInfo(SyncInfo); } TaskGroupInfo TaskGroup = TaskGroupInfoProvider.GetUserTaskGroupInfo(MembershipContext.AuthenticatedUser.UserID); if (TaskGroup != null) { TaskGroupTaskInfoProvider.AddTaskGroupToTask(TaskGroup.TaskGroupID, Task.TaskID); } } }