More complete email parsing
This commit is contained in:
@@ -58,6 +58,7 @@
|
|||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="Newtonsoft.Json">
|
<Reference Include="Newtonsoft.Json">
|
||||||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
<Package>monodevelop</Package>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -71,7 +72,6 @@
|
|||||||
<Compile Include="Plugins\Email\ImapInput.cs" />
|
<Compile Include="Plugins\Email\ImapInput.cs" />
|
||||||
<Compile Include="Plugins\Email\IEmailSetting.cs" />
|
<Compile Include="Plugins\Email\IEmailSetting.cs" />
|
||||||
<Compile Include="Model\Alert.cs" />
|
<Compile Include="Model\Alert.cs" />
|
||||||
<Compile Include="Plugins\Email\IParseRule.cs" />
|
|
||||||
<Compile Include="Model\IAlert.cs" />
|
<Compile Include="Model\IAlert.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace NOCQ.Plugins.Email
|
|||||||
public string Folder {get;set;}
|
public string Folder {get;set;}
|
||||||
public bool IsSsl {get;set;}
|
public bool IsSsl {get;set;}
|
||||||
public int Frequency { get; set; }
|
public int Frequency { get; set; }
|
||||||
public IEnumerable<IParseRule> ParseRules {get;set;}
|
public IEnumerable<ParseRule> ParseRules {get;set;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace NOCQ.Plugins.Email
|
|||||||
string Folder {get;set;}
|
string Folder {get;set;}
|
||||||
bool IsSsl {get;set;}
|
bool IsSsl {get;set;}
|
||||||
int Frequency { get; set; }
|
int Frequency { get; set; }
|
||||||
IEnumerable<IParseRule> ParseRules {get;set;}
|
IEnumerable<ParseRule> ParseRules {get;set;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace NOCQ.Plugins.Email
|
|
||||||
{
|
|
||||||
public interface IParseRule
|
|
||||||
{
|
|
||||||
string Name { get; set; }
|
|
||||||
bool Enabled { get; set; }
|
|
||||||
string From {get;set;}
|
|
||||||
string Source {get;set;}
|
|
||||||
string System {get;set;}
|
|
||||||
string Service {get;set;}
|
|
||||||
string Data {get;set;}
|
|
||||||
string Runbook { get; set;}
|
|
||||||
string Severity {get;set;}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ namespace NOCQ.Plugins.Email
|
|||||||
int port { get; set; }
|
int port { get; set; }
|
||||||
bool ssl { get; set; }
|
bool ssl { get; set; }
|
||||||
DateTime lastRun { get; set; }
|
DateTime lastRun { get; set; }
|
||||||
List<IParseRule> parseRules{ get; set; }
|
IEnumerable<ParseRule> parseRules{ get; set; }
|
||||||
|
|
||||||
public ImapInput (dynamic settings)
|
public ImapInput (dynamic settings)
|
||||||
{
|
{
|
||||||
@@ -43,13 +43,15 @@ namespace NOCQ.Plugins.Email
|
|||||||
timer.Elapsed += Execute;
|
timer.Elapsed += Execute;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(object sender, ElapsedEventArgs args)
|
private List<Alert> getAlerts()
|
||||||
{
|
{
|
||||||
|
var alerts = new List<Alert> ();
|
||||||
|
|
||||||
using(var imap = new ImapClient(server, loginName, password, ImapClient.AuthMethods.Login, 993, true)) {
|
using(var imap = new ImapClient(server, loginName, password, ImapClient.AuthMethods.Login, 993, true)) {
|
||||||
var msgs = imap.SearchMessages(
|
var msgs = imap.SearchMessages(
|
||||||
SearchCondition.Undeleted().And(
|
SearchCondition.Undeleted().And(
|
||||||
SearchCondition.SentSince(new DateTime(2014, 5, 7))
|
SearchCondition.SentSince(new DateTime(2014, 5, 7))
|
||||||
));
|
));
|
||||||
|
|
||||||
foreach (var msg in msgs)
|
foreach (var msg in msgs)
|
||||||
{
|
{
|
||||||
@@ -73,16 +75,23 @@ namespace NOCQ.Plugins.Email
|
|||||||
Console.WriteLine ("Source: " + source);
|
Console.WriteLine ("Source: " + source);
|
||||||
Console.WriteLine("System: " + sysMatch.Value);
|
Console.WriteLine("System: " + sysMatch.Value);
|
||||||
Console.WriteLine ("Service: " + servMatch.Value);
|
Console.WriteLine ("Service: " + servMatch.Value);
|
||||||
|
|
||||||
|
alerts.Add (new Alert () {
|
||||||
|
Source = source,
|
||||||
|
System = sysMatch.Value,
|
||||||
|
Service = servMatch.Value
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Console.WriteLine (system);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Execute(object sender, ElapsedEventArgs args)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
Console.WriteLine ("Start");
|
Console.WriteLine ("Start");
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using System;
|
|||||||
|
|
||||||
namespace NOCQ.Plugins.Email
|
namespace NOCQ.Plugins.Email
|
||||||
{
|
{
|
||||||
public class ParseRule : IParseRule
|
public class ParseRule
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user