示例#1
0
        public virtual IActionResult Exec([FromRoute][Required] string activityId, [FromBody] ExeScriptRequest script)
        {
            var clientContext = this.HttpContext.Items["ClientContext"] as GolemClientMockAPI.Entities.ClientContext;

            try
            {
                var activity = this.ActivityRepository.GetActivity(activityId);

                if (activity == null)
                {
                    return(this.StatusCode(404)); // Agreement not found
                }

                if (activity.RequestorNodeId != clientContext.NodeId)
                {
                    return(this.StatusCode(403)); // Not entitled to act on the activity
                }

                // TODO validate the incoming exe script batch??? Return HTTP 400 and script error info?

                var exeScriptEntity = this.ExeScriptMapper.MapToEntity(script);

                var batchId = this.ActivityProcessor.ExecAsync(activityId, exeScriptEntity);

                return(this.Content(batchId));
            }
            catch (Exception exc)
            {
                return(this.StatusCode(500, new DestroyActivityError()
                {
                    Message = exc.Message
                }));
            }
        }
示例#2
0
        public Entities.ExeScript MapToEntity(ExeScriptRequest batch)
        {
            var result = new Entities.ExeScript()
            {
                Text = batch.Text
            };

            return(result);
        }