Beispiel #1
0
        private void ServerButton_Click(object sender, EventArgs e)
        {
            Button     button     = (Button)sender;
            GameServer gameServer = (GameServer)button.Tag;

            if (gameServer.IsActive())
            {
                ServerOutput(gameServer, "This server is active!");
            }
        }
Beispiel #2
0
        private string ProcessRequest(dynamic jsonObject)
        {
            string message = "";

            if (jsonObject.server_status != null)
            {
                int        serverId   = jsonObject.server_status.id;
                GameServer gameServer = Find(serverId);

                if (gameServer != null)
                {
                    try {
                        if (gameServer.IsActive())
                        {
                            form.ServerOutput(gameServer, "Server is online");
                            message += "Server is online";
                        }
                        else
                        {
                            form.ServerOutput(gameServer, "Server is offline");
                            message += "Server is offline";
                        }
                    }
                    catch (Exception ex) {
                        form.Error("FATAL ERROR:: Could not execute server_status: " + ex);
                    }
                }
                else
                {
                    form.Error("Server_status: Could not find id " + jsonObject.server_start.id);
                    message += "Server_status: Could not find id " + jsonObject.server_start.id;
                }
            }
            else if (jsonObject.server_start != null)
            {
                int        serverId   = jsonObject.server_start.id;
                GameServer gameServer = Find(serverId);

                if (gameServer != null)
                {
                    List <string> messages;
                    try {
                        if (gameServer.Start(out messages))
                        {
                            form.ServerOutput(gameServer, "Started server: " + string.Join(",", messages.ToArray()));
                            message += "Started server: " + string.Join(",", messages.ToArray());
                        }
                        else
                        {
                            form.ServerOutput(gameServer, "Could not start server: " + string.Join(",", messages.ToArray()));
                            message += "Could not start server: " + string.Join(",", messages.ToArray());
                        }
                    }
                    catch (Exception ex) {
                        form.Error("FATAL ERROR:: Could not execute server_stats: " + ex);
                    }
                }
                else
                {
                    form.Error("Server_start: Could not find id " + jsonObject.server_start.id);
                    message += "Server_start: Could not find id " + jsonObject.server_start.id;
                }
            }
            else if (jsonObject.server_stop != null)
            {
                int        serverId   = jsonObject.server_stop.id;
                GameServer gameServer = Find(serverId);

                if (gameServer != null)
                {
                    List <string> messages;
                    try {
                        if (gameServer.Stop(out messages))
                        {
                            form.ServerOutput(gameServer, "Stopped server: " + string.Join(",", messages.ToArray()));
                            message += "Stopped server: " + string.Join(",", messages.ToArray());
                        }
                        else
                        {
                            form.ServerOutput(gameServer, "Could not stop server: " + string.Join(",", messages.ToArray()));
                            message += "Could not stop server: " + string.Join(",", messages.ToArray());
                        }
                    }
                    catch (Exception ex) {
                        form.Error("FATAL ERROR:: Could not execute server_stop: " + ex);
                    }
                }
                else
                {
                    form.Error("Server_stop: Could not find id " + jsonObject.server_start.id);
                    message += "Server_stop: Could not find id " + jsonObject.server_start.id;
                }
            }
            else if (jsonObject.server_reinstall != null)
            {
                int        serverId   = jsonObject.server_reinstall.id;
                GameServer gameServer = Find(serverId);

                if (gameServer != null)
                {
                    List <string> messages;
                    try {
                        if (gameServer.Reinstall(out messages))
                        {
                            form.ServerOutput(gameServer, "Reinstalled server: " + string.Join(",", messages.ToArray()));
                            message += "Reinstalled server: " + string.Join(",", messages.ToArray());
                        }
                        else
                        {
                            form.ServerOutput(gameServer, "Could not reinstall server: " + string.Join(",", messages.ToArray()));
                            message += "Could not reinstall server: " + string.Join(",", messages.ToArray());
                        }
                    }
                    catch (Exception ex) {
                        form.Error("FATAL ERROR:: Could not execute server_reinstall: " + ex);
                    }
                }
                else
                {
                    form.Error("Server_reinstall: Could not find id " + jsonObject.server_start.id);
                    message += "Server_reinstall: Could not find id " + jsonObject.server_start.id;
                }
            }
            else if (jsonObject.ftp_generate != null)
            {
                int        serverId   = jsonObject.ftp_generate.id;
                GameServer gameServer = Find(serverId);

                if (gameServer != null)
                {
                    List <string> messages;
                    try {
                        if (gameServer.GenerateFTP(out messages))
                        {
                            form.ServerOutput(gameServer, "Generated FTP: " + string.Join(",", messages.ToArray()));
                            message += "Generated FTP: " + string.Join(",", messages.ToArray());
                        }
                        else
                        {
                            form.ServerOutput(gameServer, "Could not generate FTP: " + string.Join(",", messages.ToArray()));
                            message += "Could not generate FTP: " + string.Join(",", messages.ToArray());
                        }
                    }
                    catch (Exception ex) {
                        form.Error("FATAL ERROR:: Could not execute ftp_generate: " + ex);
                    }
                }
                else
                {
                    form.Error("Ftp_generate: Could not find id " + jsonObject.server_start.id);
                    message += "Ftp_generate: Could not find id " + jsonObject.server_start.id;
                }
            }
            else if (jsonObject.set_server_package != null)
            {
                int        serverId   = jsonObject.set_server_package.id;
                int        packageId  = jsonObject.set_server_package.packageId;
                GameServer gameServer = Find(serverId);

                if (gameServer != null)
                {
                    if (gameServer is SAMPServer)
                    {
                        SAMPServer sampServer = (SAMPServer)gameServer;
                        sampServer.PackageId = packageId;

                        form.ServerOutput(gameServer, "Set to packageId: " + sampServer.PackageId);
                        message += "Set to packageId: " + sampServer.PackageId;
                    }
                }
                else
                {
                    form.Error("Set_server_package: Could not find id " + jsonObject.server_start.id);
                    message += "Set_server_package: Could not find id " + jsonObject.server_start.id;
                }
            }

            return(message);
        }