Пример #1
0
        public UserEventController()
        {
            _SpeechSynthesizer   = new SpeechSynthesizer();
            _UserTimeoutTimeSpan = Settings.Default.UserResendTimeout;
            _UserCleaner         = new Timer(CleanUsedUser, null, 1000, 2000);
            string jsonFile = File.ReadAllText(Settings.Default.UsersJSonPath);

            _Users = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize <Users>(jsonFile);
            _Users.UsersList[1].RunProgram();
            GreetingGenerator.LoadGreetings(Settings.Default.GreetingCSVPath);
        }
Пример #2
0
 public void OnUserRecognized(object sender, UserRecognizedEventArgs e)
 {
     if (!_UsedUsers.ContainsKey(e.Name))
     {
         Debug.WriteLine("Event fired for" + e.Name);
         if (IsUserKnown(e.Name))
         {
             _SpeechSynthesizer.SpeakAsync(GreetingGenerator.GetGreeting() + e.Name);
             _UsedUsers.TryAdd(e.Name, e.TimeStamp);
         }
     }
     else
     {
         Debug.WriteLine("Already used" + e.Name);
         //update timestamp
         DateTime dt;
         _UsedUsers.TryGetValue(e.Name, out dt);
         _UsedUsers.TryUpdate(e.Name, DateTime.Now, dt);
     }
 }