예제 #1
0
        public string getUsersList()
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                if (clsUsuario.LoggedUsers.Length > 0)
                {
                    // Cadena que representa el TAB.
                    string strTab = System.Web.UI.HtmlTextWriter.DefaultTabString;
                    // Las comillas dobles.
                    char strQuote = System.Web.UI.HtmlTextWriter.DoubleQuoteChar;
                    // Nueva línea
                    string strNewLine = System.Environment.NewLine;

                    System.Text.StringBuilder sbHTML = new System.Text.StringBuilder();
                    sbHTML.Append(string.Empty);
                    for (int x = (clsUsuario.LoggedUsers.Length - 1); x >= 0; x--)
                    {
                        if (clsUsuario.LoggedUsers[x].UserId.ToLower() != HttpContext.Current.User.Identity.Name.ToLower())
                        {
                            string strTimeSinceLastRequest = (System.DateTime.Now.Subtract(clsUsuario.LoggedUsers[x].datLastRequest)).ToString().Substring(0, 8);
                            if (System.Convert.ToInt16(strTimeSinceLastRequest.Substring(3, 2)) > 1)
                            {
                                clsUsuario Usuario = new clsUsuario();
                                Usuario.DeleteFronConnectedList(clsUsuario.LoggedUsers[x].UserId);
                                Usuario = null;
                                continue;
                            }

                            strTimeSinceLastRequest = (clsUsuario.LoggedUsers[x].datLastRequest.Subtract(clsUsuario.LoggedUsers[x].datUltimoAcceso)).ToString().Substring(0, 8);
                            string strLogoImageName = string.Empty;
                            if (clsUsuario.LoggedUsers[x].RolePrincipal.ToLower() == "director" || clsUsuario.LoggedUsers[x].RolePrincipal.ToLower() == "académico")
                            {
                                strLogoImageName = "logo_academico.gif";
                            }
                            else
                            {
                                strLogoImageName = "logo_" + clsUsuario.LoggedUsers[x].RolePrincipal.ToLower() + ".gif";
                            }
                            sbHTML.Append(strTab + strTab + "<span onclick=" + strQuote + "JavaScript:ShowMessageEditor(this, '" + clsUsuario.LoggedUsers[x].Nombre + " " + clsUsuario.LoggedUsers[x].Apellidos + "');" + strQuote + " id='" + clsUsuario.LoggedUsers[x].UserId + "' title='" + clsUsuario.LoggedUsers[x].Nombre + " " + clsUsuario.LoggedUsers[x].Apellidos + "'><img src='imagenes/" + strLogoImageName + "' border='0'>" + clsUsuario.LoggedUsers[x].UserId + "&nbsp;(" + strTimeSinceLastRequest + ")</span><br>" + strNewLine);
                        }
                    }
                    //	<span onclick="JavaScript:ShowMessageEditor(this, 'Bárbara Apellidos de Bárbara');" id='Director' title='Bárbara Apellidos de Bárbara'><img src='imagenes/logo_academico.gif' border='0'>Director&nbsp;(00:00:06)</span><br>
                    return(sbHTML.ToString());
                }
            }

            return(string.Empty);
        }
예제 #2
0
        private string forceToSignOut()
        {
            try
            {
                string strAppPath = string.Empty;
                FormsAuthentication.SignOut();
                if (HttpContext.Current.Session != null)
                {
                    HttpContext.Current.Session.Abandon();
                    strAppPath = HttpContext.Current.Request.ApplicationPath;
                }
                clsUsuario Usuario = new clsUsuario();
                Usuario.DeleteFronConnectedList(HttpContext.Current.User.Identity.Name);
                Usuario = null;

                return(strAppPath);
            }

            catch (System.Exception)
            {
                //System.Diagnostics.Debug.WriteLine(Ex.ToString());
                return(string.Empty);
            }
        }