Example #1
0
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            IList <FailureMessageAccessor> failureMessages = failuresAccessor.GetFailureMessages();

            foreach (FailureMessageAccessor failureMessageAccessor in failureMessages)
            {
                FailureDefinitionId id = failureMessageAccessor.GetFailureDefinitionId();
                try {
                    ErrorMessage = failureMessageAccessor.GetDescriptionText();
                }
                catch {
                    ErrorMessage = "Unknown Error";
                }
                try {
                    FailureSeverity failureSeverity = failureMessageAccessor.GetSeverity();
                    ErrorSeverity = failureSeverity.ToString();
                    // delete all of the warning level failures and roll back any others
                    if (failureSeverity == FailureSeverity.Warning)
                    {
                        failuresAccessor.DeleteWarning(failureMessageAccessor);
                    }
                    else
                    {
                        return(FailureProcessingResult.ProceedWithRollBack);
                    }
                }
                catch { }
            }
            return(FailureProcessingResult.Continue);
        }
Example #2
0
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            IList <FailureMessageAccessor> failureMessages = failuresAccessor.GetFailureMessages();
            //if (failureMessages.Count == 0) { return FailureProcessingResult.Continue; }

            bool   needRollBack    = false;
            string transactionName = failuresAccessor.GetTransactionName();

            foreach (FailureMessageAccessor fma in failureMessages)
            {
                FailureMessageInfo messageInfo = new FailureMessageInfo();
                try
                {
                    messageInfo.ErrorMessage      = fma.GetDescriptionText();
                    messageInfo.ErrorSeverity     = fma.GetSeverity().ToString();
                    messageInfo.FailingElementIds = fma.GetFailingElementIds().ToList();
                }
                catch { messageInfo.ErrorMessage = "Unknown Error"; }

                FailureSeverity severity = fma.GetSeverity();
                try
                {
                    if (severity == FailureSeverity.Warning)
                    {
                        failuresAccessor.DeleteWarning(fma);
                    }
                    else
                    {
                        messageInfo.ErrorSeverity     = severity.ToString();
                        messageInfo.FailingElementIds = fma.GetFailingElementIds().ToList();
                        failureMessageInfoList.Add(messageInfo);
                        needRollBack = true;
                    }
                }
                catch { }
            }

            if (needRollBack)
            {
                return(FailureProcessingResult.ProceedWithRollBack);
            }
            else
            {
                return(FailureProcessingResult.Continue);
            }
        }
Example #3
0
            public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)

            {
                IList <FailureMessageAccessor> failureMessages = failuresAccessor.GetFailureMessages();



                foreach (FailureMessageAccessor failureMessageAccessor in failureMessages)

                {
                    // We're just deleting all of the warning level

                    // failures and rolling back any others



                    FailureDefinitionId id = failureMessageAccessor.GetFailureDefinitionId();



                    try

                    {
                        ErrorMessage = failureMessageAccessor.GetDescriptionText();
                    }

                    catch

                    {
                        ErrorMessage = "Unknown Error";
                    }



                    try

                    {
                        FailureSeverity failureSeverity = failureMessageAccessor.GetSeverity();



                        ErrorSeverity = failureSeverity.ToString();



                        if (failureSeverity == FailureSeverity.Warning)

                        {
                            // 如果是警告,则禁止消息框

                            failuresAccessor.DeleteWarning(failureMessageAccessor);
                        }

                        else

                        {
                            // 如果是错误:则取消导致错误的操作,但是仍然继续整个事务

                            return(FailureProcessingResult.ProceedWithRollBack);
                        }
                    }

                    catch

                    {
                    }
                }

                return(FailureProcessingResult.Continue);
            }