示例#1
0
        public void WriteClientActivity(ClientActivity activity)
        {
            if (_writer != null && activity != null)
            {
                TimeSpan tspan = activity.EndTime - activity.StartTime;

                WriteSingleLine("activity [duration(ms) :" + tspan.TotalMilliseconds + " start_time :" + activity.StartTime.ToString(TIME_FORMAT) + " end_time :" + activity.EndTime.ToString(TIME_FORMAT) + "]");

                if (activity.Activities != null)
                {
                    for (int i = 0; i < activity.Activities.Count; i++)
                    {
                        MethodActivity mActivity = activity.Activities[i] as MethodActivity;
                        if (mActivity != null)
                        {
                            int    space2 = 40;
                            string line   = null;
                            line = mActivity.Time.ToString(TIME_FORMAT) + ":  " + mActivity.MethodName.PadRight(space2, ' ') + mActivity.Log;
                            lock (_sync_mutex)
                            {
                                _writer.WriteLine(line);
                                _writer.Flush();
                            }
                        }
                    }
                }
                WriteSingleLine("activity ends");
                WriteSingleLine("");
            }
        }
示例#2
0
        public void LogActivity(string method, string log)
        {
            ClientActivity activity = _currentActivities[Thread.CurrentThread.ManagedThreadId] as ClientActivity;

            if (activity != null)
            {
                activity.LogActivity(method, log);
            }
        }
示例#3
0
 public object Clone()
 {
     ClientActivity clone = new ClientActivity();
     lock (this)
     {
         clone._startTime = _startTime;
         clone._endTime = _endTime;
         clone._activities = _activities.Clone() as ArrayList;
     }
     return clone;
 }
示例#4
0
        public void StartActivity()
        {
            ClientActivity acitvity = new ClientActivity();
            acitvity._thread = Thread.CurrentThread;
            int tId = Thread.CurrentThread.ManagedThreadId;

            lock (_currentActivities.SyncRoot)
            {
                _currentActivities.Add(tId, acitvity);
            }
        }
示例#5
0
        public object Clone()
        {
            ClientActivity clone = new ClientActivity();

            lock (this)
            {
                clone._startTime  = _startTime;
                clone._endTime    = _endTime;
                clone._activities = _activities.Clone() as ArrayList;
            }
            return(clone);
        }
示例#6
0
        public void StartActivity()
        {
            ClientActivity acitvity = new ClientActivity();

            acitvity._thread = Thread.CurrentThread;
            int tId = Thread.CurrentThread.ManagedThreadId;

            lock (_currentActivities.SyncRoot)
            {
                _currentActivities.Add(tId, acitvity);
            }
        }
示例#7
0
        public void StopActivity()
        {
            int            tId      = Thread.CurrentThread.ManagedThreadId;
            ClientActivity activity = null;

            lock (_currentActivities.SyncRoot)
            {
                activity = _currentActivities[tId] as ClientActivity;
                _currentActivities.Remove(tId);
            }
            if (activity != null)
            {
                activity.StopActivity();
                lock (_activities.SyncRoot)
                {
                    _activities.Add(activity);
                }
            }
        }
示例#8
0
        public void WriteClientActivity(ClientActivity activity)
        {
            if (_writer != null && activity != null)
            {
                TimeSpan tspan = activity.EndTime - activity.StartTime;

                WriteSingleLine("activity [duration(ms) :" +tspan.TotalMilliseconds +  " start_time :" + activity.StartTime.ToString(TIME_FORMAT) + " end_time :" + activity.EndTime.ToString(TIME_FORMAT) + "]");

                if (activity.Activities != null)
                {
                    for (int i = 0; i < activity.Activities.Count; i++)
                    {
                        MethodActivity mActivity = activity.Activities[i] as MethodActivity;
                        if (mActivity != null)
                        {
                            int space2 = 40;
                            string line = null;
                            line = mActivity.Time.ToString(TIME_FORMAT) + ":  " + mActivity.MethodName.PadRight(space2, ' ') + mActivity.Log;
                            lock (_sync_mutex)
                            {
                                _writer.WriteLine(line);
                                _writer.Flush();
                            }
                        }
                    }
                }
                WriteSingleLine("activity ends");
                WriteSingleLine("");

            }
        }