コード例 #1
0
        private void TriggerAlert(int index)
        {
            if (!ctx.isStarted && !ignoreServer)
            {
                if (waitForServer == default(DateTime))
                {
                    waitForServer = DateTime.Now;
                }
                TimeSpan timeElapsed = DateTime.Now - waitForServer;
                if (timeElapsed.Minutes > 4)
                {
                    ignoreServer = true;
                }
                else
                {
                    return;
                }
            }

            if (alertsTriggerd.ContainsKey(index))
            {
                DateTime current   = DateTime.Now;
                DateTime lastAlert = alertsTriggerd[index];
                TimeSpan p         = current - lastAlert;
                if (p.TotalMinutes < 10)
                {
                    return;
                }
                else
                {
                    alertsTriggerd[index] = current;
                }
            }

            if (!alertsTriggerd.ContainsKey(index))
            {
                alertsTriggerd.Add(index, DateTime.Now);
            }
            VLogger.LogObj lo = alertMessages[index];
            ctx.LogMod.Log(lo.message, lo.ll);
        }
コード例 #2
0
        /// <summary>
        /// Add's a condition, which is if true a Dependency alert will trigger!
        /// </summary>
        /// <param name="condition">A condition to be tested (when true, warning will be popped)</param>

        public void AddCondition(Func <bool> condition, VLogger.LogObj alertMessage)
        {
            conditionList.Add(condition);
            alertMessages.Add(alertMessage);
        }