Skip to content

Commit

Permalink
Update UnloadAndSaveModelAsCloudCommand.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Nov 20, 2024
1 parent 1dcc60f commit d1d01c7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Test/Sample/UnloadAndSaveModelAsCloudCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit d1d01c7

Please sign in to comment.