Exemplo n.º 1
0
        public static void Login(string user, string pass, Action <bool, string> callback)
        {
            var loginTask = PlayFabExtensions.Login(new LoginRequest()
            {
                Email    = user,
                Password = pass,
                DeveloperToolProductName    = "PlayFabPowerTools CLI",
                DeveloperToolProductVersion = "1.01"
            }).ContinueWith((result) =>
            {
                if (result.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false, null);
                    return;
                }

                if (result.IsCompleted)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("Login Successful");
                    DeveloperClientToken = result.Result.Result.DeveloperClientToken;
                    callback(true, DeveloperClientToken);
                }
            });
        }
Exemplo n.º 2
0
        public static void DownloadFile(string titleId, string path, ContentInfo content, Action <bool, string, ContentInfo> callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

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

            PlayFabServerAPI.GetContentDownloadUrlAsync(new GetContentDownloadUrlRequest()
            {
                Key        = content.Key,
                HttpMethod = "GET"
            }).ContinueWith((result) =>
            {
                if (result.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false, null, null);
                    return;
                }

                if (result.IsCompleted)
                {
                    var folderPathArray = content.Key.Split('/');
                    var fileName        = folderPathArray.ToList().Last();

                    var filePath = string.Format("{0}\\{1}", path, fileName);
                    PlayFabExtensions.DownloadFile(result.Result.Result.URL, filePath, (success) =>
                    {
                        PlayFabSettings.TitleId            = currentPlayFabTitleId;
                        PlayFabSettings.DeveloperSecretKey = currentDevKey;
                        if (success)
                        {
                            callback(true, filePath, content);
                            return;
                        }
                        callback(false, null, null);
                    });
                }
            });
        }
Exemplo n.º 3
0
        public static void GetStudios(string token, Action <bool> callback)
        {
            var getStudioTask = PlayFabExtensions.GetStudios(new GetStudiosRequest()
            {
                DeveloperClientToken = token
            }).
                                ContinueWith((result) =>
            {
                if (result.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false);
                    return;
                }

                if (result.IsCompleted)
                {
                    PlayFabService.Studios = result.Result.Result.Studios.ToList();
                    callback(true);
                }
            });
        }
Exemplo n.º 4
0
        async public static Task <DownloadedFile> DownloadFile(string titleId, string path, ContentInfo content)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

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

            var result = await PlayFabServerAPI.GetContentDownloadUrlAsync(new GetContentDownloadUrlRequest()
            {
                Key        = content.Key,
                HttpMethod = "GET"
            });

            if (result.Error != null)
            {
                Console.WriteLine(PlayFabUtil.GetErrorReport(result.Error));
                return(null);
            }

            var folderPathArray = content.Key.Split('/');
            var fileName        = folderPathArray.ToList().Last();

            var filePath = string.Format("{0}\\{1}", path, fileName);
            var success  = await PlayFabExtensions.DownloadFile(result.Result.URL, filePath);

            PlayFabSettings.TitleId            = currentPlayFabTitleId;
            PlayFabSettings.DeveloperSecretKey = currentDevKey;
            if (!success)
            {
                return(null);
            }
            return(new DownloadedFile()
            {
                Data = content, FilePath = filePath
            });
        }
Exemplo n.º 5
0
        async public static Task <bool> UploadFile(string titleId, DownloadedFile fileInfo)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

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

            var key    = fileInfo.FilePath.Split('/').ToList()[fileInfo.FilePath.Split('/').ToList().Count - 1];
            var type   = MimeMapping.GetMimeMapping(key);
            var result = await PlayFabAdminAPI.GetContentUploadUrlAsync(
                new GetContentUploadUrlRequest()
            {
                Key         = fileInfo.Data.Key,
                ContentType = type
            }
                );

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

            bool success = await PlayFabExtensions.UploadFile(result.Result.URL, fileInfo.FilePath);

            if (!success)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 6
0
        public static void UploadFile(string titleId, CdnFileDataMigration.UploadFile fileInfo, Action <bool> callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

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

            var key  = fileInfo.FilePath.Split('/').ToList()[fileInfo.FilePath.Split('/').ToList().Count - 1];
            var type = MimeMapping.GetMimeMapping(key);

            PlayFabAdminAPI.GetContentUploadUrlAsync(new GetContentUploadUrlRequest()
            {
                Key         = fileInfo.Data.Key,
                ContentType = type
            }).ContinueWith((result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                PlayFabExtensions.UploadFile(result.Result.Result.URL, fileInfo.FilePath, callback);
            });
        }