Beispiel #1
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'");
                }
            }
        }
        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);
        }
        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 { }
                }
            }
        }
Beispiel #4
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);
            }
        }
Beispiel #5
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);
        }
Beispiel #6
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;
                }
            }
        }
        /// <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"></param>
        /// <returns></returns>
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            // 在事务结束时,Revit即将处理这些错误之前调用

            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);
            }
        }
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            var failureMessages = failuresAccessor.GetFailureMessages();
            //if (failureMessages.Count == 0) { return FailureProcessingResult.Continue; }

            var needRollBack = false;

            foreach (var fma in failureMessages)
            {
                var messageInfo = new FailureMessageInfo();

                var severity = fma.GetSeverity();
                try
                {
                    if (severity == FailureSeverity.Warning)
                    {
                        failuresAccessor.DeleteWarning(fma);
                    }
                    else
                    {
                        needRollBack = true;
                    }
                    messageInfo.TransactionName = failuresAccessor.GetTransactionName();
                    messageInfo.ErrorSeverity   = severity.ToString();
                    try
                    {
                        messageInfo.ErrorMessage      = fma.GetDescriptionText();
                        messageInfo.FailingElementIds = fma.GetFailingElementIds().ToList();
                    }
                    catch
                    {
                    }
                }
                catch { messageInfo.ErrorMessage = "Unknown Error"; }
                failureMessageInfoList.Add(messageInfo);
            }

            if (needRollBack)
            {
                return(FailureProcessingResult.ProceedWithRollBack);
            }
            else
            {
                return(FailureProcessingResult.Continue);
            }
        }
Beispiel #9
0
        void OnFailureProcessings(object sender, FailuresProcessingEventArgs args)
        {
            FailuresAccessor f = args.GetFailuresAccessor();

            string transName = f.GetTransactionName();

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

            if (transName.Equals("Change shared coordinates in source"))
            {
                Debug.Write("lolkek");
            }

            if (fmas.Count == 0)
            {
                args.SetProcessingResult(FailureProcessingResult.Continue);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Implements the FailureProcessing event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FailuresProcessing(object sender, FailuresProcessingEventArgs e)
        {
            FailuresAccessor failuresAccessor       = e.GetFailuresAccessor();
            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)
                    {
                        failuresAccessor.ResolveFailure(f);
                        e.SetProcessingResult(FailureProcessingResult.ProceedWithCommit);
                        return;
                    }
                }
            }
        }
Beispiel #11
0
            FailureProcessingResult IFailuresPreprocessor.PreprocessFailures(FailuresAccessor failuresAccessor)
            {
                String transactionName = failuresAccessor.GetTransactionName();

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

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

                foreach (FailureMessageAccessor fma in fmas)
                {
                    FailureSeverity fseverity = fma.GetSeverity();

                    if (fseverity == FailureSeverity.Warning)
                    {
                        failuresAccessor.DeleteWarning(fma);
                    }
                }

                return(FailureProcessingResult.Continue);
            }
Beispiel #12
0
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            string transName = failuresAccessor.GetTransactionName();

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

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

            if (transName == Properties.Messages.ElementJoin_JoinTransaction || transName == Properties.Messages.ElementJoin_UnJoinTransaction)
            {
                foreach (FailureMessageAccessor currentMessage in failMessages)
                {
                    failuresAccessor.ResolveFailure(currentMessage);
                }

                return(FailureProcessingResult.ProceedWithCommit);
            }

            return(FailureProcessingResult.Continue);
        }
Beispiel #13
0
        /// <summary>
        /// Method that Revit will invoke to process failures at the end of transaction.
        /// </summary>
        /// <param name="data"></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);
                        TaskDialog.Show("title", $"我捕捉到了消息内容为\"{fma.GetDescriptionText()}\"的错误,我在后台已经把他解决掉了0.0~~");
                    }
                }

                // 不再抛出
                return(FailureProcessingResult.ProceedWithCommit);
            }
            else
            {
                // 没有做处理,继续抛出
                return(FailureProcessingResult.Continue);
            }
        }
Beispiel #14
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;
            }
        }
Beispiel #15
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;
            }
        }