/// <summary> /// creates an item name based on the name field values in the importRow /// </summary> public string GetNewItemName(object importRow) { if (!NameFields.Any()) { throw new NullReferenceException("there are no 'Name' fields specified"); } var strItemName = new StringBuilder(); foreach (var nameField in NameFields) { try { strItemName.Append(GetFieldValue(importRow, nameField)); } catch (ArgumentException ex) { if (string.IsNullOrEmpty(ItemNameDataField)) { throw new NullReferenceException("the 'Name' field is empty"); } throw new NullReferenceException( string.Format("the field name: '{0}' does not exist in the import row", nameField)); } } return(StringUtility.GetNewItemName(strItemName.ToString(), ItemNameMaxLength)); }
/// <summary> /// creates an item name based on the name field values in the importRow /// </summary> public string GetNewItemName(object importRow) { if (!NameFields.Any()) { throw new NullReferenceException("there are no 'Name' fields specified"); } StringBuilder strItemName = new StringBuilder(); foreach (string nameField in NameFields) { try { strItemName.Append(GetFieldValue(importRow, nameField)); } catch (ArgumentException ex) { if (string.IsNullOrEmpty(this.ItemNameDataField)) { throw new NullReferenceException("the 'Name' field is empty"); } else { throw new NullReferenceException(string.Format("the field name: '{0}' does not exist in the import row: {1}", nameField, GetFieldValue(importRow, "FILENAME"))); } } } string nameValue = strItemName.ToString(); if (string.IsNullOrEmpty(nameValue)) { throw new NullReferenceException(string.Format("the name fields: '{0}' are empty in the import row: {1}", string.Join(",", NameFields), GetFieldValue(importRow, "FILENAME"))); } return(StringUtility.GetNewItemName(strItemName.ToString().Trim(), this.ItemNameMaxLength)); }