mergeconflics and removing a userfile

This commit is contained in:
Norm MacLennan
2014-05-07 16:05:12 -07:00
8 changed files with 81 additions and 96 deletions

View File

@@ -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<Alert>();
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();
*/
}
}
}

View File

@@ -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<Alert> 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<Alert>(ts);
}
}
}
}

View File

@@ -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<Alert>(ts);
}
}
}
}

View File

@@ -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";
}
}

View File

@@ -67,16 +67,17 @@
<Compile Include="Plugins\Email\EmailSettings.cs" />
<Compile Include="Imports\IDataImportHook.cs" />
<Compile Include="Imports\DataImports.cs" />
<Compile Include="DB\RedisDataase.cs" />
<Compile Include="Plugins\Email\ParseRule.cs" />
<Compile Include="Plugins\Email\ImapInput.cs" />
<Compile Include="Plugins\Email\IEmailSetting.cs" />
<Compile Include="Plugins\Email\ImapInput.cs">
<DependentUpon>EmailSettings.cs</DependentUpon>
</Compile>
<Compile Include="Model\Alert.cs" />
<Compile Include="DB\RedisQueues.cs" />
<Compile Include="Settings\SettingsFIle.cs" />
<Compile Include="Settings\RedisSettings.cs" />
<Compile Include="Settings\SettingsParser.cs" />
<Compile Include="Settings\PluginSettings.cs" />
<Compile Include="DB\RedisDatabase.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>

View File

@@ -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<ParseRule> ParseRules {get;set;}
}
}

View File

@@ -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)]