diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c8dfa3c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,49 @@ +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain + +*.jpg binary +*.png binary +*.gif binary + +*.cs text=auto diff=csharp +*.vb text=auto +*.c text=auto +*.cpp text=auto +*.cxx text=auto +*.h text=auto +*.hxx text=auto +*.py text=auto +*.rb text=auto +*.java text=auto +*.html text=auto +*.htm text=auto +*.css text=auto +*.scss text=auto +*.sass text=auto +*.less text=auto +*.js text=auto +*.lisp text=auto +*.clj text=auto +*.sql text=auto +*.php text=auto +*.lua text=auto +*.m text=auto +*.asm text=auto +*.erl text=auto +*.fs text=auto +*.fsx text=auto +*.hs text=auto + +*.csproj text=auto merge=union +*.vbproj text=auto merge=union +*.fsproj text=auto merge=union +*.dbproj text=auto merge=union +*.sln text=auto eol=crlf merge=union \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9ac0ec3..a429ea4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,15 @@ -# Build Folders (you can keep bin if you'd like, to store dlls and pdbs) -bin -obj - -# mstest test results -TestResults \ No newline at end of file +[Oo]bj/ +[Bb]in/ +*.user +target/ +*ReSharper* +*resharper* +*.suo +*.cache +Thumbs.db +*.bak +*.swp +*.docstates +*.dotCover +packages/ +build/ diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config new file mode 100644 index 0000000..67f8ea0 --- /dev/null +++ b/.nuget/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets new file mode 100644 index 0000000..c15311e --- /dev/null +++ b/.nuget/NuGet.targets @@ -0,0 +1,139 @@ + + + + $(MSBuildProjectDirectory)\..\ + + + false + + + false + + + false + + + + + + + + + + $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) + $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) + $([System.IO.Path]::Combine($(SolutionDir), "packages")) + + + + + $(SolutionDir).nuget + packages.config + $(SolutionDir)packages + + + + + $(NuGetToolsPath)\nuget.exe + @(PackageSource) + + "$(NuGetExePath)" + mono --runtime=v4.0.30319 $(NuGetExePath) + + $(TargetDir.Trim('\\')) + + + $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" -o "$(PackagesDir)" + $(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols + + + + RestorePackages; + $(BuildDependsOn); + + + + + $(BuildDependsOn); + BuildPackage; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.nuget/nuget.exe b/.nuget/nuget.exe new file mode 100644 index 0000000..e313ff9 Binary files /dev/null and b/.nuget/nuget.exe differ diff --git a/RssToEmail.sln b/RssToEmail.sln new file mode 100644 index 0000000..d0cb225 --- /dev/null +++ b/RssToEmail.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RssToEmail", "RssToEmail\RssToEmail.csproj", "{9E3553CC-2C00-4C22-BC6A-5C11FB9B0222}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F3147DA2-AA3E-48CB-98EC-7DBB8D76EEB7}" + ProjectSection(SolutionItems) = preProject + .nuget\NuGet.Config = .nuget\NuGet.Config + .nuget\nuget.exe = .nuget\nuget.exe + .nuget\NuGet.targets = .nuget\NuGet.targets + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9E3553CC-2C00-4C22-BC6A-5C11FB9B0222}.Debug|x86.ActiveCfg = Debug|x86 + {9E3553CC-2C00-4C22-BC6A-5C11FB9B0222}.Debug|x86.Build.0 = Debug|x86 + {9E3553CC-2C00-4C22-BC6A-5C11FB9B0222}.Release|x86.ActiveCfg = Release|x86 + {9E3553CC-2C00-4C22-BC6A-5C11FB9B0222}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/RssToEmail/App.config b/RssToEmail/App.config new file mode 100644 index 0000000..af3d50b --- /dev/null +++ b/RssToEmail/App.config @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RssToEmail/Models/Feed.cs b/RssToEmail/Models/Feed.cs new file mode 100644 index 0000000..f5640c4 --- /dev/null +++ b/RssToEmail/Models/Feed.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace RssToEmail.Models +{ + public class Feed + { + public string Id { get; set; } + public string Url { get; set; } + public IList SentItems { get; set; } + + public Feed() + { + SentItems = new List(); + } + } +} diff --git a/RssToEmail/Program.cs b/RssToEmail/Program.cs new file mode 100644 index 0000000..d53b2c3 --- /dev/null +++ b/RssToEmail/Program.cs @@ -0,0 +1,71 @@ +using System; +using System.Configuration; +using System.Linq; +using System.Net.Mail; +using QDFeedParser; +using Raven.Client.Embedded; +using RssToEmail.Models; + +namespace RssToEmail +{ + class Program + { + static void Main(string[] args) + { + var urls = ConfigurationManager.AppSettings["urls"].Split(new [] { ';',',' }, StringSplitOptions.RemoveEmptyEntries); + var to = new MailAddress(ConfigurationManager.AppSettings["to"]); + bool sendAllForNewFeeds; + bool.TryParse(ConfigurationManager.AppSettings["SendAllForNewFeeds"] ?? "false", out sendAllForNewFeeds); + + var feeds = new HttpFeedFactory(); + var documentStore = new EmbeddableDocumentStore + { + ConnectionStringName = "RavenDB" + }.Initialize(); + + foreach (var url in urls) + { + var feed = feeds.CreateFeed(new Uri(url)); + var from = new MailAddress(ConfigurationManager.AppSettings["from"], feed.Title); + + var session = documentStore.OpenSession(); + var savedFeed = session.Query().SingleOrDefault(x => x.Url == url) ?? + new Feed { + Url = url + }; + var isNew = !savedFeed.SentItems.Any(); + foreach (var item in feed.Items) + { + // Ignore previously processed items + if (savedFeed.SentItems.Contains(item.Id)) + continue; + + // Only send an email if the url is not new or if the user configures that new urls should send all current items + if (!isNew || sendAllForNewFeeds) + { + try + { + var message = new MailMessage(from, to) { + Subject = "[New Post] " + item.Title, + Body = item.Content + string.Format("

View the original article: {0}

", item.Link), + IsBodyHtml = true + }; + + var smtp = new SmtpClient(); + smtp.Send(message); + } + catch (Exception ex) + { + // Ignore this for now... we'll just try again next time the app runs + continue; + } + } + + savedFeed.SentItems.Add(item.Id); + } + session.Store(savedFeed); + session.SaveChanges(); + } + } + } +} diff --git a/RssToEmail/Properties/AssemblyInfo.cs b/RssToEmail/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3cec95e --- /dev/null +++ b/RssToEmail/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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("RssToEmail")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RssToEmail")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[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("8ae8306a-a635-45f0-a39e-faa5afcfd9bc")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RssToEmail/RssToEmail.csproj b/RssToEmail/RssToEmail.csproj new file mode 100644 index 0000000..699d3c4 --- /dev/null +++ b/RssToEmail/RssToEmail.csproj @@ -0,0 +1,119 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {9E3553CC-2C00-4C22-BC6A-5C11FB9B0222} + Exe + Properties + RssToEmail + RssToEmail + v4.0 + + + 512 + ..\ + true + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\RavenDB.Database.1.2.2060-Unstable\lib\net40\BouncyCastle.Crypto.dll + + + ..\packages\RavenDB.Database.1.2.2060-Unstable\lib\net40\Esent.Interop.dll + + + ..\packages\RavenDB.Database.1.2.2060-Unstable\lib\net40\ICSharpCode.NRefactory.dll + + + ..\packages\RavenDB.Database.1.2.2060-Unstable\lib\net40\Lucene.Net.dll + + + ..\packages\RavenDB.Database.1.2.2060-Unstable\lib\net40\Lucene.Net.Contrib.Spatial.dll + + + ..\packages\RavenDB.Database.1.2.2060-Unstable\lib\net40\Lucene.Net.Contrib.SpellChecker.dll + + + ..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll + + + ..\packages\qdfeed.1.0.2\lib\net35\QDFeedParser.dll + + + ..\packages\RavenDB.Client.1.2.2060-Unstable\lib\net40\Raven.Abstractions.dll + + + ..\packages\RavenDB.Database.1.2.2060-Unstable\lib\net40\Raven.Backup.exe + + + ..\packages\RavenDB.Embedded.1.2.2060-Unstable\lib\net40\Raven.Client.Embedded.dll + + + ..\packages\RavenDB.Client.1.2.2060-Unstable\lib\net40\Raven.Client.Lightweight.dll + + + ..\packages\RavenDB.Database.1.2.2060-Unstable\lib\net40\Raven.Database.dll + + + ..\packages\RavenDB.Database.1.2.2060-Unstable\lib\net40\Raven.Smuggler.exe + + + ..\packages\RavenDB.Database.1.2.2060-Unstable\lib\net40\Spatial4n.Core.dll + + + + + + + + + + + + + + + + + + + + + + + Raven.Studio.xap + PreserveNewest + + + + + + \ No newline at end of file diff --git a/RssToEmail/packages.config b/RssToEmail/packages.config new file mode 100644 index 0000000..310b017 --- /dev/null +++ b/RssToEmail/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file