Exemple #1
0
        /// <summary>
        /// Static constructor. Will be called automatically before first use of this class
        /// </summary>
        static UserAccountManager()
        {
            hitsPerSecond = new HitsPerSecondLog();
            hitsPerSecond.HitPerSecondArray   = null;
            hitsPerSecond.StartInTotalSeconds = Convert.ToInt64((double)DateTime.MinValue.Ticks / TimeSpan.TicksPerSecond);

            // Nu even snel wat accounts toevoegen
            ReadUserDatabase();
        }
Exemple #2
0
        public static void ResetRequestsCounters()
        {
            lock (lockObject)
            {
                globalNumberOfRequests = 0;

                avgHitsPerSecond = -1;
                minHitsPerSecond = -1;
                maxHitsPerSecond = -1;
                hitsPerSecond    = new HitsPerSecondLog();
                hitsPerSecond.HitPerSecondArray   = new int[sizeHitsPerSecondLog];
                hitsPerSecond.StartInTotalSeconds = Convert.ToInt64((double)DateTime.Now.Ticks / TimeSpan.TicksPerSecond);
                currentMinMaxAvgHits = null;
            }
        }
Exemple #3
0
        /// <summary>
        /// Increase counter and return value. Thread safe
        /// </summary>
        public static Int64 GlobalNumberOfRequestsInc()
        {
            lock (lockObject)
            {
                globalNumberOfRequests++;

                try
                {
                    DateTime dt           = DateTime.Now;
                    long     totalSeconds = Convert.ToInt64((double)dt.Ticks / TimeSpan.TicksPerSecond);

                    // detecteren van rollover
                    if (hitsPerSecond.HitPerSecondArray == null || (totalSeconds - hitsPerSecond.StartInTotalSeconds) >= hitsPerSecond.HitPerSecondArray.Length)
                    {
                        // Hits per seconden berekenen heeft alleen zin als er metingen zijn
                        if (hitsPerSecond.HitPerSecondArray != null)
                        {
                            calcHitsPerSecond = hitsPerSecond;
                        }

                        hitsPerSecond = new HitsPerSecondLog();
                        hitsPerSecond.HitPerSecondArray   = new int[sizeHitsPerSecondLog];
                        hitsPerSecond.StartInTotalSeconds = totalSeconds; // "nieuwe rollover"
                    }

                    int seconds = Convert.ToInt32(totalSeconds - hitsPerSecond.StartInTotalSeconds);
                    hitsPerSecond.HitPerSecondArray[seconds]++;
                }
                catch (Exception e)
                {
                    CDRLogger.Logger.LogError(e);
                }

                return(globalNumberOfRequests);
            }
        }