Update: UserHeldDevices to Repository Monitor
This commit is contained in:
@@ -13,13 +13,6 @@ namespace Disco.BI.Extensions
|
||||
{
|
||||
public static class JobExtensions
|
||||
{
|
||||
|
||||
public static void BroadcastUpdate(this Job j)
|
||||
{
|
||||
if (j.UserId != null)
|
||||
Interop.SignalRHandlers.UserHeldDevices.UserJobUpdated(j.UserId);
|
||||
}
|
||||
|
||||
public static JobAttachment CreateAttachment(this Job Job, DiscoDataContext dbContext, User CreatorUser, string Filename, string MimeType, string Comments, Stream Content, DocumentTemplate DocumentTemplate = null, byte[] PdfThumbnail = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(MimeType) || MimeType.Equals("unknown/unknown", StringComparison.InvariantCultureIgnoreCase))
|
||||
|
||||
@@ -3,19 +3,39 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.AspNet.SignalR;
|
||||
using System.Reactive.Linq;
|
||||
using Disco.Data.Repository.Monitor;
|
||||
using Disco.Models.Repository;
|
||||
|
||||
namespace Disco.BI.Interop.SignalRHandlers
|
||||
{
|
||||
public class UserHeldDevices : PersistentConnection
|
||||
{
|
||||
private static bool subscribed = false;
|
||||
private static object subscribeLock = new object();
|
||||
|
||||
internal static void UserJobUpdated(string JobUserId)
|
||||
static UserHeldDevices()
|
||||
{
|
||||
var connectionManager = GlobalHost.ConnectionManager;
|
||||
var connectionContext = connectionManager.GetConnectionContext<UserHeldDevices>();
|
||||
if (connectionContext != null)
|
||||
connectionContext.Connection.Broadcast(JobUserId);
|
||||
if (!subscribed)
|
||||
lock (subscribeLock)
|
||||
if (!subscribed)
|
||||
{
|
||||
Disco.Data.Repository.Monitor.RepositoryMonitor.StreamAfterCommit.Where(e => e.EntityType == typeof(Job)).Subscribe(UserJobUpdated);
|
||||
subscribed = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void UserJobUpdated(RepositoryMonitorEvent e)
|
||||
{
|
||||
Job j = (Job)e.Entity;
|
||||
|
||||
if (j.UserId != null)
|
||||
{
|
||||
var connectionManager = GlobalHost.ConnectionManager;
|
||||
var connectionContext = connectionManager.GetConnectionContext<UserHeldDevices>();
|
||||
if (connectionContext != null)
|
||||
connectionContext.Connection.Broadcast(j.UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.2.0506.1904")]
|
||||
[assembly: AssemblyFileVersion("1.2.0506.1904")]
|
||||
[assembly: AssemblyVersion("1.2.0506.2022")]
|
||||
[assembly: AssemblyFileVersion("1.2.0506.2022")]
|
||||
Reference in New Issue
Block a user