public ActionInitialising( WorkflowActionEntity workflowActionEntity, WorkflowService workflowService) { WorkflowActionEntity = workflowActionEntity; WorkflowService = workflowService; }
public static int CreateOrUpdateWorkflowAction( IWorkflowService workflowService, WorkflowActionEntity workflowActionEntity) { return(workflowService.DbConnection .Query <int>(CommandBuilder.CreateOrUpdateWorkflowAction(workflowActionEntity), workflowActionEntity) .FirstOrDefault()); }
public T LoadAction <T>(WorkflowActionEntity workflowActionEntity) where T : WorkflowAction { var jsonObject = JsonConvert.DeserializeObject <T>(workflowActionEntity.ActionBody); if (jsonObject is null) { throw new InvalidActionException(); } return(jsonObject); }
public ActionInitialising InitialiseAction <T>( WorkflowAction workflowAction, DateTime?expiryDate, DateTime?executeOnDate = null) where T : Workflow { var workflowType = typeof(T); var workflowName = workflowType.Name; var actionType = workflowAction.GetType(); var actionName = actionType.Name; if (expiryDate < DateTime.UtcNow || expiryDate is null) { expiryDate = DateTime.UtcNow.AddDays(1); } var workflow = StateflowDbContext .Queries .FetchWorkflowByName(this, workflowName); var actionData = workflowAction.GetData(); var output = JsonConvert.SerializeObject(actionData); var actionEntity = new WorkflowActionEntity { Uuid = Guid.NewGuid(), WorkflowUuid = workflow.Uuid, Retries = 0, ActionBody = output, ActionName = actionName, ActionEvent = string.Empty, IsComplete = false, DateToExecute = executeOnDate, DateExpires = expiryDate, DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow, DateProcessed = null }; return(new ActionInitialising(actionEntity, this)); }
public static string CreateOrUpdateWorkflowAction( WorkflowActionEntity workflowActionEntity) { return($@"INSERT INTO `workflow_actions` ( `uuid`, `workflow_uuid`, `retries`, `action_body`, `action_name`, `action_event`, `action_state`, `is_complete`, `date_expires`, `date_to_execute`, `date_created`, `date_modified`, `date_processed`) VALUES (@{nameof(workflowActionEntity.Uuid)}, @{nameof(workflowActionEntity.WorkflowUuid)}, @{nameof(workflowActionEntity.Retries)}, @{nameof(workflowActionEntity.ActionBody)}, @{nameof(workflowActionEntity.ActionName)}, @{nameof(workflowActionEntity.ActionEvent)}, @{nameof(workflowActionEntity.ActionState)}, @{nameof(workflowActionEntity.IsComplete)}, @{nameof(workflowActionEntity.DateExpires)}, @{nameof(workflowActionEntity.DateToExecute)}, @{nameof(workflowActionEntity.DateCreated)}, @{nameof(workflowActionEntity.DateModified)}, @{nameof(workflowActionEntity.DateProcessed)}) ON DUPLICATE KEY UPDATE `date_modified` = utc_timestamp(3), `retries` = @{nameof(workflowActionEntity.Retries)}, `action_body` = @{nameof(workflowActionEntity.ActionBody)}, `date_modified` = utc_timestamp(3), `date_processed` = @{nameof(workflowActionEntity.DateProcessed)};"); }