Example #1
0
		/// <summary>
		/// Imports multiple Ascii files into newly created new tables (each file into a separate table). The tables are named and stored in the project file in the provided project folder.
		/// </summary>
		/// <param name="projectFolder">The project folder in which the new tables should be created.</param>
		/// <param name="fileNames">The names of the files to import.</param>
		/// <param name="sortFileNames">If <c>true</c>, the fileNames are sorted before usage in ascending order using the default string comparator.</param>
		/// <param name="importOptions">Options used to import ASCII. This parameter must not be null, and the options must be fully specified.</param>
		/// <param name="determineImportOptionsSeparatelyForEachFile">
		/// If <c>true</c>, the import options are determined for each file separately. In this case the provided parameter <paramref name="importOptions"/> is ignored, but on return it contains the importOptions used to import the last file.
		/// If <c>false</c>, the import options are either provided by the parameter <paramref name="importOptions"/> (if not null and fully specified), or during import of the first file. The so determined importOptions are then used to import all other files.
		/// </param>
		/// <returns>The list of tables created during the import.</returns>
		private static IList<DataTable> InternalImportFilesIntoSeparateNewTables(ProjectFolder projectFolder, IEnumerable<string> fileNames, bool sortFileNames, ref AsciiImportOptions importOptions, bool determineImportOptionsSeparatelyForEachFile)
		{
			var listOfNewTables = new List<DataTable>();

			if (sortFileNames)
				fileNames = fileNames.OrderBy(x => x);

			foreach (var fileName in fileNames)
			{
				var srcTable = new DataTable(projectFolder.Name + Path.GetFileNameWithoutExtension(fileName));
				Current.ProjectService.CreateNewWorksheet(srcTable);

				if (determineImportOptionsSeparatelyForEachFile)
					ImportFromAsciiFile(srcTable, fileName);
				else if (null != importOptions && importOptions.IsFullySpecified)
					ImportFromAsciiFile(srcTable, fileName, importOptions);
				else
					ImportFromAsciiFile(srcTable, fileName, out importOptions);

				listOfNewTables.Add(srcTable);
			}

			return listOfNewTables;
		}