Notificaciones on campana
This commit is contained in:
@@ -201,6 +201,32 @@ Public Class ClsPaginas
|
|||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
#Region "GlobalDTs"
|
#Region "GlobalDTs"
|
||||||
|
|
||||||
|
Public Shared Property GlobalDTNotificacionesUsuarios(CveUsuario As Integer, CveEmpresa As Integer) As DataTable
|
||||||
|
Get
|
||||||
|
Dim AppNombre As String = $"GlobalDTNotificacionesUsuarios-{CveEmpresa}"
|
||||||
|
If HttpContext.Current.Application(AppNombre) Is Nothing Then
|
||||||
|
Using ObjUsuarios As New ClsSisNotificaciones
|
||||||
|
If ObjUsuarios.NotificacionesUsuariosGet(-1, CveEmpresa) Then HttpContext.Current.Application(AppNombre) = ObjUsuarios.DtResultados
|
||||||
|
End Using
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim filtros As New List(Of String)
|
||||||
|
If CveUsuario <> -1 Then filtros.Add($"CveUsuario = {CveUsuario}")
|
||||||
|
If filtros.Count > 0 Then
|
||||||
|
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), String.Join(" AND ", filtros), "", DataViewRowState.CurrentRows)
|
||||||
|
GlobalDTNotificacionesUsuarios = Dv.ToTable
|
||||||
|
Dv.Dispose()
|
||||||
|
Else
|
||||||
|
GlobalDTNotificacionesUsuarios = DirectCast(HttpContext.Current.Application(AppNombre), DataTable)
|
||||||
|
End If
|
||||||
|
End Get
|
||||||
|
Set(value As DataTable)
|
||||||
|
Dim AppNombre As String = $"GlobalDTNotificacionesUsuarios-{CveEmpresa}"
|
||||||
|
HttpContext.Current.Application(AppNombre) = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
|
||||||
Public Shared Property GlobalTipoCambio(Optional Fecha As Date = MinFecha) As Double
|
Public Shared Property GlobalTipoCambio(Optional Fecha As Date = MinFecha) As Double
|
||||||
Get
|
Get
|
||||||
If GlobalTipoCambio <= 0 Then
|
If GlobalTipoCambio <= 0 Then
|
||||||
|
|||||||
@@ -2323,7 +2323,107 @@ Public Class ClsSisNotificaciones
|
|||||||
Return retorno
|
Return retorno
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
#Region "Notifica2.0"
|
||||||
|
''' <summary>
|
||||||
|
''' Obtiene mensajes de notificaciones de usuarios, por defecto obtine los ultimos 20.
|
||||||
|
''' </summary>
|
||||||
|
''' <param name="cveusuarioPara">Clave del usuario destinatario.</param>
|
||||||
|
''' <param name="cveEmpresa">Clave de la empresa.</param>
|
||||||
|
''' <param name="mostrarTodos">determina si retorna todos los mensanjes o solo los ultimos 20.</param>
|
||||||
|
''' <returns>Devuelve True si la operación fue exitosa, de lo contrario False.</returns>
|
||||||
|
Public Function NotificacionesUsuariosMensajesGet(cveusuario As Int32, cveEmpresa As Int32, mostrarTodos As Boolean, verVistos As Boolean) As Boolean
|
||||||
|
Dim retorno As Boolean = False
|
||||||
|
DataAdapter("PA_SIGNotificacionesUsuariosMensajesGet", CommandType.StoredProcedure)
|
||||||
|
|
||||||
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
|
.Add("@CveusuarioPara", SqlDbType.Int).Value = cveusuario
|
||||||
|
.Add("@CveEmpresa", SqlDbType.Int).Value = cveEmpresa
|
||||||
|
.Add("@MostrarTodos", SqlDbType.Bit).Value = mostrarTodos
|
||||||
|
.Add("@verVistos", SqlDbType.Bit).Value = verVistos
|
||||||
|
End With
|
||||||
|
|
||||||
|
Try
|
||||||
|
SqlAdapter.Fill(Data)
|
||||||
|
retorno = True
|
||||||
|
Catch Ex1 As SqlException
|
||||||
|
Me.OnError("Ocurrió un error al intentar obtener Notificación.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al intentar obtener Notificación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||||
|
End Try
|
||||||
|
Return retorno
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
''' <summary>
|
||||||
|
''' Obtiene notificaciones de usuarios.
|
||||||
|
''' </summary>
|
||||||
|
''' <param name="cveusuarioPara">Clave del usuario destinatario.</param>
|
||||||
|
''' <param name="cveEmpresa">Clave de la empresa.</param>
|
||||||
|
''' <param name="mostrarTodos">determina si retorna todos los mensanjes o solo los ultimos 20.</param>
|
||||||
|
''' <returns>Devuelve True si la operación fue exitosa, de lo contrario False.</returns>
|
||||||
|
Public Function NotificacionesUsuariosGet(cveusuario As Int32, cveEmpresa As Int32) As Boolean
|
||||||
|
Dim retorno As Boolean = False
|
||||||
|
DataAdapter("PA_SIGNotificacionesUsuariosGet", CommandType.StoredProcedure)
|
||||||
|
|
||||||
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
|
.Add("@Cveusuario", SqlDbType.Int).Value = cveusuario
|
||||||
|
.Add("@CveEmpresa", SqlDbType.Int).Value = cveEmpresa
|
||||||
|
End With
|
||||||
|
|
||||||
|
Try
|
||||||
|
SqlAdapter.Fill(Data)
|
||||||
|
retorno = True
|
||||||
|
Catch Ex1 As SqlException
|
||||||
|
Me.OnError("Ocurrió un error al intentar obtener Notificación.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al intentar obtener Notificación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||||
|
End Try
|
||||||
|
Return retorno
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function NotificacionesUsuariosAdd(cveOrigen As Int32, cveusuarioPara As Int32, cveUsuarioDe As Int32, notificaCorreo As Boolean, notificaToast As Boolean, notificaCampana As Boolean,
|
||||||
|
icono As String, asunto As String, mensaje As String, cveEmpresa As Int32) As Boolean
|
||||||
|
Dim notificacion As String = "1"
|
||||||
|
NotificacionesUsuariosMensajesAdd(cveOrigen, cveusuarioPara, cveUsuarioDe, notificaCorreo, notificaToast, notificaCampana, icono, asunto, mensaje, cveEmpresa)
|
||||||
|
If (notificaCampana) Then
|
||||||
|
If (Not IsNothing(Data) AndAlso Data.Rows.Count > 0) Then
|
||||||
|
notificacion = Data(0)("Notificaciones").ToString()
|
||||||
|
End If
|
||||||
|
Dim _hubContext As IHubContext = GlobalHost.ConnectionManager.GetHubContext(Of Notificaciones)()
|
||||||
|
_hubContext.Clients.Client(Notificaciones.UsuariosConexiones(cveusuarioPara)).ContadorCampana(notificacion)
|
||||||
|
ClsPaginas.GlobalDTNotificacionesUsuarios(-1, cveEmpresa) = Nothing
|
||||||
|
End If
|
||||||
|
|
||||||
|
End Function
|
||||||
|
Private Function NotificacionesUsuariosMensajesAdd(cveOrigen As Int32, cveusuarioPara As Int32, cveUsuarioDe As Int32, notificaCorreo As Boolean, notificaToast As Boolean, notificaCampana As Boolean,
|
||||||
|
icono As String, asunto As String, mensaje As String, cveEmpresa As Int32) As Boolean
|
||||||
|
Dim retorno As Boolean = False
|
||||||
|
DataAdapter("PA_SIGNotificacionesUsuariosMensajesAdd", CommandType.StoredProcedure)
|
||||||
|
|
||||||
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
|
.Add("@CveOrigen", SqlDbType.Int).Value = cveOrigen
|
||||||
|
.Add("@CveusuarioPara", SqlDbType.Int).Value = cveusuarioPara
|
||||||
|
.Add("@CveUsuarioDe", SqlDbType.Int).Value = cveUsuarioDe
|
||||||
|
.Add("@NotificaCorreo", SqlDbType.Bit).Value = notificaCorreo
|
||||||
|
.Add("@NotificaToast", SqlDbType.Bit).Value = notificaToast
|
||||||
|
.Add("@NotificaCampana", SqlDbType.Bit).Value = notificaCampana
|
||||||
|
.Add("@Icono", SqlDbType.VarChar).Value = icono
|
||||||
|
.Add("@Asunto", SqlDbType.VarChar).Value = asunto
|
||||||
|
.Add("@Mensaje", SqlDbType.VarChar).Value = mensaje
|
||||||
|
.Add("@CveEmpresa", SqlDbType.Int).Value = cveEmpresa
|
||||||
|
End With
|
||||||
|
Try
|
||||||
|
SqlAdapter.Fill(Data)
|
||||||
|
retorno = True
|
||||||
|
Catch Ex1 As SqlException
|
||||||
|
Me.OnError("Ocurrió un error al intentar agregar Notificación.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al intentar agregar Notificación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||||
|
End Try
|
||||||
|
Return retorno
|
||||||
|
Return retorno
|
||||||
|
End Function
|
||||||
|
#End Region
|
||||||
|
|
||||||
|
|
||||||
#Region " IDisposable Support "
|
#Region " IDisposable Support "
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ Public Class NotificacionesSQLWatcher
|
|||||||
Using connection As New SqlConnection(rutadb)
|
Using connection As New SqlConnection(rutadb)
|
||||||
' Consulta para detectar cambios recientes
|
' Consulta para detectar cambios recientes
|
||||||
Dim command As New SqlCommand(
|
Dim command As New SqlCommand(
|
||||||
"SELECT CveUsuario, Notificaciones, Fecha FROM NotificacionesUsuarios", connection)
|
"SELECT CveUsuario, Notificaciones, Fecha FROM SIG_NotificacionesUsuarios", connection)
|
||||||
|
|
||||||
' Asociar dependencia SQL a la consulta
|
' Asociar dependencia SQL a la consulta
|
||||||
Dim dependency As New SqlDependency(command)
|
Dim dependency As New SqlDependency(command)
|
||||||
@@ -51,7 +51,7 @@ Public Class NotificacionesSQLWatcher
|
|||||||
' Método para enviar notificaciones solo de los registros actualizados
|
' Método para enviar notificaciones solo de los registros actualizados
|
||||||
Private Sub SendNotifications()
|
Private Sub SendNotifications()
|
||||||
Using connection As New SqlConnection(rutadb)
|
Using connection As New SqlConnection(rutadb)
|
||||||
Dim query As String = "SELECT CveUsuario, Notificaciones, Fecha FROM NotificacionesUsuarios WHERE Fecha > DATEADD(MINUTE, -1, GETDATE())"
|
Dim query As String = "SELECT CveUsuario, Notificaciones, Fecha FROM SIG_NotificacionesUsuarios WHERE Fecha > DATEADD(MINUTE, -1, GETDATE())"
|
||||||
Dim command As New SqlCommand(query, connection)
|
Dim command As New SqlCommand(query, connection)
|
||||||
|
|
||||||
connection.Open()
|
connection.Open()
|
||||||
|
|||||||
@@ -49,9 +49,9 @@
|
|||||||
GlobalConfiguration.Configure(AddressOf WebApiConfig.Register)
|
GlobalConfiguration.Configure(AddressOf WebApiConfig.Register)
|
||||||
GlobalConfiguration.Configuration.EnsureInitialized()
|
GlobalConfiguration.Configuration.EnsureInitialized()
|
||||||
|
|
||||||
|
'se comenta ya que se envbia directo desde el metodo NotificacionesUsuariosAdd en clssisnotificaciones
|
||||||
Dim watcher As New NotificacionesSQLWatcher()
|
'Dim watcher As New NotificacionesSQLWatcher()
|
||||||
watcher.StartWatching()
|
'watcher.StartWatching()
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|||||||
25
Site.master
25
Site.master
@@ -20,12 +20,12 @@
|
|||||||
</style>
|
</style>
|
||||||
<%: Scripts.Render("~/bundles/modernizr") %>
|
<%: Scripts.Render("~/bundles/modernizr") %>
|
||||||
<%: Styles.Render("~/Content/AjaxControlToolkit/Styles/Bundle") %>
|
<%: Styles.Render("~/Content/AjaxControlToolkit/Styles/Bundle") %>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com"/>
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="anonymous" />
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="anonymous" />
|
||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" type="text/css" />
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" type="text/css" />
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700;800" rel="stylesheet"/>
|
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700;800" rel="stylesheet" />
|
||||||
<link href="/Metronic/fontawesome6/css/all.min.css" rel="stylesheet" type="text/css" />
|
<link href="/Metronic/fontawesome6/css/all.min.css" rel="stylesheet" type="text/css" />
|
||||||
<link rel="stylesheet" type="text/css" href="/Scripts/PrintJS/print.min.css"/>
|
<link rel="stylesheet" type="text/css" href="/Scripts/PrintJS/print.min.css" />
|
||||||
<%-- <link href="/Metronic/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
|
<%-- <link href="/Metronic/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
|
||||||
<link href="/Metronic/assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
|
<link href="/Metronic/assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
|
||||||
<link href="/Metronic/assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />--%>
|
<link href="/Metronic/assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />--%>
|
||||||
@@ -139,13 +139,18 @@
|
|||||||
<span class='SigCampananoti badge <%=If(countNotificaciones > 0, "badge-danger", "badge-default") %>'><%= countNotificaciones %> </span>
|
<span class='SigCampananoti badge <%=If(countNotificaciones > 0, "badge-danger", "badge-default") %>'><%= countNotificaciones %> </span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li class="external">
|
<li class="external" onclick ="$('.btnSigCampananoti').click();">
|
||||||
<h3><span class="bold"><%= countNotificaciones %></span> Notificaciones pendientes</h3>
|
<h3>Click para ver notificaciones (<span class="bold"><%= countNotificaciones %></span>) pendientes</h3>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<ul class="dropdown-menu-list scroller" style="height: 250px;" data-handle-color="#637283">
|
<asp:UpdatePanel ID="UpNotificaciones" runat="server" UpdateMode="Conditional">
|
||||||
<asp:Literal ID="LtlMNotificaciones" runat="server"></asp:Literal>
|
<ContentTemplate>
|
||||||
</ul>
|
<asp:Button ID="btnSigCampananoti" CssClass="btnSigCampananoti" runat="server" Text="Enviar" OnClick="btnSigCampananoti_Click" Style="display:none" />
|
||||||
|
<ul class="dropdown-menu-list scroller" style="height: 250px;" data-handle-color="#637283">
|
||||||
|
<asp:Literal ID="LtlMNotificaciones" runat="server"></asp:Literal>
|
||||||
|
</ul>
|
||||||
|
</ContentTemplate>
|
||||||
|
</asp:UpdatePanel>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@@ -347,8 +352,8 @@
|
|||||||
<div class="page-container" runat="server" id="divpagecontainer">
|
<div class="page-container" runat="server" id="divpagecontainer">
|
||||||
|
|
||||||
<!-- BEGIN SIDEBAR -->
|
<!-- BEGIN SIDEBAR -->
|
||||||
<div class="page-sidebar-wrapper" runat="server" id="divMenuB" style=" position: fixed;">
|
<div class="page-sidebar-wrapper" runat="server" id="divMenuB" style="position: fixed;">
|
||||||
<div class="page-sidebar navbar-collapse collapse" >
|
<div class="page-sidebar navbar-collapse collapse">
|
||||||
<!-- add "navbar-no-scroll" class to disable the scrolling of the sidebar menu -->
|
<!-- add "navbar-no-scroll" class to disable the scrolling of the sidebar menu -->
|
||||||
<!-- BEGIN SIDEBAR MENU -->
|
<!-- BEGIN SIDEBAR MENU -->
|
||||||
<ul class="page-sidebar-menu" id='ulmenulateralmaster' data-keep-expanded="false" data-auto-scroll="true" data-slide-speed="200">
|
<ul class="page-sidebar-menu" id='ulmenulateralmaster' data-keep-expanded="false" data-auto-scroll="true" data-slide-speed="200">
|
||||||
|
|||||||
@@ -435,12 +435,19 @@ Partial Class Site
|
|||||||
|
|
||||||
#Region "Notificaciones"
|
#Region "Notificaciones"
|
||||||
|
|
||||||
Private Sub CargarNotificaciones()
|
Protected Sub btnSigCampananoti_Click(sender As Object, e As EventArgs)
|
||||||
|
CargarNotificaciones(True)
|
||||||
|
End Sub
|
||||||
|
Private Sub CargarNotificaciones(Optional obtnerNotis As Boolean = False)
|
||||||
Dim Notificaciones As New StringBuilder
|
Dim Notificaciones As New StringBuilder
|
||||||
|
|
||||||
'Bienvenida
|
'Bienvenida
|
||||||
Notificaciones.Append(ItemNotificaciones("Bienvenido a SIG ", "Hoy", "fa fa-bullhorn"))
|
'Notificaciones.Append(ItemNotificaciones("Bienvenido a SIG ", "Hoy", "fa fa-bullhorn"))
|
||||||
|
countNotificaciones = 0
|
||||||
|
Dim dt As DataTable = ClsPaginas.GlobalDTNotificacionesUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||||
|
If Not IsNothing(dt) AndAlso dt.Rows.Count() > 0 Then
|
||||||
|
countNotificaciones = dt(0)("Notificaciones").ToString().ToEntero()
|
||||||
|
End If
|
||||||
'Certificado
|
'Certificado
|
||||||
Dim fechacer As String = ConvertCER()
|
Dim fechacer As String = ConvertCER()
|
||||||
If fechacer = "" OrElse (((DateTime.Parse(fechacer).Month - ClsPaginas.NowADS().Month) < 2) AndAlso ((DateTime.Parse(fechacer).Year - ClsPaginas.NowADS().Year) < 1)) Then
|
If fechacer = "" OrElse (((DateTime.Parse(fechacer).Month - ClsPaginas.NowADS().Month) < 2) AndAlso ((DateTime.Parse(fechacer).Year - ClsPaginas.NowADS().Year) < 1)) Then
|
||||||
@@ -461,6 +468,16 @@ Partial Class Site
|
|||||||
End If
|
End If
|
||||||
OC.Dispose()
|
OC.Dispose()
|
||||||
End If
|
End If
|
||||||
|
If obtnerNotis Then
|
||||||
|
Using objnoti As New ClsSisNotificaciones()
|
||||||
|
If objnoti.NotificacionesUsuariosMensajesGet(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, True, True) Then
|
||||||
|
|
||||||
|
For Each row As DataRow In objnoti.DtResultados.Rows
|
||||||
|
Notificaciones.Append(ItemNotificaciones(row("Mensaje").ToString(), row("Asunto").ToString(), row("Icono").ToString()))
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
End Using
|
||||||
|
End If
|
||||||
'If UsuarioActual.TienePermisoProceso(303) Then
|
'If UsuarioActual.TienePermisoProceso(303) Then
|
||||||
' Using objgen As New ClsGenerales
|
' Using objgen As New ClsGenerales
|
||||||
' pnlNotificacionSAT.Visible = True
|
' pnlNotificacionSAT.Visible = True
|
||||||
@@ -487,7 +504,8 @@ Partial Class Site
|
|||||||
'End If
|
'End If
|
||||||
'OC.Dispose()
|
'OC.Dispose()
|
||||||
|
|
||||||
LtlMNotificaciones.Text = String.Format("{0}{1}", LtlMNotificaciones.Text, Notificaciones.ToString())
|
'LtlMNotificaciones.Text = String.Format("{0}{1}", LtlMNotificaciones.Text, Notificaciones.ToString())
|
||||||
|
LtlMNotificaciones.Text = Notificaciones.ToString()
|
||||||
Notificaciones.Clear()
|
Notificaciones.Clear()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -593,4 +611,5 @@ Partial Class Site
|
|||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
Reference in New Issue
Block a user