Пример #1
0
        public bool CanGetNewLog(Type logEventType)
        {
            lock (logMutex)
            {
                long        curTime = Environment.TickCount;
                Attribute[] attrs   = System.Attribute.GetCustomAttributes(logEventType);

                CMSLogAtt attr = null;
                foreach (Attribute curAttr in attrs)
                {
                    if (curAttr is CMSLogAtt)
                    {
                        attr = curAttr as CMSLogAtt;
                        break;
                    }
                }

                return(timingProfile.Send(attr, logEventType.ToString(), curTime, IsConnected || neverConnect));
            }
        }
Пример #2
0
        public bool Send(CMSLogAtt att, string typeName, long time, bool connected)
        {
            SortedList <CMSLogAtt, long> timings = null;

            if (connected)
            {
                timings = connectedTimings;
            }
            else
            {
                timings = unConnectedTimings;
            }

            if (!timings.ContainsKey(att))
            {
                return(false);
            }

            long dif = timings[att];

            if (dif == 0)
            {
                return(true);
            }

            if (lastTiming.ContainsKey(typeName))
            {
                long oldTime = lastTiming[typeName];
                if (time - oldTime < dif)
                {
                    return(false);
                }
                lastTiming[typeName] = time;
                return(true);
            }
            else
            {
                lastTiming[typeName] = time;
                return(true);
            }
        }
Пример #3
0
        public CMSLogEvent GetNewLog(Type logEventType)
        {
            lock (logMutex)
            {
                long        curTime = Environment.TickCount;
                Attribute[] attrs   = System.Attribute.GetCustomAttributes(logEventType);

                CMSLogAtt attr = null;
                foreach (Attribute curAttr in attrs)
                {
                    if (curAttr is CMSLogAtt)
                    {
                        attr = curAttr as CMSLogAtt;
                        break;
                    }
                }

                if (!timingProfile.Send(attr, logEventType.ToString(), curTime, IsConnected || neverConnect))
                {
                    return(null);
                }

                CMSLogEvent logEvent = Activator.CreateInstance(logEventType) as CMSLogEvent;

                /*
                 * if (includeDateTimeStamps)
                 *  logEvent.SetDateTime(DateTime.Now);
                 * logEvent.SessionNum = logConfig.SessionNum;
                 * logEvent.TimeInMillis = curTime - startTimeInMillis;
                 * logEvent.Uid = logConfig.Uid;
                 * logEvent.LogId = ++logUid;
                 */

                return(logEvent);
            }
        }