Advertisement
LaughingMan

Untitled

Aug 20th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.36 KB | None | 0 0
  1. public static IReadOnlyCollection<FileInfo> GenerateSchema(FileInfo xmlFile)
  2.         {
  3.             try
  4.             {
  5.                 Console.Write($"\rGenerating Schema (FileInfo): {xmlFile.Name}\t\t\t\t\t");
  6.  
  7.                 while (xmlFile.IsInUse())
  8.                 {
  9.                     Console.WriteLine($"Waiting for {xmlFile.Name} to free/finish\t\t\t\t\t");
  10.                     Thread.Sleep(1000);
  11.                 }
  12.  
  13.                 IReadOnlyCollection<string> args = GetXSDArguments(xmlFile);
  14.                 bool result = CallXSD(args);
  15.  
  16.                 if (!result)
  17.                     throw new FileLoadException($"The call to XSD failed on the file:\r\n{xmlFile.FullName}");
  18.  
  19.                 while (xmlFile.IsInUse())
  20.                 {
  21.                     Console.Write("\rWaiting for XML File to free/finish\t\t\t\t\t\t");
  22.                     Thread.Sleep(1000);
  23.                 }
  24.  
  25.                 ImportFileType importType = ESRIHelper.GetImportFileType(xmlFile);
  26.                 string fileExtension = ESRIHelper.GetImportFileExtension(importType);
  27.  
  28.                 string fileName = xmlFile.Name.Replace(fileExtension, "")
  29.                     .Trim('.')
  30.                     .Trim();
  31.  
  32.                 IReadOnlyCollection<FileInfo> results = OutputDirectory.GetFiles($"{fileName}*{ESRIHelper.XmlSchemaExtension}", SearchOption.AllDirectories);
  33.  
  34.                 while (results.Any(a => a.IsInUse()))
  35.                 {
  36.                     Console.Write("\rWaiting for Schema File(s) to free/finish\t\t\t\t\t\t");
  37.                     Thread.Sleep(1000);
  38.                 }
  39.  
  40.                 return results;
  41.             }
  42.             catch (Exception e)
  43.             {
  44.                 Console.WriteLine($"\r\n{e.Message}\r\n{e}");
  45.                 throw;
  46.             }
  47.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement