Exemple #1
0
        private dynamic LastCompleted(dynamic o)
        {
            var completedRequest = this.Bind <PublishLastCompletedRequest>();

            var parameters = new PublishLastCompleted
            {
                Source   = completedRequest.Source ?? "master",
                Target   = completedRequest.Target ?? "web",
                Language = completedRequest.Language ?? "en"
            };

            var date = _publishService.GetLastCompletedRun(parameters);

            return(Response.AsJson(date));
        }
        private static PublishLastCompleted GetRequest(HttpRequestBase request)
        {
            if (request.Url == null)
            {
                throw new InvalidOperationException("Missing Url");
            }

            var parameters = new PublishLastCompleted
            {
                Source   = request.Form["source"] ?? "master",
                Target   = request.Form["target"] ?? "web",
                Language = request.Form["language"] ?? "en"
            };

            return(parameters);
        }
Exemple #3
0
        public void Should_request_publish_date_of_master_and_web_in_en_when_last_completed_called_with_no_parameters()
        {
            PublishLastCompleted parameters = null;

            var expected = DateTime.Now;

            _mockPublishService
            .Setup(x => x.GetLastCompletedRun(It.IsAny <PublishLastCompleted>()))
            .Callback <PublishLastCompleted>(x => parameters = x)
            .Returns(expected);

            _browser.Get("/services/publish/lastcompleted");

            parameters.Source.ShouldEqual("master");
            parameters.Target.ShouldEqual("web");
            parameters.Language.ShouldEqual("en");
        }
        public DateTime GetLastCompletedRun(PublishLastCompleted completeParameters)
        {
            // please note http://stackoverflow.com/questions/12416141/get-the-date-time-that-sitecore-last-published

            var source = Sitecore.Configuration.Factory.GetDatabase(completeParameters.Source);
            var target = Sitecore.Configuration.Factory.GetDatabase(completeParameters.Target);

            var language = LanguageManager.GetLanguage(completeParameters.Language);


            Assert.IsNotNull(source, "Source database {0} cannot be found".Formatted(completeParameters.Source));
            Assert.IsNotNull(source, "Target database {0} cannot be found".Formatted(completeParameters.Target));
            Assert.IsNotNull(language, "Language {0} cannot be found".Formatted(completeParameters.Language));

            var date = source.Properties.GetLastPublishDate(target, language);

            return(date);
        }
Exemple #5
0
        public void Should_request_publish_date_of_source_and_target_in_specified_language_when_last_completed_called_with_parameters()
        {
            PublishLastCompleted parameters = null;

            var expected = DateTime.Now;

            const string sourceDb = "mysource";
            const string targetDb = "myTarget";
            const string language = "mylanguage";

            _mockPublishService
            .Setup(x => x.GetLastCompletedRun(It.IsAny <PublishLastCompleted>()))
            .Callback <PublishLastCompleted>(x => parameters = x)
            .Returns(expected);

            _browser.Get("/services/publish/lastcompleted/{0}/{1}/{2}".Formatted(sourceDb, targetDb, language));

            parameters.Source.ShouldEqual(sourceDb);
            parameters.Target.ShouldEqual(targetDb);
            parameters.Language.ShouldEqual(language);
        }