Ejemplo n.º 1
0
        public async Task <IEnumerable <WorkflowInstance> > GetWorkflowInstances(WorkflowStatus?status, string type, DateTime?createdFrom, DateTime?createdTo, int skip, int take)
        {
            IQueryable <WorkflowInstance> result = WorkflowInstances.AsQueryable();

            if (status.HasValue)
            {
                result = result.Where(x => x.Status == status.Value);
            }

            if (!String.IsNullOrEmpty(type))
            {
                result = result.Where(x => x.WorkflowDefinitionId == type);
            }

            if (createdFrom.HasValue)
            {
                result = result.Where(x => x.CreateTime >= createdFrom.Value);
            }

            if (createdTo.HasValue)
            {
                result = result.Where(x => x.CreateTime <= createdTo.Value);
            }

            return(result.Skip(skip).Take(take).ToList());
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <string> > GetRunnableInstances()
        {
            var now = DateTime.Now.ToUniversalTime().Ticks;

            return(WorkflowInstances.AsQueryable()
                   .Where(x => x.NextExecution.HasValue && (x.NextExecution <= now) && (x.Status == WorkflowStatus.Runnable))
                   .Select(x => x.Id).ToList());
        }
Ejemplo n.º 3
0
        public async Task <string> CreateNewWorkflow(WorkflowInstance workflow)
        {
            await WorkflowInstances.InsertOneAsync(workflow);

            return(workflow.Id);
        }
Ejemplo n.º 4
0
 public async Task <WorkflowInstance> GetWorkflowInstance(string Id)
 {
     return(WorkflowInstances.AsQueryable().First(x => x.Id == Id));
 }
Ejemplo n.º 5
0
 public async Task PersistWorkflow(WorkflowInstance workflow)
 {
     await WorkflowInstances.ReplaceOneAsync(x => x.Id == workflow.Id, workflow);
 }