예제 #1
0
        private void AddTasks(IStonebranchClient stonebranchClient, IOrchestrationJob job, string workflowInstanceId, string finishTaskId)
        {
            int vertexX = 200;
            int vertexY = 450;

            var stonebranch       = new Stonebranch(stonebranchClient, _validation);
            var tasks             = stonebranch.GetCurrentTasks(workflowInstanceId, $"*{_config.CacheDBTaskFilter}*");
            var predecessor       = _config.CacheDBPredecessor;
            var flowchartRunCount = job.flowchartRunRequest.Count;
            var i = 1;

            job.flowchartRunRequest.ToList().ForEach(flowchart =>
            {
                var alias      = $"{job.clientName}_{job.projectName}_CacheDB__{flowchart.flowchartRunUUID}";
                var successors = new List <String>();

                if (i == flowchartRunCount)
                {
                    successors.Add(_config.FinishTask);
                }

                if (!tasks.Any(x => x.Name == alias))
                {
                    var data = new TaskInsert()
                    {
                        Alias        = alias,
                        Name         = "CacheDB",
                        Predecessors = new List <String>()
                        {
                            predecessor
                        },
                        Successors         = successors,
                        VertexX            = vertexX,
                        VertexY            = vertexY,
                        WorkflowInstanceId = workflowInstanceId
                    };

                    var connection = new Uri(new Uri(_config.StonebranchUri), "taskinstance/ops-task-insert");
                    var xml        = data.ToXml();
                    var content    = new StringContent(xml, Encoding.UTF8, "application/xml");

                    var response = stonebranchClient.Client.PostAsync(connection.ToString(), content).Result;

                    _validation.ValidateResponse(response);
                    _validation.ValidateStonebranchResponse(response.Content.ReadAsStringAsync().Result);

                    if (i == flowchartRunCount)
                    {
                        stonebranch.ReleaseTask(workflowInstanceId, finishTaskId);
                    }

                    predecessor = alias;
                    vertexX    += 200;
                }

                i++;
            });
        }
예제 #2
0
        public ActionResult InvokeCacheDBWorkFlow
        (
            [FromServices] IStonebranchClient stonebranchClient,
            string customerShortName,
            string projectShortName,
            Guid jobId,
            Guid flowchartRunId,
            string workFlowInstanceId
        )
        {
            var stonebranch = new Stonebranch(stonebranchClient, _validation);

            var alias       = $"{customerShortName}_{projectShortName}_CacheDB__{flowchartRunId}";
            var predecessor = "Call_CacheDB_Workflow";
            var data        = new TaskInsert()
            {
                Alias = alias,
                Name  = "CacheDB",
                WorkflowInstanceId = workFlowInstanceId,
                Predecessors       = new List <String>()
                {
                    predecessor
                },
                Successors = new List <String>()
                {
                }
            };

            var connection = new Uri(new Uri(_config.StonebranchUri), "taskinstance/ops-task-insert");
            var xml        = data.ToXml();
            var content    = new StringContent(xml, Encoding.UTF8, "application/xml");

            var response = stonebranchClient.Client.PostAsync(connection.ToString(), content).Result;

            _validation.ValidateResponse(response);
            _validation.ValidateStonebranchResponse(response.Content.ReadAsStringAsync().Result);

            return(Ok());
        }