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 ActionResult PublishPage(LocalPagePublishingModel 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 if (model.Schedule)
                {
                    foreach (string uuid in model.Pages)
                    {
                        var queue = new LocalPublishingQueue()
                        {
                            PublishingObject = PublishingObject.Page,
                            SiteName = Site.Name,
                            UserId = User.Identity.Name,
                            UtcCreationDate = DateTime.UtcNow,
                            ObjectUUID = uuid,
                            ObjectTitle = uuid,
                            Status = QueueStatus.Pending
                        };
                        if (model.UtcTimeToPublish.HasValue)
                        {
                            queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime();
                        }
                        if (model.UtcTimeToUnpublish.HasValue)
                        {
                            queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime();
                        }

                        resultEntry.RunWithTry((data) =>
                        {
                            _manager.Add(queue);
                        });
                    }
                    resultEntry.RedirectUrl = @return;
                }
                else
                {
                    foreach (string uuid in model.Pages)
                    {
                        var page = new Page(Site, uuid);
                        Kooboo.CMS.Sites.Services.ServiceFactory.PageManager.Publish(page, false, false, false, DateTime.UtcNow, DateTime.UtcNow, User.Identity.Name);
                    }
                    resultEntry.RedirectUrl = @return;
                }
            }
            return Json(resultEntry);
        }
 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);
 }
Ejemplo n.º 4
0
        public ActionResult PublishTextContent(CreateTextContentPublishingQueueViewModel 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 if (model.Schedule)
                {
                    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();
                        var queue = new LocalPublishingQueue(Site, Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10))
                        {
                            PublishingObject = PublishingObject.TextContent,
                            UserId = User.Identity.Name,
                            UtcCreationDate = DateTime.UtcNow,
                            ObjectUUID = content.IntegrateId,
                            ObjectTitle = model.ObjectTitles[i],
                            Status = QueueStatus.Pending
                        };
                        if (model.UtcTimeToPublish.HasValue)
                        {
                            queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime();
                        }
                        if (model.UtcTimeToUnpublish.HasValue)
                        {
                            queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime();
                        }

                        resultEntry.RunWithTry((data) =>
                        {
                            _manager.Add(queue);
                        });
                    }
                    resultEntry.RedirectUrl = @return;
                }
                else
                {
                    TextFolder textFolder = new TextFolder(Repository.Current, model.LocalFolderId).AsActual();
                    foreach (string uuid in model.TextContents)
                    {
                        Kooboo.CMS.Content.Services.ServiceFactory.TextContentManager.Update(textFolder, uuid, "Published", true, User.Identity.Name);
                    }
                    resultEntry.RedirectUrl = @return;
                }
            }
            return Json(resultEntry);
        }
Ejemplo n.º 5
0
        public virtual ActionResult Publish(string siteName)
        {
            if(string.IsNullOrWhiteSpace(siteName))
                throw new ArgumentNullException("siteName");

            var site = SiteHelper.Parse(siteName);
            if (site == null)
                throw new NullReferenceException("site");
            site = site.AsActual();
            var rootSite = SiteHelper.GetRootSite(site).AsActual();
            if (string.IsNullOrWhiteSpace(rootSite.ClientId))
                throw new Exception("Customer ID is not specified".Localize());

            var ip = rootSite.FrontendDefaultIp;
            var path = Path.Combine(site.PhysicalPath, rootSite.FrontendPhysicalPath);
            var protocol = rootSite.FrontendDefaultProtocol;
            var port = rootSite.FrontendDefaultPort;
            var appPoolName = rootSite.FrontendDefaultApplicationPoolName;
            var name = site.UID; //string.Format("Frontend.{0}.{1}", rootSite.ClientId, siteName);

            //Chek domain name
            //
            if (site.Domains == null || site.Domains.Length == 0)
            {
                var result = new JsonResultData(ModelState);
                result.AddErrorMessage("Before publish site you must specify the domain name (System/Settings/Domain/Domains)".Localize());
                return Json(result);
            }

            try
            {
                //Create web site
                //
                IISHelper.CreateWebSite(appPoolName, name, protocol, ip, site.Domains.ToArray(), port, path);

            }
            catch (Exception e)
            {
                var result = new JsonResultData();
                result.AddException(new Exception("Fail to publication.".Localize() + " " + e.Message, e));
                return Json(result);
            }

            //Result
            //
            var data = new JsonResultData(ModelState);
            data.ReloadPage = true;
            return Json(data);
        }