Files
SIG/Global.asax
2023-05-14 09:32:23 -07:00

180 lines
10 KiB
Plaintext

<%@ Application Language="VB" %>
<%@ Import Namespace="System.Web.Optimization" %>
<%@ Import Namespace="Extensiones" %>
<%@ Import Namespace="system.data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="Microsoft.AspNet.SignalR" %>
<%@ Import Namespace="System.Web.Http" %>
<%@ Import Namespace="ADSSession" %>
<script RunAt="server">
Public ReadOnly Property EsProduccion As String
Get
If IsNothing(System.Configuration.ConfigurationManager.AppSettings("EsProduccion")) Then
Return "0"
Else
Return System.Configuration.ConfigurationManager.AppSettings("EsProduccion").ToString()
End If
End Get
End Property
Private Sub GuardaLogAsax(str As String)
'GuardaLog(str)
End Sub
Sub Application_Start(sender As Object, e As EventArgs)
Stimulsoft.Base.StiLicense.Key = "6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHmhQEs54hwXWiqhb7jE6yoykR4jHwP3Mz0nuxn0JR9fNMeDKv" + "sS5s+rCYr7Ex4DRTHaUJIUDqrvGmvWyMjzUl9RAEz/XG8RenfJvoEilBZ9Wqq8Uu/n92YhChB4PbAh9FeH3abSU3PF" + "LuVa6GydYWQvZGpHhFs98Idp754TAgWZatzcF3Ksp6q4laYxnyUY0cA0hYejanRBjIT1Nu59xmlOKE7EGIb9wKlLn/" + "XnW8k8PUNuReOk7ATeHO07JSMLikmvIytkWET2bXDmBI43tAX3fLUE+KlOe7FR/hvfQ6oqqtVRlSZ22QBanel09+XE" + "X8aVC8b+WuRv1nInJeQHBD9zF8b67n4ouKRgv2/vSxopOhCZXdaqdyO4ct+FmSC8cAAcMIGeiKnc5ww8Cq44ClTqJl" + "V2qsCjoS4bb8Nzd2Gy+q/TG/D3dAEKSpPGUx2EEksora/kIkNooq6+bgyH7hqCG2bHKaSQwr2g0keNrYIUcTIwROn1" + "cnQDetzsBqX4lvu64VZWq5+cQD+dyPJwOS6M"
Dim sessionData As New Dictionary(Of String, HttpSessionState)()
Application("s") = sessionData
'BANDERA PARA VALIDACION DE CFDI
Application("GlobalValidarCFDI") = True
'-------------------------------------------------------------------------------------------------------------------------
'A M O R T I Z A C I O N - C O N T A B L E
GuardaLogAsax(String.Format("Globalasax 5:{0}", DateTime.Now))
Using ObjAC As New ClsAC
If ObjAC.GetFuenteFinanciamientoCONAC() Then Application("GlobalDTAC_FuentesFinanciamientoCONAC") = ObjAC.DtResultados Else Application("GlobalDTAC_FuentesFinanciamientoCONAC") = Nothing
If ObjAC.GetProgramaCONAC() Then Application("GlobalDTAC_ProgramasCONAC") = ObjAC.DtResultados Else Application("GlobalDTAC_ProgramasCONAC") = Nothing
If ObjAC.GetPD_Programas() Then Application("GlobalDTAC_PD_Programas") = ObjAC.DtResultados Else Application("GlobalDTAC_PD_Programas") = Nothing
If ObjAC.GetPD_Estrategias() Then Application("GlobalDTAC_PD_Estrategias") = ObjAC.DtResultados Else Application("GlobalDTAC_PD_Estrategias") = Nothing
If ObjAC.GetPD_LineasAccion() Then Application("GlobalDTAC_PD_LineasAccion") = ObjAC.DtResultados Else Application("GlobalDTAC_PD_LineasAccion") = Nothing
If ObjAC.GetPD_Metas() Then Application("GlobalDTAC_PD_Metas") = ObjAC.DtResultados Else Application("GlobalDTAC_PD_Metas") = Nothing
If ObjAC.GetTipoGasto() Then Application("GlobalDTAC_TipoGasto") = ObjAC.DtResultados Else Application("GlobalDTAC_TipoGasto") = Nothing
If ObjAC.GetRubrosIngreso() Then Application("GlobalDTAC_RubrosIngreso") = ObjAC.DtResultados Else Application("GlobalDTAC_RubrosIngreso") = Nothing
If ObjAC.GetMatrizID Then Application("GlobalDTAC_MatrizIngresos") = ObjAC.DtResultados Else Application("GlobalDTAC_MatrizIngresos") = Nothing
If ObjAC.GetMatrizGD Then Application("GlobalDTAC_MatrizEgresos") = ObjAC.DtResultados Else Application("GlobalDTAC_MatrizEgresos") = Nothing
End Using
GuardaLogAsax(String.Format("Globalasax 6:{0}", DateTime.Now))
Using Finan As New ClsFinanzas
If Finan.GetRazonesFinancieras(-1) Then Application("GlobalDTFinan_RazonesFinancieras") = Finan.DtResultados
End Using
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------S I S T E M A ----------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'P A R A M E T R O S
Using ObjParametros As New ClsSisParametros
If ObjParametros.GetParametros Then Application("GlobalDTParametros") = ObjParametros.DtResultados Else Application("GlobalDTParametros") = Nothing
End Using
GuardaLogAsax(String.Format("Globalasax 35:{0}", DateTime.Now))
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'G L O B A L E S A P L I C A C I Ó N
'Using ObjGral As New ClsGenerales
' If ObjGral.GetTipoCambio(-1, Now) Then
' If ObjGral.DtResultados.Rows.Count > 0 Then
' Application("GlobalTipoCambio") = ObjGral.DtResultados.Rows(0)("TipoCambio").ToString.ToDouble
' End If
' End If
'End Using
'GuardaLogAsax(String.Format("Globalasax 41:{0}", DateTime.Now))
BundleConfig.RegistrarBundles(BundleTable.Bundles)
BundleTable.EnableOptimizations = True
' System.Web.UI.ValidationSettings.UnobtrusiveValidationMode = UnobtrusiveValidationMode.None
Dim EmpresaNotificaciones As New Empresa With {.SendMail = "signotificaciones@adssistemas.mx", .SendMailPassword = "sig123987", .SendMailServer = "mail.adssistemas.mx", .SendMailPuerto = 587}
ClsPaginas.EmpresaNotificaciones = EmpresaNotificaciones
Dim EmpresaNotificacionesGPS As New Empresa With {.SendMail = "ALERTAS@SIGNALSGPS.com", .SendMailPassword = "STJ180705IV42021ad", .SendMailServer = "mail.signalsgps.com", .SendMailPuerto = 587}
ClsPaginas.EmpresaNotificacionesGPS = EmpresaNotificacionesGPS
''------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'' R A S T R E O
'Using ObjGPS As New ClsGPS
' If ObjGPS.DispositivosGet(-1, -1, -1, -1) Then
' If ObjGPS.DtResultados.Rows.Count > 0 Then
' Application("GlobalDTDispositivos") = ObjGPS.DtResultados
' Else
' Application("GlobalDTDispositivos") = Nothing
' End If
' End If
' If ObjGPS.DispositivosUsuariosGet(-1, -1, -1, -1, -1) Then
' If ObjGPS.DtResultados.Rows.Count > 0 Then
' Application("GlobalDTDispositivosUsuarios") = ObjGPS.DtResultados
' Else
' Application("GlobalDTDispositivosUsuarios") = Nothing
' End If
' End If
'End Using
'GuardaLogAsax(String.Format("Globalasax 42:{0}", DateTime.Now))
'If EsProduccion = "1" Then
' RegisterNotification()
'End If
'-----------------
GlobalConfiguration.Configure(AddressOf WebApiConfig.Register)
GlobalConfiguration.Configuration.EnsureInitialized()
End Sub
Sub Application_End(sender As Object, e As EventArgs)
'If EsProduccion = "1" Then
' SqlDependency.Stop(ConfigurationManager.ConnectionStrings("Conexion").ConnectionString)
'End If
' Code that runs on application shutdown
End Sub
Sub Application_Error(sender As Object, e As EventArgs)
' Code that runs when an unhandled error occurs
Dim CveUsuario As String = ""
Dim Nombre As String = ""
Try
Dim user As Usuario = ADSSessionConfig.sessionUser
If Not IsNothing(user) Then
CveUsuario = user.CveUsuario.ToString()
Nombre = user.Nombre
End If
Catch ex As Exception
Usuario.CerrarSession()
End Try
Dim InfoAdicional As String = vbCrLf & "CveUsuario: " & CveUsuario & "; Nombre: " & Nombre & vbCrLf & "Ruta: " & Context.Request.RawUrl & " "
OnError("Ocurrió un error en la página.", Context.Error, InfoAdicional)
End Sub
Sub Session_Start(sender As Object, e As EventArgs)
' Code that runs when a new session is started
'Dim sessionData As Dictionary(Of String, HttpSessionState) = DirectCast(Application("s"), Dictionary(Of String, HttpSessionState))
'If sessionData.Keys.Contains(HttpContext.Current.Session.SessionID) Then
' sessionData.Remove(HttpContext.Current.Session.SessionID)
' sessionData.Add(HttpContext.Current.Session.SessionID, HttpContext.Current.Session)
'Else
' sessionData.Add(HttpContext.Current.Session.SessionID, HttpContext.Current.Session)
'End If
'Application("s") = sessionData
End Sub
Sub Session_End(sender As Object, e As EventArgs)
Dim objsession As Object = ADSSessionConfig.SessionManager(OpcionSession.removerSession, Nothing, -1, Session.SessionID)
If Not IsNothing(objsession) Then
'MyHub.RemoveConexiones(DirectCast(objsession, ADSSessionObj).CveUsuario)
End If
'Code that runs when a session ends.
' Note: The Session_End event Is raised only when the sessionstate mode
' Is set to InProc in the Web.config file. If session mode Is set to StateServer
'' or SQLServer, the event is not raised.
'Dim sessionData As Dictionary(Of String, HttpSessionState) = DirectCast(Application("s"), Dictionary(Of String, HttpSessionState))
'sessionData.Remove(HttpContext.Current.Session.SessionID)
'Application("s") = sessionData
End Sub
</script>