protected override void Execute()
        {
            var type = TypeManager.GetType(DataType);

            using (new DataScope(DataScopeIdentifier.Administrated, CultureInfo.CreateSpecificCulture(LocaleName)))
            {
                DataEntityToken dataEntityToken;

                using (var transaction = TransactionsFacade.CreateNewScope())
                {
                    var unpublishSchedule = PublishScheduleHelper.GetUnpublishSchedule(type, DataId, LocaleName);
                    Verify.IsNotNull(unpublishSchedule, "Missing an unpublish data schedule record");

                    DataFacade.Delete(unpublishSchedule);

                    var deletePublished = false;

                    var data = (IPublishControlled)DataFacade.GetDataByUniqueKey(type, DataId);
                    Verify.IsNotNull(data, "The data with the id {0} does not exist", DataId);

                    dataEntityToken = data.GetDataEntityToken();

                    var transitions = ProcessControllerFacade.GetValidTransitions(data).Keys;

                    if (transitions.Contains(GenericPublishProcessController.Draft))
                    {
                        data.PublicationStatus = GenericPublishProcessController.Draft;

                        DataFacade.Update(data);

                        deletePublished = true;
                    }
                    else
                    {
                        Log.LogWarning(LogTitle, "Scheduled unpublishing of data with label '{0}' could not be done because the data is not in a unpublisheble state", data.GetLabel());
                    }


                    if (deletePublished)
                    {
                        using (new DataScope(DataScopeIdentifier.Public))
                        {
                            var deletedData = (IPublishControlled)DataFacade.GetDataByUniqueKey(type, DataId);
                            if (deletedData != null)
                            {
                                DataFacade.Delete(deletedData, CascadeDeleteType.Disable);

                                Log.LogVerbose(LogTitle, "Scheduled unpublishing of data with label '{0}' is complete", deletedData.GetLabel());
                            }
                        }
                    }

                    transaction.Complete();
                }

                EntityTokenCacheFacade.ClearCache(dataEntityToken);
                PublishControlledHelper.ReloadDataElementInConsole(dataEntityToken);
            }
        }
Example #2
0
        protected override void Execute()
        {
            using (new DataScope(DataScopeIdentifier.Administrated, CultureInfo.CreateSpecificCulture(LocaleName)))
            {
                IPage page;

                using (var transaction = TransactionsFacade.CreateNewScope())
                {
                    var pageUnpublishSchedule = PublishScheduleHelper.GetUnpublishSchedule(typeof(IPage), PageId.ToString(), LocaleName);
                    Verify.IsNotNull(pageUnpublishSchedule, "Missing an unpublish page schedule record.");

                    DataFacade.Delete(pageUnpublishSchedule);

                    var deletePublished = false;

                    page = DataFacade.GetData <IPage>(p => p.Id == PageId).FirstOrDefault();

                    var transitions = ProcessControllerFacade.GetValidTransitions(page).Keys;
                    if (transitions.Contains(GenericPublishProcessController.Draft))
                    {
                        page.PublicationStatus = GenericPublishProcessController.Draft;

                        DataFacade.Update(page);

                        deletePublished = true;
                    }
                    else
                    {
                        Log.LogWarning(LogTitle, "Scheduled unpublishing of page with title '{0}' could not be done because the page is not in a unpublisheble state", page.Title);
                    }

                    if (deletePublished)
                    {
                        using (new DataScope(DataScopeIdentifier.Public))
                        {
                            var deletePage = DataFacade.GetData <IPage>(p => p.Id == PageId).FirstOrDefault();
                            if (deletePage != null)
                            {
                                var metaDataSet = deletePage.GetMetaData(DataScopeIdentifier.Public).Evaluate();

                                DataFacade.Delete(deletePage, CascadeDeleteType.Disable);
                                DataFacade.Delete(metaDataSet, CascadeDeleteType.Disable);

                                Log.LogVerbose(LogTitle, "Scheduled unpublishing of page with title '{0}' is complete", deletePage.Title);
                            }
                        }
                    }

                    transaction.Complete();
                }

                PublishControlledHelper.ReloadPageElementInConsole(page);
            }
        }
        protected override void Execute()
        {
            Type type = TypeManager.GetType(DataType);

            using (new DataScope(DataScopeIdentifier.Administrated, CultureInfo.CreateSpecificCulture(LocaleName)))
            {
                DataEntityToken dataEntityToken;

                using (var transaction = TransactionsFacade.CreateNewScope())
                {
                    var publishSchedule = PublishScheduleHelper.GetPublishSchedule(type, DataId, LocaleName);
                    DataFacade.Delete(publishSchedule);

                    var data = (IPublishControlled)DataFacade.TryGetDataByUniqueKey(type, DataId);
                    if (data == null)
                    {
                        Log.LogWarning(LogTitle, $"Failed to find data of type '{type}' by id '{DataId}'.");

                        transaction.Complete();
                        return;
                    }

                    dataEntityToken = data.GetDataEntityToken();

                    var transitions = ProcessControllerFacade.GetValidTransitions(data).Keys;

                    if (transitions.Contains(GenericPublishProcessController.Published))
                    {
                        data.PublicationStatus = GenericPublishProcessController.Published;

                        DataFacade.Update(data);

                        Log.LogVerbose(LogTitle, $"Scheduled publishing of data with label '{data.GetLabel()}' is complete");
                    }
                    else
                    {
                        Log.LogWarning(LogTitle, $"Scheduled publishing of data with label '{data.GetLabel()}' could not be done because the data is not in a publisheble state");
                    }

                    transaction.Complete();
                }

                EntityTokenCacheFacade.ClearCache(dataEntityToken);
                PublishControlledHelper.ReloadDataElementInConsole(dataEntityToken);
            }
        }
Example #4
0
        protected override void Execute()
        {
            using (new DataScope(DataScopeIdentifier.Administrated, CultureInfo.CreateSpecificCulture(LocaleName)))
            {
                IPage page;

                using (var transaction = TransactionsFacade.CreateNewScope())
                {
                    var pagePublishSchedule = PublishScheduleHelper.GetPublishSchedule(typeof(IPage), PageId.ToString(), LocaleName);
                    DataFacade.Delete(pagePublishSchedule);

                    page = DataFacade.GetData <IPage>(p => p.Id == PageId).FirstOrDefault();


                    Verify.IsNotNull(page, "The page with the id {0} does not exist", PageId);

                    var transitions = ProcessControllerFacade.GetValidTransitions(page).Keys;
                    if (transitions.Contains(GenericPublishProcessController.Published))
                    {
                        page.PublicationStatus = GenericPublishProcessController.Published;

                        DataFacade.Update(page);

                        Log.LogVerbose(LogTitle, "Scheduled publishing of page with title '{0}' is complete", page.Title);
                    }
                    else
                    {
                        Log.LogWarning(LogTitle, "Scheduled publishing of page with title '{0}' could not be done because the page is not in a publisheble state", page.Title);
                    }

                    transaction.Complete();
                }

                PublishControlledHelper.ReloadPageElementInConsole(page);
            }
        }