Esempio n. 1
0
        void IService.CreateWorkflow(Guid candidateId, CandidateStatus status)
        {
            #region Log
            const string method = "CreateWorkflow";
            EventSource.Raise(Event.FlowEnter, method, Event.Arg("candidateId", candidateId), Event.Arg("status", status));
            #endregion

            try
            {
                lock (GetLock(candidateId))
                {
                    var workflowId = _candidatesWorkflowCommand.GetStatusWorkflowId(candidateId);
                    if (!workflowId.HasValue)
                    {
                        CreateWorkflow(candidateId, status, false);
                    }
                    else
                    {
                        #region Log
                        EventSource.Raise(Event.Information, method, "Workflow already exists.", Event.Arg("candidateId", candidateId), Event.Arg("workflowId", workflowId.Value));
                        #endregion
                    }
                }
            }
            catch (Exception e)
            {
                #region Log
                EventSource.Raise(Event.Error, method, e, null, Event.Arg("candidateId", candidateId), Event.Arg("status", status));
                #endregion
                throw;
            }

            #region Log
            EventSource.Raise(Event.FlowExit, method, Event.Arg("candidateId", candidateId), Event.Arg("status", status));
            #endregion
        }
Esempio n. 2
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);
        }