/// <summary> /// ProcessPxFilesInFolder /// </summary> /// <param name="originalFolderPath"></param> /// <param name="destinationFolderPath"></param> public void ProcessPxFilesInFolder(string originalFolderPath, string destinationFolderPath) { if (originalFolderPath == null) { throw new ArgumentNullException(nameof(originalFolderPath)); } string dirName = new DirectoryInfo(originalFolderPath).FullName; Log.Instance.DebugFormat("Parsing *.px files in folder {0}", dirName); if (!Directory.Exists(destinationFolderPath)) // if it doesn't exist, create { Directory.CreateDirectory(destinationFolderPath); } foreach (string f in Directory.GetFiles(originalFolderPath, "*.px")) { string fileName = new FileInfo(f).Name; ProcessPxFile(f, Path.Combine(destinationFolderPath, string.Format("{0}.txt", fileName))); } Log.Instance.Debug("Parsing of all *.px files completed."); //todo: check config first before generate dictionary information files!!! PxKeywordDictionary.SaveToFile("AllTypes.txt", "AllExceptions.txt"); }
/// <summary> /// ProcessPxFile /// </summary> /// <param name="sourcePath"></param> /// <param name="destinationPath"></param> public void ProcessPxFile(string sourcePath, string destinationPath) { ADO ado = new ADO("defaultConnection"); try { var pxDoc = GetPxDocumentFromFile(sourcePath); if (pxDoc == null) { return; } // Change to PxSchemaValidator var validator = new PxSchemaValidator(); var result = validator.Validate(pxDoc); if (!result.IsValid) { foreach (var error in result.Errors) { Log.Instance.Debug(error.ErrorMessage); } return; } Log.Instance.Debug("The PX Schema is valid"); // Create another validator : SettingsValidator var matrix = new Matrix(pxDoc); var settingsValidator = new PxSettingsValidator(ado); var settingsResult = settingsValidator.Validate(matrix); if (!settingsResult.IsValid) { foreach (var error in settingsResult.Errors) { Log.Instance.Debug(error.ErrorMessage); } return; } Log.Instance.Debug("The PX Settings are valid"); // only do this if we are in debug mode! SavePxDocumentToFile(pxDoc, destinationPath); //check this!!! PxKeywordDictionary.GetTypesFromFile(pxDoc); } catch (Exception e) { Log.Instance.Error(e); } finally { ado.Dispose(); } }