public bool Generate() { bool result = false; try { if (Api == null) { return(false); } Console.WriteLine("\n+----------------------------+"); Console.WriteLine("| AbstractionLayer Generator |"); Console.WriteLine("+----------------------------+\n"); Console.WriteLine($"[INFO] Generating AbstractionLayer for vault <{Api.MFilesSettings.VaultName} ({Api.MFilesSettings.VaultGUID})>..."); // Proceed with abstraction Api.InitObjectTypes(); Api.InitClassTypes(); Api.InitPropertyDefinitions(); Api.InitValueLists(); Api.InitWorkflowWorkflowStates(); // Generating AL class files List <GeneratorArtifacts> generatorArtifactsList = new List <GeneratorArtifacts>() { GeneratorArtifacts.UTILITIES , GeneratorArtifacts.MODELS , GeneratorArtifacts.INTERFACES , GeneratorArtifacts.EVENT_HANDLERS , GeneratorArtifacts.VAULT_APPLICATION }; ALFilesWriter alFilesWriter = null; string[] generatedALFiles = { }; generatorArtifactsList.ForEach(generatorArtifact => { alFilesWriter = FilesWriterFactory.GetFilesWriter(generatorArtifact); alFilesWriter.WriteFiles(Api); generatedALFiles = generatedALFiles.Union(alFilesWriter.GeneratedFiles).ToArray(); }); Console.WriteLine($"[INFO] Successfully generated AbstractionLayer for vault <{Api.MFilesSettings.VaultName} ({Api.MFilesSettings.VaultGUID})>..."); DirectoryInfo mfTargetDirectoryInfo = ALFilesWriter.GetMFTargetDirectoryInfo(); Console.WriteLine($"[INFO] Adding generated AbstractionLayer files to <{mfTargetDirectoryInfo.Name}> project build..."); BuildUtils.IncludeFilesToProjectBuild(generatedALFiles); Console.WriteLine($"[INFO] Successfully added generated AbstractionLayer files to <{mfTargetDirectoryInfo.Name}> project build...\n"); result = true; } catch (Exception ex) { Console.WriteLine($"[ERROR] Something went wrong during execution of ALGenerator. " + ex.Message); } finally { Api?.Dispose(); } Console.WriteLine("[END]"); if (!Api.MFilesSettings.SilentExit) { Console.WriteLine($"Press any key to exit..."); Console.ReadKey(); } return(result); }
public bool Run() { Console.WriteLine("\n+--------------+"); Console.WriteLine("| VAF Deployer |"); Console.WriteLine("+--------------+\n"); DirectoryInfo vafDirectoryInfo = ALFilesWriter.GetMFTargetDirectoryInfo(); string vafProjectFullPath = vafDirectoryInfo.FullName; string vafProjectName = vafDirectoryInfo.Name; ALFilesWriter alFilesWriter = FilesWriterFactory.GetFilesWriter(GeneratorArtifacts.VAULT_APPLICATION); alFilesWriter.WriteFiles(null); BuildUtils.IncludeFilesToProjectBuild(alFilesWriter.GeneratedFiles); #if DEBUG string appPathStr = Path.Combine(new string[] { vafProjectFullPath, "bin", "Debug" }); #else string appPathStr = Path.Combine(new string[] { vafProjectFullPath, "bin", "Release" }); #endif try { Console.WriteLine($"[INFO] Building VAF project..."); BuildErrorConsoleLogger errorLogger = new BuildErrorConsoleLogger(); BuildUtils.BuildProject(errorLogger); Console.WriteLine($"[INFO] Sucessfully built VAF project..."); DirectoryInfo applicationPath = new DirectoryInfo(appPathStr); FileInfo appDefFile = new FileInfo(Path.Combine(applicationPath.FullName, "appdef.xml")); Version version = new Version("1.0.0.0"); //Version version = typeof(VAF.VaultApplication).Assembly.GetName().Version; File.WriteAllText(appDefFile.FullName, GenerateXmlFile(version.ToString())); string vault = MFilesSettings.VaultGUID; if (string.IsNullOrWhiteSpace(vault)) { vault = MFilesSettings.VaultName; } Console.WriteLine($"[INFO] Creating vault application package for <{vault}>..."); VAEBuilder vaeBuilder = new VAEBuilder(); string applicationGuid = GetApplicationGuid(appDefFile); FileInfo applicationPackage = vaeBuilder.CreateApplicationPackage(applicationGuid, applicationPath); Console.WriteLine($"[INFO] Application package for {vault} created: " + applicationPackage); if (MFilesSettings.Server != null && !string.IsNullOrWhiteSpace(vault)) { ConnectAndReinstall(applicationGuid, applicationPackage); Console.WriteLine($"[INFO] Completed deployment for vault <{MFilesSettings.VaultName} ({MFilesSettings.VaultGUID})>...\n"); return(true); } else { Console.WriteLine("[INFO] Skipping installation:"); } } catch (Exception e) { Console.WriteLine($"[ERROR] {e.Message}\n"); } if (!NoPromptExit) { Console.WriteLine($"Press any key to exit..."); Console.ReadKey(); } return(false); }