public NameValueCollection GetSourceStructure(ImportSetting setting) { var sqlService = new SqlService(); var xmlService = new XmlService(); switch (setting.SourceType) { case SourceTypeEnum.XML: return xmlService.GetSourceStructure(setting); case SourceTypeEnum.SQL: case SourceTypeEnum.SQLQUERY: return sqlService.GetSourceStructure(setting); } return new NameValueCollection(); }
public List<NameValueCollection> GetDataToImport(ImportSetting importSetting) { var objectsToImport = new List<NameValueCollection>(); var sqlService = new SqlService(); var xmlService = new XmlService(); var dataToImport = new List<NameValueCollection>(); switch (importSetting.SourceType) { case SourceTypeEnum.XML: dataToImport = xmlService.GetData(importSetting); break; case SourceTypeEnum.SQL: case SourceTypeEnum.SQLQUERY: dataToImport = sqlService.GetData(importSetting); break; } foreach (var row in dataToImport) { var objectToImport = new NameValueCollection(); foreach (var mappedField in importSetting.MappedFields) { if (!string.IsNullOrEmpty(row[mappedField.SourceField])) { if (!mappedField.IsDefault) objectToImport.Add(mappedField.KoobooField, row[mappedField.SourceField]); else objectToImport.Add(mappedField.KoobooField, mappedField.DefaultValue); } } if (objectToImport.Count > 0) objectsToImport.Add(objectToImport); } return objectsToImport; }