public static void GenerateRandomData(int standId, StatusEnum modelName) { Random r = new Random(); int completePercentage = 0; completePercentage = r.Next(1, 30); var standData = new StatusModel() { StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString() }; SendToEventhub(standData); Thread.Sleep(r.Next(_statusDelayMin, _statusDelayMax)); completePercentage = r.Next(31, 60); standData = new StatusModel() { StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString() }; SendToEventhub(standData); Thread.Sleep(r.Next(_statusDelayMin, _statusDelayMax)); completePercentage = r.Next(61, 99); standData = new StatusModel() { StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString() }; SendToEventhub(standData); Thread.Sleep(r.Next(_statusDelayMin, _statusDelayMax)); completePercentage = 100; standData = new StatusModel() { StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString() }; SendToEventhub(standData); //Pause for reset progress to 0 Thread.Sleep(_statusCompleteDelay); completePercentage = 0; standData = new StatusModel() { StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString() }; SendToEventhub(standData); }
public static void SendToEventhub(StatusModel standData) { var serialisedString = JsonConvert.SerializeObject(standData); EventData data = new EventData(Encoding.UTF8.GetBytes(serialisedString)); _eventHubClient.Send(data); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Sent: " + serialisedString); }