Beispiel #1
0
 public static bool Handle(Exception ex)
 {
     if (ex is DbModelException)
     {
         var ex1 = ex as DbModelException;
         if (string.IsNullOrEmpty(ex1.MessageId))
         {
             string msgId = SqlExceptionMessage.Get(ex);
             if (msgId != null)
             {
                 ErrorForm.ShowError(msgId);//, null, ex);
             }
             else
             {
                 ErrorForm.ShowError(ex1.Message, ex1);
             }
         }
         else
         {
             ErrorForm.ShowError(ex1.MessageId);
         }
         return(true);
     }
     if (ex is SqlException)
     {
         string msgId = SqlExceptionMessage.Get(ex as SqlException);
         if (msgId != null)
         {
             ErrorForm.ShowError(msgId);//, null, ex);
             return(true);
         }
     }
     return(false);
 }
Beispiel #2
0
        public static string GetExceptionDescription(Exception ex)
        {
            SqlException sqlException = TryGetSqlException(ex);
            string       msgId        = SqlExceptionMessage.Get(sqlException);

            if (msgId != null)
            {
                return(BvMessages.Get(msgId));
            }
            if (sqlException != null)
            {
                return(ex.Message);
            }
            return(string.Empty);
        }
Beispiel #3
0
 private static bool HandleException(Exception ex)
 {
     if (ex == null)
     {
         return(false);
     }
     ex = GetInnerException(ex);
     if (ex is SqlException)
     {
         string msgId = SqlExceptionMessage.Get(ex as SqlException);
         if (msgId != null)
         {
             ShowError(msgId);
             return(true);
         }
     }
     return(false);
 }
Beispiel #4
0
        private void btnOk_Click(Object sender, EventArgs e)
        {
            string errorMessage  = string.Empty;
            var    errorCode     = -1;
            var    bSuccessLogin = false;

            try
            {
                if (!ValidateArchiveConnection())
                {
                    return;
                }
                if (!ValidateAvrService())
                {
                    return;
                }
                InitConnection();
                bSuccessLogin = DoLogin(m_Manager, txtOrganization.Text, txtUserName.Text, txtPassword.Text, out errorCode);
                if (!bSuccessLogin)
                {
                    switch (errorCode)
                    {
                    case 6:
                        errorMessage = SecurityMessages.GetLoginErrorMessage(errorCode, txtOrganization.Text,
                                                                             txtUserName.Text);
                        break;

                    default:
                        errorMessage = SecurityMessages.GetLoginErrorMessage(errorCode);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                if (SqlExceptionHandler.Handle(ex))
                {
                    m_LoginType = LoginType.Complex;
                    UpdateTabsVisibility();
                    return;
                }
                errorMessage = SqlExceptionMessage.Get(ex);
                if (errorMessage == null)
                {
                    Dbg.Debug("unprocessed error during login: {0}", ex);
                    errorMessage = StandardErrorHelper.Error(StandardError.UnprocessedError);
                }
                else
                {
                    errorMessage = BvMessages.Get(errorMessage);
                }
            }

            if (bSuccessLogin)
            {
                SuccessLogin();
            }
            else
            {
                FailedLogin(errorMessage, errorCode);
            }
        }