コード例 #1
0
ファイル: Utils.cs プロジェクト: dmanning23/PocketBoss
 internal static void PublishWorkflowState(IMessagingService bus, WorkflowInstance newWorkflow, string auditContext)
 {
     bus.Publish<WorkflowStateNotification>(new WorkflowStateNotification()
     {
         AuditContext = auditContext,
         CorrelationId = Guid.NewGuid(),
         IsComplete = newWorkflow.CurrentState.StateTemplate.LastState,
         State = newWorkflow.CurrentState.StateTemplate.StateName,
         StateId = newWorkflow.CurrentState.Id,
         TargetObjectId = newWorkflow.TargetObjectId,
         TargetObjectType = newWorkflow.TargetObjectType,
         TenantId = newWorkflow.TenantId,
         WorkflowInstanceId = newWorkflow.Id,
         WorkflowTemplateName = newWorkflow.WorkflowTemplate.WorkflowName,
     });
 }
コード例 #2
0
ファイル: Utils.cs プロジェクト: dmanning23/PocketBoss
 internal static void PublishNewTasks(IMessagingService bus, WorkflowInstance newWorkflow, string auditContext)
 {
     newWorkflow.CurrentState.CurrentTasks.ForEach(x =>
     {
         bus.Publish<WorkflowTaskNotification>(new WorkflowTaskNotification()
         {
             AuditContext = auditContext,
             CorrelationId = Guid.NewGuid(),
             State = newWorkflow.CurrentState.StateTemplate.StateName,
             TargetObjectId = newWorkflow.TargetObjectId,
             TargetObjectType = newWorkflow.TargetObjectType,
             TenantId = newWorkflow.TenantId,
             WorkflowInstanceId = newWorkflow.Id,
             WorkflowTemplateName = newWorkflow.WorkflowTemplate.WorkflowName,
             StateId = newWorkflow.CurrentState.Id,
             TaskId = x.Id,
             Task = x.TaskTemplate.TaskName.Replace(newWorkflow.CurrentState.StateTemplate.StateName + "|",""),
             IsComplete = x.LastTask,
         });
     });
 }
コード例 #3
0
 private void updateStateAsComplete(WorkflowInstance wf, string auditContext, Guid tenantId, IMessagingService bus)
 {
     var message = new RecordStateAction()
     {
         AuditContext = auditContext,
         CorrelationId = Guid.NewGuid(),
         State = wf.CurrentState.StateTemplate.StateName,
         StateId = wf.CurrentState.Id,
         TargetObjectId = wf.TargetObjectId,
         TargetObjectType = wf.TargetObjectType,
         TenantId = tenantId,
         WorkflowInstanceId = wf.Id,
         WorkflowTemplateName = wf.WorkflowTemplate.WorkflowName,
         Event = "All_Tasks_Completed"
     };
     RecordStateActionHandler(message);
 }
コード例 #4
0
 private static void publishNewTasks(WorkflowInstance wf, PocketBoss.Models.Task task, string auditContext, Guid tenantId, IMessagingService bus)
 {
     bus.Publish<WorkflowTaskNotification>(new WorkflowTaskNotification()
     {
         AuditContext = auditContext,
         CorrelationId = Guid.NewGuid(),
         State = wf.CurrentState.StateTemplate.StateName,
         TargetObjectId = wf.TargetObjectId,
         TargetObjectType = wf.TargetObjectType,
         TenantId = tenantId,
         WorkflowInstanceId = wf.Id,
         WorkflowTemplateName = wf.WorkflowTemplate.WorkflowName,
         StateId = wf.CurrentState.Id,
         Task = task.TaskTemplate.TaskName.Replace(wf.CurrentState.StateTemplate.StateName + "|", ""),
         TaskId = task.Id,
         IsComplete = task.LastTask,
     });
 }
コード例 #5
0
 private static WorkflowInstance makeNewWorkflowInstance(InitiateWorkflowRequest message, DataContext dataContext, IMessagingService bus)
 {
     var objType = message.TargetObjectType;
     var newWorkflow = new WorkflowInstance();
     newWorkflow.TargetObjectId = message.TargetObjectId;
     newWorkflow.TargetObjectTenantId = message.TenantId;
     newWorkflow.WorkflowTemplate = Utils.GetWorkflowTemplate(dataContext, null, objType, message.WorkflowTemplateName);
     newWorkflow.StartDate = DateTime.UtcNow;
     newWorkflow.Completed = false;
     newWorkflow.CurrentState = new State()
     {
         LastState = false,
         MetaData = null,
         StateTemplate = newWorkflow.WorkflowTemplate.States.FirstOrDefault(x => x.FirstState),
         TransitionDate = DateTime.UtcNow,
         TransitionedBy = message.AuditContext,
         TransitionEvent = new WorkflowEvent()
         {
             EventDate = DateTime.UtcNow,
             EventType = newWorkflow.WorkflowTemplate.EventsTypes.FirstOrDefault(x => x.Event == "Start_Workflow"),
             ExecutedBy = message.AuditContext,
             StateParent = newWorkflow.CurrentState,
             WorkflowInstance = newWorkflow,
         },
         Tasks = new List<Models.Task>(),
     };
     newWorkflow.CurrentState.StateTemplate.Tasks.Where(x => x.FirstTask == true).ToList().ForEach(x =>
     {
         newWorkflow.CurrentState.Tasks.Add(new Models.Task()
         {
             IsCurrentTask = true,
             State = newWorkflow.CurrentState,
             TaskTemplate = x,
             TransitionDate = DateTime.UtcNow,
             TransitionedBy = message.AuditContext,
             WorkflowInstance = newWorkflow,
         });
     }
     );
     newWorkflow.TargetObjectType = message.TargetObjectType;
     dataContext.WorkflowInstances.Add(newWorkflow);
     dataContext.SaveChanges();
     return newWorkflow;
 }