private async Task ExploreAsync(string body)
 {
     try
     {
         m_logger.LogInformation($"Received Job {body}");
         var request  = JsonConvert.DeserializeObject <ExplorationRequest>(body);
         var response = new ExplorationResponse
         {
             Robots = request.Robots,
             Planet = request.Planet
         };
         try
         {
             await m_explorationService.ExplorePlanet(response);
         }
         catch (ValidationException e)
         {
             m_logger.LogWarning(e, "Validation Error Occured while trying to explore the planet");
         }
         catch (Exception e) when(e.GetType() != typeof(ValidationException))
         {
             m_logger.LogCritical("Unexpected Error Occured while trying to explore the planet");
         }
         finally
         {
             SendPlanetExplorationResult(response);
             SetRobotsStatus(request.Robots);
             SendRobotsStatus(request.Robots);
         }
     }
     catch
     {
         m_logger.LogCritical($"Could not deserialize the request body : {body}");
     }
 }
 private void SendPlanetExplorationResult(ExplorationResponse response)
 {
     m_rabbitHandler.PublishRpc(new PublishOptions
     {
         TargetQueue = m_appSettings.RabbitMqQueues.SolarApiQueue,
         Headers     = new Dictionary <string, object>
         {
             { nameof(MessageType), nameof(MessageType.ExplorationFinished) },
         },
         Message = JsonConvert.SerializeObject(response)
     });
 }
 private static void SetPlanetNewValues(Planet toUpdate, ExplorationResponse response)
 {
     toUpdate.GravityForce               = response.Planet.GravityForce;
     toUpdate.OxygenPercentage           = response.Planet.OxygenPercentage;
     toUpdate.TemperatureNight           = response.Planet.TemperatureNight;
     toUpdate.TemperatureDay             = response.Planet.TemperatureDay;
     toUpdate.WaterPercentage            = response.Planet.WaterPercentage;
     toUpdate.GravityForce               = response.Planet.GravityForce;
     toUpdate.PlanetRadius               = response.Planet.PlanetRadius;
     toUpdate.PlanetSurfaceMagneticField = response.Planet.PlanetSurfaceMagneticField;
     toUpdate.AverageSolarWindVelocity   = response.Planet.AverageSolarWindVelocity;
     toUpdate.SpinFrequency              = response.Planet.SpinFrequency;
     toUpdate.PlanetStatus               = response.Planet.PlanetStatus.Equals(PlanetStatus.Habitable) || response.Planet.PlanetStatus.Equals(PlanetStatus.Uninhabitable) ? response.Planet.PlanetStatus : PlanetStatus.Unexplored;
 }
        public async Task ExplorePlanet(ExplorationResponse response)
        {
            var planet = response.Planet;
            var robots = response.Robots;

            //one robot will complete a task in one second, and each other robot will speed up the process with 0.01% with a min waiting time of 0.5 seconds
            await GetPlanetSpinFrequency(planet, robots);
            await GetPlanetAverageSolarWindVelocity(planet, robots);
            await GetPlanetRadius(planet, robots);
            await GetPlanetTemperature(planet, robots);
            await GetPlanetWaterPercentage(planet, robots);
            await GetPlanetOxygenPercentage(planet, robots);
            await GetPlanetGravityForce(planet, robots);
            await GetPlanetSurfaceMagneticField(planet, robots);

            SumarizePlanet(planet);
        }