Esempio n. 1
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);
            }
        }
        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 { }
                }
            }
        }
Esempio n. 3
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);
        }
        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);
        }
Esempio n. 5
0
        public 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);
                }
            }
            return(FailureProcessingResult.Continue);
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
0
        public FailureProcessingResult PreprocessFailures(
            FailuresAccessor failuresAccessor)
        {
            IList <FailureResolutionType> resolutionTypeList = new List <FailureResolutionType>();

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

            if (failureMessages.Count == 0)
            {
                return(FailureProcessingResult.Continue);
            }
            else
            {
                foreach (FailureMessageAccessor fma in failureMessages)
                {
                    // check how many resolutions types were attempted to try to prevent
                    // entering infinite loop

                    /*
                     * resolutionTypeList = failuresAccessor.GetAttemptedResolutionTypes(fma);
                     * FailureDefinitionId failId = fma.GetFailureDefinitionId();
                     *
                     * string failureName = fma.ToString();
                     *
                     * if(resolutionTypeList.Count >= 3)
                     * {
                     *  return FailureProcessingResult.ProceedWithRollBack;
                     * }
                     */
                    FailureSeverity fsav = fma.GetSeverity();

                    if (fsav == FailureSeverity.Warning)
                    {
                        failuresAccessor.DeleteWarning(fma);
                    }
                    else
                    {
                        failuresAccessor.ResolveFailure(fma);
                        return(FailureProcessingResult.ProceedWithRollBack);
                    }
                }
                return(FailureProcessingResult.Continue);
            }
        }
Esempio n. 8
0
        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;
        }
Esempio n. 9
0
        public FailureProcessingResult PreprocessFailures(FailuresAccessor a)
        {
            IList <FailureMessageAccessor> failures = a.GetFailureMessages();

            foreach (FailureMessageAccessor f in failures)
            {
                FailureDefinitionId id = f.GetFailureDefinitionId();

                FailureSeverity failureSeverity = a.GetSeverity();

                if (failureSeverity == FailureSeverity.Warning)
                {
                    a.DeleteWarning(f);
                }
                else
                {
                    return(FailureProcessingResult.ProceedWithRollBack);
                }
            }
            return(FailureProcessingResult.Continue);
        }
Esempio n. 10
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);
            }
Esempio n. 11
0
        //This is the primary method for gathering the Warning information from the Document
        private void SetData(Document doc)
        {
            //Create a new List to hold the Warning Type names
            List <string> warningType = new List <string>();

            //Add the first item to the list so it can be controlled
            warningType.Add("--NONE--");

            //Check to see if the DataTable has had columns created not. If not (first time) then create olumns with the correct type of storage element
            if (dtWarnings.Columns.Count == 0)
            {
                //This is a bit redundent because they are all "warnings" as "errors" can't be ignored, but if you use custom error handlers, this may be more useful
                dtWarnings.Columns.Add(new DataColumn("Severity", typeof(FailureSeverity)));
                dtWarnings.Columns.Add(new DataColumn("Description", typeof(string)));
                dtWarnings.Columns.Add(new DataColumn("Element Ids", typeof(ICollection <ElementId>)));
                dtWarnings.Columns.Add(new DataColumn("Name", typeof(string)));
                dtWarnings.Columns.Add(new DataColumn("Creator", typeof(string)));
                dtWarnings.Columns.Add(new DataColumn("Phase Created", typeof(string)));
                dtWarnings.Columns.Add(new DataColumn("Phase Demo'd", typeof(string)));
            }
            //Use these two parameters in case it is not a workshared project
            string elemName = "None";
            string userId   = "None";

            //Loop through every warning in the document
            foreach (FailureMessage warning in doc.GetWarnings())
            {
                //Use these two parameters when the elements cannot have a phase create / demolished
                string pCreate = "";
                string pDemo   = "";

                //Set Issue Description to a string variable
                string description = warning.GetDescriptionText();

                //Check to see if the Warning Type list already has this Warning Type in it, and add it if not
                if (!warningType.Contains(description))
                {
                    warningType.Add(description);
                }

                //Get all of the Element Ids of the elements associated with the warning
                ICollection <ElementId> failingElements = warning.GetFailingElements();

                //This is a bit redundent because they are all "warnings" as "errors" can't be ignored, but if you use custom error handlers, this may be more useful
                FailureSeverity severity = warning.GetSeverity();

                //Check to make sure there are Element Ids for the elements. Some warning types (MECH Systems) do not always provide Element Ids
                if (failingElements.OfType <ElementId>().FirstOrDefault() is ElementId first)
                {
                    //Get the First element of the warning elements in the Document
                    Element elem = doc.GetElement(first);
                    //Set the parameter to the actual name instead of "None" from above
                    elemName = elem.Name;
                    //Checks to see if the Element has any phases associated with it and sets the pCreate and pDemo variables previousy defined
                    if (elem.HasPhases())
                    {
                        if (elem.CreatedPhaseId != ElementId.InvalidElementId)
                        {
                            pCreate = doc.GetElement(elem.CreatedPhaseId).Name;
                        }
                        if (elem.DemolishedPhaseId != ElementId.InvalidElementId)
                        {
                            pDemo = doc.GetElement(elem.DemolishedPhaseId).Name;
                        }
                    }
                    //Checks to see if the Document has Worksharing enables and gets the User informaiton associated with the creation of the element for refernce
                    if (doc.IsWorkshared)
                    {
                        userId = WorksharingUtils.GetWorksharingTooltipInfo(doc, first).Creator;
                    }
                }

                //Add a reow to the DataTable with all of the informaiton for the warning
                dtWarnings.Rows.Add(severity, description, failingElements, elemName, userId, pCreate, pDemo);
            }

            //Set the DataGridView's data source to the DataTable
            dgWarnings.DataSource = dtWarnings;
            //Change the AutoSize mode to fill the width of the DataGridView as it resizes
            dgWarnings.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            //Changes the text to include the number of Wanrings for reference to the User
            dgWarnings.Columns[1].HeaderText   = "Description (" + dtWarnings.Rows.Count.ToString() + ")";
            dgWarnings.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            //Hides the column that contains the Element Ids to keep the DataGridView clean
            dgWarnings.Columns[2].Visible      = false;
            dgWarnings.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dgWarnings.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dgWarnings.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dgWarnings.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            //Set the DataGridView to sort based on the Description
            dgWarnings.Sort(dgWarnings.Columns[1], System.ComponentModel.ListSortDirection.Ascending);
            //Clears the auto selection of any rows in the DataGridivew so no elements are selected initially
            dgWarnings.ClearSelection();

            //Clears the Warning Type combo box of all items
            cboWarningType.DataSource = null;
            //Reset the Warning Type combo box with the List of warnings Types
            cboWarningType.DataSource = warningType.ToList();
        }
Esempio n. 12
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);
            }