// /blink1/input/file -- Add and Start File watcher on given filepath static string Ublink1InputFile(HttpRequest request, Blink1Server blink1Server) { string pname = request.Query.Get("pname"); string iname = request.Query.Get("iname"); string fpath = request.Query.Get("arg1").Trim(); string test = request.Query.Get("test"); if (pname == null) { pname = iname; } Boolean testmode = (test == null) ? false : (test.Equals("on") || test.Equals("true")); string statusstr = "must specifiy 'iname' and 'arg1' (filepath)"; Blink1Input input = null; if (fpath != null && iname != null) { statusstr = "input file"; input = new Blink1Input(blink1Server, iname, pname, "file", fpath); input.updateFileInput(); if (!testmode) { blink1Server.inputs[iname] = input; // NOTE: this replaces input if already exists } } blink1Server.saveSettings(); Dictionary <string, object> result = new Dictionary <string, object>(); result.Add("status", statusstr); result.Add("input", input); return(JsonConvert.SerializeObject(result, Formatting.Indented, jsonSerializerSettings)); }
// /blink1/input/file -- Add and Start File watcher on given filepath static string Ublink1InputFile(HttpRequest request, Blink1Server blink1Server) { string pname = request.Query.Get("pname"); string iname = request.Query.Get("iname"); string fpath = request.Query.Get("arg1").Trim(); string test = request.Query.Get("test"); if (pname == null) pname = iname; Boolean testmode = (test == null) ? false : (test.Equals("on") || test.Equals("true")); string statusstr = "must specifiy 'iname' and 'arg1' (filepath)"; Blink1Input input = null; if (fpath != null && iname != null) { statusstr = "input file"; input = new Blink1Input(blink1Server, iname, pname, "file", fpath); input.updateFileInput(); if (!testmode) { blink1Server.inputs[iname] = input; // NOTE: this replaces input if already exists } } blink1Server.saveSettings(); Dictionary<string, object> result = new Dictionary<string, object>(); result.Add("status", statusstr); result.Add("input", input); return JsonConvert.SerializeObject(result, Formatting.Indented, jsonSerializerSettings); }