From d1d01c775d67406aef1b87d6c43e8c3079a26441 Mon Sep 17 00:00:00 2001 From: Chuong Ho Date: Wed, 20 Nov 2024 17:58:11 +0800 Subject: [PATCH] Update UnloadAndSaveModelAsCloudCommand.cs --- .../UnloadAndSaveModelAsCloudCommand.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Test/Sample/UnloadAndSaveModelAsCloudCommand.cs b/Test/Sample/UnloadAndSaveModelAsCloudCommand.cs index 6a60c57..6447fda 100644 --- a/Test/Sample/UnloadAndSaveModelAsCloudCommand.cs +++ b/Test/Sample/UnloadAndSaveModelAsCloudCommand.cs @@ -72,6 +72,14 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme { foreach (string revitPath in revitPaths) { + // if revit file name exist in temp./../ folder include scan subfolder + var fileNameTemp = Path.GetFileName(revitPath); + bool flag = IsInsideFolder(dirPath, fileNameTemp); + if (flag) + { + writer.WriteLine($"{DateTime.Now} - {fileNameTemp} - Skipped Because it is already processed"); + continue; + } // create temp folder in current directory, tempfodler name is guid string tempFolder = Path.Combine(dirPath, Guid.NewGuid().ToString()); if (!Directory.Exists(tempFolder)) @@ -114,6 +122,20 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme Process.Start(logPath); return Result.Succeeded; } + public bool IsInsideFolder(string folderPath, string fileName) + { + string[] files = System.IO.Directory.GetFiles(folderPath, "*.rvt", SearchOption.AllDirectories); + // compare == + foreach (string file in files) + { + string name = System.IO.Path.GetFileName(file); + if (name == fileName) + { + return true; + } + } + return false; + } public string OpenDirectoryDialog() { System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();