增加功能:增加页面WebSocket连接
This commit is contained in:
parent
3d574edfa8
commit
ee7f36fa53
|
@ -1,7 +1,10 @@
|
|||
using Bootstrap.Admin.Models;
|
||||
using Bootstrap.DataAccess;
|
||||
using Longbow.Web.WebSockets;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bootstrap.Admin.Controllers
|
||||
{
|
||||
|
|
|
@ -51,16 +51,11 @@
|
|||
$.extend({
|
||||
pullNotification: function () {
|
||||
if ($('.notify-row').length == 0) return;
|
||||
return;
|
||||
setTimeout(function () {
|
||||
NProgress.status = true;
|
||||
NProgress.configure({ trickle: false });
|
||||
$.bc({
|
||||
url: 'api/WS',
|
||||
method: 'GET',
|
||||
swal: false,
|
||||
callback: function (result) {
|
||||
NProgress.status = false;
|
||||
|
||||
var uri = "ws://" + window.location.host + "/WS";
|
||||
var socket = new WebSocket(uri);
|
||||
socket.onmessage = function (e) {
|
||||
var result = JSON.parse(e.data);
|
||||
for (index in result) {
|
||||
var cate = result[index].Category;
|
||||
var msg = result[index].Message;
|
||||
|
@ -74,10 +69,7 @@
|
|||
}
|
||||
};
|
||||
if (result.length > 0) $.reloadWidget();
|
||||
$.pullNotification();
|
||||
}
|
||||
});
|
||||
}, 5000);
|
||||
};
|
||||
},
|
||||
reloadWidget: function () {
|
||||
if ($('.notify-row').length == 0) return;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security" Version="1.0.3" />
|
||||
<PackageReference Include="Longbow.Web" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using Longbow.Logging;
|
||||
using Longbow.Web.WebSockets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
|
@ -39,6 +40,8 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Message", ex.Message));
|
||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@StackTrace", DBAccessFactory.ToDBValue(ex.StackTrace)));
|
||||
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
|
||||
CacheManager.Clear(RetrieveExceptionsDataKey);
|
||||
WebSocketPushManager.SendAsync(new List<object> { new { Category = "Notification", ex.Message } });
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
Loading…
Reference in New Issue