merge
This commit is contained in:
@@ -2,25 +2,9 @@
|
|||||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||||
<MonoDevelop.Ide.Workbench ActiveDocument="src/NOCQ/Plugins/Email/ImapInput.cs">
|
<MonoDevelop.Ide.Workbench ActiveDocument="src/NOCQ/Plugins/Email/ImapInput.cs">
|
||||||
<Files>
|
<Files>
|
||||||
<File FileName="src/NOCQ/Plugins/Email/EmailSettings.cs" Line="15" Column="16" />
|
<File FileName="src/NOCQ/DB/RedisDataase.cs" Line="10" Column="6" />
|
||||||
<File FileName="src/NOCQ/Plugins/Email/ImapInput.cs" Line="68" Column="31" />
|
<File FileName="src/NOCQ/Plugins/Email/ImapInput.cs" Line="9" Column="24" />
|
||||||
</Files>
|
</Files>
|
||||||
<Pads>
|
|
||||||
<Pad Id="ProjectPad">
|
|
||||||
<State expanded="True">
|
|
||||||
<Node name="NOCQ" expanded="True">
|
|
||||||
<Node name="Extensability" expanded="True" />
|
|
||||||
<Node name="Imports" expanded="True" />
|
|
||||||
<Node name="Plugins" expanded="True">
|
|
||||||
<Node name="Email" expanded="True" />
|
|
||||||
</Node>
|
|
||||||
</Node>
|
|
||||||
<Node name="NOCQ.Application" expanded="True" selected="True">
|
|
||||||
<Node name="References" expanded="True" />
|
|
||||||
</Node>
|
|
||||||
</State>
|
|
||||||
</Pad>
|
|
||||||
</Pads>
|
|
||||||
</MonoDevelop.Ide.Workbench>
|
</MonoDevelop.Ide.Workbench>
|
||||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
<BreakpointStore />
|
<BreakpointStore />
|
||||||
|
|||||||
@@ -1,11 +1,40 @@
|
|||||||
using System;
|
using System;
|
||||||
using ctstone.Redis;
|
using ctstone.Redis;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Configuration;
|
||||||
|
using Newtonsoft.Json;
|
||||||
namespace NOCQ
|
namespace NOCQ
|
||||||
{
|
{
|
||||||
public class RedisDataase
|
public class RedisDataase
|
||||||
{
|
{
|
||||||
|
public RedisDataase(){}
|
||||||
|
|
||||||
|
public static async Task SaveAlert(IAlert alert)
|
||||||
|
{
|
||||||
|
using (var redis = new RedisClientAsync(ConfigurationManager.AppSettings["DBQueueKey"],
|
||||||
|
Convert.ToInt32(ConfigurationManager.AppSettings["Port"]),
|
||||||
|
Convert.ToInt32(ConfigurationManager.AppSettings["Timeout"])
|
||||||
|
))
|
||||||
|
{
|
||||||
|
await redis.LPush(ConfigurationManager.AppSettings["DBQueueKey"], alert);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<Alert> GetNextAlert()
|
||||||
|
{
|
||||||
|
using (var redis = new RedisClientAsync(ConfigurationManager.AppSettings["DBQueueKey"],
|
||||||
|
Convert.ToInt32(ConfigurationManager.AppSettings["Port"]),
|
||||||
|
Convert.ToInt32(ConfigurationManager.AppSettings["Timeout"])
|
||||||
|
))
|
||||||
|
{
|
||||||
|
var ts = await redis.RPop(ConfigurationManager.AppSettings["DBQueueKey"]);
|
||||||
|
|
||||||
|
return JsonConvert.DeserializeObject<Alert>(ts);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/NOCQ/Model/Alert.cs
Normal file
17
src/NOCQ/Model/Alert.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NOCQ
|
||||||
|
{
|
||||||
|
public class Alert : IAlert
|
||||||
|
{
|
||||||
|
public DateTime TimeStamp {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;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
16
src/NOCQ/Model/IAlert.cs
Normal file
16
src/NOCQ/Model/IAlert.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NOCQ
|
||||||
|
{
|
||||||
|
public interface IAlert
|
||||||
|
{
|
||||||
|
DateTime TimeStamp {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;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -55,6 +55,10 @@
|
|||||||
<HintPath>..\..\packages\AE.Net.Mail.1.7.9.1\lib\net45\AE.Net.Mail.dll</HintPath>
|
<HintPath>..\..\packages\AE.Net.Mail.1.7.9.1\lib\net45\AE.Net.Mail.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Configuration" />
|
||||||
|
<Reference Include="Newtonsoft.Json">
|
||||||
|
<HintPath>..\..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
@@ -65,6 +69,10 @@
|
|||||||
<Compile Include="DB\RedisDataase.cs" />
|
<Compile Include="DB\RedisDataase.cs" />
|
||||||
<Compile Include="Plugins\Email\ParseRule.cs" />
|
<Compile Include="Plugins\Email\ParseRule.cs" />
|
||||||
<Compile Include="Plugins\Email\ImapInput.cs" />
|
<Compile Include="Plugins\Email\ImapInput.cs" />
|
||||||
|
<Compile Include="Plugins\Email\IEmailSetting.cs" />
|
||||||
|
<Compile Include="Model\Alert.cs" />
|
||||||
|
<Compile Include="Plugins\Email\IParseRule.cs" />
|
||||||
|
<Compile Include="Model\IAlert.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -76,5 +84,6 @@
|
|||||||
<Folder Include="DB\" />
|
<Folder Include="DB\" />
|
||||||
<Folder Include="Plugins\" />
|
<Folder Include="Plugins\" />
|
||||||
<Folder Include="Plugins\Email\" />
|
<Folder Include="Plugins\Email\" />
|
||||||
|
<Folder Include="Model\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -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<ParseRule> ParseRules {get;set;}
|
public IEnumerable<IParseRule> 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<ParseRule> ParseRules {get;set;}
|
IEnumerable<IParseRule> ParseRules {get;set;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
18
src/NOCQ/Plugins/Email/IParseRule.cs
Normal file
18
src/NOCQ/Plugins/Email/IParseRule.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
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<ParseRule> parseRules{ get; set; }
|
List<IParseRule> parseRules{ get; set; }
|
||||||
|
|
||||||
public ImapInput (dynamic settings)
|
public ImapInput (dynamic settings)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using System;
|
|||||||
|
|
||||||
namespace NOCQ.Plugins.Email
|
namespace NOCQ.Plugins.Email
|
||||||
{
|
{
|
||||||
public class ParseRule
|
public class ParseRule : IParseRule
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
|
|||||||
@@ -3,4 +3,5 @@
|
|||||||
<package id="AE.Net.Mail" version="1.7.9.1" targetFramework="net45" />
|
<package id="AE.Net.Mail" version="1.7.9.1" targetFramework="net45" />
|
||||||
<package id="csredis" version="1.4.7.1" targetFramework="net45" />
|
<package id="csredis" version="1.4.7.1" targetFramework="net45" />
|
||||||
<package id="Microsoft.Composition" version="1.0.27" targetFramework="net45" />
|
<package id="Microsoft.Composition" version="1.0.27" targetFramework="net45" />
|
||||||
|
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
||||||
Reference in New Issue
Block a user