private void SetUpWorkflowInstance() { _report = new ReportDerived(_identityId, QueueUnitTestFixture.AgencyDetails.Id, Guid.NewGuid(), Guid.NewGuid(), ModuleType.Arrest, false); var workflowInstance = WorkflowInstanceFactory.Create(_report, _workflow.Id, new Sequence()); _report.WorkflowInstance.ReportState = ReportState.InProgress; _report.WorkflowInstance.Sequence = 1; var workflowInstanceLog = new WorkflowInstanceLog(workflowInstance, _identityId); workflowInstance.WorkflowInstanceLogs.Add(workflowInstanceLog); _reportsUnitOfWork.Setup(mock => mock.FindAndInclude <WorkflowInstance>(It.IsAny <Guid>(), TrackingMode.Automatic, ThrowIf.NotFound, instance => instance.WorkflowInstanceLogs, instance => instance.WorkflowInstanceUsers, instance => instance.WorkflowInstanceRoles)) .Returns(workflowInstance); }
public void WorkflowInstanceLog() { var identityId = Guid.NewGuid(); var _report = new ReportDerived(ReportUnitTestFixture.IdentityId, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), ModuleType.Arrest, true); workflowInstance = new WorkflowInstanceDerived(_report, Guid.NewGuid(), "data"); workflowInstance.Sequence = 1; workflowInstance.ReportState = ReportState.Approved; workflowInstanceLogObj = new WorkflowInstanceLog(workflowInstance, identityId); workflowInstanceLogObj.Sequence.Should().Be(1); workflowInstanceLogObj.ReportState.Should().Be(ReportState.Approved); workflowInstanceLogObj.Recorded.Should().BeOnOrBefore(DateTime.Now); workflowInstanceLogObj.IdentityId.Should().Be(identityId); }
/// <summary> /// Creates a new workflow instance log from the instance and user id. /// </summary> /// <param name="instance"></param> /// <param name="userId"></param> /// <returns></returns> private static void WriteToWorkflowInstanceLog(WorkflowInstance instance, Guid userId) { var log = new WorkflowInstanceLog(instance, userId); instance.WorkflowInstanceLogs.Add(log); }
protected override WorkflowActivity BeforeUpdate(WorkflowActivity entity, WorkflowActivity entityTransformed) { if (entity.WorkflowAuthorizations != null && entity.WorkflowAuthorizations.Count > 0) { foreach (WorkflowAuthorization item in entityTransformed.WorkflowAuthorizations.Where(f => !entity.WorkflowAuthorizations.Any(t => f.UniqueId == t.UniqueId))) { item.WorkflowActivity = entityTransformed; _unitOfWork.Repository <WorkflowAuthorization>().Insert(item); } } if (CurrentUpdateActionType.HasValue) { switch (CurrentUpdateActionType) { case Common.Infrastructures.UpdateActionType.HandlingWorkflow: { entityTransformed.Status = WorkflowStatus.Progress; foreach (WorkflowAuthorization item in entity.WorkflowAuthorizations) { item.IsHandler = false; if (item.Account.Equals(CurrentDomainUser.Account, System.StringComparison.InvariantCultureIgnoreCase)) { item.IsHandler = true; } _unitOfWork.Repository <WorkflowAuthorization>().Update(item); if (item.IsHandler) { WorkflowInstanceLog workflowInstanceLogs = new WorkflowInstanceLog() { LogType = WorkflowInstanceLogType.WFTakeCharge, LogDescription = string.Concat("Assegnata a '", item.Account, "'", "l'attività di presa in carico '", entityTransformed.Name, "'"), SystemComputer = System.Environment.MachineName, Entity = entityTransformed.WorkflowInstance }; _unitOfWork.Repository <WorkflowInstanceLog>().Insert(workflowInstanceLogs); } } break; }; case Common.Infrastructures.UpdateActionType.RelaseHandlingWorkflow: { entityTransformed.Status = WorkflowStatus.Todo; foreach (WorkflowAuthorization item in entity.WorkflowAuthorizations) { if (item.IsHandler == true) { WorkflowInstanceLog workflowInstanceLogs = new WorkflowInstanceLog() { LogType = WorkflowInstanceLogType.WFRelease, LogDescription = string.Concat("Rilasciata l'attività '", entityTransformed.Name, "' in carico a '", item.Account, "'"), SystemComputer = System.Environment.MachineName, Entity = entityTransformed.WorkflowInstance }; _unitOfWork.Repository <WorkflowInstanceLog>().Insert(workflowInstanceLogs); } item.IsHandler = false; _unitOfWork.Repository <WorkflowAuthorization>().Update(item); } break; } } } if (entity.WorkflowProperties != null && entity.WorkflowProperties.Count > 0) { foreach (WorkflowProperty item in entityTransformed.WorkflowProperties.Where(f => !entity.WorkflowProperties.Any(t => f.UniqueId == t.UniqueId))) { item.WorkflowActivity = entityTransformed; _unitOfWork.Repository <WorkflowProperty>().Insert(item); } } if (entity.WorkflowActivityLogs != null && entity.WorkflowActivityLogs.Count > 0) { foreach (WorkflowActivityLog item in entityTransformed.WorkflowActivityLogs.Where(f => !entity.WorkflowActivityLogs.Any(t => f.UniqueId == t.UniqueId))) { item.Entity = entityTransformed; _unitOfWork.Repository <WorkflowActivityLog>().Insert(item); } } return(base.BeforeUpdate(entity, entityTransformed)); }