private List <NestedFolder> CustomExtractFolderStructure(BimProject orgProj) { if (!folderStructures.ContainsKey(orgProj.name)) { List <NestedFolder> existingFolderStructure = new List <NestedFolder>(); Util.LogInfo($""); Util.LogInfo($"Folder structure extraction started"); Util.LogInfo("- retrieving top folders from " + orgProj.id); // call TopFolder to get the initial folder ids to start TopFolderResponse topFolderRes = GetTopFolders(orgProj.id); if (!CustomRootFoldersExist(topFolderRes)) { Util.LogInfo("No top folders retrieved."); // Wait until new project's folders are created for (int i = 0; i < 6; i++) { Util.LogInfo("Waiting for project's folders to be created..."); Thread.Sleep(5000); topFolderRes = GetTopFolders(orgProj.id); if (CustomRootFoldersExist(topFolderRes)) { break; } } if (!CustomRootFoldersExist(topFolderRes)) { Util.LogError($"There was a problem retrievieng root folders for project {orgProj.name}. The program has been stopped. Try running the program again."); throw new ApplicationException($"Stopping the program... You can see the log file for more information."); } } Util.LogInfo("- retrieving sub-folders for 'Plans' and 'Project Files' folder. This could take a while.."); // Iterate root folders foreach (Folder folder in topFolderRes.data) { string folderName = folder.attributes.name; if (folderName == "Project Files" || folderName == "Plans") { NestedFolder rootFolder = new NestedFolder(folderName, folder.id); // recursive calls to fetch folder structure NestedFolder rootWithChildrenFolder = _foldersApi.GetFoldersHierarchy(orgProj.id, rootFolder); existingFolderStructure.Add(rootWithChildrenFolder); } } folderStructures[orgProj.name] = existingFolderStructure; return(existingFolderStructure); } else { throw new ApplicationException($""); } }
private void ExtractFolderStructure(BimProject orgProj) { if (folderStructures.ContainsKey(orgProj.name)) { return; } else { List <NestedFolder> existingFolderStructure = new List <NestedFolder>(); Log.Info($""); Log.Info($"Folder structure extraction started"); Log.Info("- retrieving top folders from " + orgProj.id); // call TopFolder to get the initial folder ids to start TopFolderResponse topFolderRes = GetTopFolders(orgProj.id); if (topFolderRes.data == null || topFolderRes.data.Count() == 0) { Log.Warn("No top folders retrieved."); return; } Log.Info("- retrieving sub-folders for 'Plans' and 'Project Files' folder. This could take a while.."); // Iterate root folders foreach (Folder folder in topFolderRes.data) { string folderName = folder.attributes.name; if (folderName == "Project Files" || folderName == "Plans") { NestedFolder rootFolder = new NestedFolder(folderName, folder.id); // recursive calls to fetch folder structure NestedFolder rootWithChildrenFolder = _foldersApi.GetFoldersHierarchy(orgProj.id, rootFolder); existingFolderStructure.Add(rootWithChildrenFolder); } } folderStructures[orgProj.name] = existingFolderStructure; } }
private List <NestedFolder> CustomExtractFolderStructure(BimProject orgProj, string adminMail) { // check if current project is activated var roleIds = GetIndustryRoleIds(orgProj.name, null); var admin = GetAdminUser(adminMail); var activated = ActivateProject(orgProj.id, admin, roleIds); if (!folderStructures.ContainsKey(orgProj.name)) { List <NestedFolder> existingFolderStructure = new List <NestedFolder>(); Util.LogInfo($""); Util.LogInfo($"Folder structure extraction started"); Util.LogInfo("- retrieving top folders from " + orgProj.id); // call TopFolder to get the initial folder ids to start TopFolderResponse topFolderRes = GetTopFolders(orgProj.id); if (!CustomRootFoldersExist(topFolderRes)) { Util.LogInfo("No top folders retrieved."); // Wait until new project's folders are created for (int i = 0; i < 6; i++) { Util.LogInfo("Waiting for project's folders to be created..."); Thread.Sleep(5000); // query the BIM360 hubs API and check if the current project already owns the requested folders Util.LogInfo("Query BIM360 and check of current project already contains folders."); topFolderRes = GetTopFolders(orgProj.id); if (CustomRootFoldersExist(topFolderRes)) { Util.LogInfo( "All CustomRootFolders exist already. "); // ToDo: please check if this log message relates with the intention of the method break; } } if (!CustomRootFoldersExist(topFolderRes)) { Util.LogError( $"There was a problem retrieving root folders for project {orgProj.name}. The program has been stopped. Try running the program again."); throw new ApplicationException( $"Stopping the program... You can see the log file for more information."); } } Util.LogInfo( "- retrieving sub-folders for 'Plans' and 'Project Files' folder. This could take a while.."); // Iterate root folders foreach (Folder folder in topFolderRes.data) { string folderName = folder.attributes.name; if (folderName == "Project Files" || folderName == "Plans") { NestedFolder rootFolder = new NestedFolder(folderName, folder.id); // recursive calls to fetch folder structure NestedFolder rootWithChildrenFolder = _foldersApi.GetFoldersHierarchy(orgProj.id, rootFolder); existingFolderStructure.Add(rootWithChildrenFolder); } } folderStructures[orgProj.name] = existingFolderStructure; return(existingFolderStructure); } else { throw new ApplicationException($""); } }