예제 #1
0
        public static void UpdateDropTableData(string titleId, List <RandomResultTable> dropTables, Action <bool> callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;

            var task = PlayFabAdminAPI.UpdateRandomResultTablesAsync(new PlayFab.AdminModels.UpdateRandomResultTablesRequest()
            {
                Tables = dropTables
            }
                                                                     )
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                if (result.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false);
                    return;
                }
                if (result.IsCompleted)
                {
                    callback(true);
                }
            });
        }
예제 #2
0
        public async Task <bool> UploadDropTables()
        {
            if (string.IsNullOrEmpty(dropTablesPath))
            {
                LogToFile("DropTables File Path is Null ");
                return(true);
            }

            LogToFile("Uploading DropTables...");
            var parsedFile = ParseFile(dropTablesPath);

            var dtDict = JsonWrapper.DeserializeObject <Dictionary <string, RandomResultTableListing> >(parsedFile);

            if (dtDict == null)
            {
                LogToFile("\tAn error occurred deserializing the DropTables.json file.", ConsoleColor.Red);
                return(false);
            }

            var dropTables = new List <RandomResultTable>();

            foreach (var kvp in dtDict)
            {
                dropTables.Add(new RandomResultTable()
                {
                    TableId = kvp.Value.TableId,
                    Nodes   = kvp.Value.Nodes
                });
            }

            var request = new UpdateRandomResultTablesRequest()
            {
                CatalogVersion = defaultCatalog,
                Tables         = dropTables
            };

            if (token.IsCancellationRequested)
            {
                return(true);
            }

            var updateResultTableTask = await PlayFabAdminAPI.UpdateRandomResultTablesAsync(request);

            //updateResultTableTask.Wait();

            if (updateResultTableTask.Error != null)
            {
                OutputPlayFabError("\tDropTable Upload Error: ", updateResultTableTask.Error);
                return(false);
            }

            LogToFile("\tUploaded DropTables!", ConsoleColor.Green);
            return(true);
        }
예제 #3
0
        private async Task <bool> DropTables(string parsedFile, CancellationToken token)
        {
            var dtDict = JsonWrapper.DeserializeObject <Dictionary <string, RandomResultTableListing> >(parsedFile);

            if (dtDict == null)
            {
                LogToFile("\tAn error occurred deserializing the DropTables.json file.");
                return(false);
            }

            var dropTables = new List <RandomResultTable>();

            foreach (var kvp in dtDict)
            {
                if (IsCancellationRequest(token))
                {
                    return(false);
                }
                dropTables.Add(new RandomResultTable()
                {
                    TableId = kvp.Value.TableId,
                    Nodes   = kvp.Value.Nodes
                });
            }

            var request = new UpdateRandomResultTablesRequest()
            {
                CatalogVersion = defaultCatalog,
                Tables         = dropTables
            };

            var updateResultTableTask = await PlayFabAdminAPI.UpdateRandomResultTablesAsync(request);

            if (updateResultTableTask.Error != null)
            {
                OutputPlayFabError("\tDropTable Upload Error: ", updateResultTableTask.Error);
                return(false);
            }

            LogToFile("\tUploaded DropTables!");
            return(true);
        }
예제 #4
0
        async public static Task <bool> UpdateDropTableData(string titleId, List <RandomResultTable> dropTables)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;

            var result = await PlayFabAdminAPI.UpdateRandomResultTablesAsync(new PlayFab.AdminModels.UpdateRandomResultTablesRequest()
            {
                Tables = dropTables
            });

            PlayFabSettings.TitleId            = currentPlayFabTitleId;
            PlayFabSettings.DeveloperSecretKey = currentDevKey;
            if (result.Error != null)
            {
                Console.WriteLine(PlayFabUtil.GetErrorReport(result.Error));
                return(false);
            }
            return(true);
        }