FailureProcessingResult IFailuresPreprocessor.PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            if (!failuresAccessor.IsTransactionBeingCommitted())
            {
                return(FailureProcessingResult.Continue);
            }

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

            if (failuresAccessor.GetSeverity() >= FailureSeverity.Error)
            {
                // Handled failures in order
                {
                    var failureDefinitionIdsToFix = FailureDefinitionIdsToFix;
                    if (failureDefinitionIdsToFix != null)
                    {
                        var result = FixFailures(failuresAccessor, failureDefinitionIdsToFix);
                        if (result != 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 != FailureProcessingResult.Continue)
                    {
                        return(result);
                    }
                }
            }

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

                failuresAccessor.DeleteAllWarnings();
            }

            return(FailureProcessingResult.Continue);
        }
Ejemplo n.º 2
0
        private void FailureProcessor(object sender, FailuresProcessingEventArgs e)
        {
            FailuresAccessor fas = e.GetFailuresAccessor();

            if (fas.GetTransactionName() == "Synchronize with Central" | fas.GetTransactionName() == "Reload Latest")
            {
                List <FailureMessageAccessor> fma = fas.GetFailureMessages().ToList();

                string error1 = "Coordination Monitor alert : A hosting element no longer exists in the link.";
                string error2 = "One or more dimension references are or have become invalid.";

                bool catched = false;

                foreach (FailureMessageAccessor fa in fma)
                {
                    string failuremessage = fa.GetDescriptionText();

                    if (failuremessage == error2 | failuremessage == error1)
                    {
                        e.SetProcessingResult(FailureProcessingResult.ProceedWithRollBack);
                        catched = true;
                    }
                }
                if (catched)
                {
                    TaskDialog.Show("Error", "Some Revit links have been modified.\nTo prevent Annotation loss:\n  1) 'Unload' the modified Revit links\n  2) 'Reload Latest'");
                }
            }
        }
Ejemplo n.º 3
0
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            var failureMessages = failuresAccessor.GetFailureMessages();
            var needRollBack    = false;

            foreach (var fma in failureMessages)
            {
                var severity = fma.GetSeverity();
                try
                {
                    var items = fma.GetFailingElementIds().ToList();

                    if (severity == FailureSeverity.Warning)
                    {
                        Log.AppendLog(LogMessageType.WARNING, "Deleted Warning");
                        failuresAccessor.DeleteWarning(fma);
                    }
                    else if (severity == FailureSeverity.Error)
                    {
                        Log.AppendLog(LogMessageType.ERROR, string.Join(",", items));
                        needRollBack = true;
                    }
                }
                catch (Exception ex)
                {
                    Log.AppendLog(LogMessageType.EXCEPTION, ex.Message);
                }
            }
            return(needRollBack ? FailureProcessingResult.ProceedWithRollBack : FailureProcessingResult.Continue);
        }
Ejemplo n.º 4
0
        FailureProcessingResult IFailuresPreprocessor.PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            string transactionName            = failuresAccessor.GetTransactionName();
            IList <FailureMessageAccessor> po = failuresAccessor.GetFailureMessages();

            if (po.Count == 0)
            {
                return(FailureProcessingResult.Continue);
            }
            if (transactionName.Equals("EXEMPLE"))
            {
                foreach (FailureMessageAccessor p1 in po)
                {
                    if (p1.GetSeverity() == FailureSeverity.Error)
                    {
                        failuresAccessor.DeleteAllWarnings();
                        return(FailureProcessingResult.ProceedWithRollBack);
                    }
                    else
                    {
                        failuresAccessor.DeleteWarning(p1);
                    }
                }
            }
            else
            {
                foreach (FailureMessageAccessor p1 in po)
                {
                    failuresAccessor.DeleteAllWarnings();
                }
            }
            return(FailureProcessingResult.Continue);
        }
Ejemplo n.º 5
0
            public FailureProcessingResult PreprocessFailures(FailuresAccessor a)
            {
                // inside event handler, get all warnings

                IList<FailureMessageAccessor> failures
                  = a.GetFailureMessages();

                foreach (FailureMessageAccessor f in failures)
                {
                    // check failure definition ids
                    // against ones to dismiss:

                    FailureDefinitionId id
                      = f.GetFailureDefinitionId();

                    a.DeleteAllWarnings();

                    //if (BuiltInFailures.CreationFailures.CannotCreateCornice
                    //  == id)
                    //{
                    //    a.DeleteWarning(f);
                    //}
                }
                return FailureProcessingResult.Continue;
            }
Ejemplo n.º 6
0
        FailureProcessingResult IFailuresPreprocessor.PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            IList <FailureMessageAccessor> failList = failuresAccessor.GetFailureMessages();

            if (_failureIdList.Count == 0)
            {
                failuresAccessor.DeleteAllWarnings();
                if (deleteErrors)
                {
                    foreach (FailureMessageAccessor accessor in failList)
                    {
                        if (accessor.GetSeverity() == FailureSeverity.Error)
                        {
                            var ids = accessor.GetFailingElementIds();
                            failuresAccessor.DeleteElements((IList <ElementId>)ids.GetEnumerator());
                        }
                    }
                }
            }
            else
            {
                foreach (FailureMessageAccessor failure in failList)
                {
                    FailureDefinitionId failId = failure.GetFailureDefinitionId();
                    if (_failureIdList.Exists(p => p == failId))
                    {
                        failuresAccessor.DeleteWarning(failure);
                    }
                }
            }
            return(FailureProcessingResult.Continue);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        private void Application_FailuresProcessing(object sender, FailuresProcessingEventArgs e)
        {
            FailuresAccessor failuresAccessor = e.GetFailuresAccessor();
            IEnumerable <FailureMessageAccessor> failureMessages =
                failuresAccessor.GetFailureMessages();

            if (failureMessages.Count() == 0)
            {
                // FailureProcessingResult.Continue is to let
                // the failure cycle continue next step.
                e.SetProcessingResult(FailureProcessingResult.Continue);
                return;
            }
            else
            {
                foreach (FailureMessageAccessor failureMessage in failureMessages)
                {
                    if (failureMessage.GetSeverity() == FailureSeverity.Warning)
                    {
                        failuresAccessor.DeleteWarning(failureMessage);
                    }
                    else
                    {
                        failuresAccessor.ResolveFailure(failureMessage);
                    }
                }
            }
            //String transactionName = failuresAccessor.GetTransactionName();
            e.SetProcessingResult(FailureProcessingResult.Continue);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Method that Revit will invoke to process failures at the end of transaction.
        /// </summary>
        /// <param name="failuresAccessor">Provides all necessary data to perform the resolution of failures.</param>
        /// <returns></returns>
        public FailureProcessingResult ProcessFailures(FailuresAccessor failuresAccessor)
        {
            IList <FailureMessageAccessor> fmas = failuresAccessor.GetFailureMessages();

            if (fmas.Count == 0)
            {
                return(FailureProcessingResult.Continue);
            }

            String transactionName = failuresAccessor.GetTransactionName();

            if (transactionName.Equals("Error_FailuresProcessor"))
            {
                foreach (FailureMessageAccessor fma in fmas)
                {
                    FailureDefinitionId id = fma.GetFailureDefinitionId();
                    if (id == Command.m_idError)
                    {
                        failuresAccessor.ResolveFailure(fma);
                    }
                }
                return(FailureProcessingResult.ProceedWithCommit);
            }
            else
            {
                return(FailureProcessingResult.Continue);
            }
        }
Ejemplo n.º 10
0
            public FailureProcessingResult PreprocessFailures(FailuresAccessor a)
            {
                // inside event handler, get all warnings

                IList <FailureMessageAccessor> failures = a.GetFailureMessages();

                foreach (FailureMessageAccessor f in failures)
                {
                    // check failure definition ids
                    // against ones to dismiss:

                    FailureDefinitionId id = f.GetFailureDefinitionId();

                    if (BuiltInFailures.InaccurateFailures.InaccurateLine == id ||
                        BuiltInFailures.OverlapFailures.DuplicateInstances == id ||
                        BuiltInFailures.InaccurateFailures.InaccurateCurveBasedFamily == id ||
                        BuiltInFailures.InaccurateFailures.InaccurateBeamOrBrace == id ||
                        BuiltInFailures.InaccurateFailures.InaccurateLine == id)
                    {
                        a.DeleteWarning(f);
                    }
                    else
                    {
                        a.RollBackPendingTransaction();
                    }
                }
                return(FailureProcessingResult.Continue);
            }
Ejemplo n.º 11
0
        public FailureProcessingResult ProcessFailures(FailuresAccessor data)
        {
            if (isDoorFail)
            {
                isDoorFail = false;
                return(FailureProcessingResult.ProceedWithRollBack);
            }
            else
            {
                IList <FailureResolutionType>  resolutionTypeList = new List <FailureResolutionType>();
                IList <FailureMessageAccessor> failList           = new List <FailureMessageAccessor>();
                // Inside event handler, get all warnings
                failList = data.GetFailureMessages();


                foreach (FailureMessageAccessor failure in failList)
                {
                    FailureDefinitionId failId     = failure.GetFailureDefinitionId();
                    string          failureMessage = failure.GetDescriptionText();
                    FailureSeverity severity       = failure.GetSeverity();
                    resolutionTypeList = data.GetAttemptedResolutionTypes(failure);

                    foreach (ElementId id in failure.GetFailingElementIds())
                    {
                        int elementId = id.IntegerValue;
                    }
                }

                return(FailureProcessingResult.Continue);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Implements the FailuresProcessing event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FailuresProcessing(object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e)
        {
            FailuresAccessor failuresAccessor = e.GetFailuresAccessor();
            //failuresAccessor
            String transactionName = failuresAccessor.GetTransactionName();

            IList <FailureMessageAccessor> fmas = failuresAccessor.GetFailureMessages();

            if (fmas.Count == 0)
            {
                e.SetProcessingResult(FailureProcessingResult.Continue);
                return;
            }

            if (transactionName.Equals("Error_FailuresProcessingEvent"))
            {
                foreach (FailureMessageAccessor fma in fmas)
                {
                    FailureDefinitionId id = fma.GetFailureDefinitionId();
                    if (id == Command.m_idError)
                    {
                        failuresAccessor.ResolveFailure(fma);
                    }
                }

                e.SetProcessingResult(FailureProcessingResult.ProceedWithCommit);
                return;
            }

            e.SetProcessingResult(FailureProcessingResult.Continue);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Implements the FailuresProcessing event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FailuresProcessing(object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e)
        {
            FailuresAccessor failuresAccessor = e.GetFailuresAccessor();
            //failuresAccessor
            String transactionName = failuresAccessor.GetTransactionName();

            IList <FailureMessageAccessor> failures = failuresAccessor.GetFailureMessages();

            if (failures.Count != 0)
            {
                foreach (FailureMessageAccessor f in failures)
                {
                    FailureDefinitionId id = f.GetFailureDefinitionId();

                    if (id == BuiltInFailures.JoinElementsFailures.CannotJoinElementsError)
                    {
                        // only default option being choosen,  not good enough!
                        //failuresAccessor.DeleteWarning(f);
                        failuresAccessor.ResolveFailure(f);
                        //failuresAccessor.
                        e.SetProcessingResult(FailureProcessingResult.ProceedWithCommit);
                    }

                    return;
                }
            }
        }
        FailureProcessingResult FixFailures(FailuresAccessor failuresAccessor, IEnumerable <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(FailureProcessingResult.ProceedWithCommit);
                }
            }

            return(FailureProcessingResult.Continue);
        }
Ejemplo n.º 15
0
 // For debugging
 public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
 {
     try
     {
         TaskDialog.Show("Preprocess failures", "Hello");
         IList <FailureMessageAccessor> failureMessages = failuresAccessor.GetFailureMessages();
         int numberOfFailures = failureMessages.Count;
         TaskDialog.Show("Preprocess failures", "Found " + numberOfFailures + " failure messages.");
         if (numberOfFailures < 5)
         {
             foreach (FailureMessageAccessor msgAccessor in failureMessages)
             {
                 TaskDialog.Show("Failure!", msgAccessor.GetDescriptionText());
             }
         }
         else
         {
             TaskDialog.Show("Failure 1 of " + numberOfFailures, failureMessages.First <FailureMessageAccessor>().GetDescriptionText());
         }
         TaskDialog.Show("Preprocess failures", "Goodbye");
         return(FailureProcessingResult.Continue);
     }
     catch (Exception e)
     {
         TaskDialog.Show("Exception", e.ToString());
         return(FailureProcessingResult.ProceedWithRollBack);
     }
 }
Ejemplo n.º 16
0
        private void OnFailuresProcessing(object sender, FailuresProcessingEventArgs e)
        {
            FailuresAccessor failuresAccessor = e.GetFailuresAccessor();

            string transactionName = failuresAccessor.GetTransactionName();
            IList <FailureMessageAccessor> fmas = failuresAccessor.GetFailureMessages();

            if (fmas.Count == 0)
            {
                e.SetProcessingResult(FailureProcessingResult.Continue);
                return;
            }
            else
            {
                foreach (FailureMessageAccessor fma in fmas)
                {
                    FailureSeverity severity = fma.GetSeverity();
                    try
                    {
                        if (severity == FailureSeverity.Warning)
                        {
                            failuresAccessor.DeleteWarning(fma);
                            e.SetProcessingResult(FailureProcessingResult.Continue);
                        }
                        else
                        {
                            e.SetProcessingResult(FailureProcessingResult.ProceedWithRollBack);
                        }
                    }
                    catch { }
                }
            }
        }
Ejemplo n.º 17
0
        private static void FaliureProcessor2(object sender, FailuresProcessingEventArgs e)
        {
            FailuresAccessor fa = e.GetFailuresAccessor();

            // Inside event handler, get all warnings

            IList <FailureMessageAccessor> a
                = fa.GetFailureMessages();

            int count = 0;

            foreach (FailureMessageAccessor failure in a)
            {
                TaskDialog.Show("Failure",
                                failure.GetDescriptionText());

                fa.ResolveFailure(failure);

                ++count;
            }

            if (0 < count &&
                e.GetProcessingResult()
                == FailureProcessingResult.Continue)
            {
                e.SetProcessingResult(
                    FailureProcessingResult.ProceedWithCommit);
            }
        }
        static private void OnFailuresProcessingEvent(object sender, FailuresProcessingEventArgs e)
        {
            FailuresAccessor failuresAccessor = e.GetFailuresAccessor();
            IList <FailureMessageAccessor> failureMessages = failuresAccessor.GetFailureMessages();

            if (failureMessages.Count == 0)
            {
                return;
            }

            foreach (FailureMessageAccessor failure in failureMessages)
            {
                if (failure.GetSeverity() == FailureSeverity.Error)
                {
                    FailureResolutionType type = FailureResolutionType.Invalid;
                    if (failure.HasResolutions() && GetFailureResolutionType(failuresAccessor, failure, ref type))
                    {
                        failure.SetCurrentResolutionType(type);
                        failuresAccessor.ResolveFailure(failure);
                        e.SetProcessingResult(FailureProcessingResult.ProceedWithCommit);
                    }
                }
                if (failure.GetSeverity() == FailureSeverity.Warning)
                {
                    failuresAccessor.DeleteWarning(failure);
                }
            }
        }
Ejemplo n.º 19
0
            public FailureProcessingResult PreprocessFailures(
                FailuresAccessor failuresAccessor)
            {
                IList <FailureMessageAccessor> failureMessages = failuresAccessor.GetFailureMessages();

                if (failureMessages.Count > 0)
                {
                    return(FailureProcessingResult.ProceedWithRollBack);
                }
                return(FailureProcessingResult.Continue);
            }
Ejemplo n.º 20
0
            private void FailureProcessor(object sender, FailuresProcessingEventArgs e)
            {
                FailuresAccessor fas = e.GetFailuresAccessor();

                List <FailureMessageAccessor> fma = fas.GetFailureMessages().ToList();

                foreach (FailureMessageAccessor fa in fma)
                {
                    fas.DeleteWarning(fa);
                }
            }
Ejemplo n.º 21
0
        /***************************************************/
        /****              Public methods               ****/
        /***************************************************/

        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            IList <FailureMessageAccessor> failureMessageAccessors = failuresAccessor.GetFailureMessages();

            foreach (FailureMessageAccessor failureMessageAccessor in failureMessageAccessors)
            {
                failuresAccessor.DeleteWarning(failureMessageAccessor);
            }

            return(FailureProcessingResult.Continue);
        }
Ejemplo n.º 22
0
        public FailureProcessingResult PreprocessFailures(FailuresAccessor a)
        {
            // inside event handler, get all warnings
            IList <FailureMessageAccessor> failures = a.GetFailureMessages();

            foreach (FailureMessageAccessor f in failures)
            {
                a.DeleteAllWarnings();
            }
            return(FailureProcessingResult.Continue);
        }
Ejemplo n.º 23
0
            public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
            {
                var failList = failuresAccessor.GetFailureMessages();

                foreach (FailureMessageAccessor failure in failList)
                {
                    failuresAccessor.DeleteWarning(failure);
                }

                return(FailureProcessingResult.Continue);
            }
Ejemplo n.º 24
0
        public FailureProcessingResult PreprocessFailures(FailuresAccessor accessor)
        {
            var failures = accessor.GetFailureMessages();

            foreach (var failure in failures)
            {
                //var id = failure.GetFailureDefinitionId();
                //if (BuiltInFailures.GeneralFailures.ErrorInFamilyResolved == id)
                accessor.DeleteWarning(failure);
            }
            return(FailureProcessingResult.Continue);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Log the failures coming from shape creation.
        /// </summary>
        /// <param name="failuresAccessor">The failure messages</param>
        /// <returns>The result of processing the failures.</returns>
        /// <remarks>This is in no way intended to be final code, as it doesn't actual handle failures,
        /// just logs them.</remarks>
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            if (LoggingEnabled && m_LogFile != null)
            {
                int currentlyProcessedEntityId          = (CurrentlyProcessedEntity != null) ? CurrentlyProcessedEntity.Id : 0;
                IList <FailureMessageAccessor> failList = failuresAccessor.GetFailureMessages();
                foreach (FailureMessageAccessor failure in failList)
                {
                    if (currentlyProcessedEntityId != 0)
                    {
                        Write("#" + currentlyProcessedEntityId + ": ");
                    }
                    else
                    {
                        Write("GENERIC ");
                    }

                    switch (failure.GetSeverity())
                    {
                    case FailureSeverity.Warning:
                        Write("WARNING: ");
                        break;

                    default:
                        Write("ERROR: ");
                        break;
                    }

                    ICollection <ElementId> failureIds = failure.GetFailingElementIds();
                    int numFailureIds = (failureIds == null) ? 0 : failureIds.Count;
                    if (numFailureIds > 0)
                    {
                        Write("(Revit Element Id");
                        if (numFailureIds > 1)
                        {
                            Write("s");
                        }
                        Write(": ");
                        foreach (ElementId failureId in failureIds)
                        {
                            Write(failureId + " ");
                        }
                        Write("): ");
                    }

                    WriteLine(failure.GetDescriptionText());
                }

                // Only remove the warnings if logging is on.
                failuresAccessor.DeleteAllWarnings();
            }
            return(FailureProcessingResult.Continue);
        }
Ejemplo n.º 26
0
 public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
 {
     // if there are any failures, rollback the transaction
     if (failuresAccessor.GetFailureMessages().Count > 0)
     {
         return(FailureProcessingResult.ProceedWithRollBack);
     }
     else
     {
         return(FailureProcessingResult.Continue);
     }
 }
Ejemplo n.º 27
0
 public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
 {
     foreach (FailureMessageAccessor failure in failuresAccessor.GetFailureMessages())
     {
         FailureDefinitionId failID = failure.GetFailureDefinitionId();
         if (failureDefinitionIdList.Exists(e => e.Guid.ToString() == failID.Guid.ToString()))
         {
             failuresAccessor.DeleteWarning(failure);
         }
     }
     return(FailureProcessingResult.Continue);
 }
Ejemplo n.º 28
0
        public FailureProcessingResult ProcessFailures(FailuresAccessor data)
        {
            switch (data.GetSeverity())
            {
            case FailureSeverity.Warning:
                data.ResolveFailures(data.GetFailureMessages());
                return(FailureProcessingResult.ProceedWithCommit);

            default:
                return(FailureProcessingResult.ProceedWithRollBack);
            }
        }
Ejemplo n.º 29
0
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            // inside event handler, get all warnings

            IList <FailureMessageAccessor> fmas = failuresAccessor.GetFailureMessages();

            if (fmas.Count == 0)
            {
                return(FailureProcessingResult.Continue);
            }

            foreach (FailureMessageAccessor fma in fmas)
            {
                FailureSeverity s = fma.GetSeverity();
                if (s == FailureSeverity.Warning)
                {
                    failuresAccessor.DeleteWarning(fma);
                }
                else if (s == FailureSeverity.Error)
                {
                    //FailureDefinitionId id = fma.GetFailureDefinitionId();

                    //if (id == BuiltInFailures.JoinElementsFailures.)
                    //{
                    // only default option being choosen,
                    // not good enough!
                    //failuresAccessor.ResolveFailure(fma);
                    //}
                    //return FailureProcessingResult.ProceedWithRollBack;
                }

                /*
                 * switch (s)
                 * {
                 *  // Slightly off axis error gets ignored
                 *  case "Element is slightly off axis and may cause inaccuracies.":
                 *
                 *      break;
                 *
                 *  case "Beam or Brace is slightly off axis and may cause inaccuracies.":
                 *      break;
                 *
                 *  default:
                 *
                 *      //GlobalVariables.WarningList.Add(new WarningEntry(a.GetTransactionName(), f.GetDescriptionText(), f.GetFailingElementIds()));
                 *      break;
                 * }
                 * a.DeleteWarning(f);
                 */
            }
            return(FailureProcessingResult.Continue);
        }
Ejemplo n.º 30
0
        private void OnFailuresProcessing(object sender, FailuresProcessingEventArgs e)
        {
            FailuresAccessor failuresAccessor = e.GetFailuresAccessor();
            //string transactionName = failuresAccessor.GetTransactionName();

            IList <FailureMessageAccessor> fmas = failuresAccessor.GetFailureMessages();

            if (fmas.Count > 0)
            {
                List <FailureMessageInfo> failureMessageInfoList = new List <FailureMessageInfo>();
                foreach (FailureMessageAccessor fma in fmas)
                {
                    FailureMessageInfo messageInfo = new FailureMessageInfo();
                    try
                    {
                        messageInfo.ErrorMessage      = fma.GetDescriptionText();
                        messageInfo.ErrorSeverity     = fma.GetSeverity().ToString();
                        messageInfo.FailingElementIds = fma.GetFailingElementIds().ToList();
                    }
                    catch { messageInfo.ErrorMessage = "Unknown Error"; }
                    failureMessageInfoList.Add(messageInfo);

                    //add log message
                    FailureDefinitionId definitionId = fma.GetFailureDefinitionId();
                    Guid defGuid = definitionId.Guid;
                    if (!FailureDefinitionIds.Contains(defGuid))
                    {
                        LogFileManager.AppendLog(messageInfo);
                        FailureDefinitionIds.Add(defGuid);
                    }

                    if (FailureSeverity.Warning == fma.GetSeverity())
                    {
                        failuresAccessor.DeleteWarning(fma);
                    }
                    else if (FailureSeverity.Error == fma.GetSeverity())
                    {
                        e.SetProcessingResult(FailureProcessingResult.ProceedWithRollBack);
                        return;
                    }
                }

                if (failuresAccessor.IsFailureResolutionPermitted())
                {
                    failuresAccessor.ResolveFailures(fmas);
                }

                e.SetProcessingResult(FailureProcessingResult.ProceedWithCommit);
                return;
            }
            e.SetProcessingResult(FailureProcessingResult.Continue);
        }
Ejemplo n.º 31
0
        public FailureProcessingResult PreprocessFailures(
          FailuresAccessor a)
        {
            // inside event handler, get all warnings

            IList<FailureMessageAccessor> failures
              = a.GetFailureMessages();

            foreach (FailureMessageAccessor f in failures)
            {
                // check failure definition ids
                // against ones to dismiss:

                FailureDefinitionId id
                  = f.GetFailureDefinitionId();

                //BuiltInFailures.JoinElementsFailures.CannotKeepJoined == id ||
                //    BuiltInFailures.JoinElementsFailures.CannotJoinElementsError == id ||
                //    BuiltInFailures.JoinElementsFailures.CannotJoinElementsStructural == id ||
                //    BuiltInFailures.JoinElementsFailures.CannotJoinElementsStructuralError == id ||
                //    BuiltInFailures.JoinElementsFailures.CannotJoinElementsWarn == id

                if (BuiltInFailures.InaccurateFailures.InaccurateLine == id ||
                    BuiltInFailures.OverlapFailures.DuplicateInstances == id ||
                    BuiltInFailures.InaccurateFailures.InaccurateCurveBasedFamily == id ||
                    BuiltInFailures.InaccurateFailures.InaccurateBeamOrBrace == id
                    )
                {
                    a.DeleteWarning(f);
                }
                //else if(BuiltInFailures.CurveFailures.LineTooShortError == id ||
                //    BuiltInFailures.CurveFailures.LineTooShortWarning == id
                //    )
                //{
                //    a.RollBackPendingTransaction();
                //}
                else
                {
                    a.RollBackPendingTransaction();
                }

            }
            return FailureProcessingResult.Continue;
        }
        FailureProcessingResult PreprocessFailures(
            FailuresAccessor a)
        {
            IList<FailureMessageAccessor> failures
              = a.GetFailureMessages();

              foreach( FailureMessageAccessor f in failures )
              {
            FailureSeverity fseverity = a.GetSeverity();

            if( fseverity == FailureSeverity.Warning )
            {
              a.DeleteWarning( f );
            }
            else
            {
              a.ResolveFailure( f );
              return FailureProcessingResult.ProceedWithCommit;
            }
              }
              return FailureProcessingResult.Continue;
        }
Ejemplo n.º 33
0
        /// <summary>
        /// This method is called when there have been failures found at the end of a transaction and Revit is about to start processing them. 
        /// </summary>
        /// <param name="failuresAccessor">The Interface class that provides access to the failure information. </param>
        /// <returns></returns>
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            IList<FailureMessageAccessor> fmas = failuresAccessor.GetFailureMessages();
            if (fmas.Count == 0)
            {
                return FailureProcessingResult.Continue;
            }

            String transactionName = failuresAccessor.GetTransactionName();
            if (transactionName.Equals("Warning_FailurePreproccessor"))
            {
                foreach (FailureMessageAccessor fma in fmas)
                {
                    FailureDefinitionId id = fma.GetFailureDefinitionId();
                    if (id == Command.m_idWarning)
                    {
                        failuresAccessor.DeleteWarning(fma);
                    }
                }

                return FailureProcessingResult.ProceedWithCommit;
            }
            else if (transactionName.Equals("Warning_FailurePreproccessor_OverlappedWall"))
            {
                foreach (FailureMessageAccessor fma in fmas)
                {
                    FailureDefinitionId id = fma.GetFailureDefinitionId();
                    if (id == BuiltInFailures.OverlapFailures.WallsOverlap)
                    {
                        failuresAccessor.DeleteWarning(fma);
                    }
                }

                return FailureProcessingResult.ProceedWithCommit;
            }
            else
            {
                return FailureProcessingResult.Continue;
            }
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Method that Revit will invoke to process failures at the end of transaction. 
        /// </summary>
        /// <param name="failuresAccessor">Provides all necessary data to perform the resolution of failures.</param>
        /// <returns></returns>
        public FailureProcessingResult ProcessFailures(FailuresAccessor failuresAccessor)
        {
            IList<FailureMessageAccessor> fmas = failuresAccessor.GetFailureMessages();
            if (fmas.Count == 0)
            {
                return FailureProcessingResult.Continue;
            }

            String transactionName = failuresAccessor.GetTransactionName();
            if (transactionName.Equals("Error_FailuresProcessor"))
            {
                foreach (FailureMessageAccessor fma in fmas)
                {
                    FailureDefinitionId id = fma.GetFailureDefinitionId();
                    if (id == Command.m_idError)
                    {
                        failuresAccessor.ResolveFailure(fma);
                    }
                }
                return FailureProcessingResult.ProceedWithCommit;
            }
            else
            {
                return FailureProcessingResult.Continue;
            }
        }
Ejemplo n.º 35
0
      /// <summary>
      /// Log the failures coming from shape creation.
      /// </summary>
      /// <param name="failuresAccessor">The failure messages</param>
      /// <returns>The result of processing the failures.</returns>
      /// <remarks>This is in no way intended to be final code, as it doesn't actual handle failures,
      /// just logs them.</remarks>
      public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
      {
         int currentlyProcessedEntityId = (CurrentlyProcessedEntity != null) ? CurrentlyProcessedEntity.Id : 0;
         IList<FailureMessageAccessor> failList = failuresAccessor.GetFailureMessages();
         foreach (FailureMessageAccessor failure in failList)
         {
            if (currentlyProcessedEntityId != 0)
               Write("#" + currentlyProcessedEntityId + ": ");
            else
               Write("GENERIC ");

            switch (failure.GetSeverity())
            {
               case FailureSeverity.Warning:
                  Write("WARNING: ");
                  break;
               default:
                  Write("ERROR: ");
                  break;
            }

            ICollection<ElementId> failureIds = failure.GetFailingElementIds();
            int numFailureIds = (failureIds == null) ? 0 : failureIds.Count;
            if (numFailureIds > 0)
            {
               Write("(Revit Element Id");
               if (numFailureIds > 1)
                  Write("s");
               Write(": ");
               foreach (ElementId failureId in failureIds)
                  Write(failureId + " ");
               Write("): ");
            }

            WriteLine(failure.GetDescriptionText());
         }

         // Only remove the warnings if logging is on.
         failuresAccessor.DeleteAllWarnings();

         return FailureProcessingResult.Continue;
      }
Ejemplo n.º 36
0
    public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
    {
        foreach (FailureMessageAccessor failure in failuresAccessor.GetFailureMessages())
                {
                    // Delete any "Can't paste duplicate types.  Only non duplicate types will be pasted." warnings
                    //if (failure.GetFailureDefinitionId() == BuiltInFailures.CopyPasteFailures.CannotCopyDuplicates)
                    if (failure.GetFailureDefinitionId() == BuiltInFailures.CopyPasteFailures.CannotCopyDuplicates)
                    {
                        failuresAccessor.DeleteWarning(failure);
                        //failuresAccessor.GetType();
                    }
                    //List<ElementId> delete = new List<ElementId>();
                    //failuresAccessor.DeleteElements(delete);
                }

                // Handle any other errors interactively
                return FailureProcessingResult.Continue;
    }
Ejemplo n.º 37
0
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            var failList = failuresAccessor.GetFailureMessages();

            var query = from fail in failList
                        let severity = fail.GetSeverity()
                        where severity == FailureSeverity.Warning
                        select fail;

            foreach (var fail in query)
            {
                DynamoLogger.Instance.Log(
                    "!! Warning: " + fail.GetDescriptionText());
                failuresAccessor.DeleteWarning(fail);
            }

            return FailureProcessingResult.Continue;
        }
Ejemplo n.º 38
0
        private static void TransactionManager_FailuresRaised(FailuresAccessor failuresAccessor)
        {
            IList<FailureMessageAccessor> failList = failuresAccessor.GetFailureMessages();

            IEnumerable<FailureMessageAccessor> query = 
                from fail in failList
                where fail.GetSeverity() == FailureSeverity.Warning
                select fail;

            foreach (FailureMessageAccessor fail in query)
            {
                dynSettings.DynamoLogger.Log("!! Warning: " + fail.GetDescriptionText());
                failuresAccessor.DeleteWarning(fail);
            }
        }
            public FailureProcessingResult PreprocessFailures(
                FailuresAccessor a)
            {
                // inside event handler, get all warnings

                IList<FailureMessageAccessor> failures
                  = a.GetFailureMessages();

                foreach( FailureMessageAccessor f in failures )
                {
                  // check failure definition ids
                  // against ones to dismiss:

                  FailureDefinitionId id
                = f.GetFailureDefinitionId();

                  if( BuiltInFailures.RoomFailures.RoomNotEnclosed
                == id )
                  {
                a.DeleteWarning( f );
                  }
                }
                return FailureProcessingResult.Continue;
            }