public Result RestartSimulation() { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Logger.WriteToFile( ); var payload = new PayloadCreator(restart, Login, Token).ToJson( ); string endpoint = CreateEndpoint(SimulationOrChaarr); var client = new RestClient(endpoint); var request = new RestRequest( ); request = RequestCreator.CreatePOSTRequest(payload); IRestResponse response = client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { var result = DescribeExecutor.Describe(Login, Token, SimulationOrChaarr); if (result != null) { return(result); } else { return(null); } } else { MessageBox.Show(response.ErrorMessage); return(null); } }
public Result Execute(Commands command, Parameters parameter, string value) { // Use SecurityProtocolType.T1sl2 if needed for compatibility reasons ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var payload = new PayloadCreator(command, parameter, value, Login, Token).ToJson( ); string endpoint = CreateEndpoint(SimulationOrChaarr); var client = new RestClient(endpoint); var request = new RestRequest( ); request = RequestCreator.CreatePOSTRequest(payload); IRestResponse response = client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { var result = DescribeExecutor.Describe(Login, Token, SimulationOrChaarr); Logger.PrepareDataToWrite(result, command.ToString(), parameter.ToString(), value); if (result.IsTerminated) { MessageBox.Show("GAME OVER. Your simulation will be restarted now. Good luck!"); RestartSimulation( ); } return(result); } else { MessageBox.Show(response.ErrorMessage + response.Content); return(null); } }