/// <summary> /// /// </summary> public static ProfileSummary Collect() { if (!IsEnable) return null; Interlocked.Increment(ref _counter); var summary = new ProfileSummary(); summary.Id = _counter; summary.IntervalSecond = DateTime.Now.Subtract(_refreshTime).TotalSeconds; _refreshTime = DateTime.Now; foreach (var pair in _entityObjectCollection) { var entityName = pair.Key; var obj = pair.Value; long postObjectCount; long processObjectCount; obj.Reset(out postObjectCount, out processObjectCount); var changeAutoMqSummary = new EntitySummary() { TotalCount = obj.ChangeAutoTimes.Total, Count = obj.ChangeAutoTimes.Reset() }; var postMqSummary = new EntitySummary() { TotalCount = obj.PostTimes.Total, Count = obj.PostTimes.Reset(), TotalObjectCount = obj.TotalPostObjectCount, ObjectCount = postObjectCount }; var processMqSummary = new EntitySummary() { TotalCount = obj.ProcessTimes.Total, Count = obj.ProcessTimes.Reset(), TotalObjectCount = obj.TotalProcessObjectCount, ObjectCount = processObjectCount }; summary.ChangeAutoMQ[entityName] = changeAutoMqSummary; summary.PostMQ[entityName] = postMqSummary; summary.ProcessMQ[entityName] = processMqSummary; var noProcessKeys = obj.PopNoProcessKeys().ToList(); obj.TotalNoProcessObjectCount += noProcessKeys.Count; summary.TotalNoProcess += obj.TotalNoProcessObjectCount; if (noProcessKeys.Count > 0) { //Write error log TraceLog.WriteError("Entity operation is not saved, \"{0}\" keys:{1}", entityName, string.Join(";", noProcessKeys)); } } foreach (var pair in _sqlCollection) { var obj = pair.Value; summary.PostSqlCount += obj.PostTimes.Reset(); summary.ProcessSqlCount += obj.ProcessTimes.Reset(); summary.TotalPostSqlCount += obj.PostTimes.Total; summary.TotalProcessSqlCount += obj.ProcessTimes.Total; summary.TotalProcessFailSqlCount += obj.TotalFailCount; } WriteProfileSummaryLog(summary); return _summary = summary; }
/// <summary> /// /// </summary> public static ProfileSummary Collect() { if (!IsEnable) { return(null); } Interlocked.Increment(ref _counter); var summary = new ProfileSummary(); summary.Id = _counter; summary.IntervalSecond = DateTime.Now.Subtract(_refreshTime).TotalSeconds; _refreshTime = DateTime.Now; foreach (var pair in _entityObjectCollection) { var entityName = pair.Key; var obj = pair.Value; long postObjectCount; long processObjectCount; obj.Reset(out postObjectCount, out processObjectCount); var changeAutoMqSummary = new EntitySummary() { TotalCount = obj.ChangeAutoTimes.Total, Count = obj.ChangeAutoTimes.Reset() }; var postMqSummary = new EntitySummary() { TotalCount = obj.PostTimes.Total, Count = obj.PostTimes.Reset(), TotalObjectCount = obj.TotalPostObjectCount, ObjectCount = postObjectCount }; var processMqSummary = new EntitySummary() { TotalCount = obj.ProcessTimes.Total, Count = obj.ProcessTimes.Reset(), TotalObjectCount = obj.TotalProcessObjectCount, ObjectCount = processObjectCount }; summary.ChangeAutoMQ[entityName] = changeAutoMqSummary; summary.PostMQ[entityName] = postMqSummary; summary.ProcessMQ[entityName] = processMqSummary; var noProcessKeys = obj.PopNoProcessKeys().ToList(); obj.TotalNoProcessObjectCount += noProcessKeys.Count; summary.TotalNoProcess += obj.TotalNoProcessObjectCount; if (noProcessKeys.Count > 0) { //Write error log TraceLog.WriteError("Entity operation is not saved, \"{0}\" keys:{1}", entityName, string.Join(";", noProcessKeys)); } } foreach (var pair in _sqlCollection) { var obj = pair.Value; summary.PostSqlCount += obj.PostTimes.Reset(); summary.ProcessSqlCount += obj.ProcessTimes.Reset(); summary.TotalPostSqlCount += obj.PostTimes.Total; summary.TotalProcessSqlCount += obj.ProcessTimes.Total; summary.TotalProcessFailSqlCount += obj.TotalFailCount; } WriteProfileSummaryLog(summary); return(_summary = summary); }