Пример #1
0
        public bool Execute(Dictionary<History, History> historyList)
        {
            var historyToCheck = new History(this.Id);

            if (historyList.ContainsKey(historyToCheck))
            {
                var history = historyList[new History(this.Id)];
                var obs = history.GetObservation(this.Timestamp);
                if (obs != null)
                {
                    Console.WriteLine(String.Format("OK {0}", obs.Data));
                }
                else
                {
                    Console.WriteLine("ERR No observation");
                }

            }
            else
            {
                Console.WriteLine(String.Format("ERR No history exists for identifier '{0}'", this.Id));
            }
            return false;
        }
Пример #2
0
 public bool Execute(Dictionary<History, History> historyList)
 {
     var history = new History(this.Id, this.Timestamp, this.Data);
     if (!historyList.ContainsKey(history))
     {
         historyList.Add(history, history);
         Console.WriteLine(String.Format("OK {0}", this.Data));
     }
     else {
         Console.WriteLine(String.Format("ERR A history already exists for identifier '{0}'", this.Id));
     }
     return false;
 }
Пример #3
0
        public bool Execute(Dictionary<History, History> historyList)
        {
            var historyToCheck = new History(this.Id);

            if (historyList.ContainsKey(historyToCheck))
            {
                var history = historyList[historyToCheck];
                var priorObs = history.GetPriorObservation(this.Timestamp);
                history.AddObservation(this.Timestamp, this.Data);
                Console.WriteLine(String.Format("OK {0}", priorObs.Data));
            }
            else
            {
                Console.WriteLine(String.Format("ERR No history exists for identifier '{0}'", this.Id));
            }
            return false;
        }