public CortonaPathModel GetPath() { try { var result = new CortonaPathModel { path = _settingsManager.GetRapidManualPath() }; return(result); } catch (Exception ex) { _logger.LogError(ex, "Exception occured while retrieving Cortona path"); return(CustomInternalServerResult <CortonaPathModel>(ex.Message)); } }
public CortonaPathModel SetPath([FromBody] ApiFormInput formData) { var model = new CortonaPathModel(); if (formData == null) { model.errors = ApiHelper.JsonError(400, new[] { "empty body" }); return(model); } if (!_authenticationManager.CheckAccessToken(formData.ticket)) { model.errors = ApiHelper.JsonError(400, new[] { "wrong token" }); return(model); } var targetCortonaFile = new FileInfo(formData.path); if (targetCortonaFile.Name != "RapidManual.exe") { model.errors = ApiHelper.JsonError(400, new[] { "Cortona path should be pointing to RapidManual.exe file" }); return(model); } string toolsPath = PathHelper.GetUserProcessingFolder(); CortonaConfigModel config = JsonConvert.DeserializeObject <CortonaConfigModel>(IOFile.ReadAllText(Path.Combine(toolsPath, "cortona.config"))); config.Path = formData.path; model.path = formData.path; IOFile.WriteAllText(Path.Combine(toolsPath, "cortona.config"), JsonConvert.SerializeObject(config)); return(model); }