Update: SignalR 2.0.3 Migration; Noticeboards

Migrate all SignalR 1.x Persistent Connections to SignalR 2.x Hubs.
Abstracts ScheduledTaskStatus with core interface and adds a Mock for
optional status reporting. Noticeboards rewritten (with new theme) to be
more resilient and accurate.
This commit is contained in:
Gary Sharp
2014-06-01 23:27:07 +10:00
parent f6fae26bc7
commit 4cd57f4a90
116 changed files with 9874 additions and 6462 deletions
+6 -6
View File
@@ -70,7 +70,7 @@ namespace Disco.Services.Logging
}
}
private static void InitalizeDatabase(Targets.LogPersistContext LogDatabase)
private static void InitalizeDatabase(Persistance.LogPersistContext LogDatabase)
{
// Add Modules
var existingModules = LogDatabase.Modules.Include("EventTypes").ToDictionary(m => m.Id);
@@ -183,7 +183,7 @@ namespace Disco.Services.Logging
if (!File.Exists(logPath))
{
// Create Database
using (var context = new Targets.LogPersistContext(connectionString))
using (var context = new Persistance.LogPersistContext(connectionString))
{
context.Database.CreateIfNotExists();
}
@@ -191,7 +191,7 @@ namespace Disco.Services.Logging
// Add Modules/Event Types
InitalizeModules();
using (var context = new Targets.LogPersistContext(connectionString))
using (var context = new Persistance.LogPersistContext(connectionString))
{
InitalizeDatabase(context);
}
@@ -211,7 +211,7 @@ namespace Disco.Services.Logging
sqlCeCSB.DataSource = yesterdaysLogPath;
var connectionString = sqlCeCSB.ToString();
int logCount;
using (var context = new Targets.LogPersistContext(connectionString))
using (var context = new Persistance.LogPersistContext(connectionString))
{
logCount = context.Events.Where(e => !(e.ModuleId == 0 && e.EventTypeId == 100)).Count();
if (logCount == 0)
@@ -267,7 +267,7 @@ namespace Disco.Services.Logging
var eventTimestamp = DateTime.Now;
if (eventType.UseLive)
{
Targets.LogLiveContext.Broadcast(logModule, eventType, eventTimestamp, Args);
LogNotificationsHub.BroadcastLog(logModule, eventType, eventTimestamp, Args);
}
if (eventType.UsePersist)
{
@@ -276,7 +276,7 @@ namespace Disco.Services.Logging
{
args = JsonConvert.SerializeObject(Args);
}
using (var context = new Targets.LogPersistContext(PersistantStoreConnectionString))
using (var context = new Persistance.LogPersistContext(PersistantStoreConnectionString))
{
var e = new Models.LogEvent()
{
@@ -0,0 +1,67 @@
using Disco.Services.Authorization;
using Disco.Services.Logging.Models;
using Disco.Services.Web.Signalling;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Disco.Services.Logging
{
[HubName("logNotifications"), DiscoHubAuthorize(Claims.Config.Logging.Show)]
public class LogNotificationsHub : Hub
{
private const string NotificationsModulePrefix = "Logging_";
public const string AllLoggingNotification = NotificationsModulePrefix + "_ALL";
public override Task OnConnected()
{
var logModules = Context.QueryString["LogModules"];
if (!string.IsNullOrWhiteSpace(logModules) && logModules.Length > 0)
{
foreach (var modules in ValidLogModuleGroupNames(logModules))
Groups.Add(Context.ConnectionId, modules);
}
return base.OnConnected();
}
internal static void BroadcastLog(LogBase logModule, LogEventType eventType, DateTime Timestamp, params object[] Arguments)
{
var message = LogLiveEvent.Create(logModule, eventType, Timestamp, Arguments);
var connectionManager = GlobalHost.ConnectionManager;
var context = connectionManager.GetHubContext<LogNotificationsHub>();
var targets = new List<string> { AllLoggingNotification, NotificationsModulePrefix + logModule.ModuleName };
context.Clients.Groups(targets).receiveLog(message);
}
private IEnumerable<string> ValidLogModuleGroupNames(string ModuleNames)
{
if (string.IsNullOrWhiteSpace(ModuleNames))
yield break;
var names = ModuleNames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var name in names)
{
// Special Case: __ALL
if (name.Equals(AllLoggingNotification, StringComparison.OrdinalIgnoreCase))
{
yield return AllLoggingNotification;
}
else
{
var module = LogContext.LogModules.Values.FirstOrDefault(m => m.ModuleName.Equals(name, StringComparison.OrdinalIgnoreCase));
if (module == null)
throw new ArgumentException(string.Format("Invalid Module Name specified: {0}", name), "ModuleNames");
yield return NotificationsModulePrefix + module.ModuleName;
}
}
}
}
}
@@ -5,7 +5,7 @@ using System.Text;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
namespace Disco.Services.Logging.Targets
namespace Disco.Services.Logging.Persistance
{
public class LogPersistContext : DbContext
{
@@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Logging.Targets
namespace Disco.Services.Logging.Persistance
{
public class LogPersistContextInitializer : IDatabaseInitializer<LogPersistContext>
{
+9 -10
View File
@@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Disco.Services.Logging.Targets;
using Disco.Data.Repository;
using System.IO;
using System.Text.RegularExpressions;
using System.Data.SqlServerCe;
using Disco.Data.Repository;
using Disco.Services.Logging.Models;
using Disco.Services.Logging.Persistance;
using System;
using System.Collections.Generic;
using System.Data.SqlServerCe;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace Disco.Services.Logging
{
@@ -45,7 +44,7 @@ namespace Disco.Services.Logging
var logModules = LogContext.LogModules;
using (var context = new Targets.LogPersistContext(sqlCeCSB.ToString()))
using (var context = new LogPersistContext(sqlCeCSB.ToString()))
{
var query = this.BuildQuery(context, logFile.Item2, results.Count);
IEnumerable<LogEvent> queryResults = query; // Run the Query
@@ -1,21 +0,0 @@
using Disco.Services.Logging.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Logging.Targets
{
public static class LogLiveContext
{
public delegate void LogBroadcastEvent(LogBase logModule, LogEventType eventType, DateTime Timestamp, params object[] Arguments);
public static event LogBroadcastEvent LogBroadcast;
internal static void Broadcast(LogBase logModule, LogEventType eventType, DateTime Timestamp, params object[] Arguments)
{
if (LogBroadcast != null)
LogBroadcast.Invoke(logModule, eventType, Timestamp, Arguments);
}
}
}