private string HubDefToListenerName(EventHubDefinition HubDef)
 {
     return string.Concat(HubDef.EventHubName, "-", HubDef.ConnectionString, "-", HubDef.ConsumerGroupName);
 }
        /*
            the following function should be removed from the final deployment
            it is only used to send test messages to event hub
        */


        private static async Task SendToEventsToEventHubAsync(
            int NumberOfMessages,
            string PublisherName,
            EventHubDefinition HubDefinition)
        {
            string EventHubConnectionString = HubDefinition.ConnectionString;
            string EventHubName = HubDefinition.EventHubName;

            EventHubClient eventHubClient = EventHubClient.CreateFromConnectionString(EventHubConnectionString, EventHubName);
            int current = 1;
            Random rand = new Random();

            do
            {
                var Event = new
                {
                    DeviceId = PublisherName,
                    FloorId = string.Concat("f", rand.Next(1, 10).ToString()),
                    BuildingId = string.Concat("b", rand.Next(1, 10).ToString()),
                    TempF = rand.Next(1, 100).ToString(),
                    Humidity = rand.Next(1, 100).ToString(),
                    Motion = rand.Next(1, 10).ToString(),
                    light = rand.Next(1, 10).ToString(),
                    EventDate = DateTime.UtcNow.ToString()
                };

                // Powershell redirects stdout to PS console.
                Console.WriteLine(
                    string.Format("sending message# {0}/{1} for Publisher {2} Hub:{3}", current, NumberOfMessages, PublisherName, HubDefinition.EventHubName));
                EventData ev = new EventData(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(Event)));
                ev.SystemProperties[EventDataSystemPropertyNames.Publisher] = PublisherName;
                await eventHubClient.SendAsync(ev);
                current++;
            } while (current <= NumberOfMessages);
        }