예제 #1
0
        public static void IngestMessagge(object message)
        {
            byte[] eventDataByte  = null;
            var    bubblingObject = (IBubblingObject)message;

            // ****************************CHECK MESSAGE TYPE*************************
            try
            {
                // Who sent the message
                var senderId          = bubblingObject.SenderPointId;
                var senderDescription = bubblingObject.SenderDescriprion;

                // Who receive the message
                LogEngine.TraceInformation(
                    $"Event received step1 from Sender {senderId} Sender description {senderDescription}");

                var receiverChannelId =
                    bubblingObject.DestinationChannelId;
                var receiverPointId =
                    bubblingObject.DestinationPointId;

                ChannelId = "asd";
                PointId   = "asd";
                var requestAvailable = (receiverChannelId.Contains(ChannelId) &&
                                        receiverPointId.Contains(PointId)) ||
                                       (receiverChannelId.Contains("*") &&
                                        receiverPointId.Contains(PointId)) ||
                                       (receiverChannelId.Contains(ChannelId) &&
                                        receiverPointId.Contains("*")) ||
                                       (receiverChannelId.Contains("*") &&
                                        receiverPointId.Contains("*"));
                if (!requestAvailable)
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                // If error then not message typeof (no property present.)
                LogEngine.TraceError(
                    $"Error in {MethodBase.GetCurrentMethod().Name} - Not GrabCaster message type received (Missing GrabCaster_MessageType_Name properties.) -DISCARED- Error {ex.Message}");
                return;
            }

            // ****************************CHECK MESSAGE TYPE*************************
            // Check if >256, the restore or not
            LogEngine.TraceInformation($"Event received step2 Check if > 256, the restore or not.");
            if (bubblingObject.Persisting)
            {
                LogEngine.TraceInformation($"Event received step3 it is > 256");
                BlobDevicePersistentProvider storagePersistent = new BlobDevicePersistentProvider();
            }
            else
            {
                LogEngine.TraceInformation($"Event received step4 it is < 256");
                eventDataByte = bubblingObject.Data;
            }

            LogEngine.TraceInformation($"Event received step5 before serialization.");
            setEventActionEventEmbedded(eventDataByte);
        }
예제 #2
0
        public static void IngestMessagge(object message)
        {
            string senderId;
            string senderDescription;

            byte[] eventDataByte   = null;
            var    skeletonMessage = (ISkeletonMessage)message;

            // ****************************CHECK MESSAGE TYPE*************************
            try
            {
                // Check message subscription, it must come from engine
                if (skeletonMessage.Properties[Configuration.GrabCasterMessageTypeName].ToString()
                    != Configuration.GrabCasterMessageTypeValue)
                {
                    LogEngine.TraceInformation("Not GrabCaster message type received -DISCARED-");
                    return;
                }
                else
                {
                    // Who sent the message
                    senderId          = skeletonMessage.Properties[Configuration.MessageDataProperty.SenderId.ToString()].ToString();
                    senderDescription =
                        skeletonMessage.Properties[Configuration.MessageDataProperty.SenderDescriprion.ToString()].ToString();

                    // Who receive the message
                    LogEngine.TraceInformation($"Event received step1 from Sender {senderId} Sender description {senderDescription}");

                    var receiverChannelId =
                        skeletonMessage.Properties[Configuration.MessageDataProperty.ReceiverChannelId.ToString()].ToString();
                    var receiverPointId =
                        skeletonMessage.Properties[Configuration.MessageDataProperty.ReceiverPointId.ToString()].ToString();

                    ChannelId = "asd";
                    PointId   = "asd";
                    var requestAvailable = (receiverChannelId.Contains(ChannelId) &&
                                            receiverPointId.Contains(PointId)) ||
                                           (receiverChannelId.Contains("*") &&
                                            receiverPointId.Contains(PointId)) ||
                                           (receiverChannelId.Contains(ChannelId) &&
                                            receiverPointId.Contains("*")) ||
                                           (receiverChannelId.Contains("*") &&
                                            receiverPointId.Contains("*"));
                    if (!requestAvailable)
                    {
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                // If error then not message typeof (no property present.)
                LogEngine.TraceError($"Error in {MethodBase.GetCurrentMethod().Name} - Not GrabCaster message type received (Missing GrabCaster_MessageType_Name properties.) -DISCARED- Error {ex.Message}");
                return;
            }

            // ****************************CHECK MESSAGE TYPE*************************
            // Check if >256, the restore or not
            LogEngine.TraceInformation($"Event received step2 Check if > 256, the restore or not.");
            if ((bool)skeletonMessage.Properties[Configuration.MessageDataProperty.Persisting.ToString()])
            {
                LogEngine.TraceInformation($"Event received step3 it is > 256");
                string messageId = skeletonMessage.Properties[Configuration.MessageDataProperty.MessageId.ToString()].ToString();
                BlobDevicePersistentProvider storagePersistent = new BlobDevicePersistentProvider();

                //var ret = storagePersistent.PersistEventFromStorage(
                //    messageId,
                //    GroupEventHubsStorageAccountName,
                //    GroupEventHubsStorageAccountKey,
                //    GroupEventHubsName);


                //eventDataByte = (byte[])ret;
            }
            else
            {
                LogEngine.TraceInformation($"Event received step4 it is < 256");
                eventDataByte = skeletonMessage.Body;
            }

            LogEngine.TraceInformation($"Event received step5 before serialization.");
            setEventActionEventEmbedded(eventDataByte);
        }