private static string formatLedgerEntry(BatchExecutionResults results, ILedgerEntry ledgerEntry) { try { string formatted = ""; formatted += ledgerEntry.FormatLine() + Environment.NewLine; foreach (var subledgerEntry in ledgerEntry.SubledgerEntries .Where(x => ((x.LineNumber > 0) && (x.Amount != 0m))) .OrderBy(y => y.LineNumber)) { formatted += subledgerEntry.FormatLine() + Environment.NewLine; } return formatted; } catch (Exception ex) { results.MarkError( new ApplicationException(string.Format("Error exporting ledger entry {0} or one of its sub-ledger entries.", ledgerEntry.Key), ex)); return ""; } }