Exemplo n.º 1
0
        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"));
            }
        }
Exemplo n.º 2
0
        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"));
            }
        }
Exemplo n.º 3
0
        private void GetServerSettings()
        {
            CL_ServerSettings contract = _shokoservices.GetServerSettings();

            // Language
            EpisodeTitleSource      = (DataSourceType)contract.EpisodeTitleSource;
            SeriesDescriptionSource = (DataSourceType)contract.SeriesDescriptionSource;
            SeriesNameSource        = (DataSourceType)contract.SeriesNameSource;

            // Trakt
            TraktEnabled   = contract.Trakt_IsEnabled;
            TraktAuthToken = contract.Trakt_AuthToken;
        }
Exemplo n.º 4
0
        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"));
            }
        }
Exemplo n.º 5
0
        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"));
        }