public ArcGISPortal GetPortal( Uri portalUri )
Public Function GetPortal( _ ByVal portalUri As Uri _ ) As ArcGISPortal
Parameters
- portalUri
- The URI that will be used to search for a matching portal
public ArcGISPortal GetPortal( Uri portalUri )
Public Function GetPortal( _ ByVal portalUri As Uri _ ) As ArcGISPortal
var projectPortal = ArcGISPortalManager.Current.GetPortal(new Uri(@"https://<serverName>.<domain>.com/portal/", UriKind.Absolute)); string owner = string.Empty; await QueuedTask.Run(() => { //Get the signed on user name owner = projectPortal.GetSignOnUsername(); }); //Get the user content from the portal var userContent = await projectPortal.GetUserContentAsync(owner); //Get the first portal project item var firstPortalProject = userContent.PortalItems.FirstOrDefault(pi => pi.PortalItemType == PortalItemType.ProProject); var portalProjectUri = firstPortalProject.ItemUri.ToString(); //Check if project can be opened string docVer = string.Empty; if (Project.CanOpen(portalProjectUri, out docVer)) { await Project.OpenAsync(portalProjectUri); } //Note: If Project.CanOpen returns false, the project cannot be opened. One reason could be // the active portal is not the same as the portal of the project. Refer to the snippet: [Workflow to open an ArcGIS Pro project](ProSnippets-sharing#workflow-to-open-an-arcgis-pro-project)
//Find the portal to sign in with using its Uri... var portal = ArcGISPortalManager.Current.GetPortal(new Uri(uri, UriKind.Absolute)); if (!portal.IsSignedOn()) { //Calling "SignIn" will trigger the OAuth popup if your credentials are //not cached (eg from a previous sign in in the session) if (portal.SignIn().success) { //Set this portal as my active portal ArcGISPortalManager.Current.SetActivePortal(portal); } }
var portal = ArcGISPortalManager.Current.GetPortal(new Uri(portalUri)); var portalInfo = await portal.GetPortalInfoAsync(); var orgid = portalInfo.OrganizationId;
Target Platforms: Windows 11, Windows 10