示例#1
0
        public async Task <Drive> GetGroupDrive(Group group, CancellationToken token)
        {
            IDriveRequestBuilder rb = client.Groups[group.Id].Drive;

            try
            {
                return(await rb.Request().GetAsync(token));
            }
            catch (Exception ex)
            {
                HandleException(ex, null, messageOnlyExceptions, $"Get drive for group: {group.DisplayName}");
            }

            return(default(Drive));
        }
示例#2
0
        public async Task <Drive> GetUserDrive(User user, CancellationToken token)
        {
            IDriveRequestBuilder rb = client.Users[user.Id].Drive;

            try
            {
                return(await rb.Request().GetAsync(token));
            }
            catch (Exception ex)
            {
                HandleException(ex, null, messageOnlyExceptions, $"Get drive for user: {user.DisplayName}");
            }

            return(default(Drive));
        }
示例#3
0
        /// <summary>
        /// 取得空間資訊,並初始化 Drive 物件
        /// </summary>
        private async Task <(CloudStorageResult result, long usedSpace, long totalSpace)> GetRootInfoAsync()
        {
            CloudStorageResult result = new CloudStorageResult();
            long usedSpace = 0, totalSpace = 0;

            try
            {
                myDriveBuilder = graphServiceClient.Me.Drive;
                Drive myDrive = await myDriveBuilder.Request().GetAsync();

                usedSpace     = myDrive.Quota.Used ?? 0;
                totalSpace    = myDrive.Quota.Total ?? 0;
                result.Status = Status.Success;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            return(result, usedSpace, totalSpace);
        }