Ejemplo n.º 1
0
        public static void PostValidCommands(ValidCommandList commandList)
        {
            try
            {
                // Go and push all the valid commands to the server
                var validCommandRequest = new RestRequest("command/valid", Method.POST);
                validCommandRequest.AddHeader("Content-Type", "application/json")
                .AddHeader("Authorization", $"Bearer {RimConnectSettings.token}")
                .AddJsonBody(commandList);

                var validCommandResponse = client.Execute <CommandOptionList>(validCommandRequest);

                if (validCommandResponse.StatusCode != System.Net.HttpStatusCode.OK)
                {
                    RimConnectSettings.initialiseSuccessful = false;
                    Log.Error("Failed to provide valid commands to the server");
                }
                else
                {
                    RimConnectSettings.initialiseSuccessful = true;

                    CommandOptionList commandOptionList = new CommandOptionList();
                    commandOptionList.commandOptions = validCommandResponse.Data.commandOptions;

                    Settings.CommandOptionListController.commandOptionList = commandOptionList;
                    Log.Message($"Provided a total of {commandOptionList.commandOptions.Count} valid commands to the server");
                }
            }
            catch (Exception e)
            {
                Log.Error($"Failed to provide valid commands to server. {e.Message}");
            }
        }
Ejemplo n.º 2
0
        public static void PostUpdatedCommandOptions(CommandOptionList updatedCommandOptionList)
        {
            // Send Updated CommandOption Settings
            try
            {
                // Go and push all the valid commands to the server
                var commandOptionRequest = new RestRequest("command/options", Method.POST);
                commandOptionRequest.AddHeader("Content-Type", "application/json")
                .AddHeader("Authorization", $"Bearer {RimConnectSettings.token}")
                .AddJsonBody(updatedCommandOptionList);

                var validCommandResponse = client.Execute <CommandOptionList>(commandOptionRequest);

                if (validCommandResponse.StatusCode != System.Net.HttpStatusCode.OK)
                {
                    Log.Error($"Failed to update command options to server. {validCommandResponse.StatusCode}");
                }
                else
                {
                    Log.Message("Updated command options to server");
                }
            }
            catch (Exception e)
            {
                Log.Error($"Failed to update command options to server. {e.Message}");
            }
        }