Update: UserHeldDevices to Repository Monitor
This commit is contained in:
@@ -13,13 +13,6 @@ namespace Disco.BI.Extensions
|
|||||||
{
|
{
|
||||||
public static class JobExtensions
|
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)
|
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))
|
if (string.IsNullOrEmpty(MimeType) || MimeType.Equals("unknown/unknown", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
|||||||
@@ -3,19 +3,39 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.AspNet.SignalR;
|
using Microsoft.AspNet.SignalR;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
using Disco.Data.Repository.Monitor;
|
||||||
|
using Disco.Models.Repository;
|
||||||
|
|
||||||
namespace Disco.BI.Interop.SignalRHandlers
|
namespace Disco.BI.Interop.SignalRHandlers
|
||||||
{
|
{
|
||||||
public class UserHeldDevices : PersistentConnection
|
public class UserHeldDevices : PersistentConnection
|
||||||
{
|
{
|
||||||
|
private static bool subscribed = false;
|
||||||
|
private static object subscribeLock = new object();
|
||||||
|
|
||||||
internal static void UserJobUpdated(string JobUserId)
|
static UserHeldDevices()
|
||||||
|
{
|
||||||
|
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 connectionManager = GlobalHost.ConnectionManager;
|
||||||
var connectionContext = connectionManager.GetConnectionContext<UserHeldDevices>();
|
var connectionContext = connectionManager.GetConnectionContext<UserHeldDevices>();
|
||||||
if (connectionContext != null)
|
if (connectionContext != null)
|
||||||
connectionContext.Connection.Broadcast(JobUserId);
|
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
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.2.0506.1904")]
|
[assembly: AssemblyVersion("1.2.0506.2022")]
|
||||||
[assembly: AssemblyFileVersion("1.2.0506.1904")]
|
[assembly: AssemblyFileVersion("1.2.0506.2022")]
|
||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.2.0506.1845")]
|
[assembly: AssemblyVersion("1.2.0506.2004")]
|
||||||
[assembly: AssemblyFileVersion("1.2.0506.1845")]
|
[assembly: AssemblyFileVersion("1.2.0506.2004")]
|
||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.2.0506.1904")]
|
[assembly: AssemblyVersion("1.2.0506.2022")]
|
||||||
[assembly: AssemblyFileVersion("1.2.0506.1904")]
|
[assembly: AssemblyFileVersion("1.2.0506.2022")]
|
||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.2.0506.1904")]
|
[assembly: AssemblyVersion("1.2.0506.2022")]
|
||||||
[assembly: AssemblyFileVersion("1.2.0506.1904")]
|
[assembly: AssemblyFileVersion("1.2.0506.2022")]
|
||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.2.0506.1904")]
|
[assembly: AssemblyVersion("1.2.0506.2022")]
|
||||||
[assembly: AssemblyFileVersion("1.2.0506.1904")]
|
[assembly: AssemblyFileVersion("1.2.0506.2022")]
|
||||||
@@ -443,7 +443,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
job.ExpectedClosedDate = null;
|
job.ExpectedClosedDate = null;
|
||||||
}
|
}
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
job.BroadcastUpdate();
|
|
||||||
}
|
}
|
||||||
private void UpdateDeviceHeldLocation(Job job, string DeviceHeldLocation)
|
private void UpdateDeviceHeldLocation(Job job, string DeviceHeldLocation)
|
||||||
{
|
{
|
||||||
@@ -577,7 +576,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
}
|
}
|
||||||
job.JobMetaNonWarranty.AccountingChargeRequiredUserId = DiscoApplication.CurrentUser.Id;
|
job.JobMetaNonWarranty.AccountingChargeRequiredUserId = DiscoApplication.CurrentUser.Id;
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
job.BroadcastUpdate();
|
|
||||||
return new Models.Job._DateChangeModel()
|
return new Models.Job._DateChangeModel()
|
||||||
{
|
{
|
||||||
Id = job.Id,
|
Id = job.Id,
|
||||||
@@ -612,7 +610,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
}
|
}
|
||||||
job.JobMetaNonWarranty.AccountingChargeAddedUserId = DiscoApplication.CurrentUser.Id;
|
job.JobMetaNonWarranty.AccountingChargeAddedUserId = DiscoApplication.CurrentUser.Id;
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
job.BroadcastUpdate();
|
|
||||||
return new Models.Job._DateChangeModel()
|
return new Models.Job._DateChangeModel()
|
||||||
{
|
{
|
||||||
Id = job.Id,
|
Id = job.Id,
|
||||||
@@ -647,7 +644,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
}
|
}
|
||||||
job.JobMetaNonWarranty.AccountingChargePaidUserId = DiscoApplication.CurrentUser.Id;
|
job.JobMetaNonWarranty.AccountingChargePaidUserId = DiscoApplication.CurrentUser.Id;
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
job.BroadcastUpdate();
|
|
||||||
return new Models.Job._DateChangeModel()
|
return new Models.Job._DateChangeModel()
|
||||||
{
|
{
|
||||||
Id = job.Id,
|
Id = job.Id,
|
||||||
@@ -1462,7 +1458,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
|
|
||||||
job.OnWaitingForUserAction(dbContext, DiscoApplication.CurrentUser, Reason);
|
job.OnWaitingForUserAction(dbContext, DiscoApplication.CurrentUser, Reason);
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
job.BroadcastUpdate();
|
|
||||||
if (redirect.HasValue && redirect.Value)
|
if (redirect.HasValue && redirect.Value)
|
||||||
return RedirectToAction(MVC.Job.Show(job.Id));
|
return RedirectToAction(MVC.Job.Show(job.Id));
|
||||||
else
|
else
|
||||||
@@ -1492,7 +1487,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
|
|
||||||
job.OnNotWaitingForUserAction(dbContext, DiscoApplication.CurrentUser, Resolution);
|
job.OnNotWaitingForUserAction(dbContext, DiscoApplication.CurrentUser, Resolution);
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
job.BroadcastUpdate();
|
|
||||||
if (redirect.HasValue && redirect.Value)
|
if (redirect.HasValue && redirect.Value)
|
||||||
return RedirectToAction(MVC.Job.Show(job.Id));
|
return RedirectToAction(MVC.Job.Show(job.Id));
|
||||||
else
|
else
|
||||||
@@ -1540,7 +1534,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
j.OnDeviceReadyForReturn(DiscoApplication.CurrentUser);
|
j.OnDeviceReadyForReturn(DiscoApplication.CurrentUser);
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
j.BroadcastUpdate();
|
|
||||||
if (redirect)
|
if (redirect)
|
||||||
return RedirectToAction(MVC.Job.Show(id));
|
return RedirectToAction(MVC.Job.Show(id));
|
||||||
else
|
else
|
||||||
@@ -1563,7 +1556,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
j.OnDeviceHeld(DiscoApplication.CurrentUser);
|
j.OnDeviceHeld(DiscoApplication.CurrentUser);
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
j.BroadcastUpdate();
|
|
||||||
if (redirect)
|
if (redirect)
|
||||||
return RedirectToAction(MVC.Job.Show(id));
|
return RedirectToAction(MVC.Job.Show(id));
|
||||||
else
|
else
|
||||||
@@ -1586,7 +1578,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
j.OnDeviceReturned(DiscoApplication.CurrentUser);
|
j.OnDeviceReturned(DiscoApplication.CurrentUser);
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
j.BroadcastUpdate();
|
|
||||||
if (redirect)
|
if (redirect)
|
||||||
return RedirectToAction(MVC.Job.Show(id));
|
return RedirectToAction(MVC.Job.Show(id));
|
||||||
else
|
else
|
||||||
@@ -1655,7 +1646,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
j.OnReopen();
|
j.OnReopen();
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
j.BroadcastUpdate();
|
|
||||||
if (redirect)
|
if (redirect)
|
||||||
return RedirectToAction(MVC.Job.Show(id));
|
return RedirectToAction(MVC.Job.Show(id));
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -453,10 +453,20 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
var updatedModel = function (id) {
|
var updatedModel = function (id) {
|
||||||
var UserId = id.toString();
|
var userId = id.toString();
|
||||||
$.getJSON('@(Url.Action(MVC.Public.UserHeldDevices.UserHeldDevice()))', { id: UserId }, function (data) {
|
|
||||||
processModel(UserId, data, false);
|
$.ajax({
|
||||||
});
|
dataType: 'json',
|
||||||
|
url: '@(Url.Action(MVC.Public.UserHeldDevices.UserHeldDevice()))',
|
||||||
|
data: { id: userId },
|
||||||
|
success: function (data) {
|
||||||
|
processModel(userId, data, false);
|
||||||
|
},
|
||||||
|
error: function(jqXHR, textStatus, errorThrown){
|
||||||
|
if (textStatus == 'parsererror') // null Result
|
||||||
|
processModel(userId, null, false);
|
||||||
|
}
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
var connectionError = function () {
|
var connectionError = function () {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.17929
|
// Runtime Version:4.0.30319.18033
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
@@ -31,9 +31,9 @@ namespace Disco.Web.Areas.Public.Views.UserHeldDevices
|
|||||||
using Disco.Web;
|
using Disco.Web;
|
||||||
using Disco.Web.Extensions;
|
using Disco.Web.Extensions;
|
||||||
|
|
||||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")]
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.4.0")]
|
||||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Public/Views/UserHeldDevices/Noticeboard.cshtml")]
|
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Public/Views/UserHeldDevices/Noticeboard.cshtml")]
|
||||||
public class Noticeboard : System.Web.Mvc.WebViewPage<dynamic>
|
public partial class Noticeboard : System.Web.Mvc.WebViewPage<dynamic>
|
||||||
{
|
{
|
||||||
public Noticeboard()
|
public Noticeboard()
|
||||||
{
|
{
|
||||||
@@ -412,19 +412,26 @@ WriteLiteral(">\r\n $(function () {\r\n var models = {};\r\n
|
|||||||
" (model.htmlLi && model.IsAlert) {\r\n model.htmlLi.addClas" +
|
" (model.htmlLi && model.IsAlert) {\r\n model.htmlLi.addClas" +
|
||||||
"s(\'alert\');\r\n }\r\n scheduleModelUpdate(mode" +
|
"s(\'alert\');\r\n }\r\n scheduleModelUpdate(mode" +
|
||||||
"l);\r\n }\r\n };\r\n\r\n var updatedModel = functio" +
|
"l);\r\n }\r\n };\r\n\r\n var updatedModel = functio" +
|
||||||
"n (id) {\r\n var UserId = id.toString();\r\n $.getJSON" +
|
"n (id) {\r\n var userId = id.toString();\r\n\r\n $.ajax(" +
|
||||||
"(\'");
|
"{\r\n dataType: \'json\',\r\n url: \'");
|
||||||
|
|
||||||
|
|
||||||
#line 457 "..\..\Areas\Public\Views\UserHeldDevices\Noticeboard.cshtml"
|
#line 460 "..\..\Areas\Public\Views\UserHeldDevices\Noticeboard.cshtml"
|
||||||
Write(Url.Action(MVC.Public.UserHeldDevices.UserHeldDevice()));
|
Write(Url.Action(MVC.Public.UserHeldDevices.UserHeldDevice()));
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
WriteLiteral(@"', { id: UserId }, function (data) {
|
WriteLiteral(@"',
|
||||||
processModel(UserId, data, false);
|
data: { id: userId },
|
||||||
});
|
success: function (data) {
|
||||||
|
processModel(userId, data, false);
|
||||||
|
},
|
||||||
|
error: function(jqXHR, textStatus, errorThrown){
|
||||||
|
if (textStatus == 'parsererror') // null Result
|
||||||
|
processModel(userId, null, false);
|
||||||
|
}
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
var connectionError = function () {
|
var connectionError = function () {
|
||||||
@@ -435,7 +442,7 @@ WriteLiteral(@"', { id: UserId }, function (data) {
|
|||||||
window.location.href = '");
|
window.location.href = '");
|
||||||
|
|
||||||
|
|
||||||
#line 467 "..\..\Areas\Public\Views\UserHeldDevices\Noticeboard.cshtml"
|
#line 477 "..\..\Areas\Public\Views\UserHeldDevices\Noticeboard.cshtml"
|
||||||
Write(Url.Action(MVC.Public.UserHeldDevices.Noticeboard()));
|
Write(Url.Action(MVC.Public.UserHeldDevices.Noticeboard()));
|
||||||
|
|
||||||
|
|
||||||
@@ -446,7 +453,7 @@ WriteLiteral("\';\r\n }, 10000);\r\n }\r\n
|
|||||||
"rsistantConnection = $.connection(\'");
|
"rsistantConnection = $.connection(\'");
|
||||||
|
|
||||||
|
|
||||||
#line 474 "..\..\Areas\Public\Views\UserHeldDevices\Noticeboard.cshtml"
|
#line 484 "..\..\Areas\Public\Views\UserHeldDevices\Noticeboard.cshtml"
|
||||||
Write(Url.Content("~/Public/UserHeldDevices/Notifications"));
|
Write(Url.Content("~/Public/UserHeldDevices/Notifications"));
|
||||||
|
|
||||||
|
|
||||||
@@ -457,7 +464,7 @@ WriteLiteral("\');\r\n persistantConnection.received(updatedModel
|
|||||||
"tion.start(function () {\r\n $.getJSON(\'");
|
"tion.start(function () {\r\n $.getJSON(\'");
|
||||||
|
|
||||||
|
|
||||||
#line 478 "..\..\Areas\Public\Views\UserHeldDevices\Noticeboard.cshtml"
|
#line 488 "..\..\Areas\Public\Views\UserHeldDevices\Noticeboard.cshtml"
|
||||||
Write(Url.Action(MVC.Public.UserHeldDevices.UserHeldDevices()));
|
Write(Url.Action(MVC.Public.UserHeldDevices.UserHeldDevices()));
|
||||||
|
|
||||||
|
|
||||||
@@ -482,14 +489,14 @@ WriteLiteral(">\r\n <img");
|
|||||||
|
|
||||||
WriteLiteral(" style=\"width: 32px; height: 32px; margin-top: -5px; margin-bottom: -15px;\"");
|
WriteLiteral(" style=\"width: 32px; height: 32px; margin-top: -5px; margin-bottom: -15px;\"");
|
||||||
|
|
||||||
WriteAttribute("src", Tuple.Create(" src=\"", 23515), Tuple.Create("\"", 23564)
|
WriteAttribute("src", Tuple.Create(" src=\"", 23895), Tuple.Create("\"", 23944)
|
||||||
|
|
||||||
#line 490 "..\..\Areas\Public\Views\UserHeldDevices\Noticeboard.cshtml"
|
#line 500 "..\..\Areas\Public\Views\UserHeldDevices\Noticeboard.cshtml"
|
||||||
, Tuple.Create(Tuple.Create("", 23521), Tuple.Create<System.Object, System.Int32>(Links.ClientSource.Style.Images.Icon32_png
|
, Tuple.Create(Tuple.Create("", 23901), Tuple.Create<System.Object, System.Int32>(Links.ClientSource.Style.Images.Icon32_png
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
, 23521), false)
|
, 23901), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteLiteral(" alt=\"Disco Logo\"");
|
WriteLiteral(" alt=\"Disco Logo\"");
|
||||||
|
|||||||
Reference in New Issue
Block a user