This commit is contained in:
Tommy Parnell
2014-05-07 10:34:39 -07:00
7 changed files with 143 additions and 4 deletions

View File

@@ -1,6 +1,27 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench />
<MonoDevelop.Ide.Workbench ActiveDocument="src/NOCQ/Extensability/Catalog.cs">
<Files>
<File FileName="src/NOCQ/Plugins/Email/EmailSettings.cs" Line="13" Column="37" />
<File FileName="src/NOCQ/Plugins/Email/ImapInput.cs" Line="60" Column="4" />
<File FileName="src/NOCQ/Extensability/Catalog.cs" Line="8" Column="6" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State expanded="True">
<Node name="NOCQ" expanded="True">
<Node name="Extensability" expanded="True">
<Node name="Catalog.cs" selected="True" />
</Node>
<Node name="Plugins" expanded="True">
<Node name="Email" expanded="True" />
</Node>
</Node>
<Node name="NOCQ.Application" expanded="True" />
</State>
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>

View File

@@ -12,7 +12,6 @@ namespace NOCQ
public Catalog()
{
Container.ComposeParts(this);
}
}
}

View File

@@ -48,6 +48,9 @@
<Reference Include="System.Composition.TypedParts">
<HintPath>..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll</HintPath>
</Reference>
<Reference Include="AE.Net.Mail">
<HintPath>..\..\packages\AE.Net.Mail.1.7.9.1\lib\net45\AE.Net.Mail.dll</HintPath>
</Reference>
<Reference Include="csredis">
<HintPath>..\..\packages\csredis.1.4.7.1\lib\net40\csredis.dll</HintPath>
</Reference>
@@ -55,9 +58,13 @@
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Extensability\Catalog.cs" />
<Compile Include="Imports\IDataImport.cs" />
<Compile Include="Plugins\Email\ImapInput.cs" />
<Compile Include="Plugins\Email\EmailSettings.cs" />
<Compile Include="Imports\IDataImportHook.cs" />
<Compile Include="Imports\DataImports.cs" />
<Compile Include="DB\RedisDataase.cs" />
<Compile Include="Plugins\Email\ParseRule.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@@ -67,5 +74,7 @@
<Folder Include="Extensability\" />
<Folder Include="Imports\" />
<Folder Include="DB\" />
<Folder Include="Plugins\" />
<Folder Include="Plugins\Email\" />
</ItemGroup>
</Project>
</Project>

View File

@@ -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<ParseRule> ParseRules {get;set;}
}
}

View File

@@ -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<ParseRule> 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 ();
}
}
}

View File

@@ -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;}
}
}

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AE.Net.Mail" version="1.7.9.1" targetFramework="net45" />
<package id="csredis" version="1.4.7.1" targetFramework="net45" />
<package id="Microsoft.Composition" version="1.0.27" targetFramework="net45" />
</packages>
</packages>