예제 #1
0
        private dynamic InvokePublishing(dynamic o)
        {
            var publishRequest = this.Bind<PublishRequest>();

            if (!IsAllowedPublishingMode(publishRequest.Mode))
            {
                return new Response
                    {
                        StatusCode = HttpStatusCode.BadRequest
                    };
            }

            var publishParameters = new PublishParameters
                {
                    Mode = publishRequest.Mode,
                    Source = publishRequest.Source ?? "master",
                    Targets = publishRequest.Targets.CsvStringToStringArray(new[] {"web"}),
                    Languages = publishRequest.Languages.CsvStringToStringArray(new[] {"en"}),
                };

            var now = DateTime.Now;
            var date = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);

            _publishService.Run(publishParameters);

            return Response.AsJson(date, HttpStatusCode.Accepted);
        }
예제 #2
0
		public void Run(PublishParameters publishParameters)
		{
			var publishingMode = publishParameters.Mode.ToLower();

			if (!_publishingActions.ContainsKey(publishingMode))
			{
				throw new InvalidOperationException(string.Format("Invalid publishing mode ({0})", publishingMode));
			}

			PublishingTask(_publishingActions[publishingMode], publishParameters);
		}
예제 #3
0
        private static void PublishingTask(Func<Database, Database[], Language[], Handle> publishType, PublishParameters publishParameters)
        {
            using (new SecurityModel.SecurityDisabler())
            {
                var master = Sitecore.Configuration.Factory.GetDatabase(publishParameters.Source);
                var targetDBs = publishParameters.Targets.Select(Sitecore.Configuration.Factory.GetDatabase).ToArray();
                var languages = publishParameters.Languages.Select(LanguageManager.GetLanguage).ToArray();

                publishType(master, targetDBs, languages);
            }
        }
        private static PublishParameters GetRequest(HttpRequestBase request)
        {
            if (request.Url == null) throw new InvalidOperationException("Missing Url");

            var publishRequest = new PublishParameters
                {
                    Mode = request.Url.PathAndQuery.Split(new[] {'/'}).Last(),
                    Source = request.Form["source"] ?? "master",
                    Targets = request.Form["targets"].CsvStringToStringArray(new[] { "web" }),
                    Languages = request.Form["languages"].CsvStringToStringArray(new[] { "en" })
                };

            return publishRequest;
        }
예제 #5
0
        public PublishModuleBehaviour()
        {
            _mockPublishService = new Mock<IPublishService>();

            _mockAuthoriser = new Mock<IAuthoriser>();

            var bootstrapper = new ConfigurableBootstrapper(with =>
            {
                with.Module<PublishModule>();
                with.Dependency(_mockPublishService.Object);
                with.Dependency(_mockAuthoriser.Object);
            });

            _browser = new Browser(bootstrapper);

            _mockAuthoriser.Setup(x => x.IsAllowed()).Returns(true);

            _publishParameters = null;

            _mockPublishService
                .Setup(x => x.Run(It.IsAny<PublishParameters>()))
                .Callback<PublishParameters>(x => _publishParameters = x);
        }