public JsonResult PublishDocument(int documentId, bool publishDescendants, bool includeUnpublished)
 {
     var content = Services.ContentService.GetById(documentId);
     var doc = new Document(content);
     //var contentService = (ContentService) Services.ContentService;
     if (publishDescendants == false)
     {
         //var result = contentService.SaveAndPublishInternal(content);
         var result = doc.SaveAndPublish(UmbracoUser.Id);
         return Json(new
             {
                 success = result.Success,
                 message = GetMessageForStatus(result.Result)
             });
     }
     else
     {
         /*var result = ((ContentService) Services.ContentService)
             .PublishWithChildrenInternal(content, UmbracoUser.Id, includeUnpublished)
             .ToArray();*/
         var result = doc.PublishWithSubs(UmbracoUser.Id, includeUnpublished);
         return Json(new
             {
                 success = result.All(x => x.Success),
                 message = GetMessageForStatuses(result.Select(x => x.Result), content)
             });
     }
 }
        public override TaskExecutionDetails Execute(string Value)
        {
            TaskExecutionDetails d = new TaskExecutionDetails();

            if (HttpContext.Current != null && HttpContext.Current.Items["pageID"] != null)
            {
                string id = HttpContext.Current.Items["pageID"].ToString();

                Document doc = new Document(Convert.ToInt32(id));

                if (doc.getProperty(PropertyAlias) != null)
                {
                    d.OriginalValue = doc.getProperty(PropertyAlias).Value.ToString();

                    doc.getProperty(PropertyAlias).Value = Value;
                    doc.SaveAndPublish(new BusinessLogic.User(0));

                    d.NewValue = Value;
                    d.TaskExecutionStatus = TaskExecutionStatus.Completed;
                }
                else
                    d.TaskExecutionStatus = TaskExecutionStatus.Cancelled;

            }
            else
                d.TaskExecutionStatus = TaskExecutionStatus.Cancelled;

            return d;
        }
        public object editPost(
            string postid,
            string username,
            string password,
            Post post,
            bool publish)
        {
            if (validateUser(username, password))
            {
                Channel userChannel = new Channel(username);
                Document doc = new Document(Convert.ToInt32(postid));


                doc.Text = HttpContext.Current.Server.HtmlDecode(post.title);

                // Excerpt
                if (userChannel.FieldExcerptAlias != null && userChannel.FieldExcerptAlias != "")
                    doc.getProperty(userChannel.FieldExcerptAlias).Value = removeLeftUrl(post.mt_excerpt);

                if (UmbracoSettings.TidyEditorContent)
                    doc.getProperty(userChannel.FieldDescriptionAlias).Value = library.Tidy(removeLeftUrl(post.description), false);
                else
                    doc.getProperty(userChannel.FieldDescriptionAlias).Value = removeLeftUrl(post.description);

                updateCategories(doc, post, userChannel);


                if (publish)
                {
                    doc.SaveAndPublish(new User(username));
                }
                return true;
            }
            else
            {
                return false;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Publishes the update.
        /// </summary>
        public void Publish()
        {
            // keep track of documents published in this request
            List<int> publishedDocuments = (List<int>)HttpContext.Current.Items["ItemUpdate_PublishedDocuments"];
            if (publishedDocuments == null)
            {
                HttpContext.Current.Items["ItemUpdate_PublishedDocuments"] = publishedDocuments = new List<int>();
            }

            // publish each modified document just once (e.g. several fields are updated)
            if(!publishedDocuments.Contains(NodeId.Value))
            {
                Document document = new Document(NodeId.Value);
                document.SaveAndPublish(Umbraco.Web.UmbracoContext.Current.UmbracoUser);
                
                publishedDocuments.Add(NodeId.Value);
            }
        }
Esempio n. 5
0
        private void SaveProject(Document project, Member user)
        {
            if (!string.IsNullOrWhiteSpace(Request["title"]))
            {
                project.getProperty("title").Value = Request["title"];
            }
            if (!string.IsNullOrWhiteSpace(Request["description"]))
                project.getProperty("description").Value = Request["description"];
            if (!string.IsNullOrWhiteSpace(Request["projectType"]))
                project.getProperty("projectType").Value = Convert.ToInt32(Request["projectType"]);
            if (!string.IsNullOrWhiteSpace(Request["area"]))
                project.getProperty("area").Value = Convert.ToInt32(Request["area"]);
            project.getProperty("allowComments").Value = !string.IsNullOrWhiteSpace(Request["allowComments"]) && Request["allowComments"].ToLower().Equals("on");

            project.getProperty("author").Value = user.Id;

            if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
            {
                var uploadedFile = Request.Files[0];
                var fileName = Path.GetFileName(uploadedFile.FileName);
                var fileSavePath = Server.MapPath("~/media/projects/" + fileName);
                uploadedFile.SaveAs(fileSavePath);

                project.getProperty("image").Value = "/media/projects/" + fileName;
            }

            project.SaveAndPublish(user.User);
            umbraco.library.UpdateDocumentCache(project.Id);
        }