/// <summary> /// Request status method to be called by Tenant. /// </summary> /// <param name="emailInterchangeId">emailInterchangeId that is passed by Tenant.</param> /// <returns>Return the User Friendly Message along with the eventid to Tenant.</returns> public AzureTBNService.InterchangeRequestStatus GetRequestStatus(System.Guid emailInterchangeId, AzureTBNService.RequestTypeForEnhancedAPI requestType) { AzureTBNService.InterchangeRequestStatus interchangeRequestStatus = new AzureTBNService.InterchangeRequestStatus(); if (string.IsNullOrEmpty(emailInterchangeId.ToString()) || emailInterchangeId == Guid.Empty) { interchangeRequestStatus.RequestStatusMessage = InvalidRequestId; } string requestTypesToBeTracked = ConfigurationManager.AppSettings[Request_Types_ToBe_Tracked].ToUpper(); try { if (requestTypesToBeTracked.Trim() != string.Empty) { string[] requestTypes = requestTypesToBeTracked.Split(','); if (requestTypes.Contains(requestType.ToString().ToUpper())) { interchangeRequestStatus = CallGetRequestStatus(emailInterchangeId, PrimaryEndpoint, requestType); } else { interchangeRequestStatus.RequestStatusMessage = String.Format(CultureInfo.InvariantCulture, Request_Type_Processing_Message, requestType.ToString().ToUpper()); } } else { interchangeRequestStatus.RequestStatusMessage = Invalid_Request_Type; } } catch (Exception) { interchangeRequestStatus = CallGetRequestStatus(emailInterchangeId, SecondaryEndpoint, requestType); } return(interchangeRequestStatus); }
/// <summary> /// Method for Calling the Azure(Primary/Secondary) Endpoint. /// </summary> /// <param name="requestId">RequestId that is passed by Tenant.</param> /// <param name="endpointName">Azure endpoint to be used((Primary/Secondary).</param> /// <returns>Returns the user friendly message along with the Event ID to the Calling method.</returns> internal AzureTBNService.InterchangeRequestStatus CallGetRequestStatus(System.Guid emailInterchangeId, string endpointName, AzureTBNService.RequestTypeForEnhancedAPI requestType) { int exceptionCount = 0; AzureTBNService.InterchangeRequestStatus interchangeRequestStatus = new AzureTBNService.InterchangeRequestStatus(); AzureTBNService.TriggerRequestNotificationClient client = null; for (int retryCount = 0; retryCount < retryAttempts; retryCount++) { try { using (client = new AzureTBNService.TriggerRequestNotificationClient(endpointName)) { interchangeRequestStatus = client.GetRequestStatus(emailInterchangeId, requestType); } if (string.IsNullOrEmpty(interchangeRequestStatus.RequestStatusMessage)) { interchangeRequestStatus.RequestStatusMessage = EmptyRequestStatusMessage; } break; } catch (Exception ex) { if (client == null) { throw; } exceptionCount++; // Throw exception if maxm retry attempts are exhausted if (exceptionCount == retryAttempts) { throw new Exception(GenericExceptionMessagePredicate + ex.Message.ToString()); } } } return(interchangeRequestStatus); }