/// <summary>
        /// Sends request for controller configs
        /// </summary>
        void sendRequest(bool is_new = true)
        {
            var service = steamClient.GetHandler <SteamUnifiedMessages>().CreateService <IPublishedFile>();

            var query = new CPublishedFile_QueryFiles_Request
            {
                return_vote_data     = true,
                return_children      = true,
                return_for_sale_data = true,
                return_kv_tags       = true,
                return_metadata      = true,
                return_tags          = true,
                return_previews      = true,
                appid      = is_new ? 241100 : appidCurrent,
                page       = pageCurrent,
                numperpage = itemsPerPage,
                query_type = 11,
                filetype   = (uint)EWorkshopFileType.GameManagedItem,
            };

            if (is_new)
            {
                query.required_kv_tags.Add(new CPublishedFile_QueryFiles_Request.KVTag()
                {
                    key = "app", value = appidCurrent.ToString()
                });

                // We don't want to see 'private' items
                query.required_kv_tags.Add(new CPublishedFile_QueryFiles_Request.KVTag()
                {
                    key = "visibility", value = "public"
                });
            }

            service.SendMessage(x => x.QueryFiles(query));

            Invoke(new MethodInvoker(delegate
            {
                if (totalPages > 0)
                {
                    currentStatus.Text = string.Format("Requesting page {0} of {1}", pageCurrent, totalPages);
                }
                else
                {
                    currentStatus.Text = string.Format("Requesting page {0}", pageCurrent, totalPages);
                }
            }));
        }
Beispiel #2
0
        public async Task <IList <PublishedFileDetails> > GetPublishedFilesForAppIdRawAsync(AppId appId, CancellationToken?cancellationToken = null)
        {
            cancellationToken = cancellationToken ?? CancellationToken.None;

            string paginationCursor           = "*";
            List <PublishedFileDetails> items = new List <PublishedFileDetails>();

            while (!cancellationToken.Value.IsCancellationRequested)
            {
                var requestDetails = new CPublishedFile_QueryFiles_Request
                {
                    query_type    = (uint)EPublishedFileQueryType.RankedByPublicationDate,
                    cursor        = paginationCursor,
                    creator_appid = appId,
                    appid         = appId,
                    numperpage    = 100,

                    return_vote_data         = true,
                    return_children          = true,
                    return_for_sale_data     = true,
                    return_kv_tags           = true,
                    return_metadata          = true,
                    return_tags              = true,
                    return_previews          = true,
                    return_details           = true,
                    return_short_description = true,
                };

                var methodResponse = await PublishedFileService.SendMessage(api => api.QueryFiles(requestDetails));

                var returnedItems = methodResponse.GetDeserializedResponse <CPublishedFile_QueryFiles_Response>();

                items.AddRange(returnedItems.publishedfiledetails);
                paginationCursor = returnedItems.next_cursor;

                if (returnedItems.publishedfiledetails.Count == 0)
                {
                    break;
                }
            }

            return(items);
        }
        /// <summary>
        /// Sends request for controller configs
        /// </summary>
        async Task <bool> sendRequest(bool is_new = true)
        {
            requestOnGoing = true;

            try
            {
                uint pageCurrent = 1;
                uint totalPages  = 0;

                var service = steamClient.GetHandler <SteamUnifiedMessages>().CreateService <IPublishedFile>();

                do
                {
                    if (totalPages > 0)
                    {
                        setStatus("Requesting page {0} of {1}", pageCurrent, totalPages);
                    }
                    else
                    {
                        setStatus("Requesting page {0}", pageCurrent, totalPages);
                    }

                    var query = new CPublishedFile_QueryFiles_Request
                    {
                        return_vote_data     = true,
                        return_children      = true,
                        return_for_sale_data = true,
                        return_kv_tags       = true,
                        return_metadata      = true,
                        return_tags          = true,
                        return_previews      = true,
                        appid      = is_new ? 241100 : appidCurrent,
                        page       = pageCurrent,
                        numperpage = itemsPerPage,
                        query_type = 11,
                        filetype   = (uint)EWorkshopFileType.GameManagedItem,
                    };

                    if (is_new)
                    {
                        if (appidCurrent > 0)
                        {
                            query.required_kv_tags.Add(new CPublishedFile_QueryFiles_Request.KVTag()
                            {
                                key = "app", value = appidCurrent.ToString()
                            });
                        }

                        query.required_kv_tags.Add(new CPublishedFile_QueryFiles_Request.KVTag()
                        {
                            key = "visibility", value = "public"
                        });
                    }

                    var callback = await service.SendMessage(x => x.QueryFiles(query));

                    var response = callback.GetDeserializedResponse <CPublishedFile_QueryFiles_Response>();

                    totalPages = (uint)Math.Ceiling(response.total / (double)itemsPerPage);
                    pageCurrent++;

                    foreach (var item in response.publishedfiledetails)
                    {
                        var info = new ConfigItem
                        {
                            App       = item.app_name,
                            Name      = item.title,
                            FileName  = item.filename.Split('/').Last(),
                            URL       = item.file_url,
                            RatesUp   = item.vote_data != null ? item.vote_data.votes_up : 0,
                            RatesDown = item.vote_data != null ? item.vote_data.votes_down : 0,
                            Details   = item
                        };

                        foreach (var tag in item.kvtags)
                        {
                            if (tag.key == "app" || tag.key == "appid")
                            {
                                uint app = 0;

                                if (!uint.TryParse(tag.value, out app))
                                {
                                    info.App = $"(NON-STEAM) {tag.value}";
                                }
                                else
                                {
                                    var game = Games.Where(x => x.AppID == app).FirstOrDefault();

                                    if (game != null)
                                    {
                                        info.App = game.Name;
                                    }
                                    // We don't know actual name
                                    else
                                    {
                                        info.App = $"AppID {app}";
                                    }
                                }
                            }
                            else if (tag.key == "visibility" || tag.key == "deleted" || tag.key == "owner" || tag.key == "autosave")
                            {
                                continue;
                            }
                            else
                            {
                            }
                        }

                        Invoke(new MethodInvoker(delegate
                        {
                            items.Add(info);
                        }));
                    }
                }while (pageCurrent <= totalPages);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                setStatus("Complete!");

                requestOnGoing = false;
            }

            return(true);
        }