private void Initialize(WorkflowHost host, string templateData) { _log = ClassLogger.Create(GetType()); _dblog = DebugOnlyLogger.Create(_log); _host = host; _workspaceContainerName = WorkflowShared.WorkflowInstanceWorkspaceName(Id); Workspace = Catalog.Preconfigure() .Add(WorkspaceLocalConfig.WorkspaceName, _workspaceContainerName) .ConfiguredResolve <IWorkspace>(_workflowWorkspaceKey); if (null == _wfLock) { _wfLock = ConstructLock(Id); } SpecifyUsingTemplate(templateData); var instance = new WorkflowInstanceInfo { Id = Id, TemplateName = Name, LastActivity = DateTime.UtcNow, NextActivationTime = DateTime.UtcNow, Status = WorkflowStatus.Active.ToString(), }; _instanceData.Store(instance); }
private void Sleep(DateTime?nextActivation = null) { _log.InfoFormat("Workflow {0} sleeping until {1}", Id, nextActivation.HasValue ? nextActivation.Value.ToString() : "waked"); DateTime na = nextActivation ?? DateTime.MaxValue; var instance = new WorkflowInstanceInfo { Id = Id, TemplateName = Name, LastActivity = DateTime.UtcNow, NextActivationTime = na, Status = WorkflowStatus.Sleeping.ToString(), }; _instanceData.Store(instance); _runAgent = false; // schedule next activation if applicable if (na != DateTime.MaxValue) { var js = Catalog.Factory.Resolve <IJobScheduler>(); var waker = new WakeWorkflowJob { Id = Id }; js.ScheduleJob(waker, na, null, WorkflowShared.WorkflowJobsRoute); } _host.DeHost(Id); }
public void CompleteWorkflow() { _runAgent = false; var instance = new WorkflowInstanceInfo { Id = Id, Status = WorkflowStatus.Complete.ToString(), NextActivationTime = DateTime.MaxValue, LastActivity = DateTime.UtcNow, TemplateName = Name }; _instanceData.Store(instance); _host.DeHost(Id); _wfLock.Release(); _log.InfoFormat("Workflow {0} completed, released", Id); }
private void RefreshInstanceInfo() { _info = _instanceData.Load(_instance).Item; }