merged
This commit is contained in:
@@ -2,9 +2,24 @@
|
|||||||
<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/DB/RedisDataase.cs" Line="10" Column="6" />
|
<File FileName="src/NOCQ/Plugins/Email/EmailSettings.cs" Line="15" Column="22" />
|
||||||
<File FileName="src/NOCQ/Plugins/Email/ImapInput.cs" Line="9" Column="24" />
|
<File FileName="src/NOCQ/Plugins/Email/ImapInput.cs" Line="98" Column="5" />
|
||||||
|
<File FileName="src/NOCQ.Application/Program.cs" Line="14" Column="2" />
|
||||||
|
<File FileName="src/NOCQ/Plugins/Email/ParseRule.cs" Line="5" Column="24" />
|
||||||
|
<File FileName="src/NOCQ/Plugins/Email/IEmailSetting.cs" Line="14" Column="15" />
|
||||||
|
<File FileName="src/NOCQ/Model/Alert.cs" Line="1" Column="1" />
|
||||||
|
<File FileName="src/NOCQ/DB/RedisDataase.cs" Line="1" Column="1" />
|
||||||
</Files>
|
</Files>
|
||||||
|
<Pads>
|
||||||
|
<Pad Id="ProjectPad">
|
||||||
|
<State expanded="True">
|
||||||
|
<Node name="NOCQ" expanded="True" selected="True" />
|
||||||
|
<Node name="NOCQ.Application" expanded="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 />
|
||||||
|
|||||||
@@ -9,29 +9,30 @@ namespace NOCQ
|
|||||||
{
|
{
|
||||||
public RedisDataase(){}
|
public RedisDataase(){}
|
||||||
|
|
||||||
public static async Task SaveAlert(IAlert alert)
|
public static async Task SaveAlert(Alert alert, string q)
|
||||||
{
|
{
|
||||||
using (var redis = new RedisClientAsync(ConfigurationManager.AppSettings["DBQueueKey"],
|
using (var redis = new RedisClientAsync(q,
|
||||||
Convert.ToInt32(ConfigurationManager.AppSettings["Port"]),
|
Convert.ToInt32(ConfigurationManager.AppSettings["Port"]),
|
||||||
Convert.ToInt32(ConfigurationManager.AppSettings["Timeout"])
|
Convert.ToInt32(ConfigurationManager.AppSettings["Timeout"])
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
await redis.LPush(ConfigurationManager.AppSettings["DBQueueKey"], alert);
|
await redis.LPush(q, alert);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<Alert> GetNextAlert()
|
public static async Task<Alert> GetNextAlert(string q)
|
||||||
{
|
{
|
||||||
using (var redis = new RedisClientAsync(ConfigurationManager.AppSettings["DBQueueKey"],
|
|
||||||
|
using (var redis = new RedisClientAsync(q,
|
||||||
Convert.ToInt32(ConfigurationManager.AppSettings["Port"]),
|
Convert.ToInt32(ConfigurationManager.AppSettings["Port"]),
|
||||||
Convert.ToInt32(ConfigurationManager.AppSettings["Timeout"])
|
Convert.ToInt32(ConfigurationManager.AppSettings["Timeout"])
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
var ts = await redis.RPop(ConfigurationManager.AppSettings["DBQueueKey"]);
|
var ts = await redis.RPop(q);
|
||||||
|
|
||||||
return JsonConvert.DeserializeObject<Alert>(ts);
|
return await JsonConvert.DeserializeObjectAsync<Alert>(ts);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/NOCQ/DB/RedisQueues.cs
Normal file
12
src/NOCQ/DB/RedisQueues.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
|
|
||||||
|
namespace NOCQ
|
||||||
|
{
|
||||||
|
public struct RedisQueues
|
||||||
|
{
|
||||||
|
public static string Input = ConfigurationManager.AppSettings["DBQueueInput"];
|
||||||
|
public static string Output = ConfigurationManager.AppSettings["DBQueueOutput"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@ using System;
|
|||||||
|
|
||||||
namespace NOCQ
|
namespace NOCQ
|
||||||
{
|
{
|
||||||
public class Alert : IAlert
|
public class Alert
|
||||||
{
|
{
|
||||||
public DateTime TimeStamp {get; set;}
|
public DateTime TimeStamp {get; set;}
|
||||||
public string Source {get;set;}
|
public string Source {get;set;}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
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;}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -73,6 +73,7 @@
|
|||||||
<Compile Include="Plugins\Email\IEmailSetting.cs" />
|
<Compile Include="Plugins\Email\IEmailSetting.cs" />
|
||||||
<Compile Include="Model\Alert.cs" />
|
<Compile Include="Model\Alert.cs" />
|
||||||
<Compile Include="Model\IAlert.cs" />
|
<Compile Include="Model\IAlert.cs" />
|
||||||
|
<Compile Include="DB\RedisQueues.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace NOCQ.Plugins.Email
|
|||||||
DateTime lastRun { get; set; }
|
DateTime lastRun { get; set; }
|
||||||
IEnumerable<ParseRule> parseRules{ get; set; }
|
IEnumerable<ParseRule> parseRules{ get; set; }
|
||||||
|
|
||||||
|
|
||||||
public ImapInput (dynamic settings)
|
public ImapInput (dynamic settings)
|
||||||
{
|
{
|
||||||
var sets = settings as EmailSettings;
|
var sets = settings as EmailSettings;
|
||||||
|
|||||||
Reference in New Issue
Block a user