Exemple #1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            _logger.LogInformation("initializing random data generation.");
            ChanceNET.Chance chance = new ChanceNET.Chance();
            var list = new List <string>();

            list.Add("dotnet");
            list.Add("node");
            list.Add("python");

            var currentTemp = 20;

            while (!stoppingToken.IsCancellationRequested)
            {
                var payload = new Payload {
                };
                payload.TimeStamp          = DateTime.UtcNow;
                payload.Temperature        = currentTemp + Rd.NextDouble();
                payload.IsAirConditionerOn = false;
                payload.TagKey             = chance.PickOne(list);
                payload.TimeStamp          = DateTime.Now;

                await QueuePayload(payload);

                await Task.Delay(TimeSpan.FromSeconds(1));
            }

            _logger.LogInformation("Cancellation requested.");
        }
Exemple #2
0
        private ChanceNET.Gender GetRandomGenderType()
        {
            var randomGenderType = ChanceNET.Gender.Male;
            var randomNum        = new ChanceNET.Chance().Integer(min: 0, max: 9);

            if (randomNum > 4)
            {
                randomGenderType = ChanceNET.Gender.Female;
            }

            return(randomGenderType);
        }
Exemple #3
0
        public Gender GetRandomGender()
        {
            Gender gender = new Gender {
                GenderType = ChanceNET.Gender.Male, GenderRef = "M"
            };
            var randomNum = new ChanceNET.Chance().Integer(min: 0, max: 9);

            if (randomNum > 4)
            {
                gender = new Gender {
                    GenderType = ChanceNET.Gender.Female, GenderRef = "F"
                };
            }

            return(gender);
        }