merged
This commit is contained in:
@@ -2,9 +2,24 @@
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="src/NOCQ/Plugins/Email/ImapInput.cs">
|
||||
<Files>
|
||||
<File FileName="src/NOCQ/DB/RedisDataase.cs" Line="10" Column="6" />
|
||||
<File FileName="src/NOCQ/Plugins/Email/ImapInput.cs" Line="9" Column="24" />
|
||||
<File FileName="src/NOCQ/Plugins/Email/EmailSettings.cs" Line="15" Column="22" />
|
||||
<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>
|
||||
<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.DebuggingService.Breakpoints>
|
||||
<BreakpointStore />
|
||||
|
||||
@@ -9,29 +9,30 @@ namespace NOCQ
|
||||
{
|
||||
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["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["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
|
||||
{
|
||||
public class Alert : IAlert
|
||||
public class Alert
|
||||
{
|
||||
public DateTime TimeStamp {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="Model\Alert.cs" />
|
||||
<Compile Include="Model\IAlert.cs" />
|
||||
<Compile Include="DB\RedisQueues.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace NOCQ.Plugins.Email
|
||||
DateTime lastRun { get; set; }
|
||||
IEnumerable<ParseRule> parseRules{ get; set; }
|
||||
|
||||
|
||||
public ImapInput (dynamic settings)
|
||||
{
|
||||
var sets = settings as EmailSettings;
|
||||
|
||||
Reference in New Issue
Block a user