public ActionResult ImportConfig(CL_ServerSettings settings) { if (ServerState.Instance.ServerOnline || ServerState.Instance.ServerStarting) { return(APIStatus.BadRequest("You may only do this before server init")); } string raw_settings = settings.ToJSON(); if (raw_settings.Length == new CL_ServerSettings().ToJSON().Length) { return(APIStatus.BadRequest("Empty settings are not allowed")); } string path = Path.Combine(ServerSettings.ApplicationPath, "temp.json"); System.IO.File.WriteAllText(path, raw_settings, Encoding.UTF8); try { ServerSettings.LoadSettingsFromFile(path, true); return(APIStatus.OK()); } catch { return(APIStatus.InternalError("Error while importing settings")); } }
public ActionResult ImportConfig(CL_ServerSettings settings) { return(BadRequest("The model that this method takes is deprecated and will break the settings file. Use APIv3")); string raw_settings = settings.ToJSON(); if (raw_settings.Length == new CL_ServerSettings().ToJSON().Length) { return(APIStatus.BadRequest("Empty settings are not allowed")); } string path = Path.Combine(ServerSettings.ApplicationPath, "temp.json"); System.IO.File.WriteAllText(path, raw_settings, Encoding.UTF8); try { ServerSettings.LoadSettingsFromFile(path, true); ServerSettings.Instance.SaveSettings(); return(APIStatus.OK()); } catch { return(APIStatus.InternalError("Error while importing settings")); } }
private object ImportConfig() { CL_ServerSettings settings = this.Bind(); string raw_settings = settings.ToJSON(); string path = Path.Combine(ServerSettings.ApplicationPath, "temp.json"); File.WriteAllText(path, raw_settings, System.Text.Encoding.UTF8); try { ServerSettings.LoadSettingsFromFile(path, true); return(APIStatus.statusOK()); } catch { return(APIStatus.internalError("Error while importing settings")); } }
public ActionResult ImportConfig([FromBody] CL_ServerSettings settings) { string raw_settings = settings.ToJSON(); if (raw_settings.Length != new CL_ServerSettings().ToJSON().Length) { string path = Path.Combine(ServerSettings.ApplicationPath, "temp.json"); System.IO.File.WriteAllText(path, raw_settings, Encoding.UTF8); try { ServerSettings.LoadSettingsFromFile(path, true); return(APIStatus.OK()); } catch { return(APIStatus.InternalError("Error while importing settings")); } } return(APIStatus.BadRequest("Empty settings are not allowed")); }