コード例 #1
0
 public Task <SpaceTask> GetTaskAsync(ApiSession apiSession, Guid taskId, CancellationToken cancellationToken)
 {
     return(Wrapped(async(token) =>
     {
         var apiResult = await _lowLevelApiClient.GetTaskAsync(apiSession, taskId, token);
         return MapOrFail(apiResult, (dto) => SpaceTaskMapper.MapFull(dto));
     }, cancellationToken, OperationType.ShortOperation));
 }
コード例 #2
0
        public async Task <SpaceTask> GetTaskAsync(ApiSession apiSession, Guid taskId, CancellationToken cancellationToken)
        {
            var nvc = new NameValueCollection();

            nvc.Add("_", DateTime.Now.Ticks.ToString());
            var url = UrlHelper.JoinUrl("space", apiSession.SpaceName, "tasks", taskId.ToString("D"));

            using (var response = await GetHttpClient().SendAsync(BuildHttpRequestMessage(HttpMethod.Get, url, null, apiSession), cancellationToken))
            {
                var dto = await HandleResponse <SpaceTaskDto>(response);

                return(SpaceTaskMapper.MapFull(dto));
            }
        }
コード例 #3
0
        /// <summary>
        /// Change task mode
        /// </summary>
        /// <param name="apiSession">api session</param>
        /// <param name="taskId">task guid</param>
        /// <param name="taskChangeModeRequest"></param>
        /// <param name="cancellationToken">cancellation token</param>
        /// <returns>Returns task status</returns>
        public Task <SpaceTask> TaskChangeModeAsync(ApiSession apiSession, Guid taskId, TaskChangeModeRequest taskChangeModeRequest, CancellationToken cancellationToken)
        {
            if (apiSession == null)
            {
                throw new ArgumentNullException(nameof(apiSession));
            }

            if (taskChangeModeRequest is null)
            {
                throw new ArgumentNullException(nameof(taskChangeModeRequest));
            }

            return(Wrapped(async(token) =>
            {
                var request = new SpaceTaskChangeModeRequestDto
                {
                    TaskEnabled = taskChangeModeRequest.TaskEnabled
                };
                var apiResult = await _lowLevelApiClient.TaskChangeModeAsync(apiSession, taskId, request, token);
                return MapOrFail(apiResult, (dto) => SpaceTaskMapper.MapFull(dto));
            }, cancellationToken, OperationType.ShortOperation));
        }