Exemplo n.º 1
0
        DB.FailureProcessingResult FixFailures(DB.FailuresAccessor failuresAccessor, IEnumerable <DB.FailureDefinitionId> failureIds)
        {
            foreach (var failureId in failureIds)
            {
                int solvedErrors = 0;

                foreach (var error in failuresAccessor.GetFailureMessages().Where(x => x.GetFailureDefinitionId() == failureId))
                {
                    if (!failuresAccessor.IsFailureResolutionPermitted(error))
                    {
                        continue;
                    }

                    // Don't try to fix two times same issue
                    if (failuresAccessor.GetAttemptedResolutionTypes(error).Any())
                    {
                        continue;
                    }

                    AddRuntimeMessage(error, true);

                    failuresAccessor.ResolveFailure(error);
                    solvedErrors++;
                }

                if (solvedErrors > 0)
                {
                    return(DB.FailureProcessingResult.ProceedWithCommit);
                }
            }

            return(DB.FailureProcessingResult.Continue);
        }
Exemplo n.º 2
0
        DB.FailureProcessingResult DB.IFailuresPreprocessor.PreprocessFailures(DB.FailuresAccessor failuresAccessor)
        {
            if (!failuresAccessor.IsTransactionBeingCommitted())
            {
                return(DB.FailureProcessingResult.Continue);
            }

            if (failuresAccessor.GetSeverity() >= DB.FailureSeverity.DocumentCorruption)
            {
                return(DB.FailureProcessingResult.ProceedWithRollBack);
            }

            if (failuresAccessor.GetSeverity() >= DB.FailureSeverity.Error)
            {
                // Handled failures in order
                {
                    var failureDefinitionIdsToFix = FailureDefinitionIdsToFix;
                    if (failureDefinitionIdsToFix != null)
                    {
                        var result = FixFailures(failuresAccessor, failureDefinitionIdsToFix);
                        if (result != DB.FailureProcessingResult.Continue)
                        {
                            return(result);
                        }
                    }
                }

                // Unhandled failures in incomming order
                {
                    var failureDefinitionIdsToFix = failuresAccessor.GetFailureMessages().GroupBy(x => x.GetFailureDefinitionId()).Select(x => x.Key);
                    var result = FixFailures(failuresAccessor, failureDefinitionIdsToFix);
                    if (result != DB.FailureProcessingResult.Continue)
                    {
                        return(result);
                    }
                }
            }

            if (failuresAccessor.GetSeverity() >= DB.FailureSeverity.Warning)
            {
                // Unsolved failures or warnings
                foreach (var error in failuresAccessor.GetFailureMessages().OrderBy(error => error.GetSeverity()))
                {
                    AddRuntimeMessage(error, false);
                }

                failuresAccessor.DeleteAllWarnings();
            }

            return(DB.FailureProcessingResult.Continue);
        }
Exemplo n.º 3
0
        public Autodesk.Revit.DB.FailureProcessingResult PreprocessFailures(Autodesk.Revit.DB.FailuresAccessor failuresAccessor)
        {
            var failList = failuresAccessor.GetFailureMessages();

            foreach (var fail in failList)
            {
                var severity = fail.GetSeverity();
                if (severity == Autodesk.Revit.DB.FailureSeverity.Warning)
                {
                    dynSettings.Controller.DynamoViewModel.Log(
                        "!! Warning: " + fail.GetDescriptionText()
                        );
                    failuresAccessor.DeleteWarning(fail);
                }
            }

            return(Autodesk.Revit.DB.FailureProcessingResult.Continue);
        }