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' break; case "hubs:autodesk.a360:PersonalHub": nodeType = "personalHub"; // if showing only BIM 360, mark this as 'unsupported' break; case "hubs:autodesk.bim360:Account": nodeType = "bim360Hubs"; break; } // create a treenode with the values jsTreeNode hubNode = new jsTreeNode(hubInfo.Value.links.self.href, hubInfo.Value.attributes.name, nodeType, !(nodeType == "unsupported")); nodes.Add(hubNode); } return(nodes); }
private async Task <IList <jsTreeNode> > GetProjectsAsync(string href) { IList <jsTreeNode> nodes = new List <jsTreeNode>(); // the API SDK ProjectsApi projectsApi = new ProjectsApi(); projectsApi.Configuration.AccessToken = Credentials.TokenInternal; // extract the hubId from the href string[] idParams = href.Split('/'); string hubId = idParams[idParams.Length - 1]; var projects = await projectsApi.GetHubProjectsAsync(hubId); foreach (KeyValuePair <string, dynamic> projectInfo in new DynamicDictionaryItems(projects.data)) { // check the type of the project to show an icon string nodeType = "projects"; switch ((string)projectInfo.Value.attributes.extension.type) { case "projects:autodesk.core:Project": nodeType = "a360projects"; break; case "projects:autodesk.bim360:Project": nodeType = "bim360projects"; break; } // create a treenode with the values jsTreeNode projectNode = new jsTreeNode(projectInfo.Value.links.self.href, projectInfo.Value.attributes.name, nodeType, false); nodes.Add(projectNode); } return(nodes); }
private async Task <IList <jsTreeNode> > GetItemVersions(string href) { IList <jsTreeNode> nodes = new List <jsTreeNode>(); // the API SDK ItemsApi itemApi = new ItemsApi(); itemApi.Configuration.AccessToken = Credentials.TokenInternal; // extract the projectId & itemId from the href string[] idParams = href.Split('/'); string itemId = idParams[idParams.Length - 1]; string projectId = idParams[idParams.Length - 3]; var versions = await itemApi.GetItemVersionsAsync(projectId, itemId); foreach (KeyValuePair <string, dynamic> version in new DynamicDictionaryItems(versions.data)) { DateTime versionDate = version.Value.attributes.lastModifiedTime; string verNum = version.Value.id.Split("=")[1]; string userName = version.Value.attributes.lastModifiedUserName; string urn = string.Empty; try { urn = (string)version.Value.relationships.derivatives.data.id; } catch { urn = Base64Encode(version.Value.id); } // some BIM 360 versions don't have viewable jsTreeNode node = new jsTreeNode( urn, string.Format("v{0}: {1} by {2}", verNum, versionDate.ToString("dd/MM/yy HH:mm:ss"), userName), "versions", false); nodes.Add(node); } return(nodes); }
private async Task <IList <jsTreeNode> > GetItemVersions(string href) { IList <jsTreeNode> nodes = new List <jsTreeNode>(); // the API SDK ItemsApi itemApi = new ItemsApi(); itemApi.Configuration.AccessToken = Credentials.TokenInternal; DerivativesApi derivativesApi = new DerivativesApi(); derivativesApi.Configuration.AccessToken = Credentials.TokenInternal; // extract the projectId & itemId from the href string[] idParams = href.Split('/'); string itemId = idParams[idParams.Length - 1]; string projectId = idParams[idParams.Length - 3]; var versions = await itemApi.GetItemVersionsAsync(projectId, itemId); foreach (KeyValuePair <string, dynamic> version in new DynamicDictionaryItems(versions.data)) { DateTime versionDate = version.Value.attributes.lastModifiedTime; string verId = version.Value.id; string verNum = version.Value.id.Split("=")[1]; string userName = version.Value.attributes.lastModifiedUserName; string urn = string.Empty; try { urn = (string)version.Value.relationships.derivatives.data.id; dynamic manifestData = await derivativesApi.GetManifestAsync(urn); foreach (KeyValuePair <string, dynamic> manifestParam in new DynamicDictionaryItems(manifestData)) { if (manifestParam.Key == "derivatives") { foreach (KeyValuePair <string, dynamic> manifestDerivativeParam in new DynamicDictionaryItems(manifestParam.Value[0])) { if (manifestDerivativeParam.Key == "children") { foreach (KeyValuePair <string, dynamic> manifestDerivativeChildrenParam in new DynamicDictionaryItems(manifestDerivativeParam.Value)) { string roomManifestStr = Convert.ToString(manifestDerivativeChildrenParam.Value); //string roomManifestStrJson = roomManifestStr.Substring(1, roomManifestStr.Length - 2); RoomManifestChildren deserializedRoomManifest = JsonConvert.DeserializeObject <RoomManifestChildren>(roomManifestStr); if (deserializedRoomManifest.Role == "3d" && deserializedRoomManifest.Status == ManifestChildren.StatusEnum.Success) { if (deserializedRoomManifest.PhaseNames != null) { jsTreeNode phaseNode = new jsTreeNode( urn + '|' + deserializedRoomManifest.ViewableId + '/' + projectId + '/' + verId, string.Format("v{0}: phase: {1}", verNum, deserializedRoomManifest.PhaseNames), "versions", false); nodes.Add(phaseNode); } } //foreach(RoomManifestChildren roomManifestChild in deserializedManifestChildren) //{ // if (roomManifestChild.Role == ManifestChildren.RoleEnum._3d && roomManifestChild.Status == ManifestChildren.StatusEnum.Success) // { // if (roomManifestChild.PhaseNames != null) // { // jsTreeNode phaseNode = new jsTreeNode( // urn + '|' + roomManifestChild.ViewableId + '/' + projectId + '/' + verId, // string.Format("v{0}: {1}", verNum, roomManifestChild.PhaseNames), // "versions", // false); // nodes.Add(phaseNode); // } // } //} //if (manifestDerivativeChildParam.Key == "role" && manifestDerivativeChildParam.Value == "3d") //{ // if(manifestDerivativeChildParam.Key == "status" && manifestDerivativeChildParam.Value == "success") // { // if(manifestDerivativeChildParam.Key == "phaseNames") // { // jsTreeNode phaseNode = new jsTreeNode( // urn + '|' + manifestDerivativeChildParam.Value.viewableID + '/' + projectId + '/' + verId, // string.Format("v{0}: {1}", verNum, manifestDerivativeChildParam.Value), // "versions", // false); // nodes.Add(phaseNode); // } // } //} } } } } } } catch (Exception ex) { string message = ex.Message; urn = Base64Encode(version.Value.id); } // some BIM 360 versions don't have viewable jsTreeNode node = new jsTreeNode( urn + '/' + projectId + '/' + verId, string.Format("v{0}: {1} by {2}", verNum, versionDate.ToString("dd/MM/yy HH:mm:ss"), userName), "versions", false); nodes.Add(node); } return(nodes); }