public static ICollection <RevitFile> AllowedFiles(CreateJournalSetting setting) { var allFiles = GetFoundFiles(setting); return(allFiles.Where(filePath => IsAllowedForJournal(filePath)) .Select(filePath => new RevitFile(filePath)).ToList()); }
public static IList <string> GetFoundFiles(CreateJournalSetting setting, string extension = "rfa") { var searchOption = SearchOption.TopDirectoryOnly; if (setting.RecursiveSearch) { searchOption = SearchOption.AllDirectories; } var filePaths = Directory.GetFiles(setting.SourceDir, $"*.{extension}", searchOption); return(filePaths); }
public void CreateAddinFile(CreateJournalSetting setting) { var fullPath = Assembly.GetAssembly(GetType()).Location; if (Guid.TryParse(setting.AddinId, out var addinGuid) == false) { throw new ArgumentException("No valid AddinId - can NOT be parsed to GUID"); } var addinId = new AddInId(addinGuid); var currentManifest = GetCurrentManifest(fullPath, addinId); if (HasCommandId(currentManifest, setting.AddinId, out var command)) { var newCommand = CreateNew(fullPath, command); var newManifest = new RevitAddInManifest(); newManifest.AddInCommands.Add(newCommand); var newManifestPath = Path.Combine(setting.DestinationDir, addinFileName); newManifest.SaveAs(newManifestPath); } }
public void CreateBatch(CreateJournalSetting setting) { var batchContent = string.Empty; batchContent += $"@echo off{Environment.NewLine}"; batchContent += $"echo {setting.JobName}{Environment.NewLine}"; batchContent += Environment.NewLine; batchContent += $"cd {setting.RevitDirectory}{Environment.NewLine}"; batchContent += Environment.NewLine; var count = 0; var fileCount = journalFiles.Count; foreach (var journalFile in journalFiles) { var fileName = Path.GetFileNameWithoutExtension(journalFile); batchContent += $"echo {++count}/{fileCount} {fileName}{Environment.NewLine}"; batchContent += $"start /W /HIGH Revit.exe {journalFile} /language {setting.Language} /nosplash{Environment.NewLine}"; batchContent += Environment.NewLine; } batchContent += $"exit{Environment.NewLine}"; FileHelper.WriteFile(setting.JobBatchFilePath, batchContent); }
public void CreateJournal(CreateJournalSetting createSetting) { try { var journalData = JournalHelper.BuildJournalStart(createSetting.DebugModus); journalData += JournalHelper.BuildDocumentOpen(createSetting.CurrentFile.FilePath); journalData += JournalHelper.BuildAddinLaunch(createSetting.AddinId, createSetting.CmdFullName); journalData += JournalHelper.BuildAddinAddinCommandData(createSetting.JournalData); var journalFile = FileHelper.ChangeExtension(createSetting.CurrentFile.FilePath, "txt"); journalFile = Path.GetFileName(journalFile); journalFile = $"{createSetting.FileCount}_{journalFile}"; journalFile = Path.Combine(createSetting.DestinationDir, journalFile); FileHelper.WriteFile(journalFile, journalData); journalFiles.Add(journalFile); } catch (Exception ex) { throw ex; } }