コード例 #1
0
        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);
        }
コード例 #2
0
        public async Task <bool> UploadTitleNews()
        {
            if (string.IsNullOrEmpty(titleNewsPath))
            {
                LogToFile("TitleNews File Path is Null ");
                return(true);
            }


            LogToFile("Uploading TitleNews...");
            var parsedFile = ParseFile(titleNewsPath);

            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
                };
                if (token.IsCancellationRequested)
                {
                    return(true);
                }

                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.", ConsoleColor.Green);
                }
            }

            return(true);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: zeya-anwar/UnicornBattle
        private static bool UploadTitleNews()
        {
            if (string.IsNullOrEmpty(titleNewsPath))
            {
                return(false);
            }

            LogToFile("Uploading TitleNews...");
            var parsedFile = ParseFile(titleNewsPath);

            var titleNewsItems = JsonWrapper.DeserializeObject <List <PlayFab.ServerModels.TitleNewsItem> >(parsedFile);

            foreach (var item in titleNewsItems)
            {
                LogToFile(string.Format("\tUploading: {0}", item.Title));

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

                var addNewsTask = PlayFabAdminAPI.AddNewsAsync(request);
                addNewsTask.Wait();

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

            return(true);
        }