diff options
| author | mo.khan <mo.khan@a0a4a051-f042-0410-9e78-9fae330bdb64> | 2008-01-05 07:16:52 +0000 |
|---|---|---|
| committer | mo.khan <mo.khan@a0a4a051-f042-0410-9e78-9fae330bdb64> | 2008-01-05 07:16:52 +0000 |
| commit | 8c137f229c36a777ead5cacb3350cb8692646292 (patch) | |
| tree | 92876c5da0ffd17767e38f94a44415ac27a3c73e /BloggerToDasBlog/trunk/src/app/BloggerToDasBlog.Console/DasBlogWriter.cs | |
| parent | cbdf42a6427eef7849d1ab7731f9185b410431d3 (diff) | |
git-svn-id: http://mokhan.googlecode.com/svn/trunk@9 a0a4a051-f042-0410-9e78-9fae330bdb64
Diffstat (limited to 'BloggerToDasBlog/trunk/src/app/BloggerToDasBlog.Console/DasBlogWriter.cs')
| -rw-r--r-- | BloggerToDasBlog/trunk/src/app/BloggerToDasBlog.Console/DasBlogWriter.cs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/BloggerToDasBlog/trunk/src/app/BloggerToDasBlog.Console/DasBlogWriter.cs b/BloggerToDasBlog/trunk/src/app/BloggerToDasBlog.Console/DasBlogWriter.cs new file mode 100644 index 0000000..51435cc --- /dev/null +++ b/BloggerToDasBlog/trunk/src/app/BloggerToDasBlog.Console/DasBlogWriter.cs @@ -0,0 +1,63 @@ +using System;
+using newtelligence.DasBlog.Runtime;
+
+namespace BloggerToDasBlog.Console {
+ public class DasBlogWriter {
+ #region Constructors
+
+ public DasBlogWriter( )
+ : this( BlogDataServiceFactory.GetService( AppDomain.CurrentDomain.BaseDirectory, null ), "Journal" ) {}
+
+ public DasBlogWriter( IBlogDataService service, String category ) {
+ _service = service;
+ _category = category;
+ }
+
+ #endregion
+
+ #region Public Methods
+
+ public void Write( IBloggerEntry bloggerEntry ) {
+ Entry entry = new Entry( );
+ entry.CreatedLocalTime = bloggerEntry.Date;
+ entry.ModifiedLocalTime = bloggerEntry.Date;
+ entry.Title =
+ ( bloggerEntry.Title.Length > 0
+ ? bloggerEntry.Title
+ : bloggerEntry.Body.Substring( 0, Math.Min( 20, bloggerEntry.Body.Length ) ) );
+ entry.Content = bloggerEntry.Body.Replace( Environment.NewLine, "<br />" );
+ entry.EntryId = Guid.NewGuid( ).ToString( );
+ entry.Categories = _category;
+ entry.Author = bloggerEntry.Author;
+ _service.SaveEntry( entry );
+ if ( bloggerEntry.Comments.Count > 0 ) {
+ foreach ( IBloggerComment bloggerComment in bloggerEntry.Comments ) {
+ WriteComments( bloggerComment, entry.EntryId );
+ }
+ }
+ }
+
+ #endregion
+
+ #region Private Methods
+
+ private void WriteComments( IBloggerComment bloggerComment, String targetEntryId ) {
+ Comment comment = new Comment( );
+ comment.CreatedLocalTime = bloggerComment.Date;
+ comment.ModifiedLocalTime = bloggerComment.Date;
+ comment.TargetEntryId = targetEntryId;
+ comment.Author = bloggerComment.Author;
+ comment.Content = bloggerComment.Body;
+ _service.AddComment( comment );
+ }
+
+ #endregion
+
+ #region Private Fields
+
+ private readonly IBlogDataService _service;
+ private readonly string _category;
+
+ #endregion
+ }
+}
\ No newline at end of file |
