Esempio n. 1
0
        /// <summary>
        /// Called when a search for users completes.
        /// </summary>
        void SearchCompleted(OpenReadEventArgs e, EventHandler <UserSearchEventArgs> callback)
        {
            if (e.Error != null)
            {
                if (callback != null)
                {
                    callback(this, new UserSearchEventArgs()
                    {
                        Error = e.Error
                    });
                }
                return;
            }

            UserSearchResult result = WebUtil.ReadObject <UserSearchResult>(e.Result);

            if (callback != null && result != null)
            {
                callback(null, new UserSearchEventArgs()
                {
                    Result = result
                });
            }
            else if (callback != null)
            {
                callback(null, new UserSearchEventArgs()
                {
                    Error = new Exception(ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.Resources.Strings.UserSearchFailed)
                });
            }
        }
        /// <summary>
        /// Called when a search for content completes.
        /// Initializes the thumbnails and invokes the callback.
        /// </summary>
        void SearchCompleted(OpenReadEventArgs e, string sort, EventHandler <ContentSearchEventArgs> callback)
        {
            if (e.Error != null)
            {
                if (callback != null)
                {
                    callback(this, new ContentSearchEventArgs()
                    {
                        Error = e.Error
                    });
                }
                return;
            }

            ContentSearchResult result = WebUtil.ReadObject <ContentSearchResult>(e.Result);

            result.Sort = sort;

            // setup the thumbnails for each result
            //
            if (result != null && result.Items != null)
            {
                foreach (ContentItem item in result.Items)
                {
                    if (item.ThumbnailPath != null)
                    {
                        string thumbnailUrl = _agol.Url + "content/items/" + item.Id + "/info/" + item.ThumbnailPath + "?tickCount=" + Environment.TickCount.ToString();
                        if (_agol.User.Current != null)
                        {
                            thumbnailUrl += "&token=" + _agol.User.Token;
                        }

                        item.Thumbnail = new BitmapImage(new Uri(thumbnailUrl));
                    }
                }
            }

            if (callback != null)
            {
                callback(null, new ContentSearchEventArgs()
                {
                    Result = result
                });
            }
        }
        /// <summary>
        /// Called when a search for groups completes.
        /// Initializes the thumbnails of the groups and invokes the callback.
        /// </summary>
        void SearchCompleted(OpenReadEventArgs e, EventHandler <GroupSearchEventArgs> callback)
        {
            if (e.Error != null)
            {
                if (callback != null)
                {
                    callback(null, new GroupSearchEventArgs()
                    {
                        Error = e.Error
                    });
                }
                return;
            }

            GroupSearchResult result = WebUtil.ReadObject <GroupSearchResult>(e.Result);

            if (result.Items != null)
            {
                // setup the thumbnails for each result
                //
                foreach (Group group in result.Items)
                {
                    if (group.ThumbnailPath != null)
                    {
                        string thumbnailUrl = _agol.Url + "community/groups/" + group.Id + "/info/" + group.ThumbnailPath;
                        if (_agol.User.Current != null)
                        {
                            thumbnailUrl += "?token=" + _agol.User.Token;
                        }

                        group.Thumbnail = new BitmapImage(new Uri(thumbnailUrl));
                    }
                }
            }

            if (callback != null)
            {
                callback(null, new GroupSearchEventArgs()
                {
                    Result = result
                });
            }
        }