Esempio n. 1
0
        public override bool ProcessError(int dbmsErrorCode, string emsg, GxErrorMask errMask, IGxConnection con, ref int status, ref bool retry, int retryCount)

        {
            GXLogging.Debug(log, "ProcessError: dbmsErrorCode=" + dbmsErrorCode + ", emsg '" + emsg + "'");
            switch (dbmsErrorCode)
            {
            case 11:
                if (con != null && m_FailedConnections < MAX_TRIES)
                {
                    status = 104;                             // General network error.  Check your network documentation - Retry [Max Pool Size] times.
                    m_FailedConnections++;
                    con.Close();
                    retry = true;
                    GXLogging.Debug(log, "ProcessError: General network error, FailedConnections:" + m_FailedConnections);
                }
                else
                {
                    return(false);
                }
                break;

            case 903:                           // Locked
                retry = Retry(errMask, retryCount);
                if (retry)
                {
                    status = 110;                            // Locked - Retry
                }
                else
                {
                    status = 103;                            //Locked
                }
                return(retry);

            case 2601:                          // Duplicated record
            case 2627:                          // Duplicated record
            case 25016:                         //A duplicate value cannot be inserted into a unique index
                status = 1;
                break;

            case 3639:                          //sql ce specific
            //case 3631:		//sql ce specific The column cannot contain null values No deberia capturarse.
            case 3637:                          //"The specified index does not exist"
            case 3723:                          //sql ce specific The reference does not exist
            case 3638:                          //"The specified index was in use"
            //case 3647:	//"The specified table already exists" => Do not catch it, it must be caught by the Reorganization
            case 25060:                         //The reference does not exist (DROP de una constraint que no existe)
            case 3701:                          // File not found
            case 3703:                          // File not found
            case 3704:                          // File not found
            case 3731:                          // File not found
            case 4902:                          // File not found
            case 3727:                          // File not found
            case 3728:                          // File not found
                status = 105;
                break;

            case 503:                           // Parent key not found
            case 547:                           //conflicted with COLUMN FOREIGN KEY constraint
                if ((errMask & GxErrorMask.GX_MASKFOREIGNKEY) > 0)
                {
                    status = 500;                                   // ForeignKeyError
                }
                break;

            default:
                return(false);
            }
            return(true);
        }
        public override bool ProcessError(int dbmsErrorCode, string emsg, GxErrorMask errMask, IGxConnection con, ref int status, ref bool retry, int retryCount)
        {
            GXLogging.Debug(log, "ProcessError: dbmsErrorCode=" + dbmsErrorCode + ", emsg '" + emsg + "'");
            switch (dbmsErrorCode)
            {
            case 2006:                                              //MySQL server has gone away
                if (con != null && m_FailedConnections < MAX_TRIES) //Retry if it is an Open operation.
                {
                    try
                    {
                        if (con.Opened)
                        {
                            con.Close();
                        }
                    }
                    catch { }
                    status = 104;                             // MySQL server has gone away.  Check your network documentation - Retry [Max Pool Size] times.
                    m_FailedConnections++;
                    con.Close();
                    retry = true;
                    GXLogging.Debug(log, "ProcessError: MySQL server has gone away, FailedConnections:" + m_FailedConnections);
                }
                else
                {
                    return(false);
                }
                break;

            case 1006:                     //Can't create database 'databaseName'
            case 1007:                     //Can't create database 'databaseName'. Database exists
                break;

            case 1205:                          // Locked
                retry = Retry(errMask, retryCount);
                if (retry)
                {
                    status = 110;                            // Locked - Retry
                }
                else
                {
                    status = 103;                            //Locked
                }
                return(retry);

            case 1062:                          // Duplicated record ER_DUP_ENTRY
                status = 1;
                break;

            case 1051:                          // File not found ER_BAD_TABLE_ERROR
            case 1091:                          // File not found ER_CANT_DROP_FIELD_OR_KEY
            //case 1146:		// File not found ER_NO_SUCH_TABLE  => Do not catch it, it must be caught by the Reorganization
            //case 1064:		// File not found ER_PARSE_ERROR => Do not catch it, it is thrown when there is a sintax error
            case 1025:                          // (Error on rename of) ER_CANT_DROP_FKEY
                status = 105;
                break;

            case 1146:
                if (!GxContext.isReorganization)
                {
                    status = 105;
                    return(false);
                }
                else
                {
                    status = 999;
                    return(false);
                }

            case 1216:                          //foreign key constraint fails
                if ((errMask & GxErrorMask.GX_MASKFOREIGNKEY) == 0)
                {
                    status = 500;                                   // ForeignKeyError
                    return(false);
                }
                break;

            default:
                status = 999;
                return(false);
            }
            return(true);
        }