Example #1
0
        internal bool LoadJobWithIdentifier(PSWorkflowId storedInstanceId)
        {
            PSWorkflowInstance instance = _runtime.Configuration.CreatePSWorkflowInstance(storedInstanceId);

            try
            {
                instance.InstanceStore.Load(WorkflowStoreComponents.JobState | WorkflowStoreComponents.Metadata);
            }
            catch (Exception e)
            {
                Tracer.TraceException(e);

                instance.JobStateRetrieved = false;
                instance.PSWorkflowContext = new PSWorkflowContext();
            }

            if (!instance.JobStateRetrieved)
            {
                instance.RemoveInstance();
                return false;
            }

            string command;
            string name;
            Guid instanceId;
            if (!WorkflowJobSourceAdapter.GetJobInfoFromMetadata(instance, out command, out name, out instanceId))
            {
                instance.RemoveInstance();
                return false;
            }

            if (instance.Timer != null)
            {
                if (instance.Timer.CheckIfTimerHasReachedAlready(WorkflowTimerType.ElapsedTimer))
                {
                    instance.RemoveInstance();
                    return false;
                }

                // starting the elapsed timer immediately.
                instance.Timer.StartTimer(WorkflowTimerType.ElapsedTimer);
            }

            if (_wfJobTable.ContainsKey(instanceId))
            {
                return true;
            }

            lock (lockObjects.GetLockObject(instanceId))
            {
                if (_wfJobTable.ContainsKey(instanceId))
                {
                    return true;
                }

                PSWorkflowJob newjob = new PSWorkflowJob(_runtime, command, name, instanceId);
                newjob.PSWorkflowInstance = instance;
                instance.PSWorkflowJob = newjob;
                newjob.RestoreFromWorkflowInstance(instance);
                newjob.WorkflowInstanceLoaded = true;
                newjob.ConfigureWorkflowHandlers();
                if (!_wfJobTable.ContainsKey(newjob.InstanceId))
                {
                    AddJob(newjob);
                }
                return true;
            }
        }
Example #2
0
		internal bool LoadJobWithIdentifier(PSWorkflowId storedInstanceId)
		{
			string str = null;
			string str1 = null;
			Guid guid;
			bool flag;
			PSWorkflowInstance pSWorkflowContext = this._runtime.Configuration.CreatePSWorkflowInstance(storedInstanceId);
			try
			{
				pSWorkflowContext.InstanceStore.Load(WorkflowStoreComponents.Metadata | WorkflowStoreComponents.JobState);
			}
			catch (Exception exception1)
			{
				Exception exception = exception1;
				PSWorkflowJobManager.Tracer.TraceException(exception);
				pSWorkflowContext.JobStateRetrieved = false;
				pSWorkflowContext.PSWorkflowContext = new PSWorkflowContext();
			}
			if (pSWorkflowContext.JobStateRetrieved)
			{
				if (WorkflowJobSourceAdapter.GetJobInfoFromMetadata(pSWorkflowContext, out str, out str1, out guid))
				{
					if (pSWorkflowContext.Timer != null)
					{
						if (!pSWorkflowContext.Timer.CheckIfTimerHasReachedAlready(WorkflowTimerType.ElapsedTimer))
						{
							pSWorkflowContext.Timer.StartTimer(WorkflowTimerType.ElapsedTimer);
						}
						else
						{
							pSWorkflowContext.RemoveInstance();
							return false;
						}
					}
					if (!this._wfJobTable.ContainsKey(guid))
					{
						lock (this.lockObjects.GetLockObject(guid))
						{
							if (!this._wfJobTable.ContainsKey(guid))
							{
								PSWorkflowJob pSWorkflowJob = new PSWorkflowJob(this._runtime, str, str1, guid);
								pSWorkflowJob.PSWorkflowInstance = pSWorkflowContext;
								pSWorkflowContext.PSWorkflowJob = pSWorkflowJob;
								pSWorkflowJob.RestoreFromWorkflowInstance(pSWorkflowContext);
								pSWorkflowJob.WorkflowInstanceLoaded = true;
								pSWorkflowJob.ConfigureWorkflowHandlers();
								if (!this._wfJobTable.ContainsKey(pSWorkflowJob.InstanceId))
								{
									this.AddJob(pSWorkflowJob);
								}
								flag = true;
							}
							else
							{
								flag = true;
							}
						}
						return flag;
					}
					else
					{
						return true;
					}
				}
				else
				{
					pSWorkflowContext.RemoveInstance();
					return false;
				}
			}
			else
			{
				pSWorkflowContext.RemoveInstance();
				return false;
			}
		}