Skip to content

Commit

Permalink
Adjust positioning of the clean XML method in the OneStop sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeWalker committed Apr 30, 2021
1 parent cbb3744 commit 9bf4ddd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
11 changes: 8 additions & 3 deletions cllc-interfaces/OneStopRestClient/OneStopRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ public OneStopRestClient(Uri baseUri, string authorizationHeaderValue, ILogger l
this._logger = logger;
}

public async Task<string> ReceiveFromPartner(string inputXml)
public string CleanXML(string inputXml)
{
var url = $"{BaseUri}?inputXML={Uri.EscapeDataString(inputXml)}";

// clean any namespaces.
inputXml = Regex.Replace(inputXml, @" xmlns:.*?"".*?""", "");
// adjust the header.
inputXml = inputXml.Replace("encoding=\"utf-16\"?>", "?>");
return inputXml;
}

public async Task<string> ReceiveFromPartner(string inputXml)
{
var url = $"{BaseUri}?inputXML={Uri.EscapeDataString(inputXml)}";

Log.Logger.Information($"InputXML to send = {inputXml}");

Expand All @@ -53,6 +57,7 @@ public interface IOneStopRestClient
{
Uri BaseUri { get; set; }
string AuthorizationHeaderValue { get; set; }
string CleanXML(string inputXml);
Task<string> ReceiveFromPartner(string inputXml);
}
}
48 changes: 28 additions & 20 deletions one-stop-service/OneStopUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,23 @@ public async Task SendChangeAddressRest(PerformContext hangfireContext, string l
}
else
{
var innerXML = req.CreateXML(licence);
var innerXml = req.CreateXML(licence);
innerXml = _onestopRestClient.CleanXML(innerXml);

if (Log.Logger != null)
{
Log.Logger.Information(innerXML);
Log.Logger.Information(innerXml);
}

if (hangfireContext != null)
{
hangfireContext.WriteLine(innerXML);
hangfireContext.WriteLine(innerXml);
}

//send message to Onestop hub
var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXML);
UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXML, outputXML);

var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXml);
UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXml, outputXML);

if (hangfireContext != null)
{
Expand Down Expand Up @@ -222,24 +224,25 @@ public async Task SendChangeNameRest(PerformContext hangfireContext, string lice
targetBusinessNumber = targetOwner.Accountnumber;
}
}
var innerXML = req.CreateXML(licence, isTransfer, targetBusinessNumber);
var innerXml = req.CreateXML(licence, isTransfer, targetBusinessNumber);


innerXml = _onestopRestClient.CleanXML(innerXml);

if (Log.Logger != null)
{
Log.Logger.Information(innerXML);
Log.Logger.Information(innerXml);
}

if (hangfireContext != null)
{
hangfireContext.WriteLine(innerXML);
hangfireContext.WriteLine(innerXml);
}

//send message to Onestop hub
var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXML);
var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXml);

UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXML, outputXML);
UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXml, outputXML);

if (hangfireContext != null)
{
Expand Down Expand Up @@ -287,22 +290,23 @@ public async Task SendChangeStatusRest(PerformContext hangfireContext, string li
{


var innerXML = req.CreateXML(licence, statusChange);
var innerXml = req.CreateXML(licence, statusChange);
innerXml = _onestopRestClient.CleanXML(innerXml);

if (Log.Logger != null)
{
Log.Logger.Information(innerXML);
Log.Logger.Information(innerXml);
}

if (hangfireContext != null)
{
hangfireContext.WriteLine(innerXML);
hangfireContext.WriteLine(innerXml);
}

//send message to Onestop hub
var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXML);
var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXml);

UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXML, outputXML);
UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXml, outputXML);

if (hangfireContext != null)
{
Expand Down Expand Up @@ -352,13 +356,15 @@ public async Task SendProgramAccountRequestREST(PerformContext hangfireContext,
{

var innerXml = req.CreateXML(licence, suffix);

innerXml = _onestopRestClient.CleanXML(innerXml);

Log.Logger?.Information(innerXml);
// send message to Onestop hub
var outputXml = await _onestopRestClient.ReceiveFromPartner(innerXml);

UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXml, outputXml);


if (hangfireContext != null)
{
hangfireContext.WriteLine(outputXml);
Expand Down Expand Up @@ -417,20 +423,22 @@ public async Task SendProgramAccountDetailsBroadcastMessageRest(PerformContext h
}
else
{
var innerXML = req.CreateXML(licence);
var innerXml = req.CreateXML(licence);

innerXml = _onestopRestClient.CleanXML(innerXml);

if (Log.Logger != null)
{
Log.Logger.Information(innerXML);
Log.Logger.Information(innerXml);
}

if (hangfireContext != null)
{
hangfireContext.WriteLine(innerXML);
hangfireContext.WriteLine(innerXml);
}

//send message to Onestop hub
var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXML);
var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXml);

if (hangfireContext != null)
{
Expand Down

0 comments on commit 9bf4ddd

Please sign in to comment.