diff --git a/NOCQ.userprefs b/NOCQ.userprefs index 8a063db..32bfcce 100644 --- a/NOCQ.userprefs +++ b/NOCQ.userprefs @@ -1,6 +1,27 @@  - + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/NOCQ/Extensability/Catalog.cs b/src/NOCQ/Extensability/Catalog.cs index f58656e..dbbcecb 100644 --- a/src/NOCQ/Extensability/Catalog.cs +++ b/src/NOCQ/Extensability/Catalog.cs @@ -12,7 +12,6 @@ namespace NOCQ public Catalog() { Container.ComposeParts(this); - } } } diff --git a/src/NOCQ/NOCQ.csproj b/src/NOCQ/NOCQ.csproj index ca3a247..e7244f6 100644 --- a/src/NOCQ/NOCQ.csproj +++ b/src/NOCQ/NOCQ.csproj @@ -48,6 +48,9 @@ ..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll + + ..\..\packages\AE.Net.Mail.1.7.9.1\lib\net45\AE.Net.Mail.dll + ..\..\packages\csredis.1.4.7.1\lib\net40\csredis.dll @@ -55,9 +58,13 @@ + + + + @@ -67,5 +74,7 @@ + + - \ No newline at end of file + diff --git a/src/NOCQ/Plugins/Email/EmailSettings.cs b/src/NOCQ/Plugins/Email/EmailSettings.cs new file mode 100644 index 0000000..bdfdb0e --- /dev/null +++ b/src/NOCQ/Plugins/Email/EmailSettings.cs @@ -0,0 +1,17 @@ +using System; + +namespace NOCQ.Plugins.Email +{ + public class EmailSettings + { + public string Username {get;set;} + public string Password {get;set;} + public string Host {get;set;} + public int Port {get;set;} + public string Folder {get;set;} + public bool IsSsl {get;set;} + public int Frequency { get; set; } + public IEnumerable ParseRules {get;set;} + } +} + diff --git a/src/NOCQ/Plugins/Email/ImapInput.cs b/src/NOCQ/Plugins/Email/ImapInput.cs new file mode 100644 index 0000000..67159e2 --- /dev/null +++ b/src/NOCQ/Plugins/Email/ImapInput.cs @@ -0,0 +1,74 @@ +using System; +using System.Timers; +using AE.Net.Mail; + +namespace NOCQ.Plugins.Email +{ + public class ImapInput + { + private string loginName { get; set; } + private string password { get; set; } + private string server { get; set; } + private string folderPath { get; set; } + private Timer timer { get; set; } + private int port { get; set; } + private bool ssl { get; set; } + private DateTime lastRun { get; set; } + private IEnumerable parseRules{ get; set; } + + public ImapInput (dynamic settings) + { + var sets = settings as EmailSettings; + + if (sets.Username == null + || sets.Password == null + || sets.Host == null + || sets.Folder == null + || sets.Frequency == null + || sets.Port == null + || sets.IsSsl == null) + throw new ArgumentException ("You are missing a required setting."); + + parseRules = sets.ParseRules.Where (x => x.Enabled); + + loginName = settings.Login; + password = settings.Password; + server = settings.Server; + folderPath = settings.FolderPath; + + timer = new Timer (settings.Frequency); + + timer.Elapsed += Execute (); + } + + + public void Execute() + { + using(var imap = new ImapClient(server, loginName, password, ImapClient.AuthMethods.Login, port, ssl)) { + var msgs = imap.SearchMessages( + SearchCondition.Undeleted().And( + SearchCondition.SentSince(new DateTime(2000, 1, 1)) + )); + + foreach (var msg in msgs) + { + var realMsg = msg.Value; + + var from = realMsg.From; + var body = realMsg.Body; + + } + } + } + + public void Run() + { + timer.Start (); + } + + public void Stop() + { + timer.Stop (); + } + } +} \ No newline at end of file diff --git a/src/NOCQ/Plugins/Email/ParseRule.cs b/src/NOCQ/Plugins/Email/ParseRule.cs new file mode 100644 index 0000000..a67b10f --- /dev/null +++ b/src/NOCQ/Plugins/Email/ParseRule.cs @@ -0,0 +1,18 @@ +using System; + +namespace NOCQ.Plugins.Email +{ + public class ParseRule + { + public string Name { get; set; } + public bool Enabled { get; set; } + public string From {get;set;} + public string Source {get;set;} + public string System {get;set;} + public string Service {get;set;} + public string Data {get;set;} + public string Runbook { get; set;} + public string Severity {get;set;} + } +} + diff --git a/src/NOCQ/packages.config b/src/NOCQ/packages.config index d2074e6..3fb6750 100644 --- a/src/NOCQ/packages.config +++ b/src/NOCQ/packages.config @@ -1,5 +1,6 @@  + - \ No newline at end of file +