JobStep.cs 1.3 KB
using System;
using Model;

namespace BLL
{
    public class JobStep<T>
    {
        private T _step;
        private DateTime _time;
        private string _msg;

        public JobStep(T step)
        {
            _step = step;
            _time = DateTime.Now;
            _msg = "";
        }

        public bool Equals(T step)
        {
            return _step.Equals(step);
        }

        public bool TimeOut(int ms)
        {
            TimeSpan span = DateTime.Now - _time;
            if (span.TotalMilliseconds > ms)
                return true;
            else
                return false;
        }

        public void NextStep(T step)
        {
            _step = step;
            _time = DateTime.Now;
            _msg = "";
        }

        public string Msg
        {
            get
            {
                return _msg;
            }
            set
            {
                if (!string.IsNullOrEmpty(value) && !_msg.Equals(value))
                {
                    _msg = value;
                    string s = string.Format("{0} (step={1})", _msg, _step.ToString());
                    Common.log.Info(s);
                    Common.log.UI_Display(_msg);
                    
                }
            }
        }

    }

}