private List <string> GetIndustryRoleIds(BimProject proj, List <string> roles, string accountId)
        {
            BimProjectsApi      _projectsApi  = new BimProjectsApi(GetToken, _options);
            List <IndustryRole> rolesFromProj = new List <IndustryRole>();
            List <string>       roleIds       = new List <string>();

            if (roles == null)
            {
                roles = new List <string>();
                roles.Add(_options.AdminRole); // Default: VDC Manager. For CLI.
            }

            _projectsApi.GetIndustryRoles(proj.id, out rolesFromProj, accountId);

            if (rolesFromProj == null || rolesFromProj.Any() == false)
            {
                Log.Warn($"- Couldn't get any project industry roles for project '{proj.name}'");
                return(null);
            }

            foreach (string role in roles)
            {
                string roleId = rolesFromProj.Find(x => x.name == role).id;
                if (role != null)
                {
                    roleIds.Add(roleId);
                }
            }

            return(roleIds != null ? roleIds : null);
        }
        public static void UpdateProject(BimProject project, int rowIndex = -1)
        {
            BimProjectsApi _projectsApi = new BimProjectsApi(GetToken, _options);
            IRestResponse  response     = _projectsApi.PatchProjects(project.id, project);

            HandleUpdateProjectResponse(response, project, rowIndex);
        }
 public FolderWorkflow(AppOptions options) : base(options)
 {
     _hubsApi    = new HubsApi(GetToken, options);
     _projectApi = new BimProjectsApi(GetToken, options);
     _foldersApi = new BimProjectFoldersApi(GetToken, options);
     DataController.InitializeAllProjects();
     DataController.InitializeCompanies();
     DataController.InitializeAccountUsers();
     DataController.InitializeHubs();
 }
        public static void ArchiveProject(BimProject project)
        {
            BimProjectsApi _projectsApi = new BimProjectsApi(GetToken, _options);

            project.status = Status.archived;
            project.include_name_to_request_body = false;
            project.service_types = "";
            IRestResponse response = _projectsApi.PatchProjects(project.id, project);

            HandleUpdateProjectResponse(response, project);
        }
        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));
        }
        private static List <BimProject> GetProjects()
        {
            if (_options == null)
            {
                return(null);
            }

            BimProjectsApi    _projectsApi = new BimProjectsApi(GetToken, _options);
            List <BimProject> projects     = new List <BimProject>();

            _projectsApi.GetProjects(out projects);
            return(projects);
        }
예제 #7
0
        private static List <BimProject> GetProjects(string sortProp = "updated_at", int limit = 100, int offset = 0)
        {
            if (_options == null)
            {
                return(null);
            }

            BimProjectsApi    _projectsApi = new BimProjectsApi(GetToken, _options);
            List <BimProject> projects     = new List <BimProject>();

            _projectsApi.GetProjects(out projects, sortProp, limit, offset);
            return(projects);
        }
        public static List <IndustryRole> GetProjectRoles(string projId, string accountId)
        {
            if (projId == null)
            {
                Log.Error("TempContainer.GetProjectRoles(): Project Id not provided.");
                return(null);
            }
            if (_options == null)
            {
                Log.Error("TempContainer.GetProjectRoles(): Option not provided.");
                return(null);
            }

            BimProjectsApi      _projectsApi = new BimProjectsApi(GetToken, _options);
            List <IndustryRole> roles        = new List <IndustryRole>();

            _projectsApi.GetIndustryRoles(projId, out roles, accountId);
            return(roles);
        }
        public static string AddProject(BimProject project, string accountId = null, int rowIndex = -1)
        {
            BimProjectsApi _projectsApi = new BimProjectsApi(GetToken, _options);

            project.include_name_to_request_body = true;

            // replace empty strings with null
            PropertyInfo[] properties = project.GetType().GetProperties();
            foreach (PropertyInfo propInfo in properties)
            {
                if (typeof(string) == propInfo.PropertyType)
                {
                    string s = propInfo.GetValue(project) as string;  //as string;
                    if (s != null && s.Equals(""))
                    {
                        propInfo.SetValue(project, null);
                    }
                }
            }

            IRestResponse response = _projectsApi.PostProject(project, accountId);

            return(HandleCreateProjectResponse(response, accountId, rowIndex));
        }
예제 #10
0
 public ProjectUserWorkflow(AppOptions options) : base(options)
 {
     _projectsApi = new BimProjectsApi(GetToken, _options);
     DataController.InitializeAllProjects();
     DataController.InitializeAccountUsers();
 }
 public ServiceWorkflow(AppOptions options) : base(options)
 {
     _projectApi = new BimProjectsApi(GetToken, options);
     DataController.InitializeAllProjects();
 }
예제 #12
0
        public static string AddProject(BimProject project, string accountId = null, int rowIndex = -1)
        {
            BimProjectsApi _projectsApi = new BimProjectsApi(GetToken, _options);

            project.include_name_to_request_body = true;

            // replace empty strings with null
            PropertyInfo[] properties = project.GetType().GetProperties();
            foreach (PropertyInfo propInfo in properties)
            {
                if (typeof(string) == propInfo.PropertyType)
                {
                    string s = propInfo.GetValue(project) as string;  //as string;
                    if (s != null && s.Equals(""))
                    {
                        propInfo.SetValue(project, null);
                    }
                }
            }

            bool          success    = false;
            BimProject    newProject = null;
            IRestResponse response   = _projectsApi.PostProject(project, accountId);

            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");
            }
        }