/// <exception cref="CopeException"><c>CopeException</c>.</exception> public ArchivePackerInfo PackArchive(string outputPath) { if (!ArchiveToolHelper.IsArchiveToolPresent()) { string msg = "Archive tool has not been found! Searched at: " + ArchiveToolHelper.GetArchiveToolPath(); LoggingManager.SendError("ArchiveCreator - " + msg); throw new CopeException(msg); } if (!outputPath.EndsWith('\\')) { outputPath += '\\'; } string uniqueName = ArchiveName + '_' + DateTime.Now.ToProperString('_'); string designFilePath = ArchiveToolHelper.GetArchiveToolDirectory() + uniqueName + ".sga_design"; WriteDesignFile(designFilePath, outputPath + ArchiveName); string arguments = string.Format(ARCHIVE_ARGUMENTS, InputDirectory.RemoveLast(1), outputPath + ArchiveName, uniqueName); Process packer = StartPacker(arguments); if (packer == null || packer.Id == 0 || packer.Id == 1) { LoggingManager.SendError("ArchiveCreator - failed to start packer. Arguments: " + arguments); throw new CopeException("Failed to start archive.exe"); } return(new ArchivePackerInfo(packer, designFilePath, outputPath + ArchiveName)); }
/// <exception cref="CopeException">Could not start archive.exe</exception> private static Process StartPacker(string arguments) { Process archivePacker = null; try { string archiveToolPath = ArchiveToolHelper.GetArchiveToolPath(); var startInfo = new ProcessStartInfo { Arguments = arguments, CreateNoWindow = true, ErrorDialog = true, UseShellExecute = false, FileName = archiveToolPath, WorkingDirectory = archiveToolPath.SubstringBeforeLast('\\') }; LoggingManager.SendMessage("ArchiveCreator - Starting archive.exe with " + arguments); archivePacker = Process.Start(startInfo); return(archivePacker); } catch (Exception ex) { if (archivePacker != null) { archivePacker.Kill(); archivePacker.Dispose(); } LoggingManager.SendError("ArchiveCreator - Failed to start archive.exe"); LoggingManager.HandleException(ex); throw new CopeException(ex, "Could not start archive.exe" + ex.Message); } }