예제 #1
0
        public async Task <Result <UploadObject> > ContinueUploadProgressAsync(string username, int id, string ipAddress, int failureCount)
        {
            var result = new UploadObject(Constants.NoValueDatetime, Constants.NoValueString, Constants.NoValueInt, Constants.NoValueString,
                                          Constants.NoValueInt, Constants.NoValueString, Constants.NoValueDouble, Constants.NoValueString,
                                          Constants.NoValueString, Constants.NoValueInt, Constants.NoValueInt, Constants.NoValueBool,
                                          Constants.NoValueString);

            // Escape condition for recursive call if exception is thrown.
            if (failureCount >= Constants.OperationRetry)
            {
                return(SystemUtilityService.CreateResult(Constants.UploadRetrievalFailedMessage, result, true));
            }

            try
            {
                result = await _uploadService.ContinueUploadProgressAsync(id).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                // Log exception.
                await _loggingManager.LogAsync(DateTime.UtcNow.ToString(Constants.LoggingFormatString),
                                               Constants.ContinueDraftOperation, username, ipAddress, ex.ToString()).ConfigureAwait(false);

                // Recursively retry the operation until the maximum amount of retries is reached.
                await ContinueUploadProgressAsync(username, id, ipAddress, ++failureCount).ConfigureAwait(false);
            }


            // Log the fact that the operation was successful.
            await _loggingManager.LogAsync(DateTime.UtcNow.ToString(Constants.LoggingFormatString),
                                           Constants.ContinueDraftOperation, username, ipAddress).ConfigureAwait(false);

            return(SystemUtilityService.CreateResult(Constants.UploadRetrievalSuccessMessage, result, false));
        }