public string RetrieveString(string command, params object[] parameters) { var req = new JsonRpcRequest() { Method = command }; if (parameters.Length > 0) req.Params = parameters; try { var respTask = node.SendCommand(JsonRpcDefaults.Encoding.GetString(req.Serialize())); var response = JsonRpcResponse.FromJsonString(respTask.Result); // Blocking! var result = (string) response.Result; _log.Debug("Got a {0} character response string.", result.Length); return result; } catch (Exception x) { _log.Error("Error when retrieving string: {0}", x.Message); return ""; } }
public JsonRpcResponse(JsonRpcRequest req) { Id = req.Id; }
public static JsonRpcResponse FromRequest(JsonRpcRequest req) { return new JsonRpcResponse(req); }
public Guid[] UploadResults(ResultRecordChunk records) { var req = new JsonRpcRequest() { Method = "uploadResults", Params = new object[] { records } }; try { _log.Info($"Uploading {records.Count} result records to Core..."); var serialized = JsonRpcDefaults.Encoding.GetString(req.Serialize()); var respTask = node.SendCommand(serialized); var response = JsonRpcResponse.FromJsonString(respTask.Result); // Blocking! if (response.Error != null) { _log.Warn($"Error uploading records: {response.Error.Message} (0x{response.Error.Code.ToString("x")})"); return new Guid[0]; } else { var result = ((JToken)response.Result).ToObject<Guid[]>(); _log.Info($"Uploaded {result.Length} result records successfully."); return result; } } catch (Exception x) { _log.Warn($"Error uploading records: {x.Message}"); return new Guid[0]; } }