public static void HandlePublishUnpublishWorkflows(IData selectedData, string cultureName, DateTime?publishDate, DateTime?unpublishDate, ref WorkflowInstance publishWorkflowInstance, ref WorkflowInstance unpublishWorkflowInstance) { var key = selectedData.GetUniqueKey().ToString(); var existingPublishSchedule = PublishScheduleHelper.GetPublishSchedule(selectedData.DataSourceId.InterfaceType, key, cultureName); if (existingPublishSchedule != null) { WorkflowFacade.AbortWorkflow(existingPublishSchedule.WorkflowInstanceId); DataFacade.Delete(existingPublishSchedule); } if (publishDate != null) { publishWorkflowInstance = WorkflowFacade.CreateNewWorkflow( typeof(DataPublishSchedulerWorkflow), new Dictionary <string, object> { { "Date", publishDate }, { "DataType", selectedData.DataSourceId.InterfaceType.FullName }, { "DataId", selectedData.GetUniqueKey().ToString() }, { "LocaleName", cultureName } } ); PublishScheduleHelper.CreatePublishSchedule(selectedData.DataSourceId.InterfaceType, selectedData.GetUniqueKey().ToString(), cultureName, publishDate.Value, publishWorkflowInstance); } var existingUnpublishSchedule = PublishScheduleHelper.GetUnpublishSchedule(selectedData.DataSourceId.InterfaceType, key, cultureName); if (existingUnpublishSchedule != null) { WorkflowFacade.AbortWorkflow(existingUnpublishSchedule.WorkflowInstanceId); DataFacade.Delete(existingUnpublishSchedule); } if (unpublishDate != null) { unpublishWorkflowInstance = WorkflowFacade.CreateNewWorkflow( typeof(DataUnpublishSchedulerWorkflow), new Dictionary <string, object> { { "Date", unpublishDate }, { "DataType", selectedData.DataSourceId.InterfaceType.FullName }, { "DataId", key }, { "LocaleName", cultureName } } ); PublishScheduleHelper.CreateUnpublishSchedule(selectedData.DataSourceId.InterfaceType, key, cultureName, unpublishDate.Value, unpublishWorkflowInstance); } }
public static void HandlePublishUnpublishWorkflows(IPage selectedPage, string cultureName, DateTime?publishDate, DateTime?unpublishDate, ref WorkflowInstance publishWorkflowInstance, ref WorkflowInstance unpublishWorkflowInstance) { var existingPublishSchedule = PublishScheduleHelper.GetPublishSchedule(typeof(IPage), selectedPage.Id.ToString(), cultureName); if (existingPublishSchedule != null) { WorkflowFacade.AbortWorkflow(existingPublishSchedule.WorkflowInstanceId); DataFacade.Delete(existingPublishSchedule); } if (publishDate != null) { publishWorkflowInstance = WorkflowFacade.CreateNewWorkflow( typeof(PagePublishSchedulerWorkflow), new Dictionary <string, object> { { "Date", publishDate }, { "PageId", selectedPage.Id }, { "LocaleName", cultureName } }); PublishScheduleHelper.CreatePublishSchedule(typeof(IPage), selectedPage.Id.ToString(), cultureName, publishDate.Value, publishWorkflowInstance); } var existingUnpublishSchedule = PublishScheduleHelper.GetUnpublishSchedule(typeof(IPage), selectedPage.Id.ToString(), cultureName); if (existingUnpublishSchedule != null) { WorkflowFacade.AbortWorkflow(existingUnpublishSchedule.WorkflowInstanceId); DataFacade.Delete(existingUnpublishSchedule); } if (unpublishDate != null) { unpublishWorkflowInstance = WorkflowFacade.CreateNewWorkflow( typeof(PageUnpublishSchedulerWorkflow), new Dictionary <string, object> { { "Date", unpublishDate }, { "PageId", selectedPage.Id }, { "LocaleName", cultureName } }); PublishScheduleHelper.CreateUnpublishSchedule(typeof(IPage), selectedPage.Id.ToString(), cultureName, unpublishDate.Value, unpublishWorkflowInstance); } }