Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Autodesk-Forge/forge-bim360.project.setup.tool
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0
Choose a base ref
...
head repository: Autodesk-Forge/forge-bim360.project.setup.tool
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Apr 15, 2020

  1. fix the issue #1

    JohnOnSoftware committed Apr 15, 2020
    Copy the full SHA
    35603b2 View commit details
  2. Copy the full SHA
    d2db63e View commit details
  3. add thumbnail to fix #3

    JohnOnSoftware committed Apr 15, 2020
    Copy the full SHA
    f87a139 View commit details
  4. update readme

    JohnOnSoftware committed Apr 15, 2020
    Copy the full SHA
    4fb71e7 View commit details
  5. update readme

    JohnOnSoftware committed Apr 15, 2020
    Copy the full SHA
    df86428 View commit details
  6. update readme

    JohnOnSoftware committed Apr 15, 2020
    Copy the full SHA
    dfe3ff2 View commit details
  7. update readme

    JohnOnSoftware committed Apr 15, 2020
    Copy the full SHA
    31aadb3 View commit details

Commits on Apr 24, 2020

  1. Fix chunking lists when more than 50 ProjectUsers

    Currently full list of users is passed when looping through chunks
    joefields authored Apr 24, 2020
    Copy the full SHA
    983a817 View commit details

Commits on May 3, 2020

  1. Copy the full SHA
    4f00afa View commit details
  2. Copy the full SHA
    dd07b67 View commit details
  3. Merge pull request #6 from Autodesk-Forge/master

    merge the changes
    JohnOnSoftware authored May 3, 2020
    Copy the full SHA
    22b660c View commit details
  4. Merge pull request #5 from joefields/master

    Fix chunking lists when more than 50 ProjectUsers
    JohnOnSoftware authored May 3, 2020
    Copy the full SHA
    a2776ac View commit details
  5. Merge pull request #7 from Autodesk-Forge/master

    merge the PR
    JohnOnSoftware authored May 3, 2020
    Copy the full SHA
    72d4b70 View commit details
  6. Copy the full SHA
    568af3c View commit details

Commits on May 7, 2020

  1. Copy the full SHA
    84b0f1e View commit details

Commits on May 9, 2020

  1. Copy the full SHA
    f4ca65d View commit details
  2. update readme

    JohnOnSoftware committed May 9, 2020
    Copy the full SHA
    1e28d0a View commit details
  3. include --CF support

    JohnOnSoftware committed May 9, 2020
    Copy the full SHA
    8fab7f8 View commit details
  4. update readme

    JohnOnSoftware committed May 9, 2020
    Copy the full SHA
    13c12a4 View commit details
  5. update readme

    JohnOnSoftware committed May 9, 2020
    Copy the full SHA
    5388f95 View commit details

Commits on May 11, 2020

  1. improve user guide

    JohnOnSoftware committed May 11, 2020
    Copy the full SHA
    06edb5e View commit details

Commits on May 13, 2020

  1. Copy the full SHA
    05d4977 View commit details

Commits on May 28, 2020

  1. Copy the full SHA
    32bb78f View commit details
  2. update change log

    JohnOnSoftware committed May 28, 2020
    Copy the full SHA
    9bca5c1 View commit details
  3. Merge pull request #9 from Autodesk-Forge/master

    merge the changes
    JohnOnSoftware authored May 28, 2020
    Copy the full SHA
    2399f69 View commit details

Commits on Jun 24, 2020

  1. Copy the full SHA
    fd8dd46 View commit details

Commits on Jul 10, 2020

  1. Copy the full SHA
    018b7ca View commit details

Commits on Aug 7, 2020

  1. Copy the full SHA
    2a7c54b View commit details
  2. delete gitignore

    joefields authored Aug 7, 2020
    Copy the full SHA
    3ce1832 View commit details

Commits on Oct 12, 2020

  1. Merge pull request #10 from joefields/master

    add update user function (PATCH)
    JohnOnSoftware authored Oct 12, 2020
    Copy the full SHA
    1e44f53 View commit details

Commits on Oct 13, 2020

  1. Copy the full SHA
    2380a2a View commit details
  2. Copy the full SHA
    7de2f36 View commit details

Commits on Oct 19, 2020

  1. Copy the full SHA
    ae4b24a View commit details
  2. Merge pull request #14 from Autodesk-Forge/dev

    wait more time for new project setup
    JohnOnSoftware authored Oct 19, 2020
    Copy the full SHA
    075a316 View commit details

Commits on Dec 13, 2020

  1. Copy the full SHA
    776e831 View commit details
  2. Merge pull request #15 from Autodesk-Forge/dev

    fix 504 gateway timeout error while creating project
    JohnOnSoftware authored Dec 13, 2020
    Copy the full SHA
    1d83dcb View commit details

Commits on Nov 24, 2023

  1. Deprecate the sample

    JohnOnSoftware authored Nov 24, 2023
    Copy the full SHA
    099aa00 View commit details
Showing with 570 additions and 74 deletions.
  1. BIN BIM360-ProjectSetupTool-UsageGuide.pdf
  2. +10 −2 BimProjectSetupCLI/Application.cs
  3. +15 −2 BimProjectSetupCLI/BimProjectSetupCLI.csproj
  4. +2 −1 BimProjectSetupCLI/sample/BIM360_ProjectUser_Template.csv
  5. +3 −0 BimProjectSetupCLI/sample/BIM360_ProjectUser_UP_Template.csv
  6. +4 −0 BimProjectSetupCLI/sample/BIM360_Projects_CF_Template.csv
  7. +3 −2 BimProjectSetupCLI/sample/BIM360_Projects_Template.csv
  8. +10 −1 BimProjectSetupCLI/sample/BIM360_Service_Template.csv
  9. +4 −4 BimProjectSetupCLI/sample/ImportProjects.bat
  10. +6 −0 BimProjectSetupCLI/sample/ImportProjectsCF.bat
  11. +4 −4 BimProjectSetupCLI/sample/ImportServices.bat
  12. +4 −4 BimProjectSetupCLI/sample/ImportUsers.bat
  13. +6 −0 BimProjectSetupCLI/sample/UpdateUsers.bat
  14. +7 −1 BimProjectSetupCommon/AppOptions.cs
  15. +57 −6 BimProjectSetupCommon/DataController.cs
  16. +19 −6 BimProjectSetupCommon/Workflows/Folder.cs
  17. +2 −2 BimProjectSetupCommon/Workflows/Project.cs
  18. +109 −5 BimProjectSetupCommon/Workflows/ProjectUser.cs
  19. +1 −1 BimProjectSetupCommon/Workflows/Service.cs
  20. +23 −0 CHANGELOG.md
  21. +2 −0 ForgeBimApi/ForgeBimApi.csproj
  22. +34 −4 ForgeBimApi/ForgeBimApiWrappers/BimProjectApi.cs
  23. +90 −0 ForgeBimApi/ForgeBimApiWrappers/BimProjectFoldersApi.cs
  24. +3 −0 ForgeBimApi/ForgeBimApiWrappers/ForgeApi.cs
  25. +48 −0 ForgeBimApi/Serialization/FolderPermission.cs
  26. +2 −0 ForgeBimApi/Serialization/NestedFolder.cs
  27. +20 −0 ForgeBimApi/Serialization/ProjectUserPatchResponse.cs
  28. +82 −29 README.md
  29. BIN download/BIM360-ProjectSetupTool.zip
  30. BIN thumbnail.gif
Binary file modified BIM360-ProjectSetupTool-UsageGuide.pdf
Binary file not shown.
12 changes: 10 additions & 2 deletions BimProjectSetupCLI/Application.cs
Original file line number Diff line number Diff line change
@@ -78,12 +78,19 @@ public void Process()
}
if (options.ProjectUserFilePath != null)
{
projectUserProcess.AddProjectUsersFromCsvProcess();
if (options.UpdateProjectUsers)
{
projectUserProcess.UpdateProjectUsersFromCsvProcess();
}
else
{
projectUserProcess.AddProjectUsersFromCsvProcess();
}
}
}
internal static void PrintHelp()
{
Console.WriteLine("Usage: Autodesk.BimProjectSetup [-p] [-x] [-u] [-c] [-s] [-a] [-b] [-t] [-z] [-e] [-d] [-r] [-h] [--CF] [--EU]");
Console.WriteLine("Usage: Autodesk.BimProjectSetup [-p] [-x] [-u] [-c] [-s] [-a] [-b] [-t] [-z] [-e] [-d] [-r] [-h] [--CF] [--EU] [--UP]");
Console.WriteLine(" -p Path to CSV input file for project creation");
Console.WriteLine(" -x Path to CSV input file for service activation");
Console.WriteLine(" -u Path to CSV input file with project user information");
@@ -100,6 +107,7 @@ internal static void PrintHelp()
// Switches
Console.WriteLine(" --CF Copy folders");
Console.WriteLine(" --EU Use the EU region account");
Console.WriteLine(" --UP Update Project User Access, Companies, or Roles");
Console.WriteLine("At least one path to an input file must be provided with the -p or -x options");
}
internal static void PrintHeader()
17 changes: 15 additions & 2 deletions BimProjectSetupCLI/BimProjectSetupCLI.csproj
100755 → 100644
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\Debug\CLI\</OutputPath>
<OutputPath>..\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -43,7 +43,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\Release\CLI\</OutputPath>
<OutputPath>..\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -86,18 +86,30 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="sample\BIM360_Projects_CF_Template.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="sample\BIM360_Projects_Template.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="sample\BIM360_ProjectUser_Template.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="sample\BIM360_ProjectUser_UP_Template.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="sample\BIM360_Service_Template.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="sample\ImportProjectsCF.bat">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="sample\ImportUsers.bat">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="sample\UpdateUsers.bat">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="sample\ImportServices.bat">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@@ -112,6 +124,7 @@
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="sample\UpdateUsers.bat" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ForgeBimApi\ForgeBimApi.csproj">
3 changes: 2 additions & 1 deletion BimProjectSetupCLI/sample/BIM360_ProjectUser_Template.csv
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
project_name;email;pm_access;docs_access;company_name;industry_roles
Setup Tool Test project 1;user@company.com;admin;admin;Autodesk;Architect
Sample Project 1;user1@company.com;admin;admin;;Architect
Sample Project 1;user2@company.com;admin;admin;;Architect
3 changes: 3 additions & 0 deletions BimProjectSetupCLI/sample/BIM360_ProjectUser_UP_Template.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
project_name;email;pm_access;docs_access;company_name;industry_roles
Sample Project 1;user1@company.com;user;user;;Architect
Sample Project 1;user2@company.com;user;user;;Architect
4 changes: 4 additions & 0 deletions BimProjectSetupCLI/sample/BIM360_Projects_CF_Template.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name;start_date;end_date;project_type;value;currency;job_number;address_line_1;address_line_2;city;state_or_province;postal_code;country;business_unit_id;timezone;language;construction_type;contract_type;folders_created_from
Sample Project from Template 1;05/21/2019;05/25/2019;Office;0;USD;;;;;;;United States;;America/New_York;en;New Construction;Design-Bid-Build;Project Template
Sample Project from Template 2;05/21/2019;05/25/2019;Office;0;USD;;;;;;;United States;;America/New_York;en;New Construction;Design-Bid-Build;Project Template

5 changes: 3 additions & 2 deletions BimProjectSetupCLI/sample/BIM360_Projects_Template.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
name;start_date;end_date;project_type;value;currency;job_number;address_line_1;address_line_2;city;state_or_province;postal_code;country;business_unit_id;timezone;language;construction_type;contract_type;folders_created_from
Setup Tool Test project 1;05/21/2019;05/25/2019;Office;0;USD;;;;;;;United States;;America/New_York;en;New Construction;Design-Bid-Build;project_for_copy_folder
name;start_date;end_date;project_type;value;currency;job_number;address_line_1;address_line_2;city;state_or_province;postal_code;country;business_unit_id;timezone;language;construction_type;contract_type
Sample Project 1;05/21/2019;05/25/2019;Office;0;USD;;;;;;;United States;;America/New_York;en;New Construction;Design-Bid-Build
Sample Project 2;05/21/2019;05/25/2019;Office;0;USD;;;;;;;United States;;America/New_York;en;New Construction;Design-Bid-Build
11 changes: 10 additions & 1 deletion BimProjectSetupCLI/sample/BIM360_Service_Template.csv
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
project_name;service_type;email;company
Setup Tool Test project 1;doc_manager;user@company.com;Autodesk
Sample Project 1;admin;admin@company.com;Company Name
Sample Project 1;doc_manager;admin@company.com;Company Name
Sample Project 1;pm;admin@company.com;Company Name
Sample Project 1;fng;admin@company.com;Company Name
Sample Project 1;collab;admin@company.com;Company Name
Sample Project 1;cost;admin@company.com;Company Name
Sample Project 1;gng;admin@company.com;Company Name
Sample Project 1;glue;admin@company.com;Company Name
Sample Project 1;plan;admin@company.com;Company Name
Sample Project 1;field;admin@company.com;Company Name
8 changes: 4 additions & 4 deletions BimProjectSetupCLI/sample/ImportProjects.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set FORGE_CLIENT_ID=<your_client_id>
set FORGE_CLIENT_SECRET=<your_client_secret>
set FORGE_BIM_ACCOUNT_ID=<your_account_id>
set FORGE_CLIENT_ID=<your_client_id_without_quotation_marks>
set FORGE_CLIENT_SECRET=<your_client_secret_without_quotation_marks>
set FORGE_BIM_ACCOUNT_ID=<your_account_id_without_quotation_marks>
cd ..
Autodesk.BimProjectSetup.exe -p ".\sample\BIM360_Projects_Template.csv" -b "https://developer.api.autodesk.com" -t ";" -z "," -e "UTF-8" -d "yyyy-MM-dd" -r false -h "admin.account@yourcompny.com"
Autodesk.BimProjectSetup.exe -p ".\sample\BIM360_Projects_Template.csv"
pause
6 changes: 6 additions & 0 deletions BimProjectSetupCLI/sample/ImportProjectsCF.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set FORGE_CLIENT_ID=<your_client_id_without_quotation_marks>
set FORGE_CLIENT_SECRET=<your_client_secret_without_quotation_marks>
set FORGE_BIM_ACCOUNT_ID=<your_account_id_without_quotation_marks>
cd ..
Autodesk.BimProjectSetup.exe -p ".\sample\BIM360_Projects_CF_Template.csv" -h "admin@company.com" --CF
pause
8 changes: 4 additions & 4 deletions BimProjectSetupCLI/sample/ImportServices.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set FORGE_CLIENT_ID=<your_client_id>
set FORGE_CLIENT_SECRET=<your_client_secret>
set FORGE_BIM_ACCOUNT_ID=<your_account_id>
set FORGE_CLIENT_ID=<your_client_id_without_quotation_marks>
set FORGE_CLIENT_SECRET=<your_client_secret_without_quotation_marks>
set FORGE_BIM_ACCOUNT_ID=<your_account_id_without_quotation_marks>
cd ..
Autodesk.BimProjectSetup.exe -x ".\sample\BIM360_Service_Template.csv" -b "https://developer.api.autodesk.com" -t ";" -z "," -e "UTF-8" -d "yyyy-MM-dd" -r false -h "admin.account@yourcompny.com"
Autodesk.BimProjectSetup.exe -x ".\sample\BIM360_Service_Template.csv"
pause
8 changes: 4 additions & 4 deletions BimProjectSetupCLI/sample/ImportUsers.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set FORGE_CLIENT_ID=<your_client_id>
set FORGE_CLIENT_SECRET=<your_client_secret>
set FORGE_BIM_ACCOUNT_ID=<your_account_id>
set FORGE_CLIENT_ID=<your_client_id_without_quotation_marks>
set FORGE_CLIENT_SECRET=<your_client_secret_without_quotation_marks>
set FORGE_BIM_ACCOUNT_ID=<your_account_id_without_quotation_marks>
cd ..
Autodesk.BimProjectSetup.exe -u ".\sample\BIM360_ProjectUser_Template.csv" -b "https://developer.api.autodesk.com" -t ";" -z "," -e "UTF-8" -d "yyyy-MM-dd" -r false -h "admin.account@yourcompny.com"
Autodesk.BimProjectSetup.exe -u ".\sample\BIM360_ProjectUser_Template.csv" -h "admin@company.com"
pause
6 changes: 6 additions & 0 deletions BimProjectSetupCLI/sample/UpdateUsers.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set FORGE_CLIENT_ID=<your_client_id_without_quotation_marks>
set FORGE_CLIENT_SECRET=<your_client_secret_without_quotation_marks>
set FORGE_BIM_ACCOUNT_ID=<your_account_id_without_quotation_marks>
cd ..
Autodesk.BimProjectSetup.exe -u ".\sample\BIM360_ProjectUser_UP_Template.csv" -h "admin@company.com" --UP
pause
8 changes: 7 additions & 1 deletion BimProjectSetupCommon/AppOptions.cs
100755 → 100644
Original file line number Diff line number Diff line change
@@ -72,6 +72,7 @@ public string FormatPattern
public bool TrialRun { get; private set; }
public string HqAdmin { get; private set; }
public bool CopyFolders { get; private set; }
public bool UpdateProjectUsers { get; private set; }
public string AccountRegion
{
get
@@ -102,6 +103,7 @@ internal AppOptions()
Encoding = GetEncoding("UTF-8");
TrialRun = false;
CopyFolders = false;
UpdateProjectUsers = false;
AccountRegion = "US";
}

@@ -172,6 +174,10 @@ public static AppOptions Parse(string[] args)
{
options.CopyFolders = true;
}
else if (arg.Equals("--UP", StringComparison.InvariantCultureIgnoreCase))
{
options.UpdateProjectUsers = true;
}
else if (arg.Equals("--AR", StringComparison.InvariantCultureIgnoreCase))
{
options.AdminRole = args[++i];
@@ -192,7 +198,7 @@ private static Encoding GetEncoding(string name)

if (encodingInfos != null)
{
encodingInfo = encodingInfos.FirstOrDefault(e => e.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));
encodingInfo = encodingInfos.FirstOrDefault(e => e.Name != null && e.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));
if (encodingInfo == null)
{
int codePage;
63 changes: 57 additions & 6 deletions BimProjectSetupCommon/DataController.cs
100755 → 100644
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
using System;
using System.Data;
using System.Collections.Generic;
using System.Threading;

using NLog;
using System.Linq;
@@ -122,7 +123,7 @@ public static BimProject GetProjectById(string projectId)
public static string GetProjectIdByName(string projectName)
{
BimProject result = null;
result = AllProjects.FirstOrDefault(p => p.name.Equals(projectName));
result = AllProjects.FirstOrDefault(p => p.name != null && p.name.Equals(projectName));
return (result != null ? result.id : null);
}
#endregion
@@ -362,7 +363,7 @@ public static Dictionary<int, ServiceActivation> GetServiceActivations()
continue;
}

BimCompany comp = Companies.FirstOrDefault(c => c.name.Equals(service.company));
BimCompany comp = Companies.FirstOrDefault(c => c.name != null && c.name.Equals(service.company));
if (comp != null) service.company_id = comp.id;
}
catch (Exception e)
@@ -385,7 +386,7 @@ private static string GetBusinessUnitId(object bu)
string result = null;
if (bu != null && BusinessUnits != null && BusinessUnits.Count > 0)
{
BusinessUnit unit = BusinessUnits.FirstOrDefault(b => b.name.Equals(buName, StringComparison.InvariantCultureIgnoreCase));
BusinessUnit unit = BusinessUnits.FirstOrDefault(b => b.name != null && b.name.Equals(buName, StringComparison.InvariantCultureIgnoreCase));
if (unit != null) result = unit.id;
}
return result;
@@ -403,7 +404,7 @@ private static string GetToken()
}
else return _token;
}
private static List<BimProject> GetProjects()
private static List<BimProject> GetProjects( string sortProp = "updated_at", int limit = 100, int offset = 0)
{
if (_options == null)
{
@@ -412,7 +413,7 @@ private static List<BimProject> GetProjects()

BimProjectsApi _projectsApi = new BimProjectsApi(GetToken, _options);
List<BimProject> projects = new List<BimProject>();
_projectsApi.GetProjects(out projects);
_projectsApi.GetProjects(out projects, sortProp, limit, offset);
return projects;
}
private static BimProject GetProject(string projId)
@@ -541,9 +542,59 @@ public static string AddProject(BimProject project, string accountId = null, int

}

bool success = false;
BimProject newProject = null;
IRestResponse response = _projectsApi.PostProject(project, accountId);
return HandleCreateProjectResponse(response, accountId, rowIndex);
if (response.StatusCode == System.Net.HttpStatusCode.Created)
{
newProject = JsonConvert.DeserializeObject<BimProject>(response.Content);
success = true;
}
// In certain case, the BIM 360 backend takes more than 10 seconds to handle the request,
// this will result in 504 gateway timeout error, but the project should be already successfully
// created, add this check to fix this issue.
if( response.StatusCode == System.Net.HttpStatusCode.GatewayTimeout )
{
Thread.Sleep(3000);
List<BimProject> projectList = GetProjects(@"-created_at");
newProject = projectList.FirstOrDefault();
success = newProject != null && newProject.name == project.name;
}
if( success )
{
if (_AllProjects == null)
{
_AllProjects = GetProjects();
}

if (accountId == null)
{
_AllProjects.Add(newProject);
}

if (rowIndex > -1)
{
_projectTable.Rows[rowIndex]["id"] = newProject.id;
_projectTable.Rows[rowIndex]["result"] = ResultCodes.ProjectCreated;
}
Log.Info($"- project {newProject.name} created with ID {newProject.id}!");
return newProject.id;
}
else
{
ResponseContent content = null;
content = JsonConvert.DeserializeObject<ResponseContent>(response.Content);
string msg = ((content != null && content.message != null) ? content.message : null);
if (rowIndex > -1)
{
_projectTable.Rows[rowIndex]["result"] = ResultCodes.Error;
_projectTable.Rows[rowIndex]["result_message"] = msg;
}
Log.Warn($"Status Code: {response.StatusCode.ToString()}\t Message: {msg}");
return "error";
}
}

public static void UpdateProject(BimProject project, int rowIndex = -1)
{
BimProjectsApi _projectsApi = new BimProjectsApi(GetToken, _options);
25 changes: 19 additions & 6 deletions BimProjectSetupCommon/Workflows/Folder.cs
100755 → 100644
Original file line number Diff line number Diff line change
@@ -288,20 +288,27 @@ private void CopyProjectFolders(BimProject orgProj, string newProjId, string uid
}

// Iterate root folders and match the name with original project folders
Log.Info("- copying folders to the new project.");
Log.Info("- copying folders(including folder permission of role) to the new project.");
foreach (Folder newRootFolder in newTopFoldersRes.data)
{
if (folderStructures.ContainsKey(orgProj.name))
{
NestedFolder existingRootFolder = folderStructures[orgProj.name].Find(x => x.name == newRootFolder.attributes.name);
if (existingRootFolder != null)
{
Log.Info("- copying the subfolders of root folder: " + newRootFolder.attributes.name);
// Without below, access to the project is forbidden...
Log.Info("- wait 30 seconds to make sure the new project is successfully setup ... ...");
Thread.Sleep(30000);

// assign permission to root folder first
Log.Info("- assigning role permissions to root folder: " + newRootFolder.attributes.name);
bool res = _foldersApi.AssignPermission(newProjId, newRootFolder.id, existingRootFolder.permissions, uid);
if (!res)
Log.Warn($"Failed to assgn role permissions to root folder: {newRootFolder.attributes.name}.");

Log.Info("- copying the subfolders(including folder permission of role) of root folder: " + newRootFolder.attributes.name);
foreach (NestedFolder childFolder in existingRootFolder.childrenFolders)
{
// Without below, access to the project is forbidden...
Thread.Sleep(3000);

// Recursively create new child folders
RecursivelyCreateFolder(newProjId, uid, newRootFolder.id, childFolder);
}
@@ -332,6 +339,12 @@ private void RecursivelyCreateFolder(string projId, string uid, string parentFol
else
{
retryCounter = 0; // Reset the counter
Log.Info("-- assigning role permission to folder: " + newFolder.name);
// assign permission to the new created folder
bool res = _foldersApi.AssignPermission(projId, newFolderId, newFolder.permissions, uid );
if( !res )
Log.Warn($"Failed to assgn role permissions to the new created folder: {newFolder.name}.");

if (newFolder.childrenFolders.Count > 0)
{
foreach (NestedFolder childFolder in newFolder.childrenFolders)
@@ -346,7 +359,7 @@ private List<IndustryRole> GetRolesForProject(string projectName)
List<IndustryRole> result = null;
if (false == _projectToRolesDict.TryGetValue(projectName, out result))
{
BimProject project = DataController.AllProjects.FirstOrDefault(p => p.name.Equals(projectName));
BimProject project = DataController.AllProjects.FirstOrDefault(p => p.name != null && p.name.Equals(projectName));
if (project == null)
{
throw new ApplicationException($"No projects found for name '{projectName}'");
Loading