This commit is contained in:
2024-12-31 07:28:53 -07:00
4 changed files with 39 additions and 5 deletions

View File

@@ -158,8 +158,18 @@ Public Class ClsSisNotificaciones
End If End If
End Sub End Sub
Public Shared Sub ContadorCampana(Mensaje As String, CveUsuario As String)
Dim hub = GlobalHost.ConnectionManager.GetHubContext(Of Notificaciones)()
'VERIFICA SI EXISTE LA CONEXION DEL USUARIO
If Notificaciones.UsuariosConexiones.Keys.Any(Function(key) key = CveUsuario) Then
hub.Clients.Client(Notificaciones.UsuariosConexiones(CveUsuario)).ContadorCampana(Mensaje)
End If
End Sub
Public Sub DispararNotificacion(CveNotificacion As Integer, CvesFiltro As List(Of Object), CveEmpresa As Integer) Public Sub DispararNotificacion(CveNotificacion As Integer, CvesFiltro As List(Of Object), CveEmpresa As Integer)
_CveNotificacion = CveNotificacion _CveNotificacion = CveNotificacion
_CveEmpresa = CveEmpresa _CveEmpresa = CveEmpresa

View File

@@ -63,6 +63,13 @@ Public Class Notificaciones
End If End If
End Sub End Sub
Public Sub ContadorCampana(ContadorMesagge As String, Para As List(Of String))
If (Para IsNot Nothing) AndAlso Para.Count > 0 Then
Dim Clients As Hubs.IHubConnectionContext(Of Object) = GlobalHost.ConnectionManager.GetHubContext(Of Notificaciones)().Clients
Clients.Users(Para).ContadorCampana(ContadorMesagge)
End If
End Sub
End Class End Class
Public Class MyhubUserIdProvider Public Class MyhubUserIdProvider
Implements IUserIdProvider Implements IUserIdProvider

View File

@@ -67,8 +67,9 @@ Partial Class Inicio
End Sub End Sub
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then If Not IsPostBack Then
'Using objnoti = New ClsSisNotificaciones()
' objnoti.ContadorCampana("Mi Mensaje", UsuarioActual.CveUsuario.ToString())
'End Using
If Not IsNothing(Request("logout")) AndAlso Request("logout").ToString() = "1" Then If Not IsNothing(Request("logout")) AndAlso Request("logout").ToString() = "1" Then
Usuario.CerrarSession() Usuario.CerrarSession()

View File

@@ -94,7 +94,11 @@ var NotificacionesADS = function () {
} }
} }
}; };
var ContadorCampana = function (contadormessage) {
console.log('(SignalR) ContadorCampana \'' + contadormessage);
localStorage.setItem("ContadorCampana", "");
localStorage.setItem("ContadorCampana", contadormessage);
}
//-------------------------------------------------------------------- EndEventos ---------------------------------------------------------------------- //-------------------------------------------------------------------- EndEventos ----------------------------------------------------------------------
function closeopenConexion() { function closeopenConexion() {
if (VentanaConConexion) { if (VentanaConConexion) {
@@ -122,6 +126,7 @@ var NotificacionesADS = function () {
}); });
proxy.client.alertaVentana = AlertaVentana; proxy.client.alertaVentana = AlertaVentana;
proxy.client.ContadorCampana = ContadorCampana;
proxy.client.Execstring = Execstring; proxy.client.Execstring = Execstring;
@@ -138,7 +143,7 @@ var NotificacionesADS = function () {
setTimeout(function () { setTimeout(function () {
nointentos = nointentos + 1; nointentos = nointentos + 1;
if (nointentos < maxintentos) { if (nointentos < maxintentos) {
$.connection.hub.start().done(function () { console.log('(SignalR)Bienvenido'); nointentos = 0; }) $.connection.hub.start().done(function () { console.log('(SignalR) Bienvenido'); nointentos = 0; })
.fail(function () { console.log(' (SignalR) no conectado (Intento:' + nointentos + ')'); signalrconectionStar(1200); }); .fail(function () { console.log(' (SignalR) no conectado (Intento:' + nointentos + ')'); signalrconectionStar(1200); });
} }
}, TimeOut); }, TimeOut);
@@ -159,6 +164,8 @@ var NotificacionesADS = function () {
/// ///
x = 1; x = 1;
} }
console.log({ key: evt.key });
console.log({newValue: evt.newValue});
switch (evt.key + "") { switch (evt.key + "") {
case 'ADSCloseConection': case 'ADSCloseConection':
closeopenConexion(); closeopenConexion();
@@ -173,6 +180,15 @@ var NotificacionesADS = function () {
window.removeEventListener("beforeunload", beforeunloadcloseopenConexion); window.removeEventListener("beforeunload", beforeunloadcloseopenConexion);
} }
break; break;
case 'ContadorCampana':
try {
console.log('(SignalR) contadormessage \'' + evt.newValue);
} catch (e) {
console.error('(SignalR) contadormessage \''+e);
}
break;
case 'ADSNotificaciones': case 'ADSNotificaciones':
try { try {
let obj = JSON.parse(evt.newValue); let obj = JSON.parse(evt.newValue);