Example #1
0
        public IActionResult Get(bool refresh)
        {
            //
            if (refresh)
            {
                CodePayload.Clear();
                InitZmodDirectory.ScanCodeDirectory();
                codeResponse = CodePayload.Get();
            }

            //
            string jsonStr = JsonConvert.SerializeObject(codeResponse, Formatting.None);

            try
            {
                if (!string.IsNullOrEmpty(jsonStr))
                {
                    var jsonObj = JsonConvert.DeserializeObject <List <CodeResponse> >(jsonStr);
                    return(Json(jsonObj));
                }
                else
                {
                    return(Ok(new { message = "No Content", errorCode = 204, exception = "No Content" }));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = "Server error.", errorCode = 404, exception = ex.StackTrace }));
            }
        }
Example #2
0
 public JobsController(IWebHostEnvironment environment, IConfiguration configuration, ILogger <CodeController> log, IScheduler factory)
 {
     //update
     _environment       = environment ?? throw new ArgumentNullException(nameof(environment));
     this.Configuration = configuration;
     this.Logger        = log;
     _scheduler         = factory;
     try
     {
         InitZmodDirectory.ScanModelsDirectory();
         jobsResponse = SchedulerPayload.Get();
     }
     catch (Exception ex)
     {
         Logger.LogCritical(ex, ex.StackTrace);
     }
 }
        public IActionResult Get(bool loaded, bool refresh)
        {
            //
            if (refresh)
            {
                ModelPayload.Clear();
                InitZmodDirectory.ScanModelsDirectory();
                responseData = ModelPayload.Get();
            }
            //
            DefaultContractResolver contractResolver = new DefaultContractResolver
            {
                NamingStrategy = new CamelCaseNamingStrategy()
            };
            string jsonStr = JsonConvert.SerializeObject(responseData, new JsonSerializerSettings
            {
                ContractResolver = contractResolver,
                Formatting       = Formatting.Indented
            });
            var jsonObj = JsonConvert.DeserializeObject <List <ModelResponse> >(jsonStr);

            //loaded
            if (loaded)
            {
                List <ModelResponse> loadedModel = new List <ModelResponse>();
                foreach (var record in jsonObj)
                {
                    if (record.Loaded)
                    {
                        loadedModel.Add(record);
                    }
                }
                return(Json(loadedModel));
            }

            return(Json(jsonObj));
        }