public static void CreateNewsNativeAPI(Guid masterNewsId, string newsTitle, string newsContent) { NewsManager newsManager = NewsManager.GetManager(); NewsItem newsItem = newsManager.GetNewsItems().Where(item => item.Id == masterNewsId).FirstOrDefault(); if (newsItem == null) { //The news item is created as a master. The newsId is assigned to the master. newsItem = newsManager.CreateNewsItem(masterNewsId); //Set the properties of the news item. newsItem.Title = newsTitle; newsItem.Content = newsContent; newsItem.DateCreated = DateTime.UtcNow; newsItem.PublicationDate = DateTime.UtcNow; newsItem.LastModified = DateTime.UtcNow; newsItem.UrlName = Regex.Replace(newsTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-"); //Recompiles and validates the url of the news item. newsManager.RecompileAndValidateUrls(newsItem); //Save the changes. newsManager.SaveChanges(); //Publish the news item. The published version acquires new ID. var bag = new Dictionary <string, string>(); bag.Add("ContentType", typeof(NewsItem).FullName); WorkflowManager.MessageWorkflow(masterNewsId, typeof(NewsItem), null, "Publish", false, bag); } }
private void CreateNews(string[] values) { NewsManager man = NewsManager.GetManager(); man.Provider.SuppressSecurityChecks = true; TaxonomyManager tMan = TaxonomyManager.GetManager(); tMan.Provider.SuppressSecurityChecks = true; string title = values[0], tags = values[1], content = values[2]; var newsItem = man.GetNewsItems().FirstOrDefault(i => i.Title == title); if (newsItem != null) { return; } newsItem = man.CreateNewsItem(); var newsId = newsItem.Id; newsItem.Title = title; newsItem.Content = content; var tag = tMan.GetTaxa <FlatTaxon>().FirstOrDefault(i => i.Title == tags); var taxa = tMan.GetTaxonomy <FlatTaxonomy>(TaxonomyManager.TagsTaxonomyId); if (tag == null) { tag = tMan.CreateTaxon <FlatTaxon>(Guid.NewGuid()); tag.Title = tags; tag.Name = tags; tag.Description = "This tag categorizes the Breakfast"; tag.UrlName = new Lstring(Regex.Replace(tags, @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-").ToLower()); taxa.Taxa.Add(tag); tMan.SaveChanges(); } newsItem.Organizer.AddTaxa("Tags", tag.Id); newsItem.DateCreated = DateTime.UtcNow; newsItem.PublicationDate = DateTime.UtcNow; newsItem.LastModified = DateTime.UtcNow; newsItem.UrlName = Regex.Replace(title.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-"); //Recompiles and validates the url of the news item. man.RecompileAndValidateUrls(newsItem); //Save the changes. man.SaveChanges(); //Publish the news item. The published version acquires new ID. var bag = new Dictionary <string, string>(); bag.Add("ContentType", typeof(NewsItem).FullName); WorkflowManager.MessageWorkflow(newsId, typeof(NewsItem), null, "Publish", false, bag); man.Lifecycle.Publish(newsItem); man.SaveChanges(); }
private NewsItem CreateNewsWithBasicProperties(NewsManager manager, string title, string content, string author, string sourceName) { var newsItem = manager.CreateNewsItem(); newsItem.Title = title; newsItem.DateCreated = DateTime.UtcNow; newsItem.PublicationDate = DateTime.UtcNow.AddDays(1); newsItem.ExpirationDate = DateTime.UtcNow.AddDays(30); newsItem.Author = author; newsItem.Content = content; newsItem.SourceName = sourceName; newsItem.UrlName = ServerArrangementUtilities.GetFormatedUrlName(title); return(newsItem); }
public ActionResult CreatePressRelease() { NewsItem item = nm.CreateNewsItem(); item.Title = "News Item 1"; item.Content = "<h2>Test content here</h2>"; item.DateCreated = DateTime.UtcNow; item.PublicationDate = DateTime.UtcNow; item.LastModified = DateTime.UtcNow; item.UrlName = Regex.Replace(item.Title, @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-"); nm.SaveChanges(); var bag = new Dictionary <string, string>(); bag.Add("ContentType", typeof(NewsItem).FullName); WorkflowManager.MessageWorkflow(item.Id, typeof(NewsItem), null, "Publish", false, bag); return(View()); }
private NewsItem CreateNewsWithBasicProperties(NewsManager manager, string title, string content, string author, string sourceName) { var newsItem = manager.CreateNewsItem(); newsItem.Title = title; newsItem.DateCreated = DateTime.UtcNow; newsItem.PublicationDate = DateTime.UtcNow.AddDays(1); newsItem.ExpirationDate = DateTime.UtcNow.AddDays(30); newsItem.Author = author; newsItem.Content = content; newsItem.SourceName = sourceName; newsItem.UrlName = ServerArrangementUtilities.GetFormatedUrlName(title); return newsItem; }