コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gatewayResult"></param>
        public ErrorHandlingInfo GetErrorInfo(ReturnResultBase returnResultBase)
        {
            ErrorHandlingInfo errorHandlingInfo = null;


            if (returnResultBase.InnerResult is GatewayResult)
            {
                GatewayErrorHandlingInfoTable.TryGetValue((GatewayErrorCode)returnResultBase.InnerResult.GetErrorId(), out errorHandlingInfo);
            }
            else if (returnResultBase.InnerResult is ReturnResult)
            {
                RtErrorHandlingInfoTable.TryGetValue((string)returnResultBase.InnerResult.GetErrorId(), out errorHandlingInfo);
            }
            else if (returnResultBase.InnerResult == null)
            {
                RtErrorHandlingInfoTable.TryGetValue((string)returnResultBase.GetErrorId(), out errorHandlingInfo);
            }
            else
            {
                Debug.Assert(false);
            }

            return(errorHandlingInfo);
        }
コード例 #2
0
        ///// <summary>
        ///// return true if this error need to be handled
        ///// </summary>
        ///// <param name="returnResultBase"></param>
        ///// <returns></returns>
        //private bool ErroNeedToBeHandled(ReturnResultBase returnResultBase)
        //{
        //   Boolean isErroNeedToBeHandled = false;

        //   ReturnResultBase innerResult = returnResultBase.InnerResult;

        //   if (innerResult is GatewayResult)
        //   {
        //      GatewayResult GatewayResult = innerResult as GatewayResult;
        //      // macro ERROR_TO_BE_HANDLED
        //      isErroNeedToBeHandled = ((GatewayErrorCode)innerResult.GetErrorId() < GatewayErrorCode.InErrorZone);
        //   }
        //   else if (innerResult is ReturnResult)
        //   {
        //      ReturnResult ReturnResult = innerResult as ReturnResult;
        //      isErroNeedToBeHandled = (((String)innerResult.GetErrorId()).Equals(MsgInterface.FMERROR_STR_DB_PROT)) ||
        //         (((String)innerResult.GetErrorId()).Equals(MsgInterface.FMERROR_STR_NO_DATABASE)) ||
        //         (((String)innerResult.GetErrorId()).Equals(MsgInterface.FMERROR_STR_EXTUSE_MULU_CNFLCT)) ||
        //         (((String)innerResult.GetErrorId()).Equals(MsgInterface.FMERROR_STR_DB_GW_VERSION_CNFLCT)) ||
        //         (((String)innerResult.GetErrorId()).Equals(MsgInterface.FMERROR_STR_NO_HDLS)) ||
        //         (((String)innerResult.GetErrorId()).Equals(MsgInterface.FMERROR_STR_TRANS_OPEN_FAILED) ||
        //         (((String)innerResult.GetErrorId()).Equals(MsgInterface.RT_STR_NON_MODIFIABLE))
        //         );
        //   }
        //   return isErroNeedToBeHandled;
        //}
        /// <summary>
        ///
        /// </summary>
        /// <param name="returnResultBase"></param>
        internal ErrorHandlingInfo HandleResult(ReturnResultBase returnResultBase)
        {
            VerifyDisplay displayType = VerifyDisplay.Box;

            ErrorHandlingInfo errorHandlingInfo = GetErrorInfo(returnResultBase);

            if (errorHandlingInfo != null)
            {
                // The "if ErroNeedToBeHandled" code need to be un comment while implement the error handling (rtry_handle_error)
                // mg_rtry.cpp "ERROR_TO_BE_HANDLED"
                //if (ErroNeedToBeHandled(returnResultBase))

                // take the display type
                displayType = errorHandlingInfo.DisplayType;
                // if the error is quit then we display it to message box otherwise display to status bar(the default)
                if (errorHandlingInfo.Quit)
                {
                    displayType = VerifyDisplay.Box;
                }

                switch (displayType)
                {
                case VerifyDisplay.Box:
                    DataviewManager.Task.ShowError(returnResultBase.ErrorDescription);
                    break;

                case VerifyDisplay.Status:
                    DataviewManager.Task.DisplayMessageToStatusBar(returnResultBase.ErrorDescription);
                    break;

                default:
                    break;
                }
            }
            return(errorHandlingInfo);
        }