Beispiel #1
0
        public void Dispose()
        {
            if (_isActive)
            {
                try
                {
                    DomainPageHitCounterSingleton.Flush(this);
                }
                catch { }
            }

            if (_flushTimer != null)
            {
                _flushTimer.Dispose();
            }
        }
Beispiel #2
0
        private static void Flush(object data)
        {
            DomainPageHitCounterSingleton instance = data as DomainPageHitCounterSingleton;

            string logFileName = "clicks_" + DateTime.Now.ToString("ddd").ToLower() + ".txt";
            string logFilePath = Path.Combine(instance.InjLogPath, logFileName);

            using (StreamWriter sw = new StreamWriter(logFilePath, true))
            {
                string hitsCount = "[ " + instance._domainHits.ToString() + " ]domain hits " + DateTime.Now.ToString("HH:mm");
                string hitsInfo  = instance._domainHitInfoBuilder.ToString();

                sw.WriteLine(hitsCount + " *" + hitsInfo + "*");
                sw.Flush();
            }

            lock (instance._countLock)
            {
                instance._domainHits = 0;
                instance._domainHitInfoBuilder.Clear();
            }
        }