本文整理汇总了C#中Subtext.Framework.Components.Entry类的典型用法代码示例。如果您正苦于以下问题:C# Entry类的具体用法?C# Entry怎么用?C# Entry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Entry类属于Subtext.Framework.Components命名空间,在下文中一共展示了Entry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
/// <summary>
/// Creates the specified entry in the back end data store attaching
/// the specified category ids.
/// </summary>
/// <param name="entry">Entry.</param>
/// <param name="categoryIds">Category I ds.</param>
/// <returns></returns>
public override int Create(Entry entry, IEnumerable<int> categoryIds)
{
ValidateEntry(entry);
entry.DateCreatedUtc = entry.DateCreatedUtc.IsNull() ? CurrentDateTimeUtc : entry.DateCreatedUtc;
entry.Id = _procedures.InsertEntry(entry.Title
, entry.Body.NullIfEmpty()
, (int)entry.PostType
, entry.Author.NullIfEmpty()
, entry.Email.NullIfEmpty()
, entry.Description.NullIfEmpty()
, BlogId
, entry.DateCreatedUtc
, (int)entry.PostConfig
, entry.EntryName.NullIfEmpty()
, entry.DatePublishedUtc.NullIfEmpty());
if (categoryIds != null)
{
SetEntryCategoryList(entry.Id, categoryIds);
}
if (entry.Id > -1)
{
Config.CurrentBlog.DateModifiedUtc = entry.DateCreatedUtc;
}
return entry.Id;
}
示例2: Run
/// <summary>
/// Posts trackbacks and pingbacks for the specified entry.
/// </summary>
public static void Run(Entry entry, Blog blog, BlogUrlHelper urlHelper)
{
if (!blog.TrackbacksEnabled)
{
return;
}
if (!Config.Settings.Tracking.EnablePingBacks && !Config.Settings.Tracking.EnableTrackBacks)
{
return;
}
if (entry != null)
{
VirtualPath blogUrl = urlHelper.BlogUrl();
Uri fullyQualifiedUrl = blogUrl.ToFullyQualifiedUrl(blog);
var notify = new Notifier
{
FullyQualifiedUrl = fullyQualifiedUrl.AbsoluteUri,
BlogName = blog.Title,
Title = entry.Title,
PostUrl = urlHelper.EntryUrl(entry).ToFullyQualifiedUrl(blog),
Description = entry.HasDescription ? entry.Description : entry.Title,
Text = entry.Body
};
//This could take a while, do it on another thread
ThreadHelper.FireAndForget(notify.Notify, "Exception occured while attempting trackback notification");
}
}
示例3: ConvertBlogPost
public Entry ConvertBlogPost(BlogMLPost post, BlogMLBlog blogMLBlog, Blog blog)
{
DateTime dateModified = blog != null ? blog.TimeZone.FromUtc(post.DateModified) : post.DateModified;
DateTime dateCreated = blog != null ? blog.TimeZone.FromUtc(post.DateCreated) : post.DateCreated;
var newEntry = new Entry((post.PostType == BlogPostTypes.Article) ? PostType.Story : PostType.BlogPost)
{
Title = GetTitleFromPost(post).Left(BlogPostTitleMaxLength),
DateCreated = dateCreated,
DateModified = dateModified,
DateSyndicated = post.Approved ? dateModified : DateTime.MaxValue,
Body = post.Content.UncodedText,
IsActive = post.Approved,
DisplayOnHomePage = post.Approved,
IncludeInMainSyndication = post.Approved,
IsAggregated = post.Approved,
AllowComments = true,
Description = post.HasExcerpt ? post.Excerpt.UncodedText: null
};
if(!string.IsNullOrEmpty(post.PostName))
{
newEntry.EntryName = post.PostName;
}
else
{
SetEntryNameForBlogspotImport(post, newEntry);
}
SetEntryAuthor(post, newEntry, blogMLBlog);
SetEntryCategories(post, newEntry, blogMLBlog);
return newEntry;
}
示例4: editPost_WithEntryHavingEnclosure_UpdatesEntryEnclosureWithNewEnclosure
public void editPost_WithEntryHavingEnclosure_UpdatesEntryEnclosureWithNewEnclosure()
{
//arrange
var entry = new Entry(PostType.BlogPost) { Title = "Title 1", Body = "Blah", IsActive = true };
entry.DateCreatedUtc = entry.DatePublishedUtc = entry.DateModifiedUtc = DateTime.ParseExact("1975/01/23", "yyyy/MM/dd", CultureInfo.InvariantCulture);
entry.Categories.Add("TestCategory");
var blog = new Blog { Id = 123, Host = "localhost", AllowServiceAccess = true, UserName = "username", Password = "password" };
var subtextContext = new Mock<ISubtextContext>();
subtextContext.Setup(c => c.Blog).Returns(blog);
subtextContext.Setup(c => c.Repository.GetEntry(It.IsAny<Int32>(), false, true)).Returns(entry);
var entryPublisher = new Mock<IEntryPublisher>();
Entry publishedEntry = null;
entryPublisher.Setup(p => p.Publish(It.IsAny<Entry>())).Callback<Entry>(e => publishedEntry = e);
FrameworkEnclosure enclosure = UnitTestHelper.BuildEnclosure("<Digital Photography Explained (for Geeks) with Aaron Hockley/>",
"http://perseus.franklins.net/hanselminutes_0107.mp3", "audio/mp3", 123, 26707573, true, true);
entry.Enclosure = enclosure;
var post = new Post { title = "Title 2", description = "Blah", dateCreated = DateTime.UtcNow };
var postEnclosure = new Enclosure
{
url = "http://codeclimber.net.nz/podcast/mypodcastUpdated.mp3",
type = "audio/mp3",
length = 123456789
};
post.enclosure = postEnclosure;
var metaWeblog = new MetaWeblog(subtextContext.Object, entryPublisher.Object);
// act
bool result = metaWeblog.editPost("123", "username", "password", post, true);
// assert
Assert.IsTrue(result);
Assert.IsNotNull(publishedEntry.Enclosure);
Assert.AreEqual("http://codeclimber.net.nz/podcast/mypodcastUpdated.mp3", entry.Enclosure.Url);
}
示例5: Create
/// <summary>
/// Creates the specified entry in the back end data store attaching
/// the specified category ids.
/// </summary>
/// <param name="entry">Entry.</param>
/// <param name="categoryIds">Category I ds.</param>
/// <returns></returns>
public override int Create(Entry entry, IEnumerable<int> categoryIds)
{
ValidateEntry(entry);
entry.Id = _procedures.InsertEntry(entry.Title
, entry.Body.NullIfEmpty()
, (int)entry.PostType
, entry.Author.NullIfEmpty()
, entry.Email.NullIfEmpty()
, entry.Description.NullIfEmpty()
, BlogId
, entry.DateCreated
, (int)entry.PostConfig
, entry.EntryName.NullIfEmpty()
, entry.DateSyndicated.NullIfEmpty()
, CurrentDateTime);
if(categoryIds != null)
{
SetEntryCategoryList(entry.Id, categoryIds);
}
if(entry.Id > -1)
{
Config.CurrentBlog.LastUpdated = entry.DateCreated;
}
return entry.Id;
}
示例6: CreateSetsDateCreated
public void CreateSetsDateCreated()
{
//arrange
var blog = new Mock<Blog>();
DateTime dateCreatedUtc = DateTime.UtcNow;
blog.Object.Id = 1;
var entry = new Entry(PostType.BlogPost, blog.Object) { Id = 123, BlogId = 1, CommentingClosed = false };
var repository = new Mock<ObjectRepository>();
repository.Setup(r => r.GetEntry(It.IsAny<int>(), true, true)).Returns(entry);
var context = new Mock<ISubtextContext>();
context.SetupGet(c => c.Repository).Returns(repository.Object);
context.SetupGet(c => c.Blog).Returns(blog.Object);
context.SetupGet(c => c.HttpContext.Items).Returns(new Hashtable());
context.SetupGet(c => c.Cache).Returns(new TestCache());
var service = new CommentService(context.Object, null);
var comment = new FeedbackItem(FeedbackType.Comment) { EntryId = 123, BlogId = 1, Body = "test", Title = "title" };
//act
service.Create(comment, true/*runFilters*/);
//assert
Assert.GreaterEqualThan(comment.DateCreatedUtc, dateCreatedUtc);
Assert.GreaterEqualThan(DateTime.UtcNow, comment.DateCreatedUtc);
}
示例7: CanUpdatePostWithCategories
public void CanUpdatePostWithCategories()
{
string hostname = UnitTestHelper.GenerateRandomString();
Assert.IsTrue(Config.CreateBlog("", "username", "password", hostname, ""));
UnitTestHelper.SetHttpContextWithBlogRequest(hostname, "");
Config.CurrentBlog.AllowServiceAccess = true;
string category1Name = UnitTestHelper.GenerateRandomString();
string category2Name = UnitTestHelper.GenerateRandomString();
UnitTestHelper.CreateCategory(Config.CurrentBlog.Id, category1Name);
UnitTestHelper.CreateCategory(Config.CurrentBlog.Id, category2Name);
Entry entry = new Entry(PostType.BlogPost);
entry.Title = "Title 1";
entry.Body = "Blah";
entry.IsActive = true;
entry.DateCreated = entry.DateSyndicated = entry.DateModified = DateTime.ParseExact("1975/01/23", "yyyy/MM/dd", CultureInfo.InvariantCulture);
entry.Categories.Add(category1Name);
int entryId = Entries.Create(entry);
MetaWeblog api = new MetaWeblog();
Post post = new Post();
post.title = "Title 2";
post.description = "Blah";
post.categories = new string[] { category2Name };
post.dateCreated = DateTime.Now;
bool result = api.editPost(entryId.ToString(CultureInfo.InvariantCulture), "username", "password", post, true);
entry = Entries.GetEntry(entryId, PostConfig.None, true);
Assert.AreEqual(1, entry.Categories.Count, "We expected one category. We didn't get what we expected.");
Assert.AreEqual(category2Name, entry.Categories[0], "Category has not been updated correctly.");
}
示例8: Create
/// <summary>
/// Creates the specified entry in the back end data store attaching
/// the specified category ids.
/// </summary>
/// <param name="entry">Entry.</param>
/// <param name="categoryIds">Category I ds.</param>
/// <returns></returns>
public override int Create(Entry entry, int[] categoryIds)
{
if(!FormatEntry(entry,true))
{
throw new BlogFailedPostException("Failed post exception");
}
entry.Id = DbProvider.Instance().InsertEntry(entry);
if(categoryIds != null)
{
DbProvider.Instance().SetEntryCategoryList(entry.Id, categoryIds);
}
if(entry.Id > -1 && Config.Settings.Tracking.UseTrackingServices)
{
entry.Url = Config.CurrentBlog.UrlFormats.EntryUrl(entry);
}
if(entry.Id > -1)
{
Config.CurrentBlog.LastUpdated = entry.DateCreated;
}
return entry.Id;
}
示例9: CreateDoesNotChangeDateCreatedAndDateModifiedIfAlreadySpecified
public void CreateDoesNotChangeDateCreatedAndDateModifiedIfAlreadySpecified()
{
//arrange
var blog = new Mock<Blog>();
DateTime dateCreated = DateTime.Now;
blog.Object.Id = 1;
blog.Setup(b => b.TimeZone.Now).Returns(dateCreated);
var entry = new Entry(PostType.BlogPost, blog.Object) {Id = 123, BlogId = 1, CommentingClosed = false};
var repository = new Mock<ObjectProvider>();
repository.Setup(r => r.GetEntry(It.IsAny<int>(), true, true)).Returns(entry);
var context = new Mock<ISubtextContext>();
context.SetupGet(c => c.Repository).Returns(repository.Object);
context.SetupGet(c => c.Blog).Returns(blog.Object);
context.SetupGet(c => c.HttpContext.Items).Returns(new Hashtable());
context.SetupGet(c => c.Cache).Returns(new TestCache());
var service = new CommentService(context.Object, null);
var comment = new FeedbackItem(FeedbackType.Comment)
{
EntryId = 123,
BlogId = 1,
Body = "test",
Title = "title",
DateCreated = dateCreated.AddDays(-2),
DateModified = dateCreated.AddDays(-1)
};
//act
service.Create(comment, true/*runFilters*/);
//assert
Assert.AreEqual(dateCreated.AddDays(-2), comment.DateCreated);
Assert.AreEqual(dateCreated.AddDays(-1), comment.DateModified);
}
示例10: Run
/// <summary>
/// Posts trackbacks and pingbacks for the specified entry.
/// </summary>
/// <param name="entry">The entry.</param>
public static void Run(Entry entry)
{
if(entry != null)
{
Notifier notify = new Notifier();
notify.FullyQualifiedUrl = Config.CurrentBlog.RootUrl.ToString();
notify.BlogName = Config.CurrentBlog.Title;
notify.Title = entry.Title;
notify.PostUrl = entry.FullyQualifiedUrl;
if(entry.HasDescription)
{
notify.Description = entry.Description;
}
else
{
notify.Description = entry.Title;
}
notify.Text = entry.Body;
//This could take a while, do it on another thread
ManagedThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(notify.Notify));
}
}
示例11: TrackBackTag
//Body of text to insert into a post with Trackback
public static string TrackBackTag(Entry entry)
{
if (entry == null)
{
throw new ArgumentNullException("entry", Resources.ArgumentNull_Generic);
}
return String.Format(CultureInfo.InvariantCulture, Resources.TrackbackTag, entry.FullyQualifiedUrl, entry.FullyQualifiedUrl, entry.Title, Config.CurrentBlog.RootUrl, entry.Id.ToString(CultureInfo.InvariantCulture));
}
示例12: EntryViewModel
public EntryViewModel(Entry entry, ISubtextContext context)
{
if (entry == null)
{
throw new ArgumentNullException("entry");
}
Entry = entry;
SubtextContext = context;
}
示例13: GetPingbackTag
//Text to insert into a file with pingback service location
public static string GetPingbackTag(BlogUrlHelper urlHelper, Entry entry)
{
VirtualPath blogUrl = urlHelper.BlogUrl();
Uri absoluteUrl = blogUrl.ToFullyQualifiedUrl(entry.Blog);
return string.Format(CultureInfo.InvariantCulture,
"<link rel=\"pingback\" href=\"{0}Services/Pingback/{1}.aspx\"></link>",
absoluteUrl.AbsoluteUri,
entry.Id);
}
示例14: EntryExtensionMethodsTest_ConvertToSearchEngineEntry_WithTags_ConvertsTagsToString
public void EntryExtensionMethodsTest_ConvertToSearchEngineEntry_WithTags_ConvertsTagsToString()
{
Entry post = new Entry(PostType.BlogPost)
{
Blog = new Blog(){ Title="MyTitle", BlogGroupId=1},
};
IList<String> tags = new List<string>() {"tag1","tag2"};
SearchEngineEntry searchEntry = post.ConvertToSearchEngineEntry(tags);
Assert.AreEqual("tag1,tag2", searchEntry.Tags);
}
示例15: EntryExtensionMethodsTest_ConvertToSearchEngineEntry_WithOutTags_ConvertsTagsToString
public void EntryExtensionMethodsTest_ConvertToSearchEngineEntry_WithOutTags_ConvertsTagsToString()
{
Entry post = new Entry(PostType.BlogPost)
{
Blog = new Blog() { Title = "MyTitle", BlogGroupId = 1 },
Body = "<a href=\"http://blah.com/subdir/tag1/\" rel=\"tag\">tag1</a><a href=\"http://blah.com/another-dir/tag2/\" rel=\"tag\">tag2</a>"
};
SearchEngineEntry searchEntry = post.ConvertToSearchEngineEntry();
Assert.AreEqual("tag1,tag2", searchEntry.Tags);
}