Exemplo n.º 1
0
		public static IReadOnlyCollection<FileInfo> GenerateSchema(FileInfo xmlFile)
		{
			try
			{
				Console.Write($"\rGenerating Schema (FileInfo): {xmlFile.Name}\t\t\t\t\t");

				IReadOnlyCollection<string> args = GetXSDArguments(xmlFile);
				bool result = CallXSD(args);

				if (!result)
					throw new FileLoadException($"The call to XSD failed on the file:\r\n{xmlFile.FullName}");

				ImportFileType importType = ESRIHelper.GetImportFileType(xmlFile);
				string fileExtension = ESRIHelper.GetImportFileExtension(importType);

				string fileName = xmlFile.Name.Replace(fileExtension, "")
					.Trim('.')
					.Trim();

				IReadOnlyCollection<FileInfo> results = WorkingDirectory.GetFiles($"{fileName}*{ESRIHelper.XmlSchemaExtension}",
					SearchOption.AllDirectories);

				return results;
			}
			catch (Exception e)
			{
				Console.WriteLine($"\r\n{e.Message}\r\n{e}");
				throw;
			}
		}
Exemplo n.º 2
0
		public static IReadOnlyCollection<FileInfo> GenerateClass(IReadOnlyCollection<FileInfo> schemaFiles)
		{
			try
			{
				IReadOnlyCollection<string> args = GetXSDArguments(schemaFiles, ImportFileType.XmlSchema, true);
				List<string> cleanArgs = args.ToList();
				cleanArgs.Remove(DatasetArgument);
				args = cleanArgs.AsReadOnly();

				FileInfo firstSchemaFile = schemaFiles.FirstOrDefault();

				if (firstSchemaFile == null
				    || !firstSchemaFile.Exists)
					throw new FileNotFoundException("The first schema file in the collection does not exist or was not found");

				ImportFileType importType = ESRIHelper.GetImportFileType(firstSchemaFile);
				string fileExtension = ESRIHelper.GetImportFileExtension(importType);

				string fileName = firstSchemaFile.Name.Replace(fileExtension, "")
					.Trim('.')
					.Replace(".", "_")
					.Trim();

				Console.Write($"\rGenerating Classes (FileInfo): {fileName}\t\t\t\t\t");
				bool result = CallXSD(args);

				if (!result)
					throw new FileLoadException(
						$"The call to XSD failed on the files:\r\n{fileName}");

				IReadOnlyCollection<FileInfo> results = OutputDirectory.GetFiles($"{fileName}*.cs", SearchOption.AllDirectories);

				int resultCount = results.Count;
				Console.Write(
					$"\r{resultCount} Class{(resultCount == 1 ? "" : "es")} Generated for {fileName}\t\t\t\t\t");

				return results;
			}
			catch (Exception e)
			{
				Console.WriteLine($"\r\n{e.Message}\r\n{e}");
				throw;
			}
		}
Exemplo n.º 3
0
        public static FileInfo CreateWorkingFile(FileInfo file)
        {
            try
            {
                ImportFileType fileType      = ESRIHelper.GetImportFileType(file);
                string         fileExtension = ESRIHelper.GetImportFileExtension(fileType);
                string         tempName      = Path.GetRandomFileName().Split('.')[0];
                tempName = tempName.Length > 8 ? tempName.Substring(0, 8) : tempName;
                string tableName       = $"{tempName}{fileExtension}";
                string workingFilePath = Path.Combine(EXEHelper.WorkingPath, tableName);

                FileInfo workingFile = file.CopyTo(workingFilePath, true);
                return(workingFile);
            }
            catch (Exception e)
            {
                Console.WriteLine($"\r\n{e.Message}\r\n{e}");
                throw;
            }
        }