public async void pollWork()
        {
            using (var client = new HttpClient())
            {
                try
                {
                    var result = await client.GetAsync(_config["BpmEngine:Address"] + "/engine/api/tasks");

                    if (result.IsSuccessStatusCode)
                    {
                        var content = await result.Content.ReadAsStringAsync();

                        List <BpmTask> bpmTasks = JsonConvert.DeserializeObject <List <BpmTask> >(content);
                        _ilogger.LogInformation(content);
                        if (bpmTasks.Count > 0)
                        {
                            foreach (var item in bpmTasks)
                            {
                                using (var scope = _services.CreateScope())
                                {
                                    var _accountDbContext = scope.ServiceProvider.GetRequiredService <AccountDbContext>();

                                    var bpmWorker = new BpmWorker
                                    {
                                        instanceID   = item.instanceID,
                                        workflowName = item.workflowName,
                                        taskID       = item.taskID
                                    };
                                    _accountDbContext.BpmWorkers.Add(bpmWorker);
                                    _accountDbContext.SaveChanges();
                                    item.InvokerId = bpmWorker.Id;

                                    item.databaseName = _accountDbContext.Organizations.FirstOrDefault().Name;//((ClaimsIdentity)HttpContext.User.Identity).FindFirst("organization").Value;
                                    _ilogger.LogInformation(item.databaseName);
                                    if (item != null)
                                    {
                                        item.IsBpm = true;
                                        _executionQueue.QueueExection(item);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception EX)
                {
                    //_ilogger.LogInformation(EX.Message);
                }
            }
        }
示例#2
0
        public ActionResult RunTask(BpmTask bpmTask)
        {
            var bpmWorker = new BpmWorker
            {
                instanceID   = bpmTask.instanceID,
                workflowName = bpmTask.workflowName,
                taskID       = bpmTask.taskID
            };

            _accountDbContext.BpmWorkers.Add(bpmWorker);
            _accountDbContext.SaveChanges();
            bpmTask.InvokerId = bpmWorker.Id;

            bpmTask.databaseName = ((ClaimsIdentity)HttpContext.User.Identity).FindFirst("organization").Value;
            bpmTask.IsBpm        = true;
            _exectionQueue.QueueExection(bpmTask);
            return(Ok());
        }