예제 #1
0
        public void TestNoWorkflow()
        {
            var candidate = new Candidate {
                Id = Guid.NewGuid(), Status = CandidateStatus.AvailableNow
            };

            _candidatesCommand.CreateCandidate(candidate);

            Assert.IsNull(_candidatesWorkflowCommand.GetStatusWorkflowId(candidate.Id));
            var without = _candidatesWorkflowQuery.GetCandidatesWithoutStatusWorkflow();

            Assert.AreEqual(1, without.Count);
            Assert.AreEqual(candidate.Id, without[0].Item1);
            Assert.AreEqual(candidate.Status, without[0].Item2);
        }
예제 #2
0
        private void ExecuteTask(int?count, int?slowdownMilliseconds)
        {
            const string method = "ExecuteTask";

            IEnumerable <Tuple <Guid, CandidateStatus> > candidates = _candidatesWorkflowQuery.GetCandidatesWithoutStatusWorkflow();

            if (count.HasValue && count.Value != 0)
            {
                candidates = candidates.Take(count.Value);
            }

            Logger.Raise(Event.Information, method, string.Format("Creating CandidateStatus workflows for {0} candidates...", candidates.Count()));

            var workflowProxy = _workflowProxyFactory.Create();

            try
            {
                foreach (var candidate in candidates)
                {
                    workflowProxy.CreateWorkflow(candidate.Item1, candidate.Item2);

                    // Wait a little to avoid a burst in workflow activities.

                    if (slowdownMilliseconds.HasValue && slowdownMilliseconds.Value != 0)
                    {
                        Thread.Sleep(slowdownMilliseconds.Value);
                    }
                }

                _workflowProxyFactory.Close(workflowProxy);
            }
            catch (Exception)
            {
                _workflowProxyFactory.Abort(workflowProxy);
                throw;
            }
        }