internal void RemoveChildJob(Job2 childWorkflowJob) { object obj = null; this._structuredTracer.RemoveJobStarted(childWorkflowJob.InstanceId); this.PopulateJobRepositoryIfRequired(); object[] instanceId = new object[1]; instanceId[0] = childWorkflowJob.InstanceId; this._tracer.WriteMessage(string.Format(CultureInfo.InvariantCulture, "WorkflowJobSourceAdapter: Removing Workflow job with instance id: {0}", instanceId)); lock (this._syncRemoveChilJob) { PSWorkflowJob pSWorkflowJob = childWorkflowJob as PSWorkflowJob; if (pSWorkflowJob != null) { PSWorkflowInstance pSWorkflowInstance = pSWorkflowJob.PSWorkflowInstance; if (pSWorkflowInstance.PSWorkflowContext.JobMetadata.TryGetValue("ParentInstanceId", out obj)) { Guid guid = (Guid)obj; ContainerParentJob item = this._jobRepository.GetItem(guid); item.ChildJobs.Remove(pSWorkflowJob); try { this.GetJobManager().RemoveJob(pSWorkflowJob.InstanceId); this._structuredTracer.JobRemoved(item.InstanceId, pSWorkflowJob.InstanceId, pSWorkflowJob.WorkflowGuid); } catch (ArgumentException argumentException1) { ArgumentException argumentException = argumentException1; object[] objArray = new object[1]; objArray[0] = argumentException; this._tracer.WriteMessage(string.Format(CultureInfo.InvariantCulture, "WorkflowJobSourceAdapter: Ingnoring the exception. Exception details: {0}", objArray)); this._structuredTracer.JobRemoveError(item.InstanceId, pSWorkflowJob.InstanceId, pSWorkflowJob.WorkflowGuid, argumentException.Message); } if (item.ChildJobs.Count == 0) { try { this._jobRepository.Remove(item); } catch (ArgumentException argumentException3) { ArgumentException argumentException2 = argumentException3; object[] objArray1 = new object[1]; objArray1[0] = argumentException2; this._tracer.WriteMessage(string.Format(CultureInfo.InvariantCulture, "WorkflowJobSourceAdapter: Ingnoring the exception. Exception details: {0}", objArray1)); } item.Dispose(); } } } } }
internal void RemoveChildJob(Job2 childWorkflowJob) { _structuredTracer.RemoveJobStarted(childWorkflowJob.InstanceId); PopulateJobRepositoryIfRequired(); _tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "WorkflowJobSourceAdapter: Removing Workflow job with instance id: {0}", childWorkflowJob.InstanceId)); lock (_syncRemoveChilJob) { PSWorkflowJob childJob = childWorkflowJob as PSWorkflowJob; if (childJob == null) { return; } object data; PSWorkflowInstance instance = childJob.PSWorkflowInstance; if (!instance.PSWorkflowContext.JobMetadata.TryGetValue(Constants.JobMetadataParentInstanceId, out data)) { return; } var parentInstanceId = (Guid)data; ContainerParentJob job = _jobRepository.GetItem(parentInstanceId); job.ChildJobs.Remove(childJob); try { GetJobManager().RemoveJob(childJob.InstanceId); _structuredTracer.JobRemoved(job.InstanceId, childJob.InstanceId, childJob.WorkflowGuid); } catch (ArgumentException exception) { //ignoring the error message and just logging them into ETW _tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "WorkflowJobSourceAdapter: Ignoring the exception. Exception details: {0}", exception)); _structuredTracer.JobRemoveError(job.InstanceId, childJob.InstanceId, childJob.WorkflowGuid, exception.Message); } if (job.ChildJobs.Count == 0) { // remove the container parent job from repository try { _jobRepository.Remove(job); } catch (ArgumentException exception) { //ignoring the error message and just logging them into ETW _tracer.WriteMessage(String.Format(CultureInfo.InvariantCulture, "WorkflowJobSourceAdapter: Ignoring the exception. Exception details: {0}", exception)); } job.Dispose(); } } }