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)); } }
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); } }
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); } }