Commit inicial Ventas Productivo
This commit is contained in:
283
LogIn.aspx.vb
Normal file
283
LogIn.aspx.vb
Normal file
@@ -0,0 +1,283 @@
|
||||
Imports System.Data
|
||||
Imports ADSSession
|
||||
Imports Extensiones
|
||||
|
||||
Partial Class LogIn
|
||||
Inherits System.Web.UI.Page
|
||||
|
||||
#Region " PROPIEDADES "
|
||||
Private Property CveUsuario As Integer
|
||||
Get
|
||||
Return ViewState("CveUsuario").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveUsuario") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property CveEmpresa As Integer
|
||||
Get
|
||||
Return ViewState("CveEmpresa").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveEmpresa") = value
|
||||
End Set
|
||||
End Property
|
||||
#End Region
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
'"187.158.96.163" es la de mi casa
|
||||
Dim iplist As String() = New String() {"", ""}
|
||||
If HttpContext.Current.Request.ServerVariables("REMOTE_ADDR").ToString().Contiene(iplist) Then
|
||||
Response.Redirect("http://www.adsistemas.mx/login.aspx") 'si alguien lo ve es correcto la pagina vieja de adsistemas
|
||||
End If
|
||||
If Not Page.IsPostBack Then
|
||||
|
||||
Dim strimg As New StringBuilder
|
||||
strimg.AppendLine("var imagenes= {'Metronic/assets/admin/pages/media/bg/1.jpg': 'center',")
|
||||
strimg.AppendLine(" 'Metronic/assets/admin/pages/media/bg/2.jpg': 'center',")
|
||||
strimg.AppendLine(" 'Metronic/assets/admin/pages/media/bg/3.jpg': 'center',")
|
||||
strimg.AppendLine(" 'Metronic/assets/admin/pages/media/bg/4.jpg': 'center'")
|
||||
strimg.AppendLine(" }")
|
||||
'strimg.AppendLine("var imagenes= ['Metronic/assets/admin/pages/media/bg/1.jpg',")
|
||||
'strimg.AppendLine(" 'Metronic/assets/admin/pages/media/bg/2.jpg',")
|
||||
'strimg.AppendLine(" 'Metronic/assets/admin/pages/media/bg/3.jpg',")
|
||||
'strimg.AppendLine(" 'Metronic/assets/admin/pages/media/bg/4.jpg'")
|
||||
'strimg.AppendLine(" ]")
|
||||
|
||||
'Alert(Request.Url.Host.ToUpper().Contains("SIGNALSGPS"), TipoMensaje.MsgConfirmacion)
|
||||
If Request.Url.Host.ToUpper().Contains("SIGNALSGPS".ToUpper()) Then
|
||||
strimg.Clear()
|
||||
strimg.AppendLine("var imagenes= {")
|
||||
strimg.AppendLine(" 'Scripts/login/Layout1/images/bg01.jpg': 'center',")
|
||||
strimg.AppendLine(" 'Scripts/login/Layout1/images/bg02.jpg': 'center',")
|
||||
strimg.AppendLine(" 'Scripts/login/Layout1/images/bg03.jpg': 'center',")
|
||||
strimg.AppendLine(" }")
|
||||
'strimg.AppendLine("var imagenes= [")
|
||||
'strimg.AppendLine(" 'Scripts/login/Layout1/images/bg01.jpg',")
|
||||
'strimg.AppendLine(" 'Scripts/login/Layout1/images/bg02.jpg',")
|
||||
'strimg.AppendLine(" 'Scripts/login/Layout1/images/bg03.jpg',")
|
||||
'strimg.AppendLine(" ]")
|
||||
LtlImgLogo.Text = "<img class="""" src=""Scripts/Login/Layout1/images/SignalLogo.png"" />"
|
||||
LtlAppName.Text = "SIGNAL GPS <br/> tu plataforma de rastreo"
|
||||
Ltlcopyright.Text = "2019 © Sistema de Monitoreo y Telemedición SA de CV"
|
||||
Ltlcopyright2.Text = "2019 © Sistema de Monitoreo y Telemedición SA de CV"
|
||||
PnlLoginB.CssClass = "logincint login-form "
|
||||
PnlContraB.CssClass = "logincint login-form "
|
||||
Else
|
||||
End If
|
||||
|
||||
HdfImagenes.Value = strimg.ToString()
|
||||
TxtUsuario.Focus()
|
||||
Me.Form.DefaultButton = BtnLogIn.ClientID
|
||||
If Request("p") IsNot Nothing AndAlso Request("p") <> "" Then
|
||||
Dim Salida As String = Decripta(Request("p"))
|
||||
|
||||
If Salida <> "" Then
|
||||
Dim UrlParametros As Hashtable = Parametros(Salida)
|
||||
|
||||
If UrlParametros("OPCION") IsNot Nothing AndAlso UrlParametros("OPCION").ToString = "Activar" Then
|
||||
|
||||
If UrlParametros("CVEU") IsNot Nothing AndAlso UrlParametros("CVEU").ToString.ToEntero > 0 Then
|
||||
CveUsuario = UrlParametros("CVEU").ToString.ToEntero
|
||||
CveEmpresa = UrlParametros("CVEE").ToString.ToEntero
|
||||
'Activo el usuario y redirecciono para que pida la nueva contraseña
|
||||
Dim currentDate As Date = Date.Now
|
||||
Dim elapsedTicks As Long = currentDate.Ticks - UrlParametros("HORA").ToString.ToLong
|
||||
Dim elapsedSpan As New TimeSpan(elapsedTicks)
|
||||
PnlLogin.Visible = False
|
||||
|
||||
|
||||
If elapsedSpan.Days < 3 Then
|
||||
|
||||
Dim Usr As New ClsSisUsuarios
|
||||
If Usr.GetUsuarios(CveUsuario, -1, -1) Then
|
||||
|
||||
Dim dr As DataRow = Usr.DtResultados.FiltroPrimero("")
|
||||
|
||||
If dr IsNot Nothing Then
|
||||
If dr("PolCambiarContraseña").ToString = "SI" Then
|
||||
PnlContra.Visible = True
|
||||
'HCambio.Visible = True
|
||||
'HdnCveUsr.Value = CveUsuario.ToString
|
||||
Me.Form.DefaultButton = BtnGuardar.ClientID
|
||||
'If Usr.UpdateUsuarioPortal(dr("Usuario").ToString, dr("Nombre").ToString,
|
||||
' dr("Permiso1").ToString = "True", dr("Permiso2").ToString = "True", dr("Permiso3").ToString = "True", dr("Permiso4").ToString = "True", dr("Permiso5").ToString = "True",
|
||||
' dr("Permiso6").ToString = "True", dr("Permiso7").ToString = "True", dr("Permiso8").ToString = "True", dr("Permiso9").ToString = "True", dr("Permiso10").ToString = "True",
|
||||
' True, TxtContrasenia1.Text, dr("CveCliente").ToString.ToEntero, dr("CveProveedor").ToString.ToEntero, CveUsr) Then
|
||||
|
||||
' Alert("Contraseña Modificada.", TipoMensaje.MsgConfirmacion, JSBtnAceptar:="location.href=""ConsultaCliente.aspx""")
|
||||
|
||||
'End If
|
||||
Else
|
||||
Alert("El usuario ya cambio su contraseña, inicie sesión normalmente.", TipoMensaje.MsgInformacion)
|
||||
PnlLogin.Visible = True
|
||||
End If
|
||||
Else
|
||||
Alert("El Usuario no existe", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Usr.Dispose()
|
||||
Else
|
||||
Alert("La Activación expiró", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
'TxtContraseña.Text = UrlParametros("CLAVE").ToString.Trim
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
CveUsuario = -1
|
||||
End If
|
||||
Else
|
||||
If CveUsuario > 0 Then
|
||||
BtnGuardar_Click(Nothing, Nothing)
|
||||
Else
|
||||
BtnLogIn_Click(Nothing, Nothing)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function Parametros(Cadena As String) As Hashtable
|
||||
Dim P1() As String = Cadena.Split("&"c)
|
||||
Dim Tmp As String
|
||||
Dim P2() As String
|
||||
|
||||
Dim URLParametros As New Hashtable
|
||||
|
||||
For Each Tmp In P1
|
||||
P2 = Tmp.Split("="c)
|
||||
URLParametros.Add(P2(0).ToString.ToUpper, P2(1))
|
||||
Next
|
||||
Return URLParametros
|
||||
End Function
|
||||
|
||||
Property GlobalDTUsuarios(Optional CveUsuario As Integer = -1, Optional CveEmpresa As Integer = -1) As Data.DataTable
|
||||
Get
|
||||
If CveUsuario <> -1 Then
|
||||
Dim Dv As New Data.DataView(DirectCast(Application("GlobalDTUsuarios"), Data.DataTable), "CveUsuario =" & CveUsuario, "", Data.DataViewRowState.CurrentRows)
|
||||
GlobalDTUsuarios = Dv.ToTable
|
||||
Dv.Dispose()
|
||||
Else
|
||||
GlobalDTUsuarios = DirectCast(Application("GlobalDTUsuarios"), Data.DataTable)
|
||||
End If
|
||||
End Get
|
||||
Set(value As Data.DataTable)
|
||||
Application("GlobalDTUsuarios") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Protected Sub BtnLogIn_Click(ByVal sender As Object, ByVal e As EventArgs) 'Handles CmdLogIn.Click
|
||||
Dim ObjUsuario As New ClsSisUsuarios
|
||||
Dim Usuario As Usuario = Nothing
|
||||
'Dim UsuarioAsignaciones As Usuario = Nothing
|
||||
|
||||
Usuario = ObjUsuario.ValidaUsuario(txtUsuario.Text, Encripta(TxtContraseña.Text.Trim), IMEI)
|
||||
'UsuarioAsignaciones = ObjUsuario.ValidaUsuarioAsignacion(Usuario.CveUsuario, Usuario.CveEmpresa)
|
||||
|
||||
ADSSessionConfig.sessionUser = Usuario
|
||||
ADSSessionConfig.sessionDpage = False
|
||||
ObjUsuario.Dispose()
|
||||
|
||||
If Usuario IsNot Nothing Then
|
||||
CreaObjetoEmpresa(Usuario)
|
||||
ADSSessionConfig.sessionUser.MultipleEmpresa = True
|
||||
|
||||
Dim x As New ADSSessionObj(Usuario.CveUsuario, Usuario.CveEmpresa)
|
||||
Dim _sessionid = Encripta(String.Format("{0}|{1}", Usuario.CveUsuario, x.SessionID))
|
||||
x = ADSSessionConfig.SessionManager(OpcionSession.agregarSession, x)
|
||||
|
||||
If Usuario.CvePlataforma = 6 And Usuario.CveRol = 10 Then
|
||||
'PLATAFORMA PORTAL CLIENTE
|
||||
FormsAuthentication.RedirectFromLoginPage(_sessionid, False)
|
||||
Response.Redirect("/PortalCliente/PortalCliente.aspx", True)
|
||||
ElseIf Usuario.CvePlataforma = 7 And Usuario.CveRol = 11 Then
|
||||
'PLATAFORMA PORTAL PROVEEDOR
|
||||
FormsAuthentication.RedirectFromLoginPage(Encripta(Usuario.CveUsuario), False)
|
||||
Response.Redirect("/PortalProveedor/PortalProveedor.aspx", True)
|
||||
|
||||
ElseIf Usuario.CveRol = 1200 And Usuario.Acceso > 0 Then
|
||||
'PLATAFORMA GPS
|
||||
Usuario.CvePlataforma = 3
|
||||
FormsAuthentication.RedirectFromLoginPage(Encripta(Usuario.CveUsuario), False)
|
||||
|
||||
Response.Redirect("/PortalGPS/InicioGPS.aspx", True)
|
||||
Else
|
||||
'PLATAFORMA SIG
|
||||
CType(Session("UsuarioSIG"), Usuario).CvePlataforma = 1
|
||||
Dim dt As Data.DataTable = GlobalDTUsuarios(Usuario.CveUsuario)
|
||||
If dt IsNot Nothing Then
|
||||
If dt.Rows.Count >= 1 Then
|
||||
If dt.Rows.Count > 1 Then
|
||||
Usuario.MultipleEmpresa = True
|
||||
End If
|
||||
FormsAuthentication.RedirectFromLoginPage(Encripta(Usuario.CveUsuario), False)
|
||||
End If
|
||||
End If
|
||||
dt.Dispose()
|
||||
End If
|
||||
|
||||
'If Usuario.Acceso > 0 Then
|
||||
|
||||
'Else
|
||||
' Alert("Usuario con acceso limitado.", TipoMensaje.MsgAdvertencia)
|
||||
'End If
|
||||
Else
|
||||
Alert("Usuario y/o Contraseña incorrectos.", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CreaObjetoEmpresa(ByRef UsuarioActual As Usuario)
|
||||
|
||||
Dim ObjEmpresa As New ClsSisEmpresas()
|
||||
If ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1") Then
|
||||
If ObjEmpresa.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa) Then
|
||||
Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados
|
||||
|
||||
Dim EmpresasFuncionalidades As New HybridDictionary
|
||||
For Each Row As Data.DataRow In dttmp.Rows
|
||||
EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString)
|
||||
Next
|
||||
ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades)
|
||||
End If
|
||||
|
||||
UsuarioActual.Empresa = ObjEmpresa.Empresa
|
||||
Else
|
||||
End If
|
||||
ObjEmpresa.Dispose()
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
|
||||
Dim TieneError As Boolean = False
|
||||
Dim ObjUsuario As New ClsSisUsuarios
|
||||
|
||||
If ObjUsuario.UpdateUsuarioContrasenia(Encripta(TxtContrasenia1.Text), CveUsuario, CveEmpresa) Then
|
||||
If ObjUsuario.GetUsuarios(CveUsuario) Then
|
||||
If ObjUsuario.DtResultados.Rows.Count = 1 Then
|
||||
Dim dr As DataRow = ObjUsuario.DtResultados.Rows(0)
|
||||
|
||||
txtUsuario.Text = dr("Usuario").ToString
|
||||
Dim Contraseña As String = Decripta(dr("Contraseña").ToString)
|
||||
TxtContraseña.Text = Contraseña
|
||||
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
ObjUsuario.Dispose()
|
||||
|
||||
If Not TieneError Then
|
||||
BtnLogIn_Click(Nothing, Nothing)
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user