예제 #1
0
        private async Task <IList <jsTreeNode> > GetHubAsync()
        {
            IList <jsTreeNode> nodes   = new List <jsTreeNode>();
            HubsApi            hubsApi = new HubsApi();

            hubsApi.Configuration.AccessToken = Credentials.TokenInternal;
            var hubs = await hubsApi.GetHubsAsync();

            foreach (KeyValuePair <string, dynamic> hubInfo in new DynamicDictionaryItems(hubs.data))
            {
                string nodeType = "hubs";
                switch ((string)hubInfo.Value.attributes.extension.type)
                {
                case "hubs:autodesk.core:Hub":
                    nodeType = "hubs";
                    break;

                case "hubs:autodesk.a360:PersonalHub":
                    nodeType = "personalHub";
                    break;

                case "hubs:autodesk.bim360.Account":
                    nodeType = "bim360Hubs";
                    break;
                }
                jsTreeNode hubNode = new jsTreeNode(hubInfo.Value.links.self.href, hubInfo.Value.attributes.name,
                                                    nodeType, true);
                nodes.Add(hubNode);
            }
            return(nodes);
        }
        private async Task<IList<jsTreeNode>> GetHubsAsync()
        {
            IList<jsTreeNode> nodes = new List<jsTreeNode>();

            // the API SDK
            HubsApi hubsApi = new HubsApi();
            hubsApi.Configuration.AccessToken = Credentials.TokenInternal;

            var hubs = await hubsApi.GetHubsAsync();
            foreach (KeyValuePair<string, dynamic> hubInfo in new DynamicDictionaryItems(hubs.data))
            {
                // check the type of the hub to show an icon
                string nodeType = "hubs";
                switch ((string)hubInfo.Value.attributes.extension.type)
                {
                    case "hubs:autodesk.core:Hub":
                        nodeType = "hubs"; // if showing only BIM 360, mark this as 'unsupported'
                        continue;
                    case "hubs:autodesk.a360:PersonalHub":
                        nodeType = "personalHub"; // if showing only BIM 360, mark this as 'unsupported'
                        continue;
                    case "hubs:autodesk.bim360:Account":
                        nodeType = "bim360Hubs";
                        break;
                }

                // create a treenode with the values
                jsTreeNode hubNode = new jsTreeNode(hubInfo.Value.id/*links.self.href*/, hubInfo.Value.attributes.name, nodeType, !(nodeType == "unsupported"));
                nodes.Add(hubNode);
            }

            return nodes;
        }
        public async Task <IList <HubInfo> > GetHubsAsync()
        {
            Credentials = await Credentials.FromSessionAsync(base.Request.Cookies, Response.Cookies);

            if (Credentials == null)
            {
                return(null);
            }

            IList <HubInfo> nodes = new List <HubInfo>();

            // the API SDK
            HubsApi hubsApi = new HubsApi();

            hubsApi.Configuration.AccessToken = Credentials.TokenInternal;

            var hubs = await hubsApi.GetHubsAsync();

            foreach (KeyValuePair <string, dynamic> hubInfo in new DynamicDictionaryItems(hubs.data))
            {
                if ((string)hubInfo.Value.attributes.extension.type != "hubs:autodesk.bim360:Account")
                {
                    continue;
                }
                nodes.Add(new HubInfo(hubInfo.Value.attributes.name, hubInfo.Value.id));
            }

            return(nodes);
        }
        private async Task <IList <TreeNode> > GetHubsAsync()
        {
            IList <TreeNode> nodes = new List <TreeNode>();

            HubsApi hubsApi = new HubsApi();

            hubsApi.Configuration.AccessToken = AccessToken;

            var hubs = await hubsApi.GetHubsAsync();

            string urn = string.Empty;

            foreach (KeyValuePair <string, dynamic> hubInfo in new DynamicDictionaryItems(hubs.data))
            {
                string nodeType = "hubs";
                switch ((string)hubInfo.Value.attributes.extension.type)
                {
                case "hubs:autodesk.core:Hub":
                    nodeType = "hubs";
                    break;

                case "hubs:autodesk.a360:PersonalHub":
                    nodeType = "personalhub";
                    break;

                case "hubs:autodesk.bim360:Account":
                    nodeType = "bim360hubs";
                    break;
                }
                TreeNode hubNode = new TreeNode(hubInfo.Value.links.self.href, (nodeType == "bim360hubs" ? "BIM 360 Projects" : hubInfo.Value.attributes.name), nodeType, true);
                nodes.Add(hubNode);
            }

            return(nodes);
        }
예제 #5
0
        public async Task <string> GetHubRegion(string hubId)
        {
            HubsApi hubsApi = new HubsApi();

            hubsApi.Configuration.AccessToken = AccessToken;
            var hub = await hubsApi.GetHubAsync(hubId);

            return(hub.data.attributes.region);
        }
 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();
 }
        private static List <Hub> GetHubs()
        {
            if (_options == null)
            {
                return(null);
            }

            HubsApi       _hubsApi = new HubsApi(GetToken, _options);
            IRestResponse response = _hubsApi.GetHubs();
            List <Hub>    result   = HandleGetHubsResponse(response);

            return(result);
        }
예제 #8
0
        public async Task <IList <Item> > GetHubs()
        {
            string sessionId, localId;

            if (!HeaderUtils.GetSessionLocalIDs(out sessionId, out localId))
            {
                return(null);
            }
            if (!await OAuthDB.IsSessionIdValid(sessionId, localId))
            {
                return(null);
            }
            string userAccessToken = await OAuthDB.GetAccessToken(sessionId, localId);

            HubsApi hubsApi = new HubsApi();

            hubsApi.Configuration.AccessToken = userAccessToken;

            IList <Item> nodes = new List <Item>();
            var          hubs  = await hubsApi.GetHubsAsync();

            foreach (KeyValuePair <string, dynamic> hubInfo in new DynamicDictionaryItems(hubs.data))
            {
                string hubType = "hubs";
                switch ((string)hubInfo.Value.attributes.extension.type)
                {
                case "hubs:autodesk.core:Hub":
                    hubType = "hubs";
                    break;

                case "hubs:autodesk.a360:PersonalHub":
                    hubType = "personalhub";
                    break;

                case "hubs:autodesk.bim360:Account":
                    hubType = "bim360hubs";
                    break;
                }
                Item item = new Item(hubInfo.Value.links.self.href, hubInfo.Value.attributes.name, hubType);
                nodes.Add(item);
            }

            return(nodes);
        }
        private async void listHubs()
        {
            var hubsApi = new HubsApi();

            hubsApi.Configuration.AccessToken = logInInfo.accessToken;

            var hubs = await hubsApi.GetHubsAsync();

            foreach (KeyValuePair <string, dynamic> hubInfo in new DynamicDictionaryItems(hubs.data))
            {
                MyTreeNode hubNode = new MyTreeNode(
                    hubInfo.Value.links.self.href,
                    hubInfo.Value.attributes.name,
                    hubInfo.Value.attributes.extension.type,
                    "",
                    NodeType.Hub
                    );
                addToTreeView(null, hubNode);
                listProjects(hubNode);
            }
        }
        public async Task <JArray> GetProjectsAsync()
        {
            Credentials = await Credentials.FromSessionAsync(base.Request.Cookies, Response.Cookies);

            if (Credentials == null)
            {
                return(null);
            }

            // array of projects
            JArray allProjects = new JArray();

            // the API SDK
            HubsApi hubsApi = new HubsApi();

            hubsApi.Configuration.AccessToken = Credentials.TokenInternal;
            ProjectsApi projectsApi = new ProjectsApi();

            projectsApi.Configuration.AccessToken = Credentials.TokenInternal;

            var hubs = await hubsApi.GetHubsAsync();

            foreach (KeyValuePair <string, dynamic> hubInfo in new DynamicDictionaryItems(hubs.data))
            {
                string hubType = (string)hubInfo.Value.attributes.extension.type;
                if (hubType != "hubs:autodesk.bim360:Account")
                {
                    continue;                                            // skip non-BIM360 hub
                }
                string hubId    = (string)hubInfo.Value.id;
                var    projects = await projectsApi.GetHubProjectsAsync(hubId);

                foreach (KeyValuePair <string, dynamic> projectInfo in new DynamicDictionaryItems(projects.data))
                {
                    allProjects.Add(JObject.FromObject(new { hub = new { id = hubInfo.Value.id, name = hubInfo.Value.attributes.name }, project = new { id = projectInfo.Value.id, name = projectInfo.Value.attributes.name } }));
                }
            }
            return(new JArray(allProjects.OrderBy(obj => (string)obj["project"]["name"])));
        }
 public void Init()
 {
     instance = new HubsApi();
 }