Ejemplo n.º 1
0
 private bool PersistPublish(IEnumerable <DeviceConfigMsg> deviceDetails, IEnumerable <object> kafkaObjects)
 {
     try
     {
         var deviceDetailsCount = deviceDetails.Count();
         if (deviceDetailsCount > 0 && deviceDetailsCount == kafkaObjects.Count())
         {
             if (_kafkaPublisher.PublishMessage(kafkaObjects, _deviceTypeFamilyContainer[deviceDetails.First().DeviceType].FamilyName))
             {
                 return(true);
             }
             throw new MessageConstructorException("Failed to publish message to Kafka");
         }
     }
     catch (Exception ex)
     {
         _loggingService.Error("Error in MessageConstructor.PersistPublish ", "MessageConstructor.PersistPublish", ex);
         throw ex;
     }
     return(false);
 }
Ejemplo n.º 2
0
        public bool ProcessBypassMessage(DeviceConfigRequestBase requestBase, ParamGroup group)
        {
            _loggingService.Debug("Device Request Message : " + JsonConvert.SerializeObject(requestBase), "");
            var failedAssets = String.Empty;

            try
            {
                if (requestBase == null || !_groupContainer.ContainsKey(requestBase.ParameterGroupName))
                {
                    _loggingService.Info("Device Message Group Name / Device Type is invalid !!", "");
                    return(false);
                }
                var groupBuilder = _groupContainer[requestBase.ParameterGroupName];
                foreach (var assetuid in requestBase.AssetUIDs)
                {
                    _loggingService.Info("Started processing group messages - AcknowledgementBypasser.ProcessBypassMessage", "");
                    var groupMessages = groupBuilder.ProcessGroupMessages(assetuid, requestBase, group);
                    var assetId       = new Guid(assetuid);
                    _loggingService.Info("Started publishing messages - AcknowledgementBypasser.ProcessBypassMessage", "");
                    if (!_kafkaPublisher.PublishMessage(assetId.ToString(), groupMessages, ""))
                    {
                        failedAssets += (failedAssets == String.Empty ? "" : ",") + assetuid;
                    }
                }
                if (failedAssets == String.Empty)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                _loggingService.Error("Exception : " + JsonConvert.SerializeObject(ex), "", ex);
                throw new Exception("Unable to Complete Device Configuration for assetuid " + failedAssets);
            }
            return(false);
        }