Exemplo n.º 1
0
        /// <summary>
        /// Set AniDB account with login, password and client port
        /// </summary>
        /// <returns></returns>
        private object SetAniDB()
        {
            Credentials cred = this.Bind();

            if (!String.IsNullOrEmpty(cred.login) && cred.login != string.Empty && !String.IsNullOrEmpty(cred.password) &&
                cred.password != string.Empty)
            {
                ServerSettings.AniDB_Username = cred.login;
                ServerSettings.AniDB_Password = cred.password;
                if (cred.port != 0)
                {
                    ServerSettings.AniDB_ClientPort = cred.port.ToString();
                }
                return(APIStatus.OK());
            }

            return(new APIMessage(400, "Login and Password missing"));
        }
Exemplo n.º 2
0
        public Image() : base("/api")
        {
            Get["/image/{type}/{id}", true] = async(x, ct) => await Task.Factory.StartNew(() => GetImage((int)x.type, (int)x.id), ct);

            Get["/image/thumb/{type}/{id}/{ratio}", true] = async(x, ct) => await Task.Factory.StartNew(() => GetThumb((int)x.type, (int)x.id, x.ratio), ct);

            Get["/image/thumb/{type}/{id}", true] = async(x, ct) => await Task.Factory.StartNew(() => GetThumb((int)x.type, (int)x.id, "0"), ct);

            Get["/image/support/{name}", true] = async(x, ct) => await Task.Factory.StartNew(() => GetSupportImage(x.name), ct);

            Get["/image/support/{name}/{ratio}", true] = async(x, ct) => await Task.Factory.StartNew(() => GetSupportImage(x.name, x.ratio), ct);

            Get["/image/validateall", true] = async(x, ct) => await Task.Factory.StartNew(() =>
            {
                Importer.ValidateAllImages();
                return(APIStatus.OK());
            }, ct);
        }
Exemplo n.º 3
0
        public ActionResult SetDefaultUserCredentials(Credentials credentials)
        {
            if (!ServerSettings.Instance.FirstRun || ServerState.Instance.ServerOnline || ServerState.Instance.ServerStarting)
            {
                return(APIStatus.BadRequest("You may only set the default user's credentials on first run"));
            }

            try
            {
                ServerSettings.Instance.Database.DefaultUserUsername = credentials.login;
                ServerSettings.Instance.Database.DefaultUserPassword = credentials.password;
                return(APIStatus.OK());
            }
            catch
            {
                return(APIStatus.InternalError());
            }
        }
Exemplo n.º 4
0
 public ActionResult <WebUI_Settings> GetWebUIConfig()
 {
     if (!string.IsNullOrEmpty(ServerSettings.Instance.WebUI_Settings))
     {
         try
         {
             return(JsonConvert.DeserializeObject <WebUI_Settings>(ServerSettings.Instance.WebUI_Settings));
         }
         catch
         {
             return(APIStatus.InternalError("error while reading webui settings"));
         }
     }
     else
     {
         return(APIStatus.NotFound());
     }
 }
Exemplo n.º 5
0
 public ActionResult SetImagepath([FromBody] ImagePath imagepath)
 {
     if (imagepath.isdefault)
     {
         ServerSettings.Instance.ImagesPath = ServerSettings.DefaultImagePath;
         return(APIStatus.OK());
     }
     if (!string.IsNullOrEmpty(imagepath.path) && imagepath.path != string.Empty)
     {
         if (Directory.Exists(imagepath.path))
         {
             ServerSettings.Instance.ImagesPath = imagepath.path;
             return(APIStatus.OK());
         }
         return(new APIMessage(404, "Directory Not Found on Host"));
     }
     return(new APIMessage(400, "Path Missing"));
 }
Exemplo n.º 6
0
        /// <summary>
        /// Get SQL Server Instances Running on this Machine
        /// </summary>
        /// <returns>List of strings that may be passed as sqlserver_databaseserver</returns>
        private object GetMSSQLInstances()
        {
            if (ServerState.Instance.ServerOnline || ServerState.Instance.ServerStarting)
            {
                return(APIStatus.BadRequest("You may only do this before server init"));
            }

            List <string> instances = new List <string>();

            DataTable dt = SmoApplication.EnumAvailableSqlServers();

            if (dt?.Rows.Count > 0)
            {
                instances.AddRange(from DataRow row in dt.Rows select row[0].ToString());
            }

            return(instances);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Set settings for LogRotator
        /// </summary>
        /// <returns></returns>
        private object SetRotateLogs()
        {
            Request     request = Request;
            SVR_JMMUser user    = (SVR_JMMUser)Context.CurrentUser;
            Logs        rotator = this.Bind();

            if (user.IsAdmin == 1)
            {
                ServerSettings.RotateLogs             = rotator.rotate;
                ServerSettings.RotateLogs_Zip         = rotator.zip;
                ServerSettings.RotateLogs_Delete      = rotator.delete;
                ServerSettings.RotateLogs_Delete_Days = rotator.days.ToString();

                return(APIStatus.OK());
            }

            return(APIStatus.AdminNeeded());
        }
Exemplo n.º 8
0
        // List the application versions for each environment
        public static void Main(string[] args)
        {
            // Use the AuthenticationService API to get a session token.
            // See its implementation on the Authorization Service API
            String token = AuthenticationExample.getToken();

            // Create an authentication object to send in the WS call and set it with the session token
            WebServiceSimpleAuthentication authentication = new WebServiceSimpleAuthentication();

            authentication.Token = token;

            // Application Management Service WS proxy created by Visual Studio
            ApplicationManagementService service = new ApplicationManagementService();

            // The status of the WS call
            bool      success = false;
            APIStatus status  = null;

            ApplicationInfo[] applicationList = null;

            // Invoke the Application_List web method
            // WS returns a boolean and status code to signal success
            success = service.Application_List(authentication, out status, out applicationList);

            // If the call was successful, print the applications and their versions
            if (success)
            {
                foreach (ApplicationInfo application in applicationList)
                {
                    Console.Write(String.Format("\n{0,-30}", application.Name));
                    foreach (EnvironmentApplicationInfo applicationInEnvironment in application.StatusInEnvironments)
                    {
                        // Print app version or '-' if it is not deployed on the environment
                        Console.Write(String.Format("{0,-20}",
                                                    applicationInEnvironment.ExistsInEnvironment ? applicationInEnvironment.Version : "-"));
                    }
                }
            }
            else
            {
                // Implement error handling by checking the status.ResponseId field
                // See the possible error codes in the APIStatus structure documentation
            }
        }
Exemplo n.º 9
0
        public APIMessage TestDatabaseConnection()
        {
            if (ServerSettings.Instance.Database.Type == Constants.DatabaseType.MySQL && new MySQL().TestConnection())
            {
                return(APIStatus.OK());
            }

            if (ServerSettings.Instance.Database.Type == Constants.DatabaseType.SqlServer && new SQLServer().TestConnection())
            {
                return(APIStatus.OK());
            }

            if (ServerSettings.Instance.Database.Type == Constants.DatabaseType.Sqlite)
            {
                return(APIStatus.OK());
            }

            return(APIStatus.BadRequest("Failed to Connect"));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Sets the default user's credentials
        /// </summary>
        /// <returns></returns>
        private object SetDefaultUserCredentials()
        {
            if (!ServerSettings.FirstRun || ServerState.Instance.ServerOnline || ServerState.Instance.ServerStarting)
            {
                return(APIStatus.BadRequest("You may only set the default user's credentials on first run"));
            }

            try
            {
                Credentials credentials = this.Bind();
                ServerSettings.DefaultUserUsername = credentials.login;
                ServerSettings.DefaultUserPassword = credentials.password;
                return(APIStatus.OK());
            }
            catch
            {
                return(APIStatus.InternalError());
            }
        }
Exemplo n.º 11
0
        static void API()
        {
            string apikey = Environment.GetEnvironmentVariable("API_KEY", EnvironmentVariableTarget.User);

            if (string.IsNullOrEmpty(apikey))
            {
                Console.WriteLine("API_KEY environment variable is empty");
                Console.Write("API_KEY:");
                byte[] inputBuffer = new byte[1024];
                Stream inputStream = Console.OpenStandardInput(inputBuffer.Length);
                Console.SetIn(new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length));
                apikey = Console.ReadLine();
                Environment.SetEnvironmentVariable("API_KEY", apikey, EnvironmentVariableTarget.User);
            }

            APIStatus APIStatus = new APIStatus();

            Console.WriteLine("Status - IsOnline = " + APIStatus.bIsOnline);
            Console.WriteLine("Status - APIVersionRelease = " + APIStatus.APIVersionRelease);
            Console.WriteLine("Status - ID = " + APIStatus.ID);
            API        pubgapi        = new API(apikey);
            APIRequest pubgapirequest = pubgapi.RequestMatch("b319f99d-fce9-4766-9c2d-b2b45b5ca30a", PlatformRegionShard.PC_NA);

            if (pubgapirequest.exception != null)
            {
                Console.WriteLine(pubgapirequest.exception.Message);
            }
            else
            {
                Console.WriteLine(pubgapirequest.Match.BaseJSON);
                Console.WriteLine(pubgapirequest.Match.TelemetryURL);
                foreach (PlayerSpecificLog psl in pubgapirequest.Telemetry.PlayerSpecificLogList)
                {
                    if (psl.PUBGName == "epickitten")
                    {
                        foreach (LogPlayerKill lpk in psl.LogPlayerKillList)
                        {
                            Console.WriteLine(lpk.Victim.PUBGName);
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Read json file that is converted into string from .config file of jmmserver
 /// </summary>
 /// <returns></returns>
 private object GetWebUIConfig()
 {
     if (!String.IsNullOrEmpty(ServerSettings.WebUI_Settings))
     {
         try
         {
             WebUI_Settings settings = JsonConvert.DeserializeObject <WebUI_Settings>(ServerSettings.WebUI_Settings);
             return(settings);
         }
         catch
         {
             return(APIStatus.internalError("error while reading webui settings"));
         }
     }
     else
     {
         return(APIStatus.notFound404());
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Set Imagepath as default or custom
        /// </summary>
        /// <returns></returns>
        private object SetImagepath()
        {
            ImagePath imagepath = this.Bind();

            if (imagepath.isdefault)
            {
                ServerSettings.ImagesPath = ServerSettings.DefaultImagePath;
                return(APIStatus.OK());
            }
            if (!String.IsNullOrEmpty(imagepath.path) && imagepath.path != string.Empty)
            {
                if (Directory.Exists(imagepath.path))
                {
                    ServerSettings.ImagesPath = imagepath.path;
                    return(APIStatus.OK());
                }
                return(new APIMessage(404, "Directory Not Found on Host"));
            }
            return(new APIMessage(400, "Path Missing"));
        }
Exemplo n.º 14
0
        /// <summary>
        /// change given user (by uid) password
        /// </summary>
        /// <returns></returns>
        private object ChangePassword(int uid)
        {
            SVR_JMMUser thisuser = (SVR_JMMUser)Context.CurrentUser;
            SVR_JMMUser user     = this.Bind();

            if (thisuser.IsAdmin == 1)
            {
                return(new ShokoServiceImplementation().ChangePassword(uid, user.Password) == string.Empty
                    ? APIStatus.OK()
                    : APIStatus.InternalError());
            }
            if (thisuser.JMMUserID == user.JMMUserID)
            {
                return(new ShokoServiceImplementation().ChangePassword(uid, user.Password) == string.Empty
                    ? APIStatus.OK()
                    : APIStatus.InternalError());
            }

            return(APIStatus.AdminNeeded());
        }
Exemplo n.º 15
0
        public ActionResult ImportConfig(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"));
        }
Exemplo n.º 16
0
        public ActionResult GetSupportImage(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(APIStatus.NotFound());
            }
            name = Path.GetFileNameWithoutExtension(name);
            ResourceManager man = Resources.ResourceManager;

            byte[] dta = (byte[])man.GetObject(name);
            if ((dta == null) || (dta.Length == 0))
            {
                return(APIStatus.NotFound());
            }
            MemoryStream ms = new MemoryStream(dta);

            ms.Seek(0, SeekOrigin.Begin);

            return(File(ms, "image/png"));
        }
Exemplo n.º 17
0
 public ActionResult <ImportFolder> AddFolder(ImportFolder folder)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     if (folder.ImportFolderLocation == string.Empty)
     {
         return(new APIMessage(StatusCodes.Status400BadRequest,
                               "Bad Request: The Folder path must not be Empty"));
     }
     try
     {
         return(RepoFactory.ImportFolder.SaveImportFolder(folder));
     }
     catch (Exception e)
     {
         return(APIStatus.InternalError(e.Message));
     }
 }
Exemplo n.º 18
0
        public ActionResult UpdateMissingAniDBXML()
        {
            try
            {
                var allAnime = RepoFactory.AniDB_Anime.GetAll().Select(a => a.AnimeID).OrderBy(a => a).ToList();
                logger.Info($"Starting the check for {allAnime.Count} anime XML files");
                int updatedAnime = 0;
                for (var i = 0; i < allAnime.Count; i++)
                {
                    var animeID = allAnime[i];
                    if (i % 10 == 1)
                    {
                        logger.Info($"Checking anime {i + 1}/{allAnime.Count} for XML file");
                    }

                    var xml = APIUtils.LoadAnimeHTTPFromFile(animeID);
                    if (xml == null)
                    {
                        CommandRequest_GetAnimeHTTP cmd = new CommandRequest_GetAnimeHTTP(animeID, true, false);
                        cmd.Save();
                        updatedAnime++;
                        continue;
                    }

                    var rawAnime = AniDBHTTPHelper.ProcessAnimeDetails(xml, animeID);
                    if (rawAnime == null)
                    {
                        CommandRequest_GetAnimeHTTP cmd = new CommandRequest_GetAnimeHTTP(animeID, true, false);
                        cmd.Save();
                        updatedAnime++;
                    }
                }
                logger.Info($"Updating {updatedAnime} anime");
            }
            catch (Exception e)
            {
                logger.Error($"Error checking and queuing AniDB XML Updates: {e}");
                return(APIStatus.InternalError(e.Message));
            }
            return(APIStatus.OK());
        }
Exemplo n.º 19
0
        /// <summary>
        /// return int position - current position
        /// return string[] lines - lines from current log file
        /// </summary>
        /// <param name="lines">max lines to return</param>
        /// <param name="position">position to seek</param>
        /// <returns></returns>
        private object GetLog(int lines, int position)
        {
            string log_file = LogRotator.GetCurrentLogFile();

            if (string.IsNullOrEmpty(log_file))
            {
                return(APIStatus.notFound404("Could not find current log name. Sorry"));
            }

            if (!File.Exists(log_file))
            {
                return(APIStatus.notFound404());
            }

            Dictionary <string, object> result = new Dictionary <string, object>();
            FileStream fs = File.OpenRead(@log_file);

            if (position >= fs.Length)
            {
                result.Add("position", fs.Length);
                result.Add("lines", new string[] { });
                return(result);
            }

            List <string> logLines = new List <string>();

            LogReader reader = new LogReader(fs, position);

            for (int i = 0; i < lines; i++)
            {
                string line = reader.ReadLine();
                if (line == null)
                {
                    break;
                }
                logLines.Add(line);
            }
            result.Add("position", reader.Position);
            result.Add("lines", logLines.ToArray());
            return(result);
        }
Exemplo n.º 20
0
        public PlexWebhookAuthenticated() : base("/plex")
        {
            this.RequiresAuthentication();
            Get["/pin"] = o => CallPlexHelper(h => h.Authenticate());
            Get["/pin/authenticated"] = o => $"{CallPlexHelper(h => h.IsAuthenticated)}";
            Get["/token/invalidate"]  = o => CallPlexHelper(h =>
            {
                h.InvalidateToken();
                return(true);
            });
            Get["/sync", true] = async(x, ct) => await Task.Factory.StartNew(() =>
            {
                new CommandRequest_PlexSyncWatched((JMMUser)this.Context.CurrentUser).Save();
                return(APIStatus.OK());
            });

            Get["/sync/all", true] = async(x, ct) => await Task.Factory.StartNew(() =>
            {
                if (((JMMUser)this.Context.CurrentUser).IsAdmin != 1)
                {
                    return(APIStatus.AdminNeeded());
                }
                ShokoServer.Instance.SyncPlex();
                return(APIStatus.OK());
            });

            Get["/sync/{id}", true] = async(x, ct) => await Task.Factory.StartNew(() =>
            {
                if (((JMMUser)this.Context.CurrentUser).IsAdmin != 1)
                {
                    return(APIStatus.AdminNeeded());
                }
                JMMUser user = RepoFactory.JMMUser.GetByID(x.id);
                ShokoServer.Instance.SyncPlex();
                return(APIStatus.OK());
            });

#if DEBUG
            Get["/test/{id}"] = o => Response.AsJson(CallPlexHelper(h => h.GetPlexSeries((int)o.id)));
#endif
        }
Exemplo n.º 21
0
        public ActionResult TestAniDB()
        {
            ShokoService.AnidbProcessor.ForceLogout();
            ShokoService.AnidbProcessor.CloseConnections();

            Thread.Sleep(1000);

            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Instance.Culture);

            ShokoService.AnidbProcessor.Init(ServerSettings.Instance.AniDb.Username, ServerSettings.Instance.AniDb.Password,
                                             ServerSettings.Instance.AniDb.ServerAddress,
                                             ServerSettings.Instance.AniDb.ServerPort, ServerSettings.Instance.AniDb.ClientPort);

            if (ShokoService.AnidbProcessor.Login())
            {
                ShokoService.AnidbProcessor.ForceLogout();
                return(APIStatus.OK());
            }

            return(APIStatus.Unauthorized());
        }
Exemplo n.º 22
0
        /// <summary>
        /// Save webui settings as json converted into string inside .config file of jmmserver
        /// </summary>
        /// <returns></returns>
        private object SetWebUIConfig()
        {
            WebUI_Settings settings = this.Bind();

            if (settings.Valid())
            {
                try
                {
                    ServerSettings.WebUI_Settings = JsonConvert.SerializeObject(settings);
                    return(APIStatus.OK());
                }
                catch
                {
                    return(APIStatus.InternalError("error at saving webui settings"));
                }
            }
            else
            {
                return(new APIMessage(400, "Config is not a Valid."));
            }
        }
Exemplo n.º 23
0
 private object StartServer()
 {
     if (ServerState.Instance.ServerOnline)
     {
         return(APIStatus.BadRequest("Already Running"));
     }
     if (ServerState.Instance.ServerStarting)
     {
         return(APIStatus.BadRequest("Already Starting"));
     }
     try
     {
         ShokoServer.RunWorkSetupDB();
     }
     catch (Exception e)
     {
         logger.Error($"There was an error starting the server: {e}");
         return(APIStatus.InternalError($"There was an error starting the server: {e}"));
     }
     return(APIStatus.OK());
 }
Exemplo n.º 24
0
        /// <summary>
        /// Set settings for LogRotator
        /// </summary>
        /// <returns></returns>
        private object SetRotateLogs()
        {
            Request request = this.Request;

            Entities.JMMUser user    = (Entities.JMMUser) this.Context.CurrentUser;
            Logs             rotator = this.Bind();

            if (user.IsAdmin == 1)
            {
                ServerSettings.RotateLogs             = rotator.rotate;
                ServerSettings.RotateLogs_Zip         = rotator.zip;
                ServerSettings.RotateLogs_Delete      = rotator.delete;
                ServerSettings.RotateLogs_Delete_Days = rotator.days.ToString();

                return(APIStatus.statusOK());
            }
            else
            {
                return(APIStatus.adminNeeded());
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Return given setting
        /// </summary>
        /// <returns></returns>
        private object GetSetting()
        {
            if (ServerState.Instance.ServerOnline || ServerState.Instance.ServerStarting)
            {
                return(APIStatus.BadRequest("You may only do this before server init"));
            }

            try
            {
                // TODO Refactor Settings to a POCO that is serialized, and at runtime, build a dictionary of types to validate against
                Settings setting = this.Bind();
                if (string.IsNullOrEmpty(setting?.setting))
                {
                    return(APIStatus.BadRequest("An invalid setting was passed"));
                }
                try
                {
                    var value = typeof(ServerSettings).GetProperty(setting.setting)?.GetValue(null, null);
                    if (value == null)
                    {
                        return(APIStatus.BadRequest("An invalid setting was passed"));
                    }

                    Settings return_setting = new Settings
                    {
                        setting = setting.setting,
                        value   = value.ToString()
                    };
                    return(return_setting);
                }
                catch
                {
                    return(APIStatus.BadRequest("An invalid setting was passed"));
                }
            }
            catch
            {
                return(APIStatus.InternalError());
            }
        }
Exemplo n.º 26
0
        //List the environments registered in LifeTime
        static void Main(string[] args)
        {
            // Use the AuthenticationService API to get a session token.
            // See its implementation on the Authorization Service API
            String token = AuthenticationExample.getToken();

            // Create an authentication object to send in the WS call and set it with the session token
            WebServiceSimpleAuthentication authentication = new WebServiceSimpleAuthentication();

            authentication.Token = token;

            //Environment Management Service WS proxy created by Visual Studio
            EnvironmentManagementService service = new EnvironmentManagementService();

            // The status of the WS call
            bool      success = false;
            APIStatus status  = null;

            EnvironmentInfo[] environments = null;

            //Invoke the Environment_List web method
            success = service.Environment_List(authentication, out status, out environments);

            //If the call was successful, print information about the environments
            if (success)
            {
                foreach (EnvironmentInfo environment in environments)
                {
                    Console.WriteLine(String.Format("{0}: {1} front-end(s) running on {2} with {3}",
                                                    environment.Name, environment.NumberOfFrontEnds,
                                                    environment.ApplicationServerType,
                                                    environment.DatabaseProvider));
                }
            }
            else
            {
                // Implement error handling by checking the status.ResponseId field
                // See the possible error codes in the APIStatus structure documentation
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Set AniDB account credentials with a Credentials object
        /// </summary>
        /// <returns></returns>
        private object SetAniDB()
        {
            if (ServerState.Instance.ServerOnline || ServerState.Instance.ServerStarting)
            {
                return(APIStatus.BadRequest("You may only do this before server init"));
            }

            Credentials cred    = this.Bind();
            var         details = new List <(string, string)>();

            if (string.IsNullOrEmpty(cred.login))
            {
                details.Add(("login", "Username missing"));
            }
            if (string.IsNullOrEmpty(cred.password))
            {
                details.Add(("password", "Password missing"));
            }
            if (details.Count > 0)
            {
                return(new APIMessage(400, "Login or Password missing", details));
            }

            ServerSettings.AniDB_Username = cred.login;
            ServerSettings.AniDB_Password = cred.password;
            if (cred.port != 0)
            {
                ServerSettings.AniDB_ClientPort = cred.port.ToString();
            }
            if (!string.IsNullOrEmpty(cred.apikey))
            {
                ServerSettings.AniDB_AVDumpKey = cred.apikey;
            }
            if (cred.apiport != 0)
            {
                ServerSettings.AniDB_AVDumpClientPort = cred.apiport.ToString();
            }

            return(APIStatus.OK());
        }
Exemplo n.º 28
0
        public ActionResult <Credentials> GetAniDB()
        {
            if (ServerState.Instance.ServerOnline || ServerState.Instance.ServerStarting)
            {
                return(APIStatus.BadRequest("You may only do this before server init"));
            }

            try
            {
                return(new Credentials
                {
                    login = ServerSettings.Instance.AniDb.Username,
                    port = ServerSettings.Instance.AniDb.ClientPort,
                    apiport = ServerSettings.Instance.AniDb.AVDumpClientPort
                });
            }
            catch
            {
                return(APIStatus.InternalError(
                           "The ports are not set as integers. Set them and try again.\n\rThe default values are:\n\rAniDB Client Port: 4556\n\rAniDB AVDump Client Port: 4557"));
            }
        }
Exemplo n.º 29
0
        public ActionResult TestDatabaseConnection()
        {
            if (ServerState.Instance.ServerOnline || ServerState.Instance.ServerStarting)
            {
                return(APIStatus.BadRequest("You may only do this before server init"));
            }
            return(APIStatus.NotImplemented()); //TODO: Needs to be redone for EFCore.

            /*if (ServerSettings.Instance.Database.Type.Equals(Constants.DatabaseType.MySQL,
             *      StringComparison.InvariantCultureIgnoreCase) && new MySQL().TestConnection())
             *  return APIStatus.OK();
             *
             * if (ServerSettings.Instance.Database.Type.Equals(Constants.DatabaseType.SqlServer,
             *      StringComparison.InvariantCultureIgnoreCase) && new SQLServer().TestConnection())
             *  return APIStatus.OK();
             *
             * if (ServerSettings.Instance.Database.Type.Equals(Constants.DatabaseType.Sqlite,
             *  StringComparison.InvariantCultureIgnoreCase))
             *  return APIStatus.OK();*/

            //return APIStatus.BadRequest("Failed to Connect");
        }
        // List the application permission levels available
        public static void Main(string[] args)
        {
            // Use the AuthenticationService API to get a session token.
            // See its implementation on the Authorization Service API
            String token = AuthenticationExample.getToken();

            // Create an authentication object to send in the WS call and set it with the session token
            WebServiceSimpleAuthentication authentication = new WebServiceSimpleAuthentication();

            authentication.Token = token;

            // Application Management Service WS proxy created by Visual Studio
            ApplicationManagementService service = new ApplicationManagementService();

            // The status of the WS call
            bool      success = false;
            APIStatus status  = null;

            ApplicationPermissionLevel[] permissionLevels = null;

            // Invoke the ApplicationPermissionLevel_List web method
            // WS returns a boolean and status code to signal success
            success = service.ApplicationPermissionLevel_List(authentication, out status, out permissionLevels);


            // If the call was successful, print the permission levels available
            if (success)
            {
                foreach (ApplicationPermissionLevel permission in permissionLevels)
                {
                    Console.WriteLine(String.Format("{0}", permission.ShortLabel));
                }
            }
            else
            {
                // Implement error handling by checking the status.ResponseId field
                // See the possible error codes in the APIStatus structure documentation
            }
        }