Example #1
0
        private async Task GetRulePackages()
        {
            try
            {
                await QueuedTask.Run(async() =>
                {
                    ArcGISPortal portal = ArcGISPortalManager.Current.GetPortal(new Uri(_arcgisOnline));
                    var query           = PortalQueryParameters.CreateForItemsOfType(PortalItemType.RulePackage, "title:\"Paris Rule package 2014\" OR title:\"Venice Rule package 2014\" OR title:\"Extrude/Color/Rooftype Rule package 2014\"");

                    //Execute to return a result set
                    PortalQueryResultSet <PortalItem> results = await ArcGISPortalExtensions.SearchForContentAsync(portal, query);

                    foreach (var item in results.Results.OfType <PortalItem>())
                    {
                        lock (_rpkLock)
                        {
                            RulePackageCollection.Add(new RulePackage(item));
                        }
                    }
                });
            }

            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Example #2
0
        /// <summary>
        /// Gets a collection of web map items from ArcGIS Online
        /// </summary>
        /// <returns></returns>
        private async Task <ObservableCollection <AddInItem> > GetAddinsAsync()
        {
            try
            {
                await QueuedTask.Run(async() =>
                {
                    ArcGISPortal portal = ArcGISPortalManager.Current.GetPortal(new Uri(_arcgisOnline));
                    query = PortalQueryParameters.CreateForItemsOfType(PortalItemType.ArcGISProAddIn);

                    PortalQueryResultSet <PortalItem> results = await ArcGIS.Desktop.Core.ArcGISPortalExtensions.SearchForContentAsync(portal, query);

                    if (results == null)
                    {
                        return;
                    }

                    foreach (var item in results.Results.OfType <PortalItem>())
                    {
                        lock (_lock)
                            AddInsCollection.Add(new AddInItem(item));
                    }
                });
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            return(_addInsCollection);
        }
Example #3
0
        /// <summary>
        /// Gets a collection of web map items from ArcGIS Online
        /// </summary>
        /// <returns></returns>
        private async Task <List <WebMapItem> > GetWebMapsAsync()
        {
            var lstWebmapItems = new List <WebMapItem>();

            try
            {
                await QueuedTask.Run(async() =>
                {
                    ArcGISPortal portal         = ArcGISPortalManager.Current.GetPortal(new Uri(_arcgisOnline));
                    PortalQueryParameters query = PortalQueryParameters.CreateForItemsOfType(PortalItemType.WebMap);

                    PortalQueryResultSet <PortalItem> results = await ArcGIS.Desktop.Core.ArcGISPortalExtensions.SearchForContentAsync(portal, query);

                    if (results == null)
                    {
                        return;
                    }

                    foreach (var item in results.Results.OfType <PortalItem>())
                    {
                        lstWebmapItems.Add(new WebMapItem(item));
                    }
                });
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            return(lstWebmapItems);
        }
Example #4
0
        private async void addProtal()
        {
            ArcGISPortal portal = await ArcGISPortal.CreateAsync(new Uri("http://esrichina3d.arcgisonline.cn/arcgis/sharing/rest"));

            PortalQueryParameters para = PortalQueryParameters.CreateForItemsOfType(PortalItemType.WebScene);

            para.Limit = 20;
            PortalQueryResultSet <PortalItem> items = await portal.FindItemsAsync(para);

            int sum = 0;

            productList = new List <Product>();
            try
            {
                OpenFileActivity.item = items.Results.First();
                foreach (PortalItem item in items.Results)
                {
                    System.IO.Stream st = await item.GetDataAsync();

                    System.IO.StreamReader reader = new StreamReader(st);
                    st.Position = 0;
                    string json = reader.ReadToEnd();
                    reader.Close();
                    st.Close();
                    productList.Add(new Product(item.ThumbnailUri.ToString(), item.Title, json));
                }
            }
            catch
            { }

            RecyclerView recyclerView = (RecyclerView)FindViewById(Resource.Id.recyclerView);

            //设置layoutManager 布局模式
            recyclerView.SetLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.Vertical));

            //  recyclerView.SetLayoutManager(new LinearLayoutManager(this));
            //设置adapter

            Context        context = this.BaseContext;
            MasonryAdapter WebSceneItemsAdapter = new MasonryAdapter(productList, context);

            WebSceneItemsAdapter.ItemClick += WebSceneItemsAdapter_ItemClick;
            recyclerView.SetAdapter(WebSceneItemsAdapter);

            //设置item之间的间隔
            SpacesItemDecoration decoration = new SpacesItemDecoration(16);

            recyclerView.AddItemDecoration(decoration);
        }
Example #5
0
        public static async void PortalMethods6()
        {
            Uri portalUri = new Uri("");

            #region Portal: Execute a portal search

            var portal     = ArcGISPortalManager.Current.GetPortal(portalUri);
            var owner      = portal.GetSignOnUsername();
            var portalInfo = await portal.GetPortalInfoAsync();

            //1. Get all web maps
            var query1 = PortalQueryParameters.CreateForItemsOfType(PortalItemType.WebMap);

            //2. Get all web maps and map services - include user, organization
            // and "usa" in the title
            var query2 = PortalQueryParameters.CreateForItemsOfTypes(new List <PortalItemType>()
            {
                PortalItemType.WebMap, PortalItemType.MapService
            }, owner, "", "title:usa");
            query2.OrganizationId = portalInfo.OrganizationId;

            //retrieve in batches of up to a 100 each time
            query2.Limit = 100;

            //Loop until done
            var portalItems = new List <PortalItem>();
            while (query2 != null)
            {
                //run the search
                PortalQueryResultSet <PortalItem> results = await portal.SearchForContentAsync(query2);

                portalItems.AddRange(results.Results);
                query2 = results.NextQueryParameters;
            }

            //process results
            foreach (var pi in portalItems)
            {
                //Do something with the portal items
            }

            #endregion
        }
        /// <summary>
        /// Searches the active portal for the item that has been uploaded.
        /// </summary>
        /// <param name="portalUrl"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        private async Task <Tuple <bool, PortalItem> > SearchPortalForItemsAsync(string portalUrl, Item item)
        {
            var portal = ArcGISPortalManager.Current.GetPortal(new Uri(portalUrl));
            //Get the PortalItemType of the item
            var portalItemType = GetProtalItemTypeFromItem(item);
            //Get the item name without the extension
            var portalItemName = System.IO.Path.GetFileNameWithoutExtension(item.Name);
            //Create the Query and the params
            var pqp = PortalQueryParameters.CreateForItemsOfType(portalItemType, $@"""{portalItemName}"" tags:""{ItemTags}""");
            //Search active portal
            PortalQueryResultSet <PortalItem> results = await ArcGISPortalExtensions.SearchForContentAsync(portal, pqp);

            //Iterate through the returned items for THE item.
            var myPortalItem = results.Results?.OfType <PortalItem>().FirstOrDefault();

            if (myPortalItem == null)
            {
                return(null);
            }
            return(new Tuple <bool, PortalItem>(true, myPortalItem));
        }