Example #1
0
 public PanelConverter(
     PreflightResourceChecker preflightSearch,
     IUserContext userContext,
     IOptions <CompilerOptions> compilerOptions,
     ILogger <PanelConverter> logger)
 {
     this.preflightSearch = preflightSearch;
     user = userContext;
     this.compilerOptions = compilerOptions.Value;
     log = logger;
 }
Example #2
0
        public async Task <ActionResult <PreflightCheckDTO> > Preflight(
            [FromBody] ResourceRef resourceRef,
            [FromServices] PreflightResourceChecker preflight)
        {
            try
            {
                var refs = new ResourceRefs(new ResourceRef[] { resourceRef });
                var preflightResources = await preflight.GetResourcesAsync(refs);

                return(Ok(new PreflightCheckDTO(preflightResources)));
            }
            catch (LeafRPCException lde)
            {
                return(StatusCode(lde.StatusCode));
            }
            catch (Exception e)
            {
                log.LogError("Failed to preflight resource. Resource:{@Resource} Error:{Error}", resourceRef, e.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Example #3
0
        public async Task <ActionResult> Preflight(
            string uid,
            [FromServices] PreflightResourceChecker preflight)
        {
            try
            {
                var @ref   = new ConceptRef(uid);
                var result = await preflight.GetConceptsAsync(@ref);

                var check = new ConceptPreflightCheckDTO(result.PreflightCheck);
                return(Ok(check));
            }
            catch (FormatException fe)
            {
                log.LogError("Malformed concept reference. Uid:{Uid} Error:{Error}", uid, fe.Message);
                return(BadRequest());
            }
            catch (Exception e)
            {
                log.LogError("Preflight check universal concept failed. UId:{UId} Error:{Error}", uid, e.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }