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);
        }
Beispiel #2
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;
            }
        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);
        }
Beispiel #4
0
        /// <summary>
        /// Preprocesses the failures.
        /// </summary>
        /// <param name="fa">The failure accessor.</param>
        /// <returns></returns>
        public FailureProcessingResult PreprocessFailures(FailuresAccessor fa)
        {
            fa.DeleteAllWarnings();
            //if (fa.CanCommitPendingTransaction())
            //{
            //    return FailureProcessingResult.ProceedWithCommit;
            //}

            return(FailureProcessingResult.Continue);
        }
Beispiel #5
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);
        }
Beispiel #6
0
        // TODO: gracefully save them somewhere, or do something about them - collect them and show them in the ui somehow?
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            //var fails = failuresAccessor.GetFailureMessages();

            //foreach(var f in fails)
            //{
            //}

            failuresAccessor.DeleteAllWarnings();
            return(FailureProcessingResult.Continue);
        }
Beispiel #7
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);
        }
Beispiel #8
0
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            //IList<FailureMessageAccessor> failureMessages = failuresAccessor.GetFailureMessages();

            //foreach (FailureMessageAccessor currenMessageAcessor in failureMessages)
            //{
            //    failuresAccessor.ResolveFailure(currenMessageAcessor);
            //}

            failuresAccessor.DeleteAllWarnings();

            return(FailureProcessingResult.Continue);
        }
        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);
        }
Beispiel #10
0
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            IList <FailureMessageAccessor> Failures = failuresAccessor.GetFailureMessages();

            foreach (FailureMessageAccessor failure in Failures)
            {
                if (failure.GetSeverity().ToString().Contains("Warning"))
                {
                    FailureDefinitionId Id = failure.GetFailureDefinitionId();
                    failuresAccessor.DeleteAllWarnings();
                }
            }
            return(FailureProcessingResult.Continue);
        }
        private void Application_FailuresProcessing(object sender, FailuresProcessingEventArgs e)
        {
            FailuresAccessor failuresAccessor = e.GetFailuresAccessor();

            failuresAccessor.DeleteAllWarnings();

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

            var options = failuresAccessor.GetFailureHandlingOptions();

            options.SetClearAfterRollback(true);
            options.SetForcedModalHandling(false);

            failuresAccessor.SetFailureHandlingOptions(options);
        }
Beispiel #12
0
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            IList <FailureMessageAccessor> failList = new List <FailureMessageAccessor>();
            var criticalFails  = 0;
            var failedElements = new List <ElementId>();

            // Inside event handler, get all warnings
            failList = failuresAccessor.GetFailureMessages();
            foreach (FailureMessageAccessor failure in failList)
            {
                // check FailureDefinitionIds against ones that you want to dismiss,
                //FailureDefinitionId failID = failure.GetFailureDefinitionId();
                // prevent Revit from showing Unenclosed room warnings
                //if (failID == BuiltInFailures.RoomFailures.RoomNotEnclosed)
                //{
                var t = failure.GetDescriptionText();
                _converter.ConversionErrors.Add(new Exception(t));

                var s = failure.GetSeverity();
                if (s == FailureSeverity.Warning)
                {
                    continue;
                }
                try
                {
                    failuresAccessor.ResolveFailure(failure);
                }
                catch (Exception e)
                {
                    // currently, the whole commit is rolled back. this should be investigated further at a later date
                    // to properly proceed with commit
                    failedElements.AddRange(failure.GetFailingElementIds());
                    _converter.ConversionErrors.Clear();
                    _converter.ConversionErrors.Add(new Exception(
                                                        "Objects failed to bake due to a fatal error!\n" +
                                                        "This is likely due to scaling issues - please ensure you've set the correct units on your objects or remove any invalid objects.\n\n" +
                                                        "Revit error: " + t));
                    // logging the error
                    var exception =
                        new Speckle.Core.Logging.SpeckleException("Revit commit failed: " + t, e,
                                                                  level: Sentry.SentryLevel.Warning);
                    return(FailureProcessingResult.ProceedWithCommit);
                }
            }

            failuresAccessor.DeleteAllWarnings();
            return(FailureProcessingResult.Continue);
        }
Beispiel #13
0
            public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
            {
                var severity = failuresAccessor.GetSeverity();

                if (severity == FailureSeverity.Warning)
                {
                    foreach (var warning in failuresAccessor.GetFailureMessages(FailureSeverity.Warning))
                    {
                        RhinoApp.WriteLine(warning.GetDescriptionText());
                    }

                    failuresAccessor.DeleteAllWarnings();
                    return(FailureProcessingResult.ProceedWithCommit);
                }

                return(FailureProcessingResult.Continue);
            }
Beispiel #14
0
        private void App_FailuresProcessing(object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e)
        {
            FailuresAccessor fa = e.GetFailuresAccessor();
            IList <FailureMessageAccessor> failList = new List <FailureMessageAccessor>();

            failList = fa.GetFailureMessages(); // Inside event handler, get all warnings
            foreach (FailureMessageAccessor failure in failList)
            {
                fa.DeleteAllWarnings();

                /*
                 * // check FailureDefinitionIds against ones that you want to dismiss, FailureDefinitionId failID = failure.GetFailureDefinitionId();
                 * // prevent Revit from showing Unenclosed room warnings
                 * FailureDefinitionId failID = failure.GetFailureDefinitionId();
                 * if (failID == BuiltInFailures.WorksharingFailures.DuplicateNamesChanged)
                 * {
                 * fa.DeleteWarning(failure);
                 * }*/
            }
        }
        private void FaliureProcessor(object sender, FailuresProcessingEventArgs e)
        {
            bool             hasFailure       = false;
            FailuresAccessor fas              = e.GetFailuresAccessor();
            List <FailureMessageAccessor> fma = fas.GetFailureMessages().ToList();
            List <ElementId> ElemntsToDelete  = new List <ElementId>();

            fas.DeleteAllWarnings();
            foreach (FailureMessageAccessor fa in fma)
            {
                try
                {
                    //use the following lines to delete the warning elements
                    List <ElementId> FailingElementIds = fa.GetFailingElementIds().ToList();
                    ElementId        FailingElementId  = FailingElementIds[0];
                    if (!ElemntsToDelete.Contains(FailingElementId))
                    {
                        ElemntsToDelete.Add(FailingElementId);
                    }

                    hasFailure = true;
                    fas.DeleteWarning(fa);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            if (ElemntsToDelete.Count > 0)
            {
                fas.DeleteElements(ElemntsToDelete);
            }
            //use the following line to disable the message supressor after the external command ends
            //CachedUiApp.Application.FailuresProcessing -= FaliureProcessor;
            if (hasFailure)
            {
                e.SetProcessingResult(FailureProcessingResult.ProceedWithCommit);
            }
            e.SetProcessingResult(FailureProcessingResult.Continue);
        }
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            IList <FailureMessageAccessor> failList = new List <FailureMessageAccessor>();

            // Inside event handler, get all warnings
            failList = failuresAccessor.GetFailureMessages();
            foreach (FailureMessageAccessor failure in failList)
            {
                // check FailureDefinitionIds against ones that you want to dismiss,
                //FailureDefinitionId failID = failure.GetFailureDefinitionId();
                // prevent Revit from showing Unenclosed room warnings
                //if (failID == BuiltInFailures.RoomFailures.RoomNotEnclosed)
                //{
                var t = failure.GetDescriptionText();
                var r = failure.GetDefaultResolutionCaption();

                Globals.ConversionErrors.Add(new SpeckleError {
                    Message = t
                });
            }

            failuresAccessor.DeleteAllWarnings();
            return(FailureProcessingResult.Continue);
        }
 public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
 {
     failuresAccessor.DeleteAllWarnings();
     return(FailureProcessingResult.Continue);
 }
      /// <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;
      }
Beispiel #19
0
        public FailureProcessingResult PreprocessFailures(FailuresAccessor accesoALosFallosDetectados)
        {
            accesoALosFallosDetectados.DeleteAllWarnings();

            return(FailureProcessingResult.Continue);
        }
Beispiel #20
0
            public FailureProcessingResult PreprocessFailures(
                FailuresAccessor a)
            {
                // inside event handler, get all warnings

                  //IList<FailureMessageAccessor> failures
                  //   = a.GetFailureMessages();
                  a.DeleteAllWarnings();
                  /*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);
                  }
                  }*/

                  IList<FailureMessageAccessor> failures = a.GetFailureMessages();
                  if (failures.Count > 0)
                  return FailureProcessingResult.ProceedWithRollBack;
                  else
                  return FailureProcessingResult.Continue;
            }