Пример #1
0
        public void InitializePortal(string PortalUrl)
        {
            ArcGISPortal arcgisPortal = new ArcGISPortal();

            arcgisPortal.InitializeAsync(PortalUrl, (p, ex) =>
            {
                if (ex == null)
                {
                    ArcGISPortalInfo portalInfo = p.ArcGISPortalInfo;
                    if (portalInfo == null)
                    {
                        MessageBox.Show("Portal Information could not be retrieved");
                        return;
                    }
                    PropertiesListBox.Items.Add(string.Format("Current Version: {0}", p.CurrentVersion));
                    PropertiesListBox.Items.Add(string.Format("Access: {0}", portalInfo.Access));
                    PropertiesListBox.Items.Add(string.Format("Host Name: {0}", portalInfo.PortalHostname));
                    PropertiesListBox.Items.Add(string.Format("Name: {0}", portalInfo.PortalName));
                    PropertiesListBox.Items.Add(string.Format("Mode: {0}", portalInfo.PortalMode));

                    ESRI.ArcGIS.Client.WebMap.BaseMap basemap = portalInfo.DefaultBaseMap;

                    PropertiesListBox.Items.Add(string.Format("Default BaseMap Title: {0}", basemap.Title));
                    PropertiesListBox.Items.Add(string.Format("WebMap Layers ({0}):", basemap.Layers.Count));

                    foreach (WebMapLayer webmapLayer in basemap.Layers)
                    {
                        PropertiesListBox.Items.Add(webmapLayer.Url);
                    }

                    portalInfo.GetFeaturedGroupsAsync((portalgroup, exp) =>
                    {
                        if (exp == null)
                        {
                            GroupsList.ItemsSource = portalgroup;
                            (ApplicationBar.Buttons[1] as IApplicationBarIconButton).IsEnabled = true;
                        }
                    });

                    portalInfo.SearchFeaturedItemsAsync(new SearchParameters()
                    {
                        Limit = 15
                    }, (result, err) =>
                    {
                        if (err == null)
                        {
                            FeaturedMapsList.ItemsSource = result.Results;
                            (ApplicationBar.Buttons[0] as IApplicationBarIconButton).IsEnabled = true;
                        }
                    });
                }
                else
                {
                    MessageBox.Show("Failed to initialize" + ex.Message.ToString());
                }
            });
        }
Пример #2
0
        // Initializes the given portal and populates UI
        private async Task InitializePortalAsync(string portalUrl)
        {
            try
            {
                var portal = await ArcGISPortal.CreateAsync(new Uri(portalUrl));

                ArcGISPortalInfo portalInfo = portal.ArcGISPortalInfo;
                if (portalInfo == null)
                {
                    MessageBox.Show("Portal Information could not be retrieved");
                    return;
                }

                PropertiesListBox.Items.Add(string.Format("Current Version: {0}", portal.CurrentVersion));
                PropertiesListBox.Items.Add(string.Format("Access: {0}", portalInfo.Access));
                PropertiesListBox.Items.Add(string.Format("Host Name: {0}", portalInfo.PortalHostname));
                PropertiesListBox.Items.Add(string.Format("Name: {0}", portalInfo.PortalName));
                PropertiesListBox.Items.Add(string.Format("Mode: {0}", portalInfo.PortalMode));

                BaseMap basemap = portalInfo.DefaultBaseMap;

                PropertiesListBox.Items.Add(string.Format("Default BaseMap Title: {0}", basemap.Title));
                PropertiesListBox.Items.Add(string.Format("WebMap Layers ({0}):", basemap.Layers.Count));

                foreach (WebMapLayer webmapLayer in basemap.Layers)
                {
                    PropertiesListBox.Items.Add(webmapLayer.Url);
                }

                var portalgroup = await portalInfo.GetFeaturedGroupsAsync();

                PropertiesListBox.Items.Add("Groups:");

                ListBox listGroups = new ListBox();
                listGroups.ItemTemplate = layoutGrid.Resources["PortalGroupTemplate"] as DataTemplate;
                listGroups.ItemsSource  = portalgroup;
                PropertiesListBox.Items.Add(listGroups);

                var result = await portalInfo.SearchFeaturedItemsAsync(new SearchParameters()
                {
                    Limit = 15
                });

                FeaturedMapsList.ItemsSource = result.Results;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to initialize" + ex.Message);
            }
        }