private static Workflow WaitForWfRun(WfTriggerOnSchedule tos) { long relTypeId = new EntityRef("core:workflowBeingRun").Id; Workflow workflow = null; // wait up to a minute checking if it starts. for (int i = 0; i < maximumChecks; i++) { Thread.Sleep(secondsBetweenChecks * 1000); // refetch the workflow to see if it tried to run workflow = Entity.Get <Workflow>(tos.WorkflowToRun); // manually clear entity-relationship-cache, because 'RunningInstances' is one of the special relationships that // we've set to suppress invalidations for performance reasons. See Entity.SaveInvalidate. EntityRelationshipCache.Instance.Remove(EntityRelationshipCacheTypeKey.Create(workflow.Id, Direction.Reverse, relTypeId), true); if (workflow.RunningInstances.Count > 0) { Console.WriteLine("WaitForWfRun: waiting time " + i * secondsBetweenChecks); break; } } return(workflow); }
public void AddRecordRemoveDifferentTypeWithType(Direction direction, int forwardCacheCount, int forwardTypeCacheCount, int forwardReverseCacheCount, int reverseCacheCount, int reverseTypeCacheCount, int reverseReverseCacheCount) { EntityRelationshipCache.Instance.Clear( ); EntityRelationshipCache.Instance.Merge(EntityRelationshipCacheKey.Create(1, direction), CreateCacheValue(2, 3)); EntityRelationshipCache.Instance.Remove(EntityRelationshipCacheTypeKey.Create(3, Flip(direction), 4)); Expect(forwardCacheCount, forwardTypeCacheCount, forwardReverseCacheCount, reverseCacheCount, reverseTypeCacheCount, reverseReverseCacheCount); }