Exemple #1
0
        /// <summary>Checks all triggers in a collection for activations.</summary>
        /// <param name="triggers">Collection of triggers to check.</param>
        /// <returns>True if one or more triggers activated; otherwise false.</returns>
        internal bool CheckForActivations(List <Trigger> triggers)
        {
            int      triggersActivated = 0;
            bool     returnResult      = false;
            DateTime triggerTime;

            for (int i = 0; i < triggers.Count; i++)
            {
                triggers[i].ParentLastActivated = this.LastActivated;
                triggerTime = APIRegistry.GetNextQueryTime(triggers[i].APIName);
                Terminal.CountdownTo("Querying In", triggerTime);
                bool result = triggers[i].Check();
                APIRegistry.AddQueryRecord(triggers[i].APIName);

                if (result)
                {
                    triggersActivated++;
                    returnResult = true;
                }

                if (i == 0)
                {
                    Terminal.PrintLine(this.Name, triggers[i].Description, result, triggers[i].CurrentCheckInfo, '·');
                }
                else
                {
                    Terminal.PrintLine(string.Empty, triggers[i].Description, result, triggers[i].CurrentCheckInfo);
                }
            }

            return(returnResult);
        }
Exemple #2
0
        /// <summary>Gets the next DateTime the API can be safely-queried.</summary>
        /// <param name="apiName">The name of the API to query.</param>
        /// <returns>When the API can be safely-queried.</returns>
        public static DateTime GetNextQueryTime(string apiName)
        {
            apiName = apiName.Trim().ToLower();

            if (!APIRegistry.IsRegisteredAPIName(apiName))
            {
                throw new Exception("API '" + apiName + "' not defined in API Registry!");
            }

            return(apiInfoStore[apiName].GetNextQueryTime());
        }