public void CopyProjectToTargetHubProcess(BimProject orgProj, string targetAccountId, string adminEmail, List <string> roles = null) { Log.Info(""); Log.Info("============================================================"); Log.Info("HUB2HUB PROJECT COPY WORKFLOW started for " + orgProj.name); Log.Info("============================================================"); Log.Info(""); Log.Info($"Creating project by copying data from original project '{orgProj.name}'"); List <string> roleIds = new List <string>(); HqUser admin = new HqUser(); // Get service activated in the original project if (orgProj.service_types == null || orgProj.service_types == "") { orgProj = DataController.GetProjectWithServiceById(orgProj.id); if (orgProj.service_types.Contains("insight")) { orgProj.service_types = orgProj.service_types.Replace("insight,", ""); } } // Check if target hub supports the services // Make sure the target hub is allowing same service types. // Create project to the target hub try { ExtractFolderStructure(orgProj); bool result = CreateProjectFromTargetHub(orgProj, targetAccountId, out string newProjId); if (result) { IRestResponse res = _projectApi.GetProject(newProjId, targetAccountId); BimProject newProj = DataController.HandleGetProjectResponse(res); roleIds = GetIndustryRoleIds(newProj, roles, targetAccountId); admin = GetAdminUserFromTargetHub(adminEmail, targetAccountId); bool status = false; do { status = ActivateProject(newProjId, admin, roleIds, targetAccountId); } while (status == false); if (status) { if (folderStructures.ContainsKey(orgProj.name)) { CopyProjectFolders(orgProj, newProjId, admin.uid); } } } Log.Info(""); Log.Info("HUB2HUB PROJECT COPY WORKFLOW finished for " + orgProj.name); } catch (Exception ex) { Log.Error(ex); } }
private static BimProject GetProject(string projId) { if (_options == null) { return(null); } BimProjectsApi _projectsApi = new BimProjectsApi(GetToken, _options); IRestResponse response = _projectsApi.GetProject(projId); return(HandleGetProjectResponse(response)); }