Пример #1
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);
            }
        }
Пример #2
0
        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);
        }
Пример #3
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);
        }
Пример #4
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);
                }
            });
        }
Пример #5
0
        public async Task <bool> UploadStores()
        {
            if (string.IsNullOrEmpty(storesPath))
            {
                LogToFile("Stores File Path is Null ");
                return(true);
            }

            LogToFile("Uploading Stores...");
            var parsedFile = ParseFile(storesPath);

            var storesList = JsonWrapper.DeserializeObject <List <StoreWrapper> >(parsedFile);

            foreach (var eachStore in storesList)
            {
                LogToFile("\tUploading: " + eachStore.StoreId);

                var request = new UpdateStoreItemsRequest
                {
                    CatalogVersion = defaultCatalog,
                    StoreId        = eachStore.StoreId,
                    Store          = eachStore.Store,
                    MarketingData  = eachStore.MarketingData
                };
                if (token.IsCancellationRequested)
                {
                    return(true);
                }

                var updateStoresTask = await PlayFabAdminAPI.SetStoreItemsAsync(request);

                //updateStoresTask.Wait();

                if (updateStoresTask.Error != null)
                {
                    OutputPlayFabError("\t\tStore Upload: " + eachStore.StoreId, updateStoresTask.Error);
                }
                else
                {
                    LogToFile("\t\tStore: " + eachStore.StoreId + " Uploaded. ", ConsoleColor.Green);
                }
            }

            return(true);
        }
Пример #6
0
        private static bool UploadStores(string filePath, string catalogName)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return(false);
            }

            LogToFile("Uploading Stores...");
            var parsedFile = ParseFile(filePath);

            var storesList = JsonWrapper.DeserializeObject <List <StoreWrapper> >(parsedFile);

            foreach (var eachStore in storesList)
            {
                LogToFile("\tUploading: " + eachStore.StoreId);

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

                var updateStoresTask = PlayFabAdminAPI.SetStoreItemsAsync(request);
                updateStoresTask.Wait();

                if (updateStoresTask.Result.Error != null)
                {
                    OutputPlayFabError("\t\tStore Upload: " + eachStore.StoreId, updateStoresTask.Result.Error);
                }
                else
                {
                    LogToFile("\t\tStore: " + eachStore.StoreId + " Uploaded. ", ConsoleColor.Green);
                }
            }
            return(true);
        }
Пример #7
0
        private static bool UploadStores()
        {
            if (string.IsNullOrEmpty(storesPath))
            {
                return(false);
            }

            LogToFile("Uploading Stores...");
            var parsedFile = ParseFile(storesPath);

            var storesDict = JsonWrapper.DeserializeObject <Dictionary <string, List <StoreItem> > >(parsedFile);

            foreach (var kvp in storesDict)
            {
                LogToFile(string.Format("\tUploading: {0}", kvp.Key));

                var request = new UpdateStoreItemsRequest()
                {
                    CatalogVersion = defaultCatalog,
                    StoreId        = kvp.Key,
                    Store          = kvp.Value
                };

                var updateStoresTask = PlayFabAdminAPI.SetStoreItemsAsync(request);
                updateStoresTask.Wait();

                if (updateStoresTask.Result.Error != null)
                {
                    OutputPlayFabError("\t\tStore Upload: " + kvp.Key, updateStoresTask.Result.Error);
                }
                else
                {
                    LogToFile(string.Format("\t\tStore: {0} Uploaded.", kvp.Key), ConsoleColor.Green);
                }
            }
            return(true);
        }