public RosettianClientMessageInspector()
 {
     _errorLoggingService = new ErrorLoggingService();
     var enterpriseExceptions = new EnterpriseExceptionHandler(_errorLoggingService);
     var resourceInformationInquiry = new ResourceInformationInquiryClient();
     _syncPlant = new ConsolidatedSyncResource(resourceInformationInquiry, _errorLoggingService, enterpriseExceptions);
 }
        /// <summary>
        /// Sync Plant Data.
        /// </summary>
        /// <param name="locationId">The locationId.</param>
        /// <param name="headerArgs"></param>
        /// <returns></returns>
        public bool SyncPlantData(string locationId, HeaderArgs headerArgs)
        {
            try
            {
                var response = new syncResourceResponse();

                if (string.IsNullOrWhiteSpace(locationId))
                {
                    throw new EnterpriseServiceException("LocationId cannot be null or empty or whitespace");
                }

                var esbRequest = CreateSyncPlantRequest(locationId, headerArgs);

                using (var client = new ResourceInformationInquiryClient())
                {
                     response = client.syncResource(esbRequest.syncResource);
                }

                if (response == null
                       || response.syncResourceOutput == null
                           || response.syncResourceOutput.Payload == null
                                 || response.syncResourceOutput.Payload.BusinessInteraction == null)
                {
                    throw new EnterpriseServiceException("No response received from ESB");
                }

                bool status;
                var responseStatus =
                    response.syncResourceOutput.Payload.BusinessInteraction.interactionStatus;

                if (bool.TryParse(responseStatus, out status))
                {
                    return status;
                }

                throw new EnterpriseServiceException("Invalid status received from ESB");
            }
            catch (System.Exception e)
            {
                if (_errorLoggingService != null)
                {
                    _errorLoggingService.LogErrorNoContext(e);
                }

                var isServiceException = _enterpriseExceptionHandler.HandleGeneralServiceExceptions(e);

                if (isServiceException)
                {
                    var myException = new System.Exception(Constants.IsServiceExceptionUpperCase, e);
                    throw myException;
                }

                throw;
            }
        }