public override Wisdom EnlightMe(Question question) { using (var guruClient = new GuruClient()) { var result = guruClient.EnlightMe(question); return result; } }
public override Wisdom EnlightMe(Question question) { DateTime startOfEnlightning = DateTime.Now; Think(); var result = new Wisdom { By = PresentYourSelf(), Question = question, Answer = new Answer { Content = getAnswerContent() } }; DateTime endOfEnlightning = DateTime.Now; result.ThinkTime = endOfEnlightning - startOfEnlightning; return result; }
public override Wisdom EnlightMe(Question question) { var result = WisdomDataAccessFind.Find(question); if (result == null) { m_log.Debug("WisdomDataAccessFind didn't find an answer. Asking the RealGuru"); result = RealGuru.EnlightMe(question); WisdomDataAccessSave.Save(result); } return result; }
public virtual Wisdom GetWisdom(Question question) { Wisdom result = null; Locked.DoLocked( () => { if (MinAddLockMillis > 0) { int sleepMillis = Random.Next(MinGetLockMillis, MaxGetLockMillis); m_log.Debug(string.Format("GetWisdom --> sleeping for {0} millis", sleepMillis)); Thread.Sleep(sleepMillis); } question = new Question { Content = question.Content.ToLower() }; if (m_store.ContainsKey(question)) { result = m_store[question]; } }); return result; }
public WisdomViewModel EnlightMe(Question question) { BeginWork(); bool failed = false; try { var startedAt = DateTime.Now; var wisdomViewModel = new WisdomViewModel(this, Guru.EnlightMe(question), startedAt); return wisdomViewModel; } catch (Exception) { failed = true; throw; } finally { EndWork(failed); } }
public abstract Wisdom EnlightMe(Question question);
public Wisdom Find(Question question) { var result = Store.GetWisdom(question); return result; }
private void AskAllGurusAQuestion(Question question, int numberOfTimes, bool askInParallel) { m_log.Debug(string.Format("AskAllGurusAQuestion, {0}times, in parallel {1}", numberOfTimes, askInParallel)); for (var i = 0; i < numberOfTimes; i++) { foreach (var guruViewModel in GuruViewModels) { if (askInParallel) { var localGuruViewModel = guruViewModel; Task.Factory.StartNew(() => AskAGuruAQuestion(localGuruViewModel, question)); } else { AskAGuruAQuestion(guruViewModel, question); } } } }
private void AskAllGurusAQuestion(Question question, int numberOfTimes, bool askInParallel, bool waitForAnswer) { if (waitForAnswer) { m_log.Debug("AskAllGurusAQuestion, waitForAnswer"); AskAllGurusAQuestion(question, numberOfTimes, askInParallel); } else { m_log.Debug("AskAllGurusAQuestion, don't waitForAnswer"); Task.Factory.StartNew(() => AskAllGurusAQuestion(question, numberOfTimes, askInParallel)); } }
private void AskAGuruAQuestion(GuruViewModel guruViewModel, Question question) { try { var wisdomViewModel = guruViewModel.EnlightMe(question); if (CollectWisdom) { Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => WisdomViewModels.Insert(0, wisdomViewModel))); } } catch (Exception e) { m_log.Error(string.Format("AskAGuruAQuestion got an exception when asking # {0}: {1} the question {2}", guruViewModel.Nr, guruViewModel.Nick, question), e); } }
public override Wisdom EnlightMe(Question question) { var result = m_realGuru.EnlightMe(question); return result; }