public ActionResult PublishPage(RemotePagePublishingModel model, string @return) { var resultEntry = new JsonResultData(ModelState); if (ModelState.IsValid) { if (model.Schedule && !model.UtcTimeToPublish.HasValue && !model.UtcTimeToUnpublish.HasValue) { resultEntry.AddErrorMessage("UtcTimeToPublish and UtcTimeToUnpublish can not be both empty.".Localize()); } else { foreach (string uuid in model.Pages) { foreach (string endpoint in model.RemoteEndPoints) { var queue = new RemotePublishingQueue() { PublishingObject = PublishingObject.Page, SiteName = Site.Name, UserId = User.Identity.Name, UtcCreationDate = DateTime.UtcNow, RemoteEndpoint = endpoint, ObjectUUID = uuid, ObjectTitle = uuid, Status = QueueStatus.Pending }; if (model.Schedule) { if (model.UtcTimeToPublish.HasValue) { queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime(); } if (model.UtcTimeToUnpublish.HasValue) { queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime(); } } else { queue.UtcTimeToPublish = DateTime.UtcNow; } resultEntry.RunWithTry((data) => { _manager.Add(queue); }); } } resultEntry.RedirectUrl = @return; } } return Json(resultEntry); }
public virtual void PublishPage(string[] docs, bool localPublish, bool remotePublish, bool publishSchedule, bool publishDraft, string[] remoteEndpoints, DateTime? publishDate, DateTime? unpublishDate, string userName) { foreach (string uuid in docs) { if (localPublish) { if (publishSchedule) { var queue = new LocalPublishingQueue() { ObjectUUID = uuid, ObjectTitle=uuid, UserId = userName, SiteName = Site.Current.Name, UtcCreationDate = DateTime.UtcNow, PublishingObject = PublishingObject.Page, PublishDraft = publishDraft, Status = QueueStatus.Pending }; if (publishDate.HasValue) { queue.UtcTimeToPublish = publishDate.Value.ToUniversalTime(); } if (unpublishDate.HasValue) { queue.UtcTimeToUnpublish = unpublishDate.Value.ToUniversalTime(); } this._localPublishingQueueManager.Add(queue); } else { var page = new Page(Site.Current, uuid); page = page.AsActual(); _pageManager.Publish(page, publishDraft, userName); _publishingLogProvider.Add(new PublishingLog() { QueueType = QueueType.Local, SiteName = Site.Current.Name, PublishingObject = PublishingObject.Page, ObjectUUID = uuid, ObjectTitle = uuid, PublishingAction = PublishingAction.Publish, UserId = userName, PublishDraft = publishDraft, Status = QueueStatus.OK, UtcProcessedTime = DateTime.UtcNow }); } } if (remotePublish) { foreach (var endpoint in remoteEndpoints) { var queue = new RemotePublishingQueue() { ObjectUUID = uuid, ObjectTitle = uuid, PublishingObject = PublishingObject.Page, SiteName = Site.Current.Name, UserId = userName, RemoteEndpoint = endpoint, UtcCreationDate = DateTime.UtcNow, PublishDraft = publishDraft, Status = QueueStatus.Pending }; if (publishSchedule) { if (publishDate.HasValue) { queue.UtcTimeToPublish = publishDate.Value.ToUniversalTime(); } if (unpublishDate.HasValue) { queue.UtcTimeToUnpublish = unpublishDate.Value.ToUniversalTime(); } } else { queue.UtcTimeToPublish = DateTime.UtcNow; } this._remotePublishingQueueManager.Add(queue); } } } }
public ActionResult PublishTextContent(CreateTextContentPublishingQueueViewModel model, string @return) { if (model.TextFolderMappings == null || model.TextFolderMappings.Length == 0) { ModelState.AddModelError("TextFolderMappings", "Required".Localize()); } var resultEntry = new JsonResultData(ModelState); if (ModelState.IsValid) { if (model.Schedule && !model.UtcTimeToPublish.HasValue && !model.UtcTimeToUnpublish.HasValue) { resultEntry.AddErrorMessage("UtcTimeToPublish and UtcTimeToUnpublish can not be both empty."); } else { TextFolder textFolder = new TextFolder(Repository.Current, model.LocalFolderId).AsActual(); for (int i = 0, j = model.TextContents.Length; i < j; i++) { var content = textFolder.CreateQuery().WhereEquals("UUID", model.TextContents[i]).FirstOrDefault(); if (content != null) { foreach (string mapping in model.TextFolderMappings) { var queue = new RemotePublishingQueue() { PublishingObject = PublishingObject.TextContent, SiteName = Site.Name, UserId = User.Identity.Name, UtcCreationDate = DateTime.UtcNow, TextFolderMapping = mapping, ObjectUUID = content.IntegrateId, ObjectTitle = model.ObjectTitles[i], Status = QueueStatus.Pending }; if (model.Schedule) { if (model.UtcTimeToPublish.HasValue) { queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime(); } if (model.UtcTimeToUnpublish.HasValue) { queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime(); } } else { queue.UtcTimeToPublish = DateTime.UtcNow; } resultEntry.RunWithTry((data) => { _manager.Add(queue); }); } } } resultEntry.RedirectUrl = @return; } } return Json(resultEntry); }
public virtual void PublishTextContent(TextFolder textFolder, string[] docs, bool localPublish, bool remotePublish, bool publishSchedule, string[] publishingMappings, DateTime? publishDate, DateTime? unpublishDate, string userName) { foreach (string uuid in docs) { var content = textFolder.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault(); if (content != null) { if (localPublish) { if (publishSchedule) { var queue = new LocalPublishingQueue() { ObjectUUID = content.IntegrateId, ObjectTitle=content.GetSummary(), UserId = userName, SiteName = Site.Current.Name, UtcCreationDate = DateTime.UtcNow, PublishingObject = PublishingObject.TextContent, Status = QueueStatus.Pending }; if (publishDate.HasValue) { queue.UtcTimeToPublish = publishDate.Value.ToUniversalTime(); } if (unpublishDate.HasValue) { queue.UtcTimeToUnpublish = unpublishDate.Value.ToUniversalTime(); } this._localPublishingQueueManager.Add(queue); } else { this._textContentManager.Publish(textFolder, uuid, userName); _publishingLogProvider.Add(new PublishingLog() { QueueType = QueueType.Local, SiteName = Site.Current.Name, PublishingObject = PublishingObject.TextContent, ObjectUUID = uuid, ObjectTitle = uuid, PublishingAction = PublishingAction.Publish, UserId = userName, Status = QueueStatus.OK, UtcProcessedTime = DateTime.UtcNow }); } } if (remotePublish) { foreach (string mapping in publishingMappings) { var queue = new RemotePublishingQueue() { ObjectUUID = content.IntegrateId, ObjectTitle = content.GetSummary(), PublishingObject = PublishingObject.TextContent, SiteName = Site.Current.Name, UserId = userName, TextFolderMapping = mapping, UtcCreationDate = DateTime.UtcNow, Status = QueueStatus.Pending }; if (publishSchedule) { if (publishDate.HasValue) { queue.UtcTimeToPublish = publishDate.Value.ToUniversalTime(); } if (unpublishDate.HasValue) { queue.UtcTimeToUnpublish = unpublishDate.Value.ToUniversalTime(); } } else { queue.UtcTimeToPublish = DateTime.UtcNow; } this._remotePublishingQueueManager.Add(queue); } } } } }