Example #1
0
        private async Task<IssueResult> RegisterEx(bool doThrow, IssueRequest request)
        {
            if (string.IsNullOrEmpty(request.SessionKey))
                throw new ArgumentException("No SessionKey has been assigned.");

            var result = new IssueResult();
            IssueResponse response = null;

            try
            {
                OnIssueRegistrationStartedEvent(new IssueRegistrationStartedEventArgs(request));

                response = await _sessionHandler.Client.WebApiClient.CreateAsync<IssueRequest, IssueResponse>("Client/Issue", request);
            }
            catch (Exception exception)
            {
                result.SetException(exception);
                _issuesThatFailedToRegister.Enqueue(new Tuple<IssueRequest, Exception>(request, exception));

                if (doThrow)
                    throw;
            }
            finally
            {
                result.SetCompleted(response);
                OnIssueRegistrationCompletedEvent(new IssueRegistrationCompletedEventArgs(request, result));
            }

            return result;
        }
 internal IssueRegistrationCompletedEventArgs(IssueRequest request, IssueResult result)
 {
     Request = request;
     Result = result;
 }