Пример #1
0
        public static bool TryApplyVersion(this PathData path, ContentVersion version, string versionKey, ContentVersionRepository repository)
        {
            if (version != null)
            {
                var page = repository.DeserializeVersion(version);
                if (!string.IsNullOrEmpty(versionKey))
                {
                    var item = page.FindDescendantByVersionKey(versionKey);
                    if (item != null)
                    {
                        path.CurrentPage = page;
                        path.CurrentItem = item;
                        return(true);
                    }
                }

                if (path.CurrentItem.IsPage)
                {
                    path.CurrentPage = null;
                    path.CurrentItem = page;
                }
                else
                {
                    path.CurrentPage = page;
                    path.CurrentItem = page.FindDescendantByVersionKey(versionKey)
                                       ?? page.FindPartVersion(path.CurrentItem);
                }

                return(true);
            }
            return(false);
        }
Пример #2
0
        private void PublishPendingVersions()
        {
            var scheduledForAutoPublish = versionRepository.GetVersionsScheduledForPublish(Utility.CurrentTime()).ToList();

            foreach (var version in scheduledForAutoPublish)
            {
                try
                {
                    var scheduledVersion = versionRepository.DeserializeVersion(version);
                    scheduledVersion["FuturePublishDate"] = null;
                    if (scheduledVersion.VersionOf.HasValue && scheduledVersion.VersionOf.Value != null)
                    {
                        versioner.Publish(persister, scheduledVersion);
                    }
                    else
                    {
                        //Delete versions if master item doesn't exists
                        versioner.DeleteVersion(scheduledVersion);
                    }
                }
                catch (Exception ex)
                {
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    logger.Error(ex);
                }
            }
        }
Пример #3
0
        public void MovingPublishedItem_BetweenZones_CreatesDraft_ContainingChanges()
        {
            var part = CreateOneItem <Items.DataItem>(0, "part", root);

            part.ZoneName = "ZoneOne";

            request[PathData.ItemQueryKey] = part.Path;
            request["below"] = root.Path;
            request["zone"]  = "ZoneTwo";

            var response = mover.HandleRequest(request);

            var draft = versionRepository.GetVersions(root).Single();

            versionRepository.DeserializeVersion(draft).Children.Single().ZoneName.ShouldBe("ZoneTwo");
        }
Пример #4
0
        private void PublishPendingVersions()
        {
            var scheduledForAutoPublish = versionRepository.GetVersionsScheduledForPublish(Utility.CurrentTime()).ToList();

            foreach (var version in scheduledForAutoPublish)
            {
                var scheduledVersion = versionRepository.DeserializeVersion(version);
                scheduledVersion["FuturePublishDate"] = null;
                versioner.Publish(persister, scheduledVersion);
            }
        }
Пример #5
0
        public void UpgradeVersion_CopiesBuiltInProperties()
        {
            using (persister)
            {
                worker.UpgradeVersion(version);
            }

            var newVersion = repository.GetVersion(master, version.VersionIndex);

            //newVersion.Expired.ShouldBe(version.Expires);
            newVersion.FuturePublish.ShouldBe(version["FuturePublish"]);
            newVersion.ItemCount.ShouldBe(1);
            newVersion.Master.ID.ShouldBe(master.ID);
            newVersion.Published.ShouldBe(version.Published);
            //newVersion.PublishedBy.ShouldBe(version.SavedBy);
            newVersion.Saved.StripMilliseconds().ShouldBe(version.Updated.StripMilliseconds());
            newVersion.SavedBy.ShouldBe(version.SavedBy);
            newVersion.State.ShouldBe(version.State);
            newVersion.Title.ShouldBe(version.Title);
            newVersion.VersionIndex.ShouldBe(version.VersionIndex);
            var versionData = repository.DeserializeVersion(newVersion);

            versionData.ID.ShouldBe(0);
            versionData.Created.StripMilliseconds().ShouldBe(version.Created.StripMilliseconds());
            //versionData.Expires.ShouldBe(version.Expires);
            versionData.Name.ShouldBe(version.Name);
            versionData.Published.Value.StripMilliseconds().ShouldBe(version.Published.Value.StripMilliseconds());
            versionData.SavedBy.ShouldBe(version.SavedBy);
            versionData.SortOrder.ShouldBe(version.SortOrder);
            versionData.State.ShouldBe(version.State);
            versionData.TemplateKey.ShouldBe(version.TemplateKey);
            versionData.Title.ShouldBe(version.Title);
            versionData.TranslationKey.ShouldBe(version.TranslationKey);
            //versionData.Updated.ShouldBe(version.Updated);
            versionData.VersionIndex.ShouldBe(version.VersionIndex);
            versionData.Visible.ShouldBe(version.Visible);
            versionData.ZoneName.ShouldBe(version.ZoneName);
        }
Пример #6
0
        public void CreateUrlProvider_CratesItems_WithoutEditables_AndRedirectsTo_DraftVersion()
        {
            request["discriminator"] = "DataItem";
            request["returnUrl"]     = "/back/to/here?edit=drag";
            request["below"]         = root.Path;
            request["zone"]          = "SomeZone";
            long initialCount = persister.Repository.Count();

            var response = creator.HandleRequest(request);

            response["dialog"].ShouldBe("no");
            response["redirect"].ShouldBe("/back/to/here?edit=drag&n2versionIndex=1");
            persister.Repository.Count().ShouldBe(initialCount);
            versionRepository.Repository.Count().ShouldBe(1);
            versionRepository.DeserializeVersion(versionRepository.GetVersion(root)).Children.Single().ShouldBeOfType <Items.DataItem>();
        }
Пример #7
0
        public void VersionIndex_IsKeptWhenSavingVersion()
        {
            var page = CreateOneItem <Items.NormalPage>(0, "page", null);

            persister.Save(page);

            var versionItem = page.Clone(true);

            versionItem.VersionIndex = page.VersionIndex + 1;
            versionItem.State        = ContentState.Draft;
            versionItem.VersionOf    = page;

            var version = repository.Save(versionItem);

            repository.Repository.Dispose();
            var savedVersion = repository.GetVersion(page, versionItem.VersionIndex);

            savedVersion.VersionIndex.ShouldBe(versionItem.VersionIndex);
            repository.DeserializeVersion(savedVersion).VersionIndex.ShouldBe(versionItem.VersionIndex);
        }
Пример #8
0
        private void PublishPendingVersions()
        {
            var scheduledForAutoPublish = versionRepository.GetVersionsScheduledForPublish(Utility.CurrentTime()).ToList();

            foreach (var version in scheduledForAutoPublish)
            {
                try
                {
                    var scheduledVersion = versionRepository.DeserializeVersion(version);
                    scheduledVersion["FuturePublishDate"] = null;
                    versioner.Publish(persister, scheduledVersion);
                }
                catch (Exception ex)
                {
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    logger.Error(ex);
                }
            }
        }
Пример #9
0
		private void CheckRelatedVersions(ContentItem item)
		{
			hlNewerVersion.Visible = false;
			hlOlderVersion.Visible = false;

			if (!item.IsPage)
				return;

			if (item.VersionOf.HasValue)
			{
				DisplayThisIsVersionInfo(item.VersionOf);
			}
			else
			{
				var page = Find.ClosestPage(item);
				var version = Engine.Resolve<N2.Edit.Versioning.DraftRepository>().FindDrafts(page).FirstOrDefault();
				if (version != null && version.Saved > item.Updated)
				{
					DisplayThisHasNewerVersionInfo(Repository.DeserializeVersion(version).FindPartVersion(item));
				}
			}
		}