From fad18020a7a15f4afdf425d8f5f2b9467141f598 Mon Sep 17 00:00:00 2001 From: mo khan Date: Sun, 10 Jun 2007 19:26:57 -0600 Subject: import from svn --- BloggerToDasBlog.Console.sln | 20 ++++ build.bat | 3 + lib/newtelligence.DasBlog.Runtime.Proxies.dll | Bin 0 -> 32768 bytes lib/newtelligence.DasBlog.Runtime.dll | Bin 0 -> 237568 bytes lib/newtelligence.DasBlog.Util.dll | Bin 0 -> 135168 bytes projectName.build | 32 ++++++ src/app/BloggerToDasBlog.Console/BloggerComment.cs | 32 ++++++ .../BloggerCommentXmlElement.cs | 10 ++ src/app/BloggerToDasBlog.Console/BloggerEntry.cs | 55 ++++++++++ .../BloggerEntryXmlElement.cs | 12 ++ src/app/BloggerToDasBlog.Console/BloggerReader.cs | 122 +++++++++++++++++++++ .../BloggerToDasBlog.Console.csproj | 67 +++++++++++ src/app/BloggerToDasBlog.Console/DasBlogWriter.cs | 63 +++++++++++ .../BloggerToDasBlog.Console/IBloggerComment.cs | 11 ++ src/app/BloggerToDasBlog.Console/IBloggerEntry.cs | 18 +++ src/app/BloggerToDasBlog.Console/Program.cs | 19 ++++ .../Properties/AssemblyInfo.cs | 33 ++++++ .../bloggerBackupGenerator.template | 20 ++++ 18 files changed, 517 insertions(+) create mode 100644 BloggerToDasBlog.Console.sln create mode 100644 build.bat create mode 100644 lib/newtelligence.DasBlog.Runtime.Proxies.dll create mode 100644 lib/newtelligence.DasBlog.Runtime.dll create mode 100644 lib/newtelligence.DasBlog.Util.dll create mode 100644 projectName.build create mode 100644 src/app/BloggerToDasBlog.Console/BloggerComment.cs create mode 100644 src/app/BloggerToDasBlog.Console/BloggerCommentXmlElement.cs create mode 100644 src/app/BloggerToDasBlog.Console/BloggerEntry.cs create mode 100644 src/app/BloggerToDasBlog.Console/BloggerEntryXmlElement.cs create mode 100644 src/app/BloggerToDasBlog.Console/BloggerReader.cs create mode 100644 src/app/BloggerToDasBlog.Console/BloggerToDasBlog.Console.csproj create mode 100644 src/app/BloggerToDasBlog.Console/DasBlogWriter.cs create mode 100644 src/app/BloggerToDasBlog.Console/IBloggerComment.cs create mode 100644 src/app/BloggerToDasBlog.Console/IBloggerEntry.cs create mode 100644 src/app/BloggerToDasBlog.Console/Program.cs create mode 100644 src/app/BloggerToDasBlog.Console/Properties/AssemblyInfo.cs create mode 100644 src/app/BloggerToDasBlog.Console/bloggerBackupGenerator.template diff --git a/BloggerToDasBlog.Console.sln b/BloggerToDasBlog.Console.sln new file mode 100644 index 0000000..98f91e0 --- /dev/null +++ b/BloggerToDasBlog.Console.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BloggerToDasBlog.Console", "src\app\BloggerToDasBlog.Console\BloggerToDasBlog.Console.csproj", "{271369C6-0CA5-47CC-B037-13C1B4462324}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {271369C6-0CA5-47CC-B037-13C1B4462324}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {271369C6-0CA5-47CC-B037-13C1B4462324}.Debug|Any CPU.Build.0 = Debug|Any CPU + {271369C6-0CA5-47CC-B037-13C1B4462324}.Release|Any CPU.ActiveCfg = Release|Any CPU + {271369C6-0CA5-47CC-B037-13C1B4462324}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..5737616 --- /dev/null +++ b/build.bat @@ -0,0 +1,3 @@ +@echo off +cls +Tools\nant-0.85\bin\NAnt.exe -buildfile:projectName.build %* \ No newline at end of file diff --git a/lib/newtelligence.DasBlog.Runtime.Proxies.dll b/lib/newtelligence.DasBlog.Runtime.Proxies.dll new file mode 100644 index 0000000..9bbe733 Binary files /dev/null and b/lib/newtelligence.DasBlog.Runtime.Proxies.dll differ diff --git a/lib/newtelligence.DasBlog.Runtime.dll b/lib/newtelligence.DasBlog.Runtime.dll new file mode 100644 index 0000000..1d044ca Binary files /dev/null and b/lib/newtelligence.DasBlog.Runtime.dll differ diff --git a/lib/newtelligence.DasBlog.Util.dll b/lib/newtelligence.DasBlog.Util.dll new file mode 100644 index 0000000..d5f3e7c Binary files /dev/null and b/lib/newtelligence.DasBlog.Util.dll differ diff --git a/projectName.build b/projectName.build new file mode 100644 index 0000000..0c8a847 --- /dev/null +++ b/projectName.build @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/app/BloggerToDasBlog.Console/BloggerComment.cs b/src/app/BloggerToDasBlog.Console/BloggerComment.cs new file mode 100644 index 0000000..213d537 --- /dev/null +++ b/src/app/BloggerToDasBlog.Console/BloggerComment.cs @@ -0,0 +1,32 @@ +using System; + +namespace BloggerToDasBlog.Console { + public class BloggerComment : IBloggerComment { + public BloggerComment( ) {} + + public BloggerComment( string author, DateTime date, string body ) { + _author = author; + _date = date; + _body = body; + } + + public string Author { + get { return _author; } + set { _author = value; } + } + + public DateTime Date { + get { return _date; } + set { _date = value; } + } + + public string Body { + get { return _body; } + set { _body = value; } + } + + private String _author; + private DateTime _date; + private String _body; + } +} \ No newline at end of file diff --git a/src/app/BloggerToDasBlog.Console/BloggerCommentXmlElement.cs b/src/app/BloggerToDasBlog.Console/BloggerCommentXmlElement.cs new file mode 100644 index 0000000..26a7d43 --- /dev/null +++ b/src/app/BloggerToDasBlog.Console/BloggerCommentXmlElement.cs @@ -0,0 +1,10 @@ +using System; + +namespace BloggerToDasBlog.Console { + public class BloggerCommentXmlElement { + public const String Root = "bi_comments"; + public const String Author = "bi_commentauthor"; + public const String Date = "bi_commentdate"; + public const String Body = "bi_commentbody"; + } +} \ No newline at end of file diff --git a/src/app/BloggerToDasBlog.Console/BloggerEntry.cs b/src/app/BloggerToDasBlog.Console/BloggerEntry.cs new file mode 100644 index 0000000..bb710c5 --- /dev/null +++ b/src/app/BloggerToDasBlog.Console/BloggerEntry.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; + +namespace BloggerToDasBlog.Console { + public class BloggerEntry : IBloggerEntry { + public BloggerEntry( ) { + _comments = new List< IBloggerComment >( ); + } + + public BloggerEntry( Uri url, string title, string body, string author, DateTime date, + IList< IBloggerComment > comments ) { + _url = url; + _title = title; + _body = body; + _author = author; + _date = date; + _comments = comments; + } + + public Uri Url { + get { return _url; } + } + + public string Title { + get { return _title; } + set { _title = value; } + } + + public string Body { + get { return _body; } + set { _body = value; } + } + + public string Author { + get { return _author; } + set { _author = value; } + } + + public DateTime Date { + get { return _date; } + set { _date = value; } + } + + public IList< IBloggerComment > Comments { + get { return _comments; } + } + + private Uri _url; + private String _title; + private String _body; + private String _author; + private DateTime _date; + private IList< IBloggerComment > _comments; + } +} \ No newline at end of file diff --git a/src/app/BloggerToDasBlog.Console/BloggerEntryXmlElement.cs b/src/app/BloggerToDasBlog.Console/BloggerEntryXmlElement.cs new file mode 100644 index 0000000..d0b01ee --- /dev/null +++ b/src/app/BloggerToDasBlog.Console/BloggerEntryXmlElement.cs @@ -0,0 +1,12 @@ +using System; + +namespace BloggerToDasBlog.Console { + public class BloggerEntryXmlElement { + public const String Root = "bi_entry"; + public const String Url = "bi_url"; + public const String Title = "bi_title"; + public const String Body = "bi_body"; + public const String Author = "bi_author"; + public const String Date = "bi_date"; + } +} \ No newline at end of file diff --git a/src/app/BloggerToDasBlog.Console/BloggerReader.cs b/src/app/BloggerToDasBlog.Console/BloggerReader.cs new file mode 100644 index 0000000..3af31c6 --- /dev/null +++ b/src/app/BloggerToDasBlog.Console/BloggerReader.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Xml; + +namespace BloggerToDasBlog.Console { + public sealed class BloggerReader { + #region Constructors + + private BloggerReader( ) {} + + #endregion + + #region Public Methods + + public static IList< IBloggerEntry > Read( Uri filePath ) { + XmlDocument document = new XmlDocument( ); + document.LoadXml( File.ReadAllText( filePath.LocalPath ) ); + + XmlNodeReader reader = new XmlNodeReader( document ); + reader.MoveToContent( ); + + IList< IBloggerEntry > results = new List< IBloggerEntry >( ); + if ( reader.Read( ) ) { + if ( reader.NodeType == XmlNodeType.Element ) { + if ( String.Compare( reader.LocalName, BloggerEntryXmlElement.Root, true, CultureInfo.InvariantCulture ) == 0 ) { + String entryNode; + while ( !String.IsNullOrEmpty( entryNode = reader.ReadOuterXml( ) ) ) { + IBloggerEntry entry = ParseSingle( entryNode ); + if ( null != entry ) { + results.Add( entry ); + } + } + return results; + } + } + } + return null; + } + + #endregion + + #region Private Methods + + private static IBloggerEntry ParseSingle( String resultXmlRecord ) { + if ( String.IsNullOrEmpty( resultXmlRecord ) ) { + return null; + } + XmlDocument document = new XmlDocument( ); + document.LoadXml( resultXmlRecord ); + XmlNodeReader reader = new XmlNodeReader( document ); + + IBloggerEntry entry = new BloggerEntry( ); + reader.MoveToContent( ); + try { + while ( reader.Read( ) ) { + if ( reader.NodeType == XmlNodeType.Element ) { + switch ( reader.LocalName.ToLower( CultureInfo.InvariantCulture ) ) { + case BloggerEntryXmlElement.Title: + entry.Title = reader.ReadString( ); + break; + case BloggerEntryXmlElement.Body: + entry.Body = reader.ReadString( ); + break; + case BloggerEntryXmlElement.Author: + entry.Author = reader.ReadString( ); + break; + case BloggerEntryXmlElement.Date: + DateTime dateTime; + entry.Date = DateTime.TryParse( reader.ReadString( ), out dateTime ) ? dateTime : DateTime.MinValue; + break; + case BloggerCommentXmlElement.Root: + String commentNode = reader.ReadOuterXml( ); + if ( !String.IsNullOrEmpty( commentNode ) ) { + entry.Comments.Add( ParseComment( commentNode ) ); + } + break; + } + } + } + return entry; + } + catch ( FormatException ) { + return null; + } + } + + private static IBloggerComment ParseComment( string xml ) { + if ( String.IsNullOrEmpty( xml ) ) { + return null; + } + + IBloggerComment comment = new BloggerComment( ); + XmlDocument document = new XmlDocument( ); + document.LoadXml( xml ); + XmlNodeReader reader = new XmlNodeReader( document ); + reader.MoveToContent( ); + + while ( reader.Read( ) ) { + if ( reader.NodeType == XmlNodeType.Element ) { + switch ( reader.LocalName ) { + case BloggerCommentXmlElement.Author: + comment.Author = reader.ReadString( ); + break; + case BloggerCommentXmlElement.Date: + DateTime dateTime; + comment.Date = DateTime.TryParse( reader.ReadString( ), out dateTime ) ? dateTime : DateTime.MinValue; + break; + + case BloggerCommentXmlElement.Body: + comment.Body = reader.ReadString( ); + break; + } + } + } + return comment; + } + + #endregion + } +} \ No newline at end of file diff --git a/src/app/BloggerToDasBlog.Console/BloggerToDasBlog.Console.csproj b/src/app/BloggerToDasBlog.Console/BloggerToDasBlog.Console.csproj new file mode 100644 index 0000000..8d3a738 --- /dev/null +++ b/src/app/BloggerToDasBlog.Console/BloggerToDasBlog.Console.csproj @@ -0,0 +1,67 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {271369C6-0CA5-47CC-B037-13C1B4462324} + Exe + Properties + BloggerToDasBlog.Console + BloggerToDasBlog.Console + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\lib\newtelligence.DasBlog.Runtime.dll + + + + + + + + + + + + + + + + + + + + Always + + + + + + + + \ No newline at end of file diff --git a/src/app/BloggerToDasBlog.Console/DasBlogWriter.cs b/src/app/BloggerToDasBlog.Console/DasBlogWriter.cs new file mode 100644 index 0000000..51435cc --- /dev/null +++ b/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, "
" ); + 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 diff --git a/src/app/BloggerToDasBlog.Console/IBloggerComment.cs b/src/app/BloggerToDasBlog.Console/IBloggerComment.cs new file mode 100644 index 0000000..8a7e5b4 --- /dev/null +++ b/src/app/BloggerToDasBlog.Console/IBloggerComment.cs @@ -0,0 +1,11 @@ +using System; + +namespace BloggerToDasBlog.Console { + public interface IBloggerComment { + string Author { get; set; } + + DateTime Date { get; set; } + + string Body { get; set; } + } +} \ No newline at end of file diff --git a/src/app/BloggerToDasBlog.Console/IBloggerEntry.cs b/src/app/BloggerToDasBlog.Console/IBloggerEntry.cs new file mode 100644 index 0000000..1b06a6a --- /dev/null +++ b/src/app/BloggerToDasBlog.Console/IBloggerEntry.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace BloggerToDasBlog.Console { + public interface IBloggerEntry { + Uri Url { get; } + + string Title { get; set; } + + string Body { get; set; } + + string Author { get; set; } + + DateTime Date { get; set; } + + IList< IBloggerComment > Comments { get; } + } +} \ No newline at end of file diff --git a/src/app/BloggerToDasBlog.Console/Program.cs b/src/app/BloggerToDasBlog.Console/Program.cs new file mode 100644 index 0000000..21dcc68 --- /dev/null +++ b/src/app/BloggerToDasBlog.Console/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.IO; + +namespace BloggerToDasBlog.Console { + internal class Program { + private static void Main( ) { + IList< IBloggerEntry > bloggerEntries = + BloggerReader.Read( new Uri( Path.Combine( Environment.CurrentDirectory, "mokhan.blogspot.com.xml" ) ) ); + + foreach ( IBloggerEntry bloggerEntry in bloggerEntries ) { + new DasBlogWriter( ).Write( bloggerEntry ); + } + System.Console.WriteLine( bloggerEntries ); + System.Console.WriteLine( bloggerEntries.Count + " Entries have been created!" ); + System.Console.ReadLine( ); + } + } +} \ No newline at end of file diff --git a/src/app/BloggerToDasBlog.Console/Properties/AssemblyInfo.cs b/src/app/BloggerToDasBlog.Console/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a96538f --- /dev/null +++ b/src/app/BloggerToDasBlog.Console/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System; +using System.Reflection; +using System.Runtime.InteropServices; +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly : AssemblyTitle( "BloggerToDasBlog.Console" )] +[assembly : AssemblyDescription( "" )] +[assembly : AssemblyConfiguration( "" )] +[assembly : AssemblyCompany( "" )] +[assembly : AssemblyProduct( "BloggerToDasBlog.Console" )] +[assembly : AssemblyCopyright( "Copyright © 2007" )] +[assembly : AssemblyTrademark( "" )] +[assembly : AssemblyCulture( "" )] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly : ComVisible( false )] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly : Guid( "0d3f6143-1978-43f8-8340-e3eff891bb32" )] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly : AssemblyVersion( "1.0.0.0" )] +[assembly : AssemblyFileVersion( "1.0.0.0" )] +[assembly : CLSCompliant( true )] \ No newline at end of file diff --git a/src/app/BloggerToDasBlog.Console/bloggerBackupGenerator.template b/src/app/BloggerToDasBlog.Console/bloggerBackupGenerator.template new file mode 100644 index 0000000..75ddffa --- /dev/null +++ b/src/app/BloggerToDasBlog.Console/bloggerBackupGenerator.template @@ -0,0 +1,20 @@ + + + + ]]> + ]]> + ]]> + ]]> + ]]> + + + + ]]> + ]]> + ]]> + + + + + + \ No newline at end of file -- cgit v1.2.3