Exemple #1
0
        public async Task <(CloudStorageResult, CloudStorageAccountInfo)> LoginAsync()
        {
            CloudStorageResult      result      = new CloudStorageResult();
            CloudStorageAccountInfo accountInfo = new CloudStorageAccountInfo();

            try
            {
                if (await oauthClient.GetTokenAsync())
                {
                    SaveAccessTokenDelegate?.Invoke(oauthClient.AccessToken);
                    SaveRefreshTokenDelegate?.Invoke(oauthClient.RefreshToken);
                    InitDriveService();
                    (result, accountInfo.userName, accountInfo.userEmail) = await GetUserInfoAsync();

                    if (result.Status == Status.Success)
                    {
                        (result, accountInfo.usedSpace, accountInfo.totalSpace) = await GetRootInfoAsync();
                    }
                }
                else
                {
                    result.Message = oauthClient.LastError;
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            return(result, accountInfo);
        }
Exemple #2
0
        public async Task <(CloudStorageResult result, CloudStorageAccountInfo info)> GetAccountInfoAsync()
        {
            CloudStorageResult      result;
            CloudStorageAccountInfo info = new CloudStorageAccountInfo();

            (result, info.userName, info.userEmail) = await GetUserInfoAsync();

            if (result.Status == Status.Success)
            {
                (result, info.usedSpace, info.totalSpace) = await GetRootInfoAsync();
            }
            return(result, info);
        }
Exemple #3
0
        public async Task <(CloudStorageResult result, CloudStorageAccountInfo info)> GetAccountInfoAsync()
        {
            CloudStorageResult      result = new CloudStorageResult();
            CloudStorageAccountInfo info   = new CloudStorageAccountInfo();

            //if (string.IsNullOrEmpty(LastRefreshToken))
            //    return (result, info);

            (result, info.userName, info.userEmail) = await GetUserInfoAsync();

            if (result.Status == Status.Success)
            {
                (result, info.usedSpace, info.totalSpace) = await GetRootInfoAsync();
            }
            return(result, info);
        }