private void AppendFields(OrderedFields fields, StringBuilder content) { var entity = fields.Any() ? fields.First().Entity : string.Empty; _process.Logger.EntityDebug(entity, "Entity auto found {0} field{1}.", fields.Count, fields.Count == 1 ? string.Empty : "s"); content.AppendLine(" <fields>"); foreach (var f in fields) { AppendField(content, f); } content.AppendLine(" </fields>"); }
private static IEnumerable <string> RowsToValues(OrderedFields fields, IEnumerable <Row> rows) { var preProcessed = new string[fields.Count][]; for (var i = 0; i < fields.Count; i++) { var field = fields.ElementAt(i); preProcessed[i] = new[] { field.Alias, field.SimpleType, field.Quote() }; } foreach (var row in rows) { var values = new List <string>(); foreach (var field in preProcessed) { var value = row[field[0]]; if (value == null) { continue; } var strValue = value.ToString(); if (string.IsNullOrWhiteSpace(strValue)) { continue; } if (field[1].StartsWith("bool")) { strValue = strValue.Equals("True", StringComparison.Ordinal) ? "1" : "0"; } values.Add(field[2] == string.Empty ? strValue : string.Concat(field[2], strValue.Replace("'", "''"), field[2])); } yield return(string.Join(",", values)); } }
private static IEnumerable<string> RowsToValues(OrderedFields fields, IEnumerable<Row> rows) { var preProcessed = new string[fields.Count][]; for (var i = 0; i < fields.Count; i++) { var field = fields.ElementAt(i); preProcessed[i] = new[] { field.Alias, field.SimpleType, field.Quote() }; } foreach (var row in rows) { var values = new List<string>(); foreach (var field in preProcessed) { var value = row[field[0]]; if (value == null) continue; var strValue = value.ToString(); if (string.IsNullOrWhiteSpace(strValue)) continue; if (field[1].StartsWith("bool")) { strValue = strValue.Equals("True", StringComparison.Ordinal) ? "1" : "0"; } values.Add(field[2] == string.Empty ? strValue : string.Concat(field[2], strValue.Replace("'", "''"), field[2])); } yield return string.Join(",", values); } }