示例#1
0
 internal void SetupTimer(WorkflowTimerType timerType, TimeSpan interval)
 {
     if (!this.disposed)
     {
         if (!this._timers.ContainsKey(timerType))
         {
             if (timerType != WorkflowTimerType.ElapsedTimer)
             {
                 if (timerType == WorkflowTimerType.RunningTimer)
                 {
                     this._timers.Add(timerType, new PSTimer(timerType, false, false, interval, new WorkflowTimerElapsedHandler(this.Timer_WorkflowTimerElapsed)));
                 }
                 return;
             }
             else
             {
                 this._timers.Add(timerType, new PSTimer(timerType, false, true, interval, new WorkflowTimerElapsedHandler(this.Timer_WorkflowTimerElapsed)));
                 return;
             }
         }
         else
         {
             return;
         }
     }
     else
     {
         return;
     }
 }
示例#2
0
        internal void StopTimer(WorkflowTimerType timerType)
        {
            if (disposed)
            {
                return;
            }

            if (_timers.ContainsKey(timerType))
            {
                _timers[timerType].Stop();
            }
        }
示例#3
0
 internal PSTimer(WorkflowTimerType type, bool isRecurring, bool isOneTimeTimer, TimeSpan interval, WorkflowTimerElapsedHandler handler)
 {
     this.syncLock              = new object();
     this.TimerType             = type;
     this.IsRecurring           = isRecurring;
     this.IsOneTimeTimer        = isOneTimeTimer;
     this.Interval              = interval;
     this.RemainingTime         = interval;
     this.StartedAtForFirstTime = null;
     this.StartedTime           = null;
     this.IsRunning             = false;
     this.Handler = handler;
 }
示例#4
0
文件: PSTimer.cs 项目: nickchal/pash
		internal PSTimer(WorkflowTimerType type, bool isRecurring, bool isOneTimeTimer, TimeSpan interval, WorkflowTimerElapsedHandler handler)
		{
			this.syncLock = new object();
			this.TimerType = type;
			this.IsRecurring = isRecurring;
			this.IsOneTimeTimer = isOneTimeTimer;
			this.Interval = interval;
			this.RemainingTime = interval;
			this.StartedAtForFirstTime = null;
			this.StartedTime = null;
			this.IsRunning = false;
			this.Handler = handler;
		}
示例#5
0
        internal bool CheckIfTimerHasReachedAlready(WorkflowTimerType timerType)
        {
            if (disposed)
            {
                return(false);
            }

            if (_timers.ContainsKey(timerType) && _timers[WorkflowTimerType.ElapsedTimer].TimerReachedAlready)
            {
                return(true);
            }

            return(false);
        }
示例#6
0
 internal void StopTimer(WorkflowTimerType timerType)
 {
     if (!this.disposed)
     {
         if (this._timers.ContainsKey(timerType))
         {
             this._timers[timerType].Stop();
         }
         return;
     }
     else
     {
         return;
     }
 }
示例#7
0
        internal PSTimer(WorkflowTimerType type, bool isRecurring, bool isOneTimeTimer, TimeSpan interval, WorkflowTimerElapsedHandler handler)
        {
            Debug.Assert(!(isRecurring == true && isOneTimeTimer == true), "Timer cannot be recurring and one-time-timer at the same time.");

            this.TimerType = type;
            this.IsRecurring = isRecurring;
            this.IsOneTimeTimer = isOneTimeTimer;

            this.Interval = interval;
            this.RemainingTime = interval;
            this.StartedAtForFirstTime = null;
            this.StartedTime = null;
            this.IsRunning = false;

            this.Handler = handler;
        }
示例#8
0
        internal PSTimer(WorkflowTimerType type, bool isRecurring, bool isOneTimeTimer, TimeSpan interval, WorkflowTimerElapsedHandler handler)
        {
            Debug.Assert(!(isRecurring == true && isOneTimeTimer == true), "Timer cannot be recurring and one-time-timer at the same time.");

            this.TimerType      = type;
            this.IsRecurring    = isRecurring;
            this.IsOneTimeTimer = isOneTimeTimer;

            this.Interval              = interval;
            this.RemainingTime         = interval;
            this.StartedAtForFirstTime = null;
            this.StartedTime           = null;
            this.IsRunning             = false;

            this.Handler = handler;
        }
示例#9
0
 internal PSTimer(Dictionary <string, object> data, WorkflowTimerElapsedHandler handler)
 {
     this.syncLock       = new object();
     this.TimerType      = (WorkflowTimerType)data["TimerType"];
     this.IsRecurring    = (bool)data["IsRecurring"];
     this.IsOneTimeTimer = (bool)data["IsOneTimeTimer"];
     this.Interval       = (TimeSpan)data["Interval"];
     if (this.IsRecurring || this.IsOneTimeTimer)
     {
         if (this.IsRecurring || !this.IsOneTimeTimer)
         {
             this.RemainingTime = this.Interval;
         }
         else
         {
             DateTime item     = (DateTime)data["StartedAtForFirstTime"];
             DateTime utcNow   = DateTime.UtcNow;
             TimeSpan interval = this.Interval - utcNow.Subtract(item);
             if (interval > TimeSpan.FromSeconds(0))
             {
                 if (interval >= TimeSpan.FromSeconds(2))
                 {
                     this.RemainingTime = interval;
                 }
                 else
                 {
                     this.RemainingTime = TimeSpan.FromSeconds(2);
                 }
             }
             else
             {
                 this.TimerReachedAlready = true;
                 this.RemainingTime       = TimeSpan.FromSeconds(2);
             }
         }
     }
     else
     {
         this.RemainingTime = (TimeSpan)data["RemainingTime"];
     }
     this.StartedAtForFirstTime = null;
     this.StartedTime           = null;
     this.IsRunning             = false;
     this.Handler = handler;
 }
示例#10
0
文件: PSTimer.cs 项目: nickchal/pash
		internal PSTimer(Dictionary<string, object> data, WorkflowTimerElapsedHandler handler)
		{
			this.syncLock = new object();
			this.TimerType = (WorkflowTimerType)data["TimerType"];
			this.IsRecurring = (bool)data["IsRecurring"];
			this.IsOneTimeTimer = (bool)data["IsOneTimeTimer"];
			this.Interval = (TimeSpan)data["Interval"];
			if (this.IsRecurring || this.IsOneTimeTimer)
			{
				if (this.IsRecurring || !this.IsOneTimeTimer)
				{
					this.RemainingTime = this.Interval;
				}
				else
				{
					DateTime item = (DateTime)data["StartedAtForFirstTime"];
					DateTime utcNow = DateTime.UtcNow;
					TimeSpan interval = this.Interval - utcNow.Subtract(item);
					if (interval > TimeSpan.FromSeconds(0))
					{
						if (interval >= TimeSpan.FromSeconds(2))
						{
							this.RemainingTime = interval;
						}
						else
						{
							this.RemainingTime = TimeSpan.FromSeconds(2);
						}
					}
					else
					{
						this.TimerReachedAlready = true;
						this.RemainingTime = TimeSpan.FromSeconds(2);
					}
				}
			}
			else
			{
				this.RemainingTime = (TimeSpan)data["RemainingTime"];
			}
			this.StartedAtForFirstTime = null;
			this.StartedTime = null;
			this.IsRunning = false;
			this.Handler = handler;
		}
示例#11
0
 internal bool CheckIfTimerHasReachedAlready(WorkflowTimerType timerType)
 {
     if (!this.disposed)
     {
         if (!this._timers.ContainsKey(timerType) || !this._timers[WorkflowTimerType.ElapsedTimer].TimerReachedAlready)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }
示例#12
0
		internal bool CheckIfTimerHasReachedAlready(WorkflowTimerType timerType)
		{
			if (!this.disposed)
			{
				if (!this._timers.ContainsKey(timerType) || !this._timers[WorkflowTimerType.ElapsedTimer].TimerReachedAlready)
				{
					return false;
				}
				else
				{
					return true;
				}
			}
			else
			{
				return false;
			}
		}
示例#13
0
        private void Timer_WorkflowTimerElapsed(PSTimer sender, ElapsedEventArgs e)
        {
            if (!this.disposed)
            {
                PSWorkflowTimer.StructuredTracer.Correlate();
                this.Tracer.WriteMessage(string.Concat("PSWorkflowTimer Elapsed: ", sender.TimerType));
                if (!this.disposed)
                {
                    WorkflowTimerType timerType = sender.TimerType;
                    switch (timerType)
                    {
                    case WorkflowTimerType.RunningTimer:
                    {
                        sender.Stop();
                        this.TerminateWorkflow(Resources.RunningTimeReached);
                        return;
                    }

                    case WorkflowTimerType.ElapsedTimer:
                    {
                        sender.Stop();
                        this.TerminateAndRemoveWorkflow(Resources.ElapsedTimeReached);
                        return;
                    }

                    default:
                    {
                        return;
                    }
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }
示例#14
0
        internal void SetupTimer(WorkflowTimerType timerType, TimeSpan interval)
        {
            if (disposed)
            {
                return;
            }

            if (_timers.ContainsKey(timerType))
            {
                return;
            }

            if (timerType == WorkflowTimerType.ElapsedTimer)
            {
                _timers.Add(timerType, new PSTimer(timerType, false, true, interval, Timer_WorkflowTimerElapsed));
            }
            else if (timerType == WorkflowTimerType.RunningTimer)
            {
                _timers.Add(timerType, new PSTimer(timerType, false, false, interval, Timer_WorkflowTimerElapsed));
            }
        }
示例#15
0
        internal PSTimer(Dictionary <string, object> data, WorkflowTimerElapsedHandler handler)
        {
            this.TimerType      = (WorkflowTimerType)data["TimerType"];
            this.IsRecurring    = (bool)data["IsRecurring"];
            this.IsOneTimeTimer = (bool)data["IsOneTimeTimer"];
            this.Interval       = (TimeSpan)data["Interval"];

            if (IsRecurring == false && IsOneTimeTimer == false)
            {
                this.RemainingTime = (TimeSpan)data["RemainingTime"];
            }
            else if (IsRecurring == false && IsOneTimeTimer == true)
            {
                DateTime tmpStartedAtForFirstTime = (DateTime)data["StartedAtForFirstTime"];
                TimeSpan diff = Interval - DateTime.UtcNow.Subtract(tmpStartedAtForFirstTime);
                if (diff <= TimeSpan.FromSeconds(0))
                {
                    this.TimerReachedAlready = true;
                    this.RemainingTime       = TimeSpan.FromSeconds(2);
                }
                else if (diff < TimeSpan.FromSeconds(2))
                {
                    this.RemainingTime = TimeSpan.FromSeconds(2);
                }
                else
                {
                    this.RemainingTime = diff;
                }
            }
            else
            {
                this.RemainingTime = Interval;
            }

            this.StartedAtForFirstTime = null;
            this.StartedTime           = null;
            this.IsRunning             = false;

            this.Handler = handler;
        }
示例#16
0
        internal PSTimer(Dictionary<string, object> data, WorkflowTimerElapsedHandler handler)
        {
            this.TimerType = (WorkflowTimerType)data["TimerType"];
            this.IsRecurring = (bool)data["IsRecurring"];
            this.IsOneTimeTimer = (bool)data["IsOneTimeTimer"];
            this.Interval = (TimeSpan)data["Interval"];

            if (IsRecurring == false && IsOneTimeTimer == false)
            {
                this.RemainingTime = (TimeSpan)data["RemainingTime"];
            }
            else if (IsRecurring == false && IsOneTimeTimer == true)
            {
                DateTime tmpStartedAtForFirstTime = (DateTime)data["StartedAtForFirstTime"];
                TimeSpan diff = Interval - DateTime.UtcNow.Subtract(tmpStartedAtForFirstTime);
                if (diff <= TimeSpan.FromSeconds(0))
                {
                    this.TimerReachedAlready = true;
                    this.RemainingTime = TimeSpan.FromSeconds(2);
                }
                else if (diff < TimeSpan.FromSeconds(2))
                    this.RemainingTime = TimeSpan.FromSeconds(2);
                else
                    this.RemainingTime = diff;
            }
            else
            {
                this.RemainingTime = Interval;
            }

            this.StartedAtForFirstTime = null;
            this.StartedTime = null;
            this.IsRunning = false;

            this.Handler = handler;

        }
示例#17
0
		internal void SetupTimer(WorkflowTimerType timerType, TimeSpan interval)
		{
			if (!this.disposed)
			{
				if (!this._timers.ContainsKey(timerType))
				{
					if (timerType != WorkflowTimerType.ElapsedTimer)
					{
						if (timerType == WorkflowTimerType.RunningTimer)
						{
							this._timers.Add(timerType, new PSTimer(timerType, false, false, interval, new WorkflowTimerElapsedHandler(this.Timer_WorkflowTimerElapsed)));
						}
						return;
					}
					else
					{
						this._timers.Add(timerType, new PSTimer(timerType, false, true, interval, new WorkflowTimerElapsedHandler(this.Timer_WorkflowTimerElapsed)));
						return;
					}
				}
				else
				{
					return;
				}
			}
			else
			{
				return;
			}
		}
示例#18
0
		internal void StopTimer(WorkflowTimerType timerType)
		{
			if (!this.disposed)
			{
				if (this._timers.ContainsKey(timerType))
				{
					this._timers[timerType].Stop();
				}
				return;
			}
			else
			{
				return;
			}
		}
示例#19
0
        internal void StopTimer(WorkflowTimerType timerType)
        {
            if (disposed)
                return;

            if (_timers.ContainsKey(timerType))
            {
                _timers[timerType].Stop();
            }
        }
示例#20
0
        internal bool CheckIfTimerHasReachedAlready(WorkflowTimerType timerType)
        {
            if (disposed)
                return false;

            if (_timers.ContainsKey(timerType) && _timers[WorkflowTimerType.ElapsedTimer].TimerReachedAlready)
                return true;

            return false;
        }
示例#21
0
        internal void SetupTimer(WorkflowTimerType timerType, TimeSpan interval)
        {
            if (disposed)
                return;

            if (_timers.ContainsKey(timerType))
                return;

            if (timerType == WorkflowTimerType.ElapsedTimer)
            {
                _timers.Add(timerType, new PSTimer(timerType, false, true, interval, Timer_WorkflowTimerElapsed));
            }
            else if (timerType == WorkflowTimerType.RunningTimer)
            {
                _timers.Add(timerType, new PSTimer(timerType, false, false, interval, Timer_WorkflowTimerElapsed));
            }
        }