public IEnumerable <ResultMessageViewModel> ImportLocalFiles() { var results = new List <ResultMessageViewModel>(); var request = HttpContext.Current.Request; XMLDataToImport headerFileXMLFileToImport = null; if (request.Files.AllKeys.Contains(HeaderFileInputElementName)) { var headerFile = request.Files[HeaderFileInputElementName]; var headerFileData = new DataFromFileSystem(headerFile.FileName, headerFile.InputStream); headerFileXMLFileToImport = new XMLDataToImport(headerFileData); } else { results.Add(new ResultMessageViewModel(ResultMessageViewModel.RESULT_LEVEL_WARN, "Header file is not uploaded, use default value.")); } var sampleFile = request.Files[SampleFileInputElementName]; var chemistryFile = request.Files[ChemistryFileInputElementName]; var sampleFileData = new DataFromFileSystem(sampleFile.FileName, sampleFile.InputStream); var sampleFileCSVFileToImport = new CSVDataToImport(sampleFileData); var chemistryFileData = new DataFromFileSystem(chemistryFile.FileName, chemistryFile.InputStream); var chemistryCSVFileToImport = new CSVDataToImport(chemistryFileData); var esdatDataToImport = new ESDATDataToImport(headerFileXMLFileToImport, sampleFileCSVFileToImport, chemistryCSVFileToImport); var importer = ESDATDataImportHelper.BuildESDATDataImporter(_wqDefaultValueProvider); results.AddRange(PersistESDATData(esdatDataToImport, importer)); return(results); }
public IEnumerable <ResultMessageViewModel> ImportFtpFiles(FtpFileImportDataViewModel data) { XMLDataToImport headerFileXMLFileToImport = null; if (!string.IsNullOrEmpty(data.HeaderFileURL)) { var headerFileHttpFileSystem = new FTPFileSystem(data.HeaderFileURL); headerFileXMLFileToImport = new XMLDataToImport(headerFileHttpFileSystem.FetchData()); } var sampleFileFtpFileSystem = new FTPFileSystem(data.SampleFileURL, data.UserName, data.Password); var sampleFileCSVFileToImport = new CSVDataToImport(sampleFileFtpFileSystem.FetchData()); var chemistryFileFtpFileSystem = new FTPFileSystem(data.ChemistryFileURL, data.UserName, data.Password); var chemistryCSVFileToImport = new CSVDataToImport(chemistryFileFtpFileSystem.FetchData()); var esdatDataToImport = new ESDATDataToImport(headerFileXMLFileToImport, sampleFileCSVFileToImport, chemistryCSVFileToImport); var importer = ESDATDataImportHelper.BuildESDATDataImporter(_wqDefaultValueProvider); var results = PersistESDATData(esdatDataToImport, importer); return(results); }