/// <summary> /// Hangfire job to send Change Status message to One stop. /// </summary> public async Task SendChangeNameRest(PerformContext hangfireContext, string licenceGuidRaw, string queueItemId) { IDynamicsClient dynamicsClient = DynamicsSetupUtil.SetupDynamics(_configuration); if (hangfireContext != null) { hangfireContext.WriteLine("Starting OneStop REST ChangeName Job."); } string licenceGuid = Utils.ParseGuid(licenceGuidRaw); //prepare soap content var req = new ChangeName(); var licence = dynamicsClient.GetLicenceByIdWithChildren(licenceGuid); if (hangfireContext != null && licence != null) { hangfireContext.WriteLine($"Got Licence {licenceGuid}."); } if (licence == null) { if (hangfireContext != null) { hangfireContext.WriteLine($"Unable to get licence {licenceGuid}."); } if (Log.Logger != null) { Log.Logger.Error($"Unable to get licence {licenceGuid}."); } } else { var innerXML = req.CreateXML(licence); if (Log.Logger != null) { Log.Logger.Information(innerXML); } if (hangfireContext != null) { hangfireContext.WriteLine(innerXML); } //send message to Onestop hub var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXML); UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXML, outputXML); if (hangfireContext != null) { hangfireContext.WriteLine(outputXML); hangfireContext.WriteLine("End of OneStop REST ChangeName Job."); } } }
/// <summary> /// Hangfire job to send Change Status message to One stop. /// </summary> public async Task SendChangeNameRest(PerformContext hangfireContext, string licenceGuidRaw, string queueItemId, bool isTransfer) { IDynamicsClient dynamicsClient = DynamicsSetupUtil.SetupDynamics(_configuration); if (hangfireContext != null) { hangfireContext.WriteLine("Starting OneStop REST ChangeName Job."); } string licenceGuid = Utils.ParseGuid(licenceGuidRaw); //prepare soap content var req = new ChangeName(); var licence = dynamicsClient.GetLicenceByIdWithChildren(licenceGuid); if (hangfireContext != null && licence != null) { hangfireContext.WriteLine($"Got Licence {licenceGuid}."); } if (licence == null || licence.AdoxioEstablishment == null) { if (hangfireContext != null) { hangfireContext.WriteLine($"Unable to get licence {licenceGuid}."); } if (Log.Logger != null) { Log.Logger.Error($"Unable to get licence {licenceGuid}."); } } else { string targetBusinessNumber = null; ChangeNameType changeNameType = ChangeNameType.ChangeName; if (isTransfer && !string.IsNullOrEmpty(licence._adoxioProposedownerValue)) { changeNameType = ChangeNameType.Transfer; var targetOwner = dynamicsClient.GetAccountById(licence._adoxioProposedownerValue); if (targetOwner != null) { targetBusinessNumber = targetOwner.Accountnumber; } } else { if (!string.IsNullOrEmpty(licence._adoxioThirdpartyoperatoridValue)) { changeNameType = ChangeNameType.ThirdPartyOperator; } } var innerXml = req.CreateXML(licence, changeNameType, targetBusinessNumber); innerXml = _onestopRestClient.CleanXML(innerXml); if (Log.Logger != null) { Log.Logger.Information(innerXml); } if (hangfireContext != null) { hangfireContext.WriteLine(innerXml); } //send message to Onestop hub var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXml); UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXml, outputXML); if (hangfireContext != null) { hangfireContext.WriteLine(outputXML); hangfireContext.WriteLine("End of OneStop REST ChangeName Job."); } } }