示例#1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create an annotation in response to an error returned by a check.
        /// The check calls this delegate whenever an error is found.
        /// </summary>
        /// <param name="args">Information about the potential inconsistency being reported</param>
        /// ------------------------------------------------------------------------------------
        public void RecordError(RecordErrorEventArgs args)
        {
            ScrCheckingToken firstToken = args.Tts.FirstToken as ScrCheckingToken;
            ScrCheckingToken lastToken  = args.Tts.LastToken as ScrCheckingToken;

            Debug.Assert(firstToken != null);
            Debug.Assert(lastToken != null);
            Debug.Assert(firstToken.Object == lastToken.Object);
            int    offset       = args.Tts.Offset;
            int    length       = args.Tts.Length;
            Guid   checkId      = args.CheckId;
            string formattedMsg = args.Tts.Message;

            // If the token is for a missing reference, then replace the token's
            // reference range with the missing reference range.
            if (args.Tts.MissingStartRef != null && !args.Tts.MissingStartRef.IsEmpty)
            {
                firstToken.m_startRef = new BCVRef(firstToken.MissingStartRef);
                firstToken.m_endRef   = new BCVRef(firstToken.MissingEndRef != null ?
                                                   firstToken.m_missingEndRef : firstToken.m_startRef);
            }

            int    bookNum   = firstToken.StartRef.Book;
            string citedText = args.Tts.Text;

            IScrBookAnnotations annotations =
                (IScrBookAnnotations)m_scr.BookAnnotationsOS[bookNum - 1];

            // key for the error with the same cited text and message at a particular reference.
            string errorLocKey = firstToken.StartRef.AsString + lastToken.EndRef.AsString +
                                 citedText + formattedMsg;
            // key for an error with the same cited text and message.
            string errorKey = checkId.ToString() + citedText + formattedMsg;

            if (CheckForPreviousInconsistency(firstToken, lastToken, citedText, offset, length, checkId, errorLocKey, errorKey))
            {
                return;
            }

            // NOTE: A maxIdenticalErrors value of -1 indicates that there is no maximum set.
            int maxIdenticalErrors = GetMaxIdenticalErrors(checkId);
            int errorCount         = m_errorCounts.GetValue(errorKey);

            // Check the number of times this same error has already been reported.
            // If the maximum allowed number of identical errors already has been reached then
            // we don't want to report the error as usual.
            if (errorCount == maxIdenticalErrors)
            {
                formattedMsg = GetExceededErrorMsg(checkId);
            }
            else if (errorCount > maxIdenticalErrors && maxIdenticalErrors > -1)
            {
                // We have exceeded the maximum allowed for this error, so don't write out an annotation.
                return;
            }

            m_errorCounts.IncrementError(errorKey);
            AddErrorAnnotation(citedText, offset, length, checkId, firstToken, lastToken, formattedMsg);
            m_bookChecksFailed[bookNum][checkId] = ScrCheckRunResult.Inconsistencies;
        }
示例#2
0
        private void recorder_Error(object sender, RecordErrorEventArgs e)
        {
            Trace.TraceError(e.Exception.ToString());
            Exception inneException = e.Exception.InnerException;

            if (inneException is TrackingException) // This usually happens if specified window get closed
            {
                this.ResetTracker();
            }
            this.view.ShowError(e.Exception.Message);
            this.anyRecord = IOUtil.FileExists(this.recorder.FileName);
        }
示例#3
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Record errors returned by a check. The check calls this delegate whenever an error
 /// is found.
 /// </summary>
 /// <param name="args">Information about the potential inconsistency being reported</param>
 /// ------------------------------------------------------------------------------------
 public void RecordError(RecordErrorEventArgs args)
 {
     m_errors.Add(args);
 }