static void sendInvalidCommandLineJsonResponse(string[] commandLineArguments) { var e = new MsmException("Invalid JSON Request Argument"); e.hint.message = "You must provide a valid JSON parameter as the ONLY argument when calling MSM"; e.hint.input = Newtonsoft.Json.JsonConvert.SerializeObject(commandLineArguments); e.hint.output = "Usage: MintySensorMonitor.exe {json:here}"; e.hint.result = "Example Usage: MintySensorMonitor.exe {help:true}"; sendInvalidJsonResponse(e); }
void logUnknownServiceRequested(MsmMonitorRequestParameters request) { var e = new MsmException("Sending an dummy request to MsmServiceExample for an example response"); log.Debug("Unknown Service Requested " + request.source); e.hint.message = "You must provide a valid 'source' within the MsmMonitorRequest"; e.hint.input = Newtonsoft.Json.JsonConvert.SerializeObject(request); e.hint.output = "@SOURCE#" + request.source; e.hint.result = "@EXAMPLE#" + Newtonsoft.Json.JsonConvert.SerializeObject(getExampleJson()); log.Debug(e); }
public MsmMonitorRequest(String json) { log.Debug("@JSON#" + json); type = GetType().Name; try { MsmMonitorRequestParameters data = Newtonsoft.Json.JsonConvert.DeserializeObject <MsmMonitorRequestParameters>(json); debugRequestJsonData(data); this.source = data.source; this.type = data.type; this.debug = data.debug; this.help = data.help; } catch (Exception exception) { log.Error("Unable to parse JSON request @JSON#" + json); var e = new MsmException("Unable to parse JSON request", exception); e.hint.message = "Your JSON parameter was malformed"; e.hint.input = Newtonsoft.Json.JsonConvert.SerializeObject(json); e.hint.output = e.Message; e.exception = e; log.Debug(e); } }
public static String processRequest(String json) { log.Info("MsmJniWrapper poll..."); if (json == null) { log.Debug("Invalid JSON request specified : @JSON#" + json); var e = new MsmException("Invalid JSON Request Argument"); e.hint.message = "You must provide a valid MSMRequest in a JSON format"; e.hint.input = Newtonsoft.Json.JsonConvert.SerializeObject(json); e.hint.output = "Usage: new MsmJniWrapper().poll({json:here})"; e.hint.result = "Example Usage: MsmJniWrapper().poll({debug:true})"; return(Newtonsoft.Json.JsonConvert.SerializeObject(e)); } else { try { var monitor = new MintySenorMonitor(new MsmMonitorRequest(json)); return(monitor.getSensorInfoAsJSON()); } catch (MsmException e) { log.Debug("@" + e.InnerException.Source + "#" + e.Message, e); return(Newtonsoft.Json.JsonConvert.SerializeObject(e)); } } }
static void sendInvalidJsonResponse(MsmException exception) { log.Debug(exception); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(exception)); }