Exemple #1
0
        async public static Task <bool> UpdateStoreData(string titleId, string storeId, string catalogVersion, StoreMarketingModel marketingModel, List <PlayFab.AdminModels.StoreItem> store)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;
            //Console.WriteLine("Updating Store: " + storeId + " on title" + titleId);
            var result = await PlayFabAdminAPI.SetStoreItemsAsync(new PlayFab.AdminModels.UpdateStoreItemsRequest()
            {
                CatalogVersion = catalogVersion,
                StoreId        = storeId,
                MarketingData  = marketingModel,
                Store          = store
            });

            PlayFabSettings.TitleId            = currentPlayFabTitleId;
            PlayFabSettings.DeveloperSecretKey = currentDevKey;
            if (result.Error != null)
            {
                Console.WriteLine("Update Store Error: " + PlayFabUtil.GetErrorReport(result.Error));
                return(false);
            }
            return(true);
        }
Exemple #2
0
        // NOTE: If there is an existing catalog with the version number in question, it will be deleted and replaced with only the items specified in this call.
        async public static Task <bool> UpdateCatalogData(string titleId, string catalogVersion, bool isDefault, List <PlayFab.AdminModels.CatalogItem> catalog)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;
            var result = await PlayFabAdminAPI.SetCatalogItemsAsync(new PlayFab.AdminModels.UpdateCatalogItemsRequest()
            {
                Catalog             = catalog,
                CatalogVersion      = catalogVersion,
                SetAsDefaultCatalog = isDefault
            });

            PlayFabSettings.TitleId            = currentPlayFabTitleId;
            PlayFabSettings.DeveloperSecretKey = currentDevKey;
            if (result.Error != null)
            {
                Console.WriteLine(PlayFabUtil.GetErrorReport(result.Error));
                return(false);
            }
            return(true);
        }
Exemple #3
0
        async public static Task <GetStoreItemsResult> GetStoreData(string titleId, string storeId)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

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

            var result = await PlayFabAdminAPI.GetStoreItemsAsync(new PlayFab.AdminModels.GetStoreItemsRequest()
            {
                StoreId = storeId
            });

            PlayFabSettings.TitleId            = currentPlayFabTitleId;
            PlayFabSettings.DeveloperSecretKey = currentDevKey;
            if (result.Error != null)
            {
                Console.WriteLine("Get Store Error: " + PlayFabUtil.GetErrorReport(result.Error));
                return(null);
            }
            //var version = result.Result.CatalogVersion;
            //var marketingModel = result.Result.MarketingData;
            //var currentStoreId = result.Result.StoreId;

            return(result.Result);
        }
Exemple #4
0
        public static void GetStoreData(string titleId, string storeId, Action <bool, string, string, StoreMarketingModel, List <PlayFab.AdminModels.StoreItem> > callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

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

            var task = PlayFabAdminAPI.GetStoreItemsAsync(new PlayFab.AdminModels.GetStoreItemsRequest()
            {
                StoreId = storeId
            })
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                if (result.Result.Error != null)
                {
                    Console.WriteLine("Get Store Error: " + PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false, null, null, null, null);
                    return;
                }
                if (result.IsCompleted)
                {
                    var version        = result.Result.Result.CatalogVersion;
                    var marketingModel = result.Result.Result.MarketingData;
                    var currentStoreId = result.Result.Result.StoreId;
                    callback(true, version, currentStoreId, marketingModel, result.Result.Result.Store);
                }
            });
        }
Exemple #5
0
        public static void UpdateStoreData(string titleId, string storeId, string catalogVersion, StoreMarketingModel marketingModel, List <PlayFab.AdminModels.StoreItem> store, Action <bool> callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;
            Console.WriteLine("Updating Store: " + storeId + " on title" + titleId);
            var task = PlayFabAdminAPI.SetStoreItemsAsync(new PlayFab.AdminModels.UpdateStoreItemsRequest()
            {
                CatalogVersion = catalogVersion,
                StoreId        = storeId,
                MarketingData  = marketingModel,
                Store          = store
            })
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                if (result.Result.Error != null)
                {
                    Console.WriteLine("Update Store Error: " + PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false);
                    return;
                }
                if (result.IsCompleted)
                {
                    callback(true);
                }
            });
        }
Exemple #6
0
        public static void GetDropTableData(string titleId, Action <bool, Dictionary <string, PlayFab.AdminModels.RandomResultTableListing> > callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

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

            var task = PlayFabAdminAPI.GetRandomResultTablesAsync(new PlayFab.AdminModels.GetRandomResultTablesRequest())
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                Task <PlayFabResult <PlayFab.AdminModels.GetRandomResultTablesResult> > taskC = result as Task <PlayFabResult <PlayFab.AdminModels.GetRandomResultTablesResult> >;
                if (taskC.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(taskC.Result.Error));
                    callback(false, null);
                    return;
                }
                if (result.IsCompleted)
                {
                    callback(true, taskC.Result.Result.Tables);
                }
            });
        }
Exemple #7
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);
                }
            });
        }
Exemple #8
0
        public static void UpdateCatalogData(string titleId, string catalogVersion, bool isDefault, List <PlayFab.AdminModels.CatalogItem> catalog, 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.SetCatalogItemsAsync(new PlayFab.AdminModels.UpdateCatalogItemsRequest()
            {
                Catalog             = catalog,
                CatalogVersion      = catalogVersion,
                SetAsDefaultCatalog = isDefault
            })
                       .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);
                }
            });
        }
Exemple #9
0
        public static void GetContentList(string titleId, Action <bool, List <ContentInfo> > callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

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

            var task = PlayFabAdminAPI.GetContentListAsync(new GetContentListRequest())
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                if (result.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false, null);
                    return;
                }
                if (result.IsCompleted)
                {
                    callback(true, result.Result.Result.Contents);
                }
            });
        }
Exemple #10
0
        public static void UpdateCloudScript(string titleId, List <CloudScriptFile> cloudScriptData, 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.UpdateCloudScriptAsync(new UpdateCloudScriptRequest()
            {
                Files   = cloudScriptData,
                Publish = true
            })
                       .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);
                }
            });
        }
        private async Task <bool> TitleData(string parsedFile, CancellationToken token)
        {
            var titleDataDict = JsonWrapper.DeserializeObject <Dictionary <string, string> >(parsedFile);

            foreach (var kvp in titleDataDict)
            {
                if (IsCancellationRequest(token))
                {
                    return(false);
                }
                LogToFile("\tUploading: " + kvp.Key);

                var request = new SetTitleDataRequest()
                {
                    Key   = kvp.Key,
                    Value = kvp.Value
                };

                var setTitleDataTask = await PlayFabAdminAPI.SetTitleDataAsync(request);

                if (setTitleDataTask.Error != null)
                {
                    OutputPlayFabError("\t\tTitleData Upload: " + kvp.Key, setTitleDataTask.Error);
                }
                else
                {
                    LogToFile("\t\t" + kvp.Key + " Uploaded.");
                }
            }
            return(true);
        }
        private async Task <bool> Stores(string parsedFile, CancellationToken token)
        {
            var storesList = JsonWrapper.DeserializeObject <List <StoreWrapper> >(parsedFile);

            foreach (var eachStore in storesList)
            {
                if (IsCancellationRequest(token))
                {
                    return(false);
                }
                LogToFile("\tUploading: " + eachStore.StoreId);

                var request = new UpdateStoreItemsRequest
                {
                    CatalogVersion = defaultCatalog,
                    StoreId        = eachStore.StoreId,
                    Store          = eachStore.Store,
                    MarketingData  = eachStore.MarketingData
                };

                var updateStoresTask = await PlayFabAdminAPI.SetStoreItemsAsync(request);

                if (updateStoresTask.Error != null)
                {
                    OutputPlayFabError("\t\tStore Upload: " + eachStore.StoreId, updateStoresTask.Error);
                }
                else
                {
                    LogToFile("\t\tStore: " + eachStore.StoreId + " Uploaded. ");
                }
            }
            return(true);
        }
Exemple #13
0
    /// <summary>
    /// Requests a remote endpoint for uploads from the PlaFab service.
    /// </summary>
    void GetContentUploadURL(AssetBundleHelperObject asset)
    {
        var request = new GetContentUploadUrlRequest();

        if (asset.BundlePlatform == AssetBundleHelperObject.BundleTypes.Android)
        {
            request.Key = "Android/" + asset.ContentKey;        // folder location & file name to use on the remote server
        }
        else if (asset.BundlePlatform == AssetBundleHelperObject.BundleTypes.iOS)
        {
            request.Key = "iOS/" + asset.ContentKey;
        }
        else // stand-alone
        {
            request.Key = asset.ContentKey;
        }
        request.ContentType = asset.MimeType;       // mime type to match the file

#if UNITY_WEBPLAYER
        //UnityEngine.Deubg.Log("Webplayer does not support uploading files.");
#else
        PlayFabAdminAPI.GetContentUploadUrl(request, result =>
        {
            asset.PutUrl = result.URL;

            byte[] fileContents = File.ReadAllBytes(asset.LocalPutPath);
            PutFile(asset, fileContents);
        }, OnPlayFabError);
#endif
    }
Exemple #14
0
 public void ConfirmModifyUserTitleName()
 {
     if (usernameNewValue.text.ToCharArray().Length < 4)
     {
         Inform("Username too short!");
         return;
     }
     else
     {
         PlayFabAdminAPI.UpdateUserTitleDisplayName(new UpdateUserTitleDisplayNameRequest {
             PlayFabId   = lastPlayerIdentifier.playerID,
             DisplayName = usernameNewValue.text
         },
                                                    result => {
             Debug.Log("UPDATE DISPLAY NAME OK: " + result.ToJson().ToString());
             Inform(string.Format("Successfully renamed {0} to {1}",
                                  lastPlayerIdentifier.displayName,
                                  usernameNewValue.text));
         },
                                                    error => {
             Debug.LogError("UPDATE NAME FAILURE: " + error.ToString());
             Inform("Unable to update name! " + error.ErrorMessage);
         });
     }
 }
Exemple #15
0
    public void GetUserInventory()
    {
        ShowLoader();
        PlayerID playerIdentifier = lastPlayerIdentifier;

        PlayFabAdminAPI.GetUserInventory(new GetUserInventoryRequest {
            PlayFabId = playerIdentifier.playerID
        },
                                         result => {
            HideLoader();
            Debug.Log("GOT INVENTORY OK: " + result.ToJson());
            string items  = "";
            int itemCount = 0;
            foreach (var item in result.Inventory)
            {
                itemCount++;
                items += string.Format("\n{0}. {1}", itemCount, item.DisplayName);
            }
            Inform(string.Format("\"{0}'s\" inventory:\n{1}", lastPlayerIdentifier.displayName, items));
        },
                                         error => {
            HideLoader();
            Debug.LogError("GET INVENTORY FAILED: " + error.ToString());
            Inform("Unable to get inventory for \"" + playerIdentifier.displayName + "\"!\n\n" + error.ErrorMessage);
        });
    }
Exemple #16
0
        public static void UpdateCurrencyData(string titleId, List <VirtualCurrencyData> currencyData, 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.AddVirtualCurrencyTypesAsync(new AddVirtualCurrencyTypesRequest()
            {
                VirtualCurrencies = currencyData
            })
                       .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);
                }
            });
        }
Exemple #17
0
        public async Task SetStoreItems(List <FutbolPlayer> players)
        {
            var items = new List <StoreItem> {
            };

            foreach (var player in players)
            {
                items.Add(new StoreItem
                {
                    ItemId = player.ID,
                    VirtualCurrencyPrices = new Dictionary <string, uint>()
                    {
                        { configuration.Currency, player.Price }
                    },
                    CustomData = JsonConvert.SerializeObject(player)
                });
            }

            var reqUpdateStoreItems = new UpdateStoreItemsRequest
            {
                CatalogVersion = configuration.CatalogName,
                Store          = items,
                StoreId        = configuration.StoreName
            };

            var result = await PlayFabAdminAPI.SetStoreItemsAsync(reqUpdateStoreItems);

            if (result.Error != null)
            {
                Console.WriteLine(result.Error.ErrorMessage);
            }
        }
    public void FetchApiPolicy()
    {
        var getPolicyRequest = new PlayFab.AdminModels.GetPolicyRequest()
        {
            PolicyName = "ApiPolicy"
        };

        PlayFabAdminAPI.GetPolicy(getPolicyRequest,
                                  delegate(GetPolicyResponse getPolicyResponse)
        {
            Debug.Log(getPolicyResponse.PolicyName);

            foreach (var statement in getPolicyResponse.Statements)
            {
                Debug.Log("Action: " + statement.Action);
                Debug.Log("Comment: " + statement.Comment);

                if (statement.ApiConditions != null)
                {
                    Debug.Log("ApiConditions.HasSignatureOrEncryption: " + statement.ApiConditions.HasSignatureOrEncryption);
                }
                Debug.Log("Effect: " + statement.Effect);
                Debug.Log("Principal: " + statement.Principal);
                Debug.Log("Resource: " + statement.Resource);
            }
        },
                                  SharedError.OnSharedError);
    }
        public static bool UploadFileToCDN(string relativeFileName, byte[] content)
        {
            GetContentUploadUrlRequest request = new GetContentUploadUrlRequest();

            request.ContentType = "binary/octet-stream";
            request.Key         = relativeFileName;


            var result = PlayFabAdminAPI.GetContentUploadUrlAsync(request).GetAwaiter().GetResult();

            if (result.Error == null)
            {
                bool uploadResult = UploadFile(result.Result.URL, content);
                //HttpClient client = new HttpClient();
                //ByteArrayContent data = new ByteArrayContent(content);
                //var response = client.PutAsync(result.Result.URL, data).GetAwaiter().GetResult();

                if (uploadResult)
                {
                    return(true);
                }
                else
                {
                    Console.WriteLine("HTTP PUT ERROR" + " " + result.Result.URL);
                }
            }
            else
            {
                Console.WriteLine(result.Error.ErrorMessage);
            }
            return(false);
        }
        protected override void getDropTables(CatalogModel catalogModel, Action <DropTableCollection> onSuccessHandler, Action onFailureHandler)
        {
            GetRandomResultTablesRequest request = new GetRandomResultTablesRequest()
            {
                CatalogVersion = catalogModel.ID
            };

            PlayFabAdminAPI.GetRandomResultTablesAsync(request).ContinueWith(t => {
                if (t.Result.Error != null)
                {
                    Log.Error("PlayFabDropTableService drop tables error: " + t.Result.Error.ErrorMessage);
                    onFailureHandler();
                }
                else
                {
                    DropTableCollection dropTableCollection = new DropTableCollection();
                    foreach (var kvp in t.Result.Result.Tables)
                    {
                        int id = int.Parse(kvp.Value.TableId);
                        DropTableModel dropTableModel = new DropTableModel(id);
                        dropTableCollection.Add(id, dropTableModel);
                        for (int i = 0; i < kvp.Value.Nodes.Count; i++)
                        {
                            int itemID          = int.Parse(kvp.Value.Nodes[i].ResultItem);
                            float weight        = kvp.Value.Nodes[i].Weight;
                            ItemModel itemModel = catalogModel.GetItemByID(itemID);
                            dropTableModel.AddItem(itemModel, weight);
                        }
                    }
                    onSuccessHandler(dropTableCollection);
                }
            });
        }
Exemple #21
0
        private async Task <bool> UploadAsset(string key, string path)
        {
            var request = new GetContentUploadUrlRequest()
            {
                Key         = key,
                ContentType = "application/x-gzip"
            };

            LogToFile("\tFetching CDN endpoint for " + key);
            if (token.IsCancellationRequested)
            {
                return(true);
            }

            var getContentUploadTask = await PlayFabAdminAPI.GetContentUploadUrlAsync(request);

            //getContentUploadTask.Wait();

            if (getContentUploadTask.Error != null)
            {
                OutputPlayFabError("\t\tAcquire CDN URL Error: ", getContentUploadTask.Error);
                return(false);
            }

            var destUrl = getContentUploadTask.Result.URL;

            LogToFile("\t\tAcquired CDN Address: " + key, ConsoleColor.Green);

            byte[] fileContents = File.ReadAllBytes(path);

            return(await PutFile(key, destUrl, fileContents));
        }
Exemple #22
0
        public async Task <bool> UploadVc()
        {
            LogToFile("Uploading Virtual Currency Settings...");
            if (string.IsNullOrEmpty(currencyPath))
            {
                LogToFile("irtual Currency Settings File Path is Null ");
                return(true);
            }
            var parsedFile = ParseFile(currencyPath);
            var vcData     = JsonWrapper.DeserializeObject <List <VirtualCurrencyData> >(parsedFile);
            var request    = new AddVirtualCurrencyTypesRequest
            {
                VirtualCurrencies = vcData
            };

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

            var updateVcTask = await PlayFabAdminAPI.AddVirtualCurrencyTypesAsync(request);

            //updateVcTask.Wait();

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

            LogToFile("\tUploaded VC!", ConsoleColor.Green);
            return(true);
        }
Exemple #23
0
        private async Task <bool> UpdateCatalog(List <CatalogItem> catalog)
        {
            var request = new UpdateCatalogItemsRequest
            {
                CatalogVersion = defaultCatalog,
                Catalog        = catalog
            };

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

            var updateCatalogItemsTask = await PlayFabAdminAPI.UpdateCatalogItemsAsync(request);

            //updateCatalogItemsTask.Wait();

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

            LogToFile("\tUploaded Catalog!", ConsoleColor.Green);
            return(true);
        }
        private async Task <bool> TitleNews(string parsedFile, CancellationToken token)
        {
            var titleNewsItems = JsonWrapper.DeserializeObject <List <PlayFab.ServerModels.TitleNewsItem> >(parsedFile);

            foreach (var item in titleNewsItems)
            {
                LogToFile("\tUploading: " + item.Title);

                var request = new AddNewsRequest()
                {
                    Title = item.Title,
                    Body  = item.Body
                };

                var addNewsTask = await PlayFabAdminAPI.AddNewsAsync(request);

                if (addNewsTask.Error != null)
                {
                    OutputPlayFabError("\t\tTitleNews Upload: " + item.Title, addNewsTask.Error);
                }
                else
                {
                    LogToFile("\t\t" + item.Title + " Uploaded.");
                }
            }

            return(true);
        }
Exemple #25
0
        public async Task RevokeInventoryItems(string playFabId, List <ItemInstance> inventory)
        {
            var items = new List <RevokeInventoryItem> {
            };

            foreach (var item in inventory)
            {
                items.Add(new RevokeInventoryItem
                {
                    PlayFabId      = playFabId,
                    ItemInstanceId = item.ItemInstanceId
                });
            }

            var reqGetInventory = new RevokeInventoryItemsRequest
            {
                Items = items
            };

            var result = await PlayFabAdminAPI.RevokeInventoryItemsAsync(reqGetInventory);

            if (result.Error != null)
            {
                Console.WriteLine(result.Error.ErrorMessage);
            }
        }
Exemple #26
0
    public void ConfirmBanUser()
    {
        var request = new BanRequest();

        try {
            if (!string.IsNullOrEmpty(banTimeInHours.text))
            {
                request.DurationInHours = uint.Parse(banTimeInHours.text);
            }
        } catch (System.Exception e) {
            request.DurationInHours = 0;
        }
        request.Reason    = banReason.text;
        request.PlayFabId = lastPlayerIdentifier.playerID;
        var banList = new List <BanRequest>();

        banList.Add(request);
        PlayFabAdminAPI.BanUsers(new BanUsersRequest {
            Bans = banList
        },
                                 result => {
            banModal.SetActive(false);
            Debug.Log("BAN USER OK: " + result.ToJson().ToString());
            Inform(string.Format("{0} was successfully banned for {1} hours for \"{2}\"",
                                 lastPlayerIdentifier.displayName, banTimeInHours.text, banReason.text));
        },
                                 error => {
            Debug.LogError("BAN PLAYER FAILED: " + error.ToString());
            Inform("Unable to ban user! " + error.ErrorMessage);
            banModal.SetActive(false);
        });
    }
        private async Task <bool> StatisticDefination(string parsedFile, CancellationToken token)
        {
            var statisticDefinitions = JsonWrapper.DeserializeObject <List <PlayerStatisticDefinition> >(parsedFile);

            foreach (var item in statisticDefinitions)
            {
                if (IsCancellationRequest(token))
                {
                    return(false);
                }
                LogToFile("\tUploading: " + item.StatisticName);

                var request = new CreatePlayerStatisticDefinitionRequest()
                {
                    StatisticName         = item.StatisticName,
                    VersionChangeInterval = item.VersionChangeInterval,
                    AggregationMethod     = item.AggregationMethod
                };

                var createStatTask = await PlayFabAdminAPI.CreatePlayerStatisticDefinitionAsync(request);

                if (createStatTask.Error != null)
                {
                    if (createStatTask.Error.Error == PlayFabErrorCode.StatisticNameConflict)
                    {
                        LogToFile("\tStatistic Already Exists, Updating values: " + item.StatisticName);
                        var updateRequest = new UpdatePlayerStatisticDefinitionRequest()
                        {
                            StatisticName         = item.StatisticName,
                            VersionChangeInterval = item.VersionChangeInterval,
                            AggregationMethod     = item.AggregationMethod
                        };
                        if (IsCancellationRequest(token))
                        {
                            return(false);
                        }
                        var updateStatTask = await PlayFabAdminAPI.UpdatePlayerStatisticDefinitionAsync(updateRequest);

                        if (updateStatTask.Error != null)
                        {
                            OutputPlayFabError("\t\tStatistics Definition Error: " + item.StatisticName, updateStatTask.Error);
                        }
                        else
                        {
                            LogToFile("\t\tStatistics Definition:" + item.StatisticName + " Updated");
                        }
                    }
                    else
                    {
                        OutputPlayFabError("\t\tStatistics Definition Error: " + item.StatisticName, createStatTask.Error);
                    }
                }
                else
                {
                    LogToFile("\t\tStatistics Definition: " + item.StatisticName + " Created");
                }
            }
            return(true);
        }
Exemple #28
0
        public void RevokeItem(string itemInstanceId)
        {
            var revokeRequest = new AdminModels.RevokeInventoryItemRequest();

            revokeRequest.PlayFabId      = playFabId;
            revokeRequest.CharacterId    = characterId;
            revokeRequest.ItemInstanceId = itemInstanceId;
            PlayFabAdminAPI.RevokeInventoryItem(revokeRequest, RevokeItemCallback, PfSharedControllerEx.FailCallback("RevokeInventoryItem"));
        }
Exemple #29
0
    public void SelectSegment(SegmentID id)
    {
        ShowLoader();
        PlayFabAdminAPI.GetPlayersInSegment(new GetPlayersInSegmentRequest {
            SegmentId = id.segmentID
        },
                                            result => {
            Debug.Log("GOT SEGMENT PLAYERS OK: " + result.ToJson().ToString());
            foreach (var playerProfile in result.PlayerProfiles)
            {
                GameObject newPlayerButton = Instantiate(playerButton,
                                                         Vector3.zero, Quaternion.identity,
                                                         playerButton.transform.parent) as GameObject;

                PlayerID identity  = newPlayerButton.GetComponent <PlayerID>();
                identity.avatarURL = playerProfile.AvatarUrl;
                if (playerProfile.BannedUntil.HasValue)
                {
                    identity.bannedUntil = playerProfile.BannedUntil.Value.ToLocalTime().ToString();
                }
                else
                {
                    identity.bannedUntil = "N/A";
                }
                identity.creationDate = playerProfile.Created.Value.ToLocalTime().ToString();
                identity.lastLogin    = playerProfile.LastLogin.Value.ToLocalTime().ToString();
                identity.displayName  = playerProfile.DisplayName;
                foreach (var location in playerProfile.Locations)
                {
                    identity.location = location.Value.City + ", " +
                                        location.Value.CountryCode;
                    identity.latLong = location.Value.Latitude + "," +
                                       location.Value.Longitude;
                }
                string currencies = "";
                foreach (var currency in playerProfile.VirtualCurrencyBalances)
                {
                    currencies += "\n" + currency.Key + ": " + currency.Value;
                }
                identity.currencies     = currencies;
                identity.originPlatform = playerProfile.Origination.Value.ToString();
                identity.playerID       = playerProfile.PlayerId;
                identity.nameText.text  = playerProfile.DisplayName;
                newPlayerButton.SetActive(true);
            }
            DestroySegmentWindow();
            playerWindow.SetActive(true);
            HideLoader();
        },
                                            error => {
            HideLoader();
            Debug.LogError("ERROR GETTING SEGMENT PLAYERS: " + error.GenerateErrorReport());
            Inform(error.ErrorMessage);
        });
    }
Exemple #30
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);
        }