public static string RunGamesRemote(dynamic JsonParams, List <double> Vector, int RandSeed) { try { //dynamic JsonMessage = new JObject(Manager.GetParameters().JsonParams); dynamic JsonMessage = new JObject(JsonParams); int x = 0; foreach (var Param in JsonMessage.parameters) { if ((bool)Param.enabled == true) { int ListSize = Param.listsize != null ? (int)Param.listsize : 1; if (ListSize == 1) { Param.Add("value", Vector != null ? Vector[x] : 0); } else { Param.Add("value", Vector != null ? new JArray(Vector.GetRange(x, ListSize)) : new JArray(new double[ListSize])); } x += ListSize; } } JsonMessage.Add("randomseed", RandSeed); RPCClient rpcClient = null; var P = JsonParams.bridge; while (rpcClient == null) { try { rpcClient = new RPCClient((string)P.queuename, (string)P.server, (int)P.port, (string)P.username, (string)P.password, (string)P.amqpurl); } catch { rpcClient = null; } } var response = rpcClient.CallRunGame(JsonMessage.ToString()); rpcClient.Close(); return(response); } catch (Exception e) { return(null); } }
string GetRemoteGameResults(RPCData sendData, string HostName) { try { string message = ""; XmlSerializer xmlSerializer = new XmlSerializer(sendData.GetType()); using (StringWriter textWriter = new StringWriter()) { xmlSerializer.Serialize(textWriter, sendData); message = textWriter.ToString(); } RPCClient rpcClient = null; while (rpcClient == null) { try { rpcClient = new RPCClient(HostName); } catch { rpcClient = null; } } var response = rpcClient.CallRunGame(message); rpcClient.Close(); return(response); } catch (Exception e) { Console.WriteLine(" ERROR: " + e.Message); return("0,0,0,0"); //RunResults[i] } }