IssuesDumper
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Relativity.Transfer.Aspera.Issues
{
    public static class IssuesDumper
    {
        private const int _MAX_ISSUES_COUNT = 1000000;
        private const string _ISSUES_TEMPLATE = "Issues ({0}): ";
        private const string _MESSAGE_TEMPLATE = "Message: {0}";
        private const string _ATTRIBUTES_TEMPLATE = "Attributes: {0}";
        private const string _RETRY_TEMPLATE = "RetryAttempt: {0}";
        private const string _CODE_TEMPLATE = "Code: {0} ({1})";
        private const string _EMPTY_CODE = "Code: [NULL]";
        public static string Dump(IReadOnlyCollection<ITransferIssue> issues)
        {
            if (issues == null || issues.Count > 1000000)
                return string.Empty;
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.AppendLine($"""{issues.Count}""");
            foreach (ITransferIssue item in from x in issues
            orderby x.Index
            select x) {
                string text = $"""{item.Message}";
                string text2 = item.Code.HasValue ? $"""{item.Code.Value}""{AsperaErrorCodes.GetExplanation(item.Code.Value)}""" : "Code: [NULL]";
                string text3 = $"""{item.Attributes}";
                string text4 = $"""{item.RetryAttempt}";
                stringBuilder.AppendLine($"""{item.Timestamp}""{text}""{text2}""{text3}""{text4}""");
            }
            return stringBuilder.ToString();
        }
    }
}