Ejemplo n.º 1
0
        public virtual string BuildNewItemName(object importRow)
        {
            if (!ItemNameFields.Any())
            {
                throw new NullReferenceException("there are no 'Name' fields specified");
            }

            StringBuilder strItemName = new StringBuilder();

            foreach (string nameField in ItemNameFields)
            {
                try
                {
                    strItemName.Append(GetFieldValue(importRow, nameField));
                }
                catch (ArgumentException)
                {
                    throw new NullReferenceException(string.Format("the field name: '{0}' does not exist in the import row", nameField));
                }
            }

            string nameValue = strItemName.ToString();

            if (string.IsNullOrEmpty(nameValue))
            {
                throw new NullReferenceException(string.Format("the name fields: '{0}' are empty in the import row", string.Join(",", ItemNameFields)));
            }
            return(StringService.GetValidItemName(nameValue, this.ItemNameMaxLength).Trim());
        }