Пример #1
0
        /// <summary>
        /// Получить форматированное сообщение.
        /// </summary>
        /// <returns>Форматированное сообщение.</returns>
        private string GetFormattedMessage(IReportMessage message, char[] quotableCharacters, string doubleQuoteChar)
        {
            var columns = new[]
            {
                message.Code,
                message.Severity.ToString(),
                message.Description,
                message.Document.Name,
                message.Position.Line.ToString(),
                message.Position.Column.ToString()
            };

            var stringBuilder = new StringBuilder();
            var isFirstColumn = true;

            foreach (var currentColumn in columns)
            {
                if (!isFirstColumn)
                {
                    stringBuilder.Append(this.Delimiter);
                }
                isFirstColumn = false;

                bool currentColumnQuoting;
                switch (this.Quoting)
                {
                case CsvQuotingMode.All:
                    currentColumnQuoting = true;
                    break;

                case CsvQuotingMode.Nothing:
                    currentColumnQuoting = false;
                    break;

                default:
                    currentColumnQuoting = currentColumn.IndexOfAny(quotableCharacters) >= 0;
                    break;
                }

                if (currentColumnQuoting)
                {
                    stringBuilder.Append(this.QuoteChar);
                    stringBuilder.Append(currentColumn.Replace(this.QuoteChar, doubleQuoteChar));
                    stringBuilder.Append(this.QuoteChar);
                }
                else
                {
                    stringBuilder.Append(currentColumn);
                }
            }
            return(stringBuilder.ToString());
        }
Пример #2
0
        /// <summary>
        /// Показать сообщение отчета.
        /// </summary>
        /// <param name="message"></param>
        private void ShowReportMessage(IReportMessage message)
        {
            var documentViewer = PanelManager.Instance
                                 .GetPanels <DocumentViewerViewModel>()
                                 .FirstOrDefault(v => v.Document == message.Document);

            if (documentViewer == null)
            {
                documentViewer = PanelManager.Instance.CreatePanel <DocumentViewerViewModel>(false, message.Document);

                var messages = this.Report.Messages
                               .Where(m => m.Document == message.Document);
                documentViewer.AddReportMessages(messages);
            }

            documentViewer.Show();
            documentViewer.CaretOffset = message.Position.StartIndex;
        }