diff --git a/NOCQ.userprefs b/NOCQ.userprefs deleted file mode 100644 index 8b8d573..0000000 --- a/NOCQ.userprefs +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/NOCQ.Application/Program.cs b/src/NOCQ.Application/Program.cs index 6b8dbdd..f447897 100644 --- a/src/NOCQ.Application/Program.cs +++ b/src/NOCQ.Application/Program.cs @@ -1,9 +1,15 @@ using System; using System.Dynamic; +<<<<<<< HEAD using NOCQ.Settings; +======= +using System.Linq; +>>>>>>> e5ed166572b47afde75d47f888768ae5b8d528f2 using NOCQ.Plugins.Email; +using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace NOCQ.Application { @@ -24,6 +30,29 @@ namespace NOCQ.Application emailPlugin.Execute(null,null); Console.ReadKey (); +/* + var list = new List(); + for (var i = 0; i < 3000; i++) + { + var al = new Alert() + {Data = "data" + Guid.NewGuid(), Runbook = "runbook", Service = "service", + Severity = "sev", + Source = "Source", + System = "System", + TimeStamp = new DateTime(2011,1,1) + }; + list.Add(al); + } + list.ForEach(al => RedisDatabase.SaveAlert(al, "127.0.0.1", RedisQueues.Input, 6379, 3000)); + for (var i = 0; i < 3000; i++) + { + var s = RedisDatabase.GetNextAlert("127.0.0.1", RedisQueues.Input, 6379, 3000); + Console.WriteLine(s.Data); + } + + Console.ReadLine(); + +*/ } } } diff --git a/src/NOCQ/DB/RedisDataase.cs b/src/NOCQ/DB/RedisDataase.cs deleted file mode 100644 index 609e3cc..0000000 --- a/src/NOCQ/DB/RedisDataase.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using ctstone.Redis; -using System.Threading.Tasks; -using System.Configuration; -using Newtonsoft.Json; -namespace NOCQ -{ - public class RedisDataase - { - public RedisDataase(){} - - public static async Task SaveAlert(Alert alert, string q) - { - using (var redis = new RedisClientAsync(q, - Convert.ToInt32(ConfigurationManager.AppSettings["Port"]), - Convert.ToInt32(ConfigurationManager.AppSettings["Timeout"]) - )) - { - await redis.LPush(q, alert); - - } - - } - - public static async Task GetNextAlert(string q) - { - - using (var redis = new RedisClientAsync(q, - Convert.ToInt32(ConfigurationManager.AppSettings["Port"]), - Convert.ToInt32(ConfigurationManager.AppSettings["Timeout"]) - )) - { - var ts = await redis.RPop(q); - - return await JsonConvert.DeserializeObjectAsync(ts); - - } - } - - } -} - diff --git a/src/NOCQ/DB/RedisDatabase.cs b/src/NOCQ/DB/RedisDatabase.cs new file mode 100644 index 0000000..e0d749f --- /dev/null +++ b/src/NOCQ/DB/RedisDatabase.cs @@ -0,0 +1,44 @@ +using System; +using ctstone.Redis; +using System.Threading.Tasks; +using System.Configuration; +using Newtonsoft.Json; +namespace NOCQ +{ + public class RedisDatabase + { + public RedisDatabase(){} + + public static void SaveAlert(Alert alert, string host, string q, int port, int timeout) + { + using (var redis = new RedisClient(host, + port, + timeout + )) + { + + + redis.LPush(q, JsonConvert.SerializeObject(alert)); + + } + + } + + public static Alert GetNextAlert(string host, string q, int port, int timeout ) + { + + using (var redis = new RedisClient(host, + port, + timeout + )) + { + var ts = redis.RPop(q); + + return JsonConvert.DeserializeObject(ts); + + } + } + + } +} + diff --git a/src/NOCQ/DB/RedisQueues.cs b/src/NOCQ/DB/RedisQueues.cs index e6c8556..8afe855 100644 --- a/src/NOCQ/DB/RedisQueues.cs +++ b/src/NOCQ/DB/RedisQueues.cs @@ -5,8 +5,8 @@ namespace NOCQ { public struct RedisQueues { - public static string Input = ConfigurationManager.AppSettings["DBQueueInput"]; - public static string Output = ConfigurationManager.AppSettings["DBQueueOutput"]; + public static string Input = "DBQueueInput"; + public static string Output = "DBQueueOutput"; } } diff --git a/src/NOCQ/NOCQ.csproj b/src/NOCQ/NOCQ.csproj index 75b1b6a..224f1d2 100644 --- a/src/NOCQ/NOCQ.csproj +++ b/src/NOCQ/NOCQ.csproj @@ -67,16 +67,17 @@ - - - + + EmailSettings.cs + + diff --git a/src/NOCQ/Plugins/Email/IEmailSetting.cs b/src/NOCQ/Plugins/Email/IEmailSetting.cs deleted file mode 100644 index 1e4dfc2..0000000 --- a/src/NOCQ/Plugins/Email/IEmailSetting.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -namespace NOCQ.Plugins.Email -{ - public interface IEmailSetting - { - string Username {get;set;} - string Password {get;set;} - string Host {get;set;} - int Port {get;set;} - string Folder {get;set;} - bool IsSsl {get;set;} - int Frequency { get; set; } - IEnumerable ParseRules {get;set;} - } -} - diff --git a/src/NOCQ/Properties/AssemblyInfo.cs b/src/NOCQ/Properties/AssemblyInfo.cs index 29cfbc3..c61243c 100644 --- a/src/NOCQ/Properties/AssemblyInfo.cs +++ b/src/NOCQ/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ using System.Reflection; using System.Runtime.CompilerServices; - +using System.Security.Permissions; // Information about this assembly is defined by the following attributes. // Change them to the values specific to your project. [assembly: AssemblyTitle("NOCQ")] @@ -15,6 +15,7 @@ using System.Runtime.CompilerServices; // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. [assembly: AssemblyVersion("1.0.*")] + // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. //[assembly: AssemblyDelaySign(false)]