/// <summary> /// The method to post a SwapShift request in a offered state. /// </summary> /// <param name="jSession">Kronos session.</param> /// <param name="personNumber">The Kronos personNumber.</param> /// <param name="reqId">The reqId of swap shift request.</param> /// <param name="querySpan">The querySpan.</param> /// <param name="comment">The comment for request.</param> /// <param name="endpointUrl">Endpoint Kronos URL.</param> /// <returns>request to send to Kronos.</returns> public async Task <SubmitResponse.Response> SubmitSwapShiftAsync( string jSession, string personNumber, string reqId, string querySpan, string comment, Uri endpointUrl) { var telemetryProps = new Dictionary <string, string>() { { "KronosRequestId", reqId }, { "KronosPersonNumber", personNumber }, { "QueryDateSpan", querySpan }, }; this.telemetryClient.TrackTrace($"SwapShiftActivity - SubmitSwapShiftAsync starts: {DateTime.UtcNow.ToString("O", CultureInfo.InvariantCulture)}", telemetryProps); try { string xmlRequest = this.CreateSwapShiftSubmitRequest( personNumber, reqId, querySpan, comment); var tupleResponse = await this.apiHelper.SendSoapPostRequestAsync( endpointUrl, ApiConstants.SoapEnvOpen, xmlRequest, ApiConstants.SoapEnvClose, jSession).ConfigureAwait(false); SubmitResponse.Response response = this.ProcessSwapShiftDraftResponse(tupleResponse.Item1); this.telemetryClient.TrackTrace($"SwapShiftActivity - SubmitSwapShiftAsync ends: {DateTime.UtcNow.ToString("O", CultureInfo.InvariantCulture)}", telemetryProps); return(response); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) #pragma warning restore CA1031 // Do not catch general exception types { this.telemetryClient.TrackException(ex, telemetryProps); return(null); } }
/// <summary> /// The method to create the Swap Shift Request in Draft state. /// </summary> /// <param name="jSession">The jSession.</param> /// <param name="obj">The input SwapShiftObj.</param> /// <param name="apiEndpoint">The Kronos API Endpoint.</param> /// <returns>A unit of execution that contains the response object.</returns> public async Task <SubmitResponse.Response> DraftSwapShiftAsync( string jSession, SwapShiftObj obj, string apiEndpoint) { this.telemetryClient.TrackTrace($"SwapShiftActivity - DraftSwapShiftAsync starts at: {DateTime.UtcNow.ToString("O", CultureInfo.InvariantCulture)}"); if (obj is null) { throw new ArgumentNullException(nameof(obj)); } try { string xmlRequest = this.CreateSwapShiftDraftRequest(obj); var tupleResponse = await this.apiHelper.SendSoapPostRequestAsync( new Uri(apiEndpoint), ApiConstants.SoapEnvOpen, xmlRequest, ApiConstants.SoapEnvClose, jSession).ConfigureAwait(false); SubmitResponse.Response response = this.ProcessSwapShiftDraftResponse(tupleResponse.Item1); this.telemetryClient.TrackTrace($"SwapShiftActivity - DraftSwapShiftAsync ends at: {DateTime.UtcNow.ToString("O", CultureInfo.InvariantCulture)}"); return(response); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) #pragma warning restore CA1031 // Do not catch general exception types { this.telemetryClient.TrackException(ex); return(null); } }