public async Task Fire(string name, [FromBody] JObject parameters)
        {
            var projectTrigger = await _projectTriggerRepository.Queryable().Include(pt => pt.Trigger).FirstOrDefaultAsync(pt => pt.Trigger.Name == name);

            if (projectTrigger == null)
            {
                throw new InvalidInputException(@"Trigger was not found.");
            }

            var schemes = await _workflowSchemesRepository.ToListAsync(ws => ws.TriggerId == projectTrigger.TriggerId);


            foreach (var scheme in schemes)
            {
                var workflowAssociation = new WorkflowAssociation
                {
                    //Id = Guid.NewGuid(),

                    SchemeCode = scheme.Code,

                    Entity = Convert.ToString(parameters)
                };

                await _workflowAssociationsRepository.InsertAsync(workflowAssociation);

                await _workflowService.RunSchemeAsync(scheme.Code, workflowAssociation.Id);
            }
        }
Exemple #2
0
        public async Task <string> Run(string code)
        {
            if (string.IsNullOrWhiteSpace(code))
            {
                return("The name of the Workflow scheme is empty.");
            }

            var scheme = await _workflowSchemesRepository.FirstOrDefaultAsync(ws => ws.Code == code);

            if (scheme == null)
            {
                return("The name of the Workflow scheme was not found.");
            }

            var workflowAssociation = new WorkflowAssociation
            {
                Id = Guid.NewGuid(),

                SchemeCode = scheme.Code,

                Entity = "{}"
            };

            await _workflowAssociationsRepository.InsertAsync(workflowAssociation);

            await _workflowService.RunSchemeAsync(workflowAssociation.SchemeCode, workflowAssociation.Id);

            return("Your request has been added to the Workflow queue and will be processed soon.");
        }