コード例 #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
ファイル: WorkflowTimers.cs プロジェクト: x1m0/PowerShell
        internal void StopTimer(WorkflowTimerType timerType)
        {
            if (disposed)
            {
                return;
            }

            if (_timers.ContainsKey(timerType))
            {
                _timers[timerType].Stop();
            }
        }
コード例 #3
0
ファイル: PSTimer.cs プロジェクト: modulexcite/pash-1
 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
ファイル: WorkflowTimers.cs プロジェクト: x1m0/PowerShell
        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
ファイル: WorkflowTimers.cs プロジェクト: 40a/PowerShell
        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
ファイル: WorkflowTimers.cs プロジェクト: x1m0/PowerShell
        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
ファイル: PSTimer.cs プロジェクト: modulexcite/pash-1
 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
ファイル: PSWorkflowTimer.cs プロジェクト: nickchal/pash
		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
ファイル: WorkflowTimers.cs プロジェクト: x1m0/PowerShell
        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
ファイル: WorkflowTimers.cs プロジェクト: x1m0/PowerShell
        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
ファイル: WorkflowTimers.cs プロジェクト: 40a/PowerShell
        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
ファイル: PSWorkflowTimer.cs プロジェクト: nickchal/pash
		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
ファイル: PSWorkflowTimer.cs プロジェクト: nickchal/pash
		internal void StopTimer(WorkflowTimerType timerType)
		{
			if (!this.disposed)
			{
				if (this._timers.ContainsKey(timerType))
				{
					this._timers[timerType].Stop();
				}
				return;
			}
			else
			{
				return;
			}
		}
コード例 #19
0
ファイル: WorkflowTimers.cs プロジェクト: 40a/PowerShell
        internal void StopTimer(WorkflowTimerType timerType)
        {
            if (disposed)
                return;

            if (_timers.ContainsKey(timerType))
            {
                _timers[timerType].Stop();
            }
        }
コード例 #20
0
ファイル: WorkflowTimers.cs プロジェクト: 40a/PowerShell
        internal bool CheckIfTimerHasReachedAlready(WorkflowTimerType timerType)
        {
            if (disposed)
                return false;

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

            return false;
        }
コード例 #21
0
ファイル: WorkflowTimers.cs プロジェクト: 40a/PowerShell
        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));
            }
        }