Exemple #1
0
 public static void LogText(string contextualMessage)
 {
     try
     {
         // log exception with contextual information that's visible when
         // clicking on the error in the Elmah log
         var annotatedException = new iQException(contextualMessage, iQExceptionCode.INFO);
         ErrorSignal.FromCurrentContext().Raise(annotatedException, HttpContext.Current);
     }
     catch (Exception)
     {
         // uh oh! just keep going
     }
 }
Exemple #2
0
        public new static bool Login(string username, string password, string server)
        {
            List <string> servers = new List <string>();

            if (server != string.Empty)
            {
                servers.Add(server);
            }
            //servers.Add(GetActiveServer());
            if (SettingsMng.Instance.GetLANServer() != string.Empty)
            {
                servers.Add(SettingsMng.Instance.GetLANServer());
            }
            if (SettingsMng.Instance.GetWANServer() != string.Empty)
            {
                servers.Add(SettingsMng.Instance.GetWANServer());
            }
            servers.Add(nHManager.Instance.Host);

            for (int i = 1; i <= servers.Count; i++)
            {
                try
                {
                    nHManager.Instance.SetCredentials(User.MapToDBUsername(username), password, string.Empty, servers[i - 1]);

                    if (DoLogin(username, password))
                    {
                        SettingsMng.Instance.SetDBUser(username);
                        SettingsMng.Instance.SetDBPassword(password);

                        return(true);
                    }
                    else
                    {
                        ClearCredentials(username);
                    }

                    return(false);
                }
                catch (Exception ex)
                {
                    iQException iQex = iQExceptionHandler.ConvertToiQException(ex);

                    switch (iQex.Code)
                    {
                    case iQExceptionCode.SERVER_NOT_FOUND:
                        if (i == servers.Count)
                        {
                            throw iQex;
                        }
                        break;

                    case iQExceptionCode.DB_VERSION_MISSMATCH:
                        throw iQex;

                    case iQExceptionCode.PASSWORD_FAILED:
                        throw new iQAuthorizationException(string.Format(moleQule.Library.Resources.Errors.LOGIN_FAILED, username),
                                                           iQex.SysMessage,
                                                           iQex.Code);

                    case iQExceptionCode.LOCKED_USER:
                        throw new iQAuthorizationException(string.Format(moleQule.Library.Resources.Errors.USER_LOCKED, username),
                                                           iQex.SysMessage,
                                                           iQex.Code);

                    case iQExceptionCode.LOCKED_ROW:
                        throw new iQLockException(string.Format(moleQule.Library.Resources.Errors.USER_LOGGED, username));

                    default:
                        throw iQex;
                    }
                }
            }

            return(false);
        }
Exemple #3
0
        /// <summary>
        /// Implementación de la función virtual LoginBase.LoginAction().
        /// </summary>
        /// <remarks>
        /// Realiza las tareas de login de usuario mediante el objeto Principal que gestiona el usuario activo.
        /// Dicho objeto obtiene una lista de schemas accesibles para el usuario indicado
        /// en el formulario.
        /// </remarks>
        protected override void LoginAction()
        {
            _action_result = DialogResult.None;

            try
            {
                string server = (Server_CkB.Checked) ? Server_TB.Text : string.Empty;

                if (Principal.Login(UserName_TB.Text, Password_TB.Text, server))
                {
                    PgMng.Grow();

                    SettingsMng.Instance.SetLastUser(AppContext.User.Name);

                    string version = SettingsMng.Instance.GetApplicationVersion();

                    if (String.CompareOrdinal(System.Windows.Forms.Application.ProductVersion, version) < 0)
                    {
                        PgMng.ShowInfoException(String.Format(Resources.Messages.NEW_VERSION_AVAILABLE, version));
                        _action_result = DialogResult.Ignore;
                        return;
                    }

                    MainForm.Instance.LoadSchema();

                    //Si el usuario inicia sesión correctamente se guarda como el último usuario
                    //La próxima vez que se arranque la aplicación cargará el nombre de este usuario
                    Principal.SetLastUser(AppContext.User.Name);
                    Principal.SetLastServer(Server_TB.Text);
#if DEMO
                    MessageBox.Show("¡¡AVISO IMPORTANTE!!" + Environment.NewLine + Environment.NewLine +
                                    "Esta versión de evaluación de " + ControlerBase.GetApplicationTitle() + " almacena los datos en un servidor remoto por lo que puede sufrir tiempos de espera" +
                                    " superiores a los de la versión de pago." + Environment.NewLine + Environment.NewLine +
                                    " Los datos se resetean diariamente, por esta razón la información que introduzca tiene carácter temporal.",
                                    ControlerBase.GetApplicationTitle(),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
#endif
                    _action_result = DialogResult.OK;

                    PgMng.Grow();
                }
                else
                {
                    PgMng.ShowInfoException(Library.Resources.Messages.USER_NOT_AUTHENTIFICATED);
                }
            }
            catch (Exception ex)
            {
                iQException iQex = iQExceptionHandler <iQException> .GetiQException(ex);

                if (null != iQex)
                {
                    PgMng.ShowInfoException(iQex.Message);
                }
                else
                {
                    PgMng.ShowInfoException(ex);
                }
            }
        }