예제 #1
0
        public void CreatesNewCollectionWhenAddingItems()
        {
            FailureMessages list = FailureMessages.Empty.With(FailureMessage.Expected("expectation"));

            list.ToString().ShouldBe("expectation expected");
            list.ShouldNotBeSameAs(FailureMessages.Empty);
        }
예제 #2
0
        /// <summary>
        /// Invokes the current action based on the provided message.
        /// </summary>
        /// <param name="message">The message upon which the action acts.</param>
        public void Invoke(ICommunicationMessage message)
        {
            var msg = message as DataDownloadRequestMessage;

            if (msg == null)
            {
                Debug.Assert(false, "The message is of the incorrect type.");
                return;
            }

            if (!m_Uploads.HasRegistration(msg.Token))
            {
                m_Diagnostics.Log(
                    LevelToLog.Warn,
                    CommunicationConstants.DefaultLogTextPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "No file was registered for uploading with token {0}",
                        msg.Token));

                SendMessage(msg, new FailureMessage(m_Layer.Id, msg.Id));
                return;
            }

            var filePath    = m_Uploads.Deregister(msg.Token);
            var tokenSource = new CancellationTokenSource();

            m_Diagnostics.Log(
                LevelToLog.Debug,
                CommunicationConstants.DefaultLogTextPrefix,
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Transferring file: {0}",
                    filePath));
            var task = m_Layer.UploadData(msg.Sender, filePath, tokenSource.Token, m_Scheduler);

            ICommunicationMessage returnMsg;

            try
            {
                task.Wait();
                returnMsg = new SuccessMessage(m_Layer.Id, msg.Id);
            }
            catch (AggregateException e)
            {
                m_Diagnostics.Log(
                    LevelToLog.Error,
                    CommunicationConstants.DefaultLogTextPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "An error occurred during the transfer of the file {0}. Exception was: {1}",
                        filePath,
                        e));

                returnMsg = new FailureMessage(m_Layer.Id, msg.Id);
                m_Uploads.Reregister(msg.Token, filePath);
            }

            SendMessage(msg, returnMsg);
        }
예제 #3
0
        public Mission(MissionPrefab prefab, Location[] locations)
        {
            System.Diagnostics.Debug.Assert(locations.Length == 2);

            this.prefab = prefab;

            Description    = prefab.Description;
            SuccessMessage = prefab.SuccessMessage;
            FailureMessage = prefab.FailureMessage;
            Headers        = new List <string>(prefab.Headers);
            Messages       = new List <string>(prefab.Messages);

            for (int n = 0; n < 2; n++)
            {
                if (Description != null)
                {
                    Description = Description.Replace("[location" + (n + 1) + "]", locations[n].Name);
                }
                if (SuccessMessage != null)
                {
                    SuccessMessage = SuccessMessage.Replace("[location" + (n + 1) + "]", locations[n].Name);
                }
                if (FailureMessage != null)
                {
                    FailureMessage = FailureMessage.Replace("[location" + (n + 1) + "]", locations[n].Name);
                }
                for (int m = 0; m < Messages.Count; m++)
                {
                    Messages[m] = Messages[m].Replace("[location" + (n + 1) + "]", locations[n].Name);
                }
            }
        }
예제 #4
0
        public static void PostFailure(Document document, FailureDefinitionId failureId, ElementId elementId)
        {
            var msg = new FailureMessage(failureId);

            msg.SetFailingElement(elementId);
            document.PostFailure(msg);
        }
예제 #5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (TradeId.Length != 0)
            {
                hash ^= TradeId.GetHashCode();
            }
            if (Token.Length != 0)
            {
                hash ^= Token.GetHashCode();
            }
            if (Success != false)
            {
                hash ^= Success.GetHashCode();
            }
            if (FailureReason != global::Trading.TradeFailureReason.SessionId)
            {
                hash ^= FailureReason.GetHashCode();
            }
            if (FailureMessage.Length != 0)
            {
                hash ^= FailureMessage.GetHashCode();
            }
            hash ^= items_.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
예제 #6
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Success != false)
            {
                hash ^= Success.GetHashCode();
            }
            if (FailureReason != global::Authentication.AuthFailureReason.AuthType)
            {
                hash ^= FailureReason.GetHashCode();
            }
            if (FailureMessage.Length != 0)
            {
                hash ^= FailureMessage.GetHashCode();
            }
            if (SessionId.Length != 0)
            {
                hash ^= SessionId.GetHashCode();
            }
            if (expiry_ != null)
            {
                hash ^= Expiry.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
예제 #7
0
        protected async override Task OnHandleMessageAsync(Message message, NetworkSession session)
        {
            FailureMessage failureMessage = (FailureMessage)message;
            AuthSession    authSession    = (AuthSession)session;

            await authSession.AuthFailedAsync(failureMessage.Reason).ConfigureAwait(false);
        }
예제 #8
0
        public void CanIndicateSpecificExpectation()
        {
            var failure = (ExpectationFailureMessage)FailureMessage.Expected("statement");

            failure.Expectation.ShouldBe("statement");
            failure.ToString().ShouldBe("statement expected");
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (TradeId.Length != 0)
            {
                hash ^= TradeId.GetHashCode();
            }
            if (Token.Length != 0)
            {
                hash ^= Token.GetHashCode();
            }
            if (Success != false)
            {
                hash ^= Success.GetHashCode();
            }
            if (FailureReason != 0)
            {
                hash ^= FailureReason.GetHashCode();
            }
            if (FailureMessage.Length != 0)
            {
                hash ^= FailureMessage.GetHashCode();
            }
            hash ^= items_.GetHashCode();
            return(hash);
        }
예제 #10
0
        public override int GetHashCode()
        {
            unchecked {
                int hash = 17;
                hash = hash * 23 + Status.GetHashCode();
                hash = hash * 23 + Amount.GetHashCode();
                hash = hash * 23 + Currency.GetHashCode();
                hash = hash * 23 + Description.GetHashCode();
                hash = hash * 23 + Capture.GetHashCode();
                hash = hash * 23 + Authorized.GetHashCode();
                hash = hash * 23 + Reversed.GetHashCode();
                hash = hash * 23 + Paid.GetHashCode();
                hash = hash * 23 + Transaction.GetHashCode();
                hash = hash * 23 + Card.GetHashCode();
                hash = hash * 23 + Refunded.GetHashCode();
                hash = hash * 23 + Refunds.GetHashCode();
                hash = hash * 23 + FailureCode.GetHashCode();
                hash = hash * 23 + FailureMessage.GetHashCode();
                hash = hash * 23 + Customer.GetHashCode();
                hash = hash * 23 + IP.GetHashCode();
                hash = hash * 23 + Dispute.GetHashCode();
                hash = hash * 23 + ReturnURI.GetHashCode();
                hash = hash * 23 + AuthorizeURI.GetHashCode();

                return(hash);
            }
        }
예제 #11
0
    // Update is called once per frame
    void Update()
    {
        if (score >= winScore && score != 0)
        {
            Debug.Log("Level Complete");

            SuccessMessage successMessage = new SuccessMessage();

            successMessage.nextLevel         = nextLevel;
            successMessage.nextLevelWinScore = nextLevelWinScore;

            Debug.Log("Publishing Success Message");
            AudioManager.instance.Play("Win");
            PubSubServerInstance.Publish(successMessage);

            score    = 0;
            winScore = nextLevelWinScore;
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Debug.Log("Level Failed");
            FailureMessage failureMessage = new FailureMessage();

            Debug.Log("Publishing Failure Message");
            PubSubServerInstance.Publish(failureMessage);

            AudioManager.instance.Play("Fail");
        }
    }
예제 #12
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Success != false)
            {
                hash ^= Success.GetHashCode();
            }
            if (FailureReason != 0)
            {
                hash ^= FailureReason.GetHashCode();
            }
            if (FailureMessage.Length != 0)
            {
                hash ^= FailureMessage.GetHashCode();
            }
            if (SessionId.Length != 0)
            {
                hash ^= SessionId.GetHashCode();
            }
            if (expiry_ != null)
            {
                hash ^= Expiry.GetHashCode();
            }
            if (ExpiresIn != 0)
            {
                hash ^= ExpiresIn.GetHashCode();
            }
            return(hash);
        }
예제 #13
0
        public void Invoke(ICommunicationMessage message)
        {
            var msg = message as UnknownMessageTypeMessage;

            if (msg != null)
            {
                // We don't want to respond to our own messages otherwise we get a nasty
                // feedback loop that just keeps going, and going and going and going and
                // .... well I think you get the point.
                return;
            }

            try
            {
                var returnMessage = new FailureMessage(m_Current, message.Id);
                m_SendMessage(message.Sender, returnMessage, CommunicationConstants.DefaultMaximuNumberOfRetriesForMessageSending);
            }
            catch (Exception e)
            {
                m_Diagnostics.Log(
                    LevelToLog.Error,
                    CommunicationConstants.DefaultLogTextPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "Error while trying to send unknown message response. Exception is: {0}",
                        e));
            }
        }
예제 #14
0
        public void CanIncludeBacktrackErrors()
        {
            var deepBacktrack = FailureMessage.Backtrack(new Position(3, 4),
                                                         FailureMessages.Empty
                                                         .With(FailureMessage.Expected("A"))
                                                         .With(FailureMessage.Expected("B")));

            var shallowBacktrack = FailureMessage.Backtrack(new Position(2, 3),
                                                            FailureMessages.Empty
                                                            .With(FailureMessage.Expected("C"))
                                                            .With(FailureMessage.Expected("D"))
                                                            .With(deepBacktrack));

            var unrelatedBacktrack = FailureMessage.Backtrack(new Position(1, 2),
                                                              FailureMessages.Empty
                                                              .With(FailureMessage.Expected("E"))
                                                              .With(FailureMessage.Expected("F")));

            FailureMessages.Empty
            .With(deepBacktrack)
            .ToString().ShouldBe("[(3, 4): A or B expected]");

            FailureMessages.Empty
            .With(shallowBacktrack)
            .ToString().ShouldBe("[(2, 3): C or D expected [(3, 4): A or B expected]]");

            FailureMessages.Empty
            .With(FailureMessage.Expected("G"))
            .With(FailureMessage.Expected("H"))
            .With(shallowBacktrack)
            .With(unrelatedBacktrack)
            .ToString().ShouldBe("G or H expected [(1, 2): E or F expected] [(2, 3): C or D expected [(3, 4): A or B expected]]");
        }
예제 #15
0
        public void CanIndicatePotentialErrors()
        {
            var potentialErrors = FailureMessages.Empty
                                  .With(FailureMessage.Expected("A"))
                                  .With(FailureMessage.Expected("B"));

            new Success <object>("x", _unparsed, potentialErrors).FailureMessages.ShouldBe(potentialErrors);
        }
예제 #16
0
 public WarningItem(FailureMessage msg, Document doc)
 {
     CentralPath     = FileInfoUtil.GetCentralFilePath(doc).ToLower();
     FailingElements = msg.GetFailingElements().Select(x => doc.GetElement(x).UniqueId).ToList();
     DescriptionText = msg.GetDescriptionText();
     // (Konrad) I am not setting created by here on purpose. This will be set when warnings are reconciled.
     UniqueId = msg.GetFailureDefinitionId().Guid + string.Join("", FailingElements);
 }
예제 #17
0
 private void PostWarningIsFamilyDocument(Document document, ElementId id)
 {
     using (FailureMessage message = new FailureMessage(_warnIsFamilyDocumentId))
     {
         message.SetFailingElement(id);
         document.PostFailure(message);
     }
 }
예제 #18
0
        public void CanIndicateMultipleErrorsAtTheCurrentPosition()
        {
            var errors = FailureMessages.Empty
                         .With(FailureMessage.Expected("A"))
                         .With(FailureMessage.Expected("B"));

            new Failure <object>(endOfInput, errors).FailureMessages.ToString().ShouldBe("A or B expected");
        }
예제 #19
0
        /// <summary>
        /// When the json string is successfully parsed will return with an IServerMessage implementation.
        /// </summary>
        public static IServerMessage Parse(IJsonEncoder encoder, string json)
        {
            // Nothing to parse?
            if (string.IsNullOrEmpty(json))
            {
                HTTPManager.Logger.Error("MessageFactory", "Parse - called with empty or null string!");
                return(null);
            }

            // We don't have to do further decoding, if it's an empty json object, then it's a KeepAlive message from the server
            if (json.Length == 2 && json == "{}")
            {
                return(new KeepAliveMessage());
            }

            IDictionary <string, object> msg = null;

            try
            {
                // try to decode the json message with the encoder
                msg = encoder.DecodeMessage(json);
            }
            catch (Exception ex)
            {
                HTTPManager.Logger.Exception("MessageFactory", "Parse - encoder.DecodeMessage", ex);
                return(null);
            }

            if (msg == null)
            {
                HTTPManager.Logger.Error("MessageFactory", "Parse - Json Decode failed for json string: \"" + json + "\"");
                return(null);
            }

            // "C" is for message id
            IServerMessage result = null;

            if (!msg.ContainsKey("C"))
            {
                // If there are no ErrorMessage in the object, then it was a success
                if (!msg.ContainsKey("E"))
                {
                    result = new ResultMessage();
                }
                else
                {
                    result = new FailureMessage();
                }
            }
            else
            {
                result = new MultiMessage();
            }

            result.Parse(msg);

            return(result);
        }
예제 #20
0
        /// <inheritdoc/>
        public override IReply <TValue> Parse(TokenStream tokens)
        {
            if (tokens.Current.Kind == _kind)
            {
                return(new Success <TValue>(_value, tokens.Advance()));
            }

            return(new Failure <TValue>(tokens, FailureMessage.Expected(_kind.Name)));
        }
예제 #21
0
            protected internal override bool matchesSafely(ResponseMessage t)
            {
                assertThat(t, instanceOf(typeof(FailureMessage)));
                FailureMessage msg = ( FailureMessage )t;

                assertThat(msg.Status(), equalTo(_status));
                assertThat(msg.Message(), containsString(_message));
                return(true);
            }
예제 #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailDifferentlyIfTooManyFailedAuthAttempts() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailDifferentlyIfTooManyFailedAuthAttempts()
        {
            // Given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long timeout = System.currentTimeMillis() + 60_000;
            long           timeout        = DateTimeHelper.CurrentUnixTimeMillis() + 60_000;
            FailureMessage failureMessage = null;

            // When
            while (failureMessage == null)
            {
                if (DateTimeHelper.CurrentUnixTimeMillis() > timeout)
                {
                    fail("Timed out waiting for the authentication failure to occur.");
                }

                ExecutorService executor = Executors.newFixedThreadPool(10);

                // Fire up some parallel connections that all send wrong authentication tokens
                IList <CompletableFuture <FailureMessage> > futures = new List <CompletableFuture <FailureMessage> >();
                for (int i = 0; i < 10; i++)
                {
                    futures.Add(CompletableFuture.supplyAsync(this.collectAuthFailureOnFailedAuth, executor));
                }

                try
                {
                    // Wait for all tasks to complete
                    CompletableFuture.allOf(futures.ToArray()).get(30, SECONDS);

                    // We want at least one of the futures to fail with our expected code
                    for (int i = 0; i < futures.Count; i++)
                    {
                        FailureMessage recordedMessage = futures[i].get();

                        if (recordedMessage != null)
                        {
                            failureMessage = recordedMessage;

                            break;
                        }
                    }
                }
                catch (TimeoutException)
                {
                    // if jobs did not complete, let's try again
                    // do nothing
                }
                finally
                {
                    executor.shutdown();
                }
            }

            assertThat(failureMessage.Status(), equalTo(Org.Neo4j.Kernel.Api.Exceptions.Status_Security.AuthenticationRateLimit));
            assertThat(failureMessage.Message(), containsString("The client has provided incorrect authentication details too many times in a row."));
        }
예제 #23
0
        /// <inheritdoc/>
        public override IGeneralReply ParseGenerally(TokenStream tokens)
        {
            if (tokens.Current.Kind == _kind)
            {
                return(new GeneralSuccess(tokens.Advance()));
            }

            return(new GeneralFailure(tokens, FailureMessage.Expected(_kind.Name)));
        }
예제 #24
0
        public static void PostFailure(Document document, IEnumerable<Exception> exceptions)
        {
            var log = new ExceptionLog();
            log.Add(exceptions);
            log.SaveToFile(Paths.ErrorFile);

            var msg = new FailureMessage(GeneralFailure);
            document.PostFailure(msg);
        }
예제 #25
0
 public void OmitsUnknownErrorsWhenAdditionalErrorsExist()
 {
     FailureMessages.Empty
     .With(FailureMessage.Expected("A"))
     .With(FailureMessage.Expected("B"))
     .With(FailureMessage.Unknown())
     .With(FailureMessage.Expected("C"))
     .ToString().ShouldBe("A, B or C expected");
 }
예제 #26
0
    void Death()
    {
        Debug.Log("Level Failed");

        FailureMessage failureMessage = new FailureMessage();

        Debug.Log("Publishing Failure Message");
        PubSubServer.Instance.Publish(failureMessage);

        AudioManager.instance.Play("Fail");
    }
        /// <inheritdoc/>
        public override IReply <TValue> Parse(TokenStream tokens)
        {
            if (tokens.Current.Kind != _kind)
            {
                return(new Failure <TValue>(tokens, FailureMessage.Expected(_kind.Name)));
            }

            var parsedValue = _lexemeMapping(tokens.Current.Lexeme);

            return(new Success <TValue>(parsedValue, tokens.Advance()));
        }
예제 #28
0
            protected internal override bool MatchesSafely(ResponseMessage t)
            {
                assertThat(t, instanceOf(typeof(FailureMessage)));
                FailureMessage msg = ( FailureMessage )t;

                if (!msg.Status().Equals(Org.Neo4j.Kernel.Api.Exceptions.Status_Security.Unauthorized) || !msg.Message().Contains("The client is unauthorized due to authentication failure."))
                {
                    SpecialMessage = msg;
                }
                return(true);
            }
예제 #29
0
        /// <inheritdoc/>
        public override IReply <string> Parse(TokenStream tokens)
        {
            var currentToken = tokens.Current;

            if (currentToken.Kind != _kind)
            {
                return(new Failure <string>(tokens, FailureMessage.Expected(_kind.Name)));
            }

            return(new Success <string>(currentToken.Lexeme, tokens.Advance()));
        }
예제 #30
0
 /// <summary>
 /// Determines if the Exception is local to the element, or if export should be aborted.
 /// </summary>
 /// <param name="ex">The unexpected exception.</param>
 public static bool IsFatalException(Document document, Exception exception)
 {
     string msg = exception.ToString();
     if (msg.Contains("Error in allocating memory"))
     {
         FailureMessage fm = new FailureMessage(BuiltInFailures.ExportFailures.IFCFatalToolkitExportError);
         document.PostFailure(fm); 
         return true;
     }
     return false;
 }
예제 #31
0
        public static void PostFailure(Document document, IEnumerable <Exception> exceptions)
        {
            var log = new ExceptionLog();

            log.Add(exceptions);
            log.SaveToFile(Paths.ErrorFile);

            var msg = new FailureMessage(GeneralFailure);

            document.PostFailure(msg);
        }
예제 #32
0
        public void AllowedAuthenticationsTest()
        {
            FailureMessage target = new FailureMessage(); // TODO: Initialize to an appropriate value

            string[] expected = null;                     // TODO: Initialize to an appropriate value
            string[] actual;
            target.AllowedAuthentications = expected;
            actual = target.AllowedAuthentications;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
예제 #33
0
        public void Execute(UpdaterData data)
        {
            Document doc = data.GetDocument();
            Application app = doc.Application;
            foreach (ElementId id in data.GetDeletedElementIds())
            {
                if (Command.IsProtected(id))
                {
                    FailureMessage failureMessage
                      = new FailureMessage(_failureId);

                    failureMessage.SetFailingElement(id);
                    doc.PostFailure(failureMessage);
                }
            }
        }
예제 #34
0
        /// <summary>
        /// Handles the unexpected Exception.
        /// </summary>
        /// <param name="ex">The unexpected exception.</param>
        /// <param name="element ">The element got the exception.</param>
        internal void HandleUnexpectedException(Exception exception, ExporterIFC exporterIFC, Element element)
        {
            Document document = element.Document;
            string errMsg = String.Format("IFC error: Exporting element \"{0}\",{1} - {2}", element.Name, element.Id, exception.ToString());
            element.Document.Application.WriteJournalComment(errMsg, true);

            if (!ExporterUtil.IsFatalException(document, exception))
            {
                FailureMessage fm = new FailureMessage(BuiltInFailures.ExportFailures.IFCGenericExportWarning);
                fm.SetFailingElement(element.Id);
                document.PostFailure(fm);
            }
            else
            {
                // This exception should be rethrown back to the main Revit application.
                throw exception;
            }
        }
 public FailureMessageExpected(FailureMessage failureMessage)
 {
     this.failureMessage = failureMessage;
 }
예제 #36
0
파일: Command.cs 프로젝트: AMEE/revit
        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application 
        /// which contains data related to the command, 
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application 
        /// which will be displayed if a failure or cancellation is returned by 
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application 
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command. 
        /// A result of Succeeded means that the API external method functioned as expected. 
        /// Cancelled can be used to signify that the user cancelled the external operation 
        /// at some point. Failure should be returned if the application is unable to proceed with 
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
        ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            m_revitApp = commandData.Application.Application;
            m_doc = commandData.Application.ActiveUIDocument.Document;

            Level level1 = GetLevel();
            if (level1 == null)
            {
                throw new Exception("[ERROR] Failed to get level 1");
            }

            try
            {
                //
                // Post a warning and resolve it in FailurePreproccessor
                try
                {
                    Transaction transaction = new Transaction(m_doc, "Warning_FailurePreproccessor");
                    FailureHandlingOptions options = transaction.GetFailureHandlingOptions();
                    FailurePreproccessor preproccessor = new FailurePreproccessor();
                    options.SetFailuresPreprocessor(preproccessor);
                    transaction.SetFailureHandlingOptions(options);
                    transaction.Start();
                    FailureMessage fm = new FailureMessage(m_idWarning);
                    m_doc.PostFailure(fm);
                    transaction.Commit();
                }
                catch (System.Exception)
                {
                    message = "Failed to commit transaction Warning_FailurePreproccessor";
                    return Result.Failed;
                }

                //
                // Dismiss the overlapped wall warning in FailurePreproccessor
                try
                {
                    Transaction transaction = new Transaction(m_doc, "Warning_FailurePreproccessor_OverlappedWall");
                    FailureHandlingOptions options = transaction.GetFailureHandlingOptions();
                    FailurePreproccessor preproccessor = new FailurePreproccessor();
                    options.SetFailuresPreprocessor(preproccessor);
                    transaction.SetFailureHandlingOptions(options);
                    transaction.Start();

                    Line line = m_revitApp.Create.NewLineBound(new XYZ(-10, 0, 0), new XYZ(-20, 0, 0));
                    Wall wall1 = m_doc.Create.NewWall(line, level1, false);
                    Wall wall2 = m_doc.Create.NewWall(line, level1, false);
                    m_doc.Regenerate();

                    transaction.Commit();
                }
                catch (System.Exception)
                {
                    message = "Failed to commit transaction Warning_FailurePreproccessor_OverlappedWall";
                    return Result.Failed;
                }

                //
                // Post an error and resolve it in FailuresProcessingEvent
                try
                {
                    m_revitApp.FailuresProcessing += new EventHandler<Autodesk.Revit.DB.Events.FailuresProcessingEventArgs>(FailuresProcessing);
                    Transaction transaction = new Transaction(m_doc, "Error_FailuresProcessingEvent");
                    transaction.Start();

                    Line line = m_revitApp.Create.NewLineBound(new XYZ(0, 10, 0), new XYZ(20, 10, 0));
                    Wall wall = m_doc.Create.NewWall(line, level1, false);
                    m_doc.Regenerate();

                    FailureMessage fm = new FailureMessage(m_idError);
                    FailureResolution fr = DeleteElements.Create(m_doc, wall.Id);
                    fm.AddResolution(FailureResolutionType.DeleteElements, fr);
                    m_doc.PostFailure(fm);
                    transaction.Commit();
                }
                catch (System.Exception)
                {
                    message = "Failed to commit transaction Error_FailuresProcessingEvent";
                    return Result.Failed;
                }

                //
                // Post an error and resolve it in FailuresProcessor
                try
                {
                    FailuresProcessor processor = new FailuresProcessor();
                    Application.RegisterFailuresProcessor(processor);
                    Transaction transaction = new Transaction(m_doc, "Error_FailuresProcessor");
                    transaction.Start();

                    Line line = m_revitApp.Create.NewLineBound(new XYZ(0, 20, 0), new XYZ(20, 20, 0));
                    Wall wall = m_doc.Create.NewWall(line, level1, false);
                    m_doc.Regenerate();

                    FailureMessage fm = new FailureMessage(m_idError);
                    FailureResolution fr = DeleteElements.Create(m_doc, wall.Id);
                    fm.AddResolution(FailureResolutionType.DeleteElements, fr);
                    m_doc.PostFailure(fm);
                    transaction.Commit();
                }
                catch (System.Exception)
                {
                    message = "Failed to commit transaction Error_FailuresProcessor";
                    return Result.Failed;
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return Result.Failed;
            }

            return Result.Succeeded;
        }
예제 #37
0
 public void SetUp()
 {
     testExpression = Substitute.For<TestExpressionProvider>();
     TestExpression.OverrideProvider(testExpression);
     sut = new FailureMessage();
 }
예제 #38
0
 public static void PostFailure(Document document, FailureDefinitionId failureId)
 {
     var msg = new FailureMessage(failureId);
     document.PostFailure(msg);
 }
예제 #39
0
      /// <summary>
      /// Post any delayed errors or warnings to the current document.
      /// </summary>
      /// <remarks>Needs to occur inside of a transaction.</remarks>
      public static void PostDelayedLinkErrors(Document doc)
      {
         if (m_ImportPostedErrors == null)
            return;

         try
         {
            foreach (FailureDefinitionId failureDefId in m_ImportPostedErrors)
            {
               FailureMessage fm = new FailureMessage(failureDefId);
               doc.PostFailure(fm);
            }
         }
         catch
         {
         }
         finally
         {
            m_ImportPostedErrors = null;
         }
      }
예제 #40
0
 public static void PostFailure(Document document, FailureDefinitionId failureId, ElementId elementId)
 {
     var msg = new FailureMessage(failureId);
     msg.SetFailingElement(elementId);
     document.PostFailure(msg);
 }