AnsweredAssumed Answered

How do I use ArcGISPortalManager?

Question asked by htudosieesri-ca-esridist Employee on Dec 6, 2016
Latest reply on Dec 12, 2016 by cmacleod-esristaff

I'm working with ArcGis Pro 1.4.0-alpha.3

My goal is to get a GeoDatabase or a Zip file produced in my extension and move it in MyContent on the portal.

I set up the portal in Project/Portals:

And I want to use that setting.

 

However, trying to use PortalManager (documented in ArcGIS Pro 1.3 API Reference Guide - How do I get the help for 1.4?) I'm told thet this object is obsolete and redirected to use ArcGISPortalManager, which shows up in the code as part of ArcGis.Desktop.Core, but has peculiarities: most of its methods (which look fine and I want to use,) do not work on the current thread, and do not work on the QueuedTask thread!

Starting with GetActivePortal, I try to do this (on a constructor of a button): 

QueuedTask.Run(() =>

   var a = ArcGISPortalManager.Current.GetActivePortal();
   IsChecked = a.IsSignedOn();
});

It does not work either with or without the QueryTask, neither in the constructor, nor in InClick event! (I have even tried in other parts of the extension, as in the initialization of the Module!)

 

As I've found some work-around to obtain the active portal and open it in the browser:

 

protected override void OnClick()
{
#pragma warning disable 618
   var url = new UriBuilder(PortalManager.GetActivePortal())
   {
      Path = "home/content.html"
   };
#pragma warning restore 618
   Process.Start(url.Uri.AbsoluteUri);
}

This code mixes the obsolete PortalManager with the new one (as in):

#pragma warning disable 618
m_portal = ArcGISPortalManager.Current.GetPortal(PortalManager.GetActivePortal());
#pragma warning restore 618

And does not let me use the wonderful methods of ArcGISPortal objects (m-portal) for the treading issues already mentioned!

Outcomes