Example #1
0
        /// <inheritdoc />
        public async Task <CompiledScript> CompileScriptAsync(long id, int?revision = null)
        {
            CompiledScript script = cache.GetObject <CompiledScript, long>(id, revision ?? 0);

            if (script != null)
            {
                return(script);
            }

            Script scriptdata = await scriptservice.GetScript(id);

            if (revision.HasValue && revision.Value != 0)
            {
                if (revision != scriptdata.Revision)
                {
                    scriptdata = await archive.GetArchivedObject <Script>(id, revision.Value);
                }
            }

            script = await Parse(scriptdata);

            cache.StoreObject(id, revision ?? 0, script);
            return(script);
        }
Example #2
0
        public async Task <IActionResult> GetScript(int id, CancellationToken cancellationToken)
        {
            if (id <= 0)
            {
                return(BadRequest());
            }

            var script = await _service.GetScript(id, HttpContext.GetCurrentUserId(), cancellationToken);

            if (script == null)
            {
                return(NotFound());
            }

            return(Ok(script));
        }
Example #3
0
 public async Task <Script> CreateScript(ScriptData script)
 {
     logger.LogInformation("Creating new script {scriptname}", script.Name);
     return(await scriptservice.GetScript(await scriptservice.CreateScript(script)));
 }
Example #4
0
 public async Task <JsonResult> OnGetScriptAsync(string scriptId)
 {
     return(new JsonResult(ScriptService.GetScript(scriptId)));
 }