Ejemplo n.º 1
0
        private void AnalyzeStepCount(string userURIPath)
        {
            Console.WriteLine("Analize step count invoked!");

            var LANG = storeAPI.GetLang(userURIPath);

            var now     = DateTime.UtcNow;
            var startTs = (long)ChangeTime(now, 0, 0).Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
            var endTs   = (long)now.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;;

            int userStepCount = storeAPI.GetUserStepCount(userURIPath, startTs, endTs);

            Console.WriteLine("Analize steps count " + userStepCount);

            if (userStepCount < 1000)
            {
                Console.WriteLine("Case < 1000");
                var caregiverMsg = string.Format(Loc.Get(LANG, Loc.MSG, Loc.STEPS_LESS_1000, Loc.CAREGVR), userStepCount);
                InformCaregivers(userURIPath, "steps", "high", caregiverMsg, Loc.Get(LANG, Loc.DES, Loc.STEPS_LESS_1000, Loc.CAREGVR));
            }
            else if (userStepCount < 2000)
            {
                Console.WriteLine("Case > 1000 && < 2000");
                var endUserMsg = string.Format(Loc.Get(LANG, Loc.MSG, Loc.STEPS_BETWEEN_1000_2000, Loc.USR), userStepCount);
                InformUser(userURIPath, "steps", "medium", endUserMsg, Loc.Get(LANG, Loc.DES, Loc.STEPS_BETWEEN_1000_2000, Loc.USR));
            }
            else if (userStepCount > 6000)
            {
                try{
                    Console.WriteLine("Case > 6000");
                    var endUserMsg = string.Format(Loc.Get(LANG, Loc.MSG, Loc.STEPS_BIGGER_6000, Loc.USR), userStepCount);
                    InformUser(userURIPath, "steps", "low", endUserMsg, string.Format(Loc.Get(LANG, Loc.DES, Loc.STEPS_BIGGER_6000, Loc.USR), userStepCount));
                }
                catch (Exception e) {
                    Console.WriteLine("ERROR: " + e.ToString());
                }
            }
        }