Esempio n. 1
0
        /// <summary>
        /// 初始化信息
        /// </summary>
        public async void InitRecommendationAsync()
        {
            userFavorInformationList = new List <FoodWeightChange>();
            foodInformationList      = await _loadJsonService.ReadJsonAsync();

            _foodFavorService.InitAsync(foodInformationList);
            await _logService.InitAsync();

            userFavorInformationList = await _userFavorService.ReadJsonAsync();

            InitWeight(foodInformationList, userFavorInformationList);
            WeatherRoot data = await _weatherService.GetWeatherAsync();

            weatherStatus             = new TempWeather();
            weatherStatus.Temperature = double.Parse(data.main.temp).ToTemperature();
            weatherStatus.Humidity    = double.Parse(data.main.humidity).ToHumidity();
        }
Esempio n. 2
0
        public async System.Threading.Tasks.Task <List <FoodInformation> > ReFlashAsync()
        {
            food_infs = await _loadJsonService.ReadJsonAsync();

            int         len  = food_infs.Capacity;
            WeatherRoot data = await _weatherService.GetWeatherAsync();

            double tep  = double.Parse(data.main.temp);
            int    flag = -1;

            // 转换当地的天气状态
            if (tep > 30)
            {
                flag = 3;
            }
            else if (tep < 0)
            {
                flag = 1;
            }
            else
            {
                flag = 2;
            }
            int[] arr = new int[2];
            int   cnt = 0;

            while (cnt < 2)
            {
                int get_num = getOneFoodNum(flag);
                if (Array.IndexOf(arr, get_num) != -1)
                {
                    continue;
                }
                arr.SetValue(get_num, cnt++);
            }
            List <FoodInformation> get_food_name = new List <FoodInformation>();

            for (int i = 0; i < cnt; i++)
            {
                get_food_name.Add(food_infs[arr[i]]);
            }
            return(get_food_name);
        }