// Get public JsonMarkerInfoReply GetMarkerInfo(string s) { var invalid = new JsonMarkerInfoReply { Ok = "0" }; if (string.IsNullOrWhiteSpace(s)) { invalid.EMsg = "params is empty"; return invalid; } var arr = s.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries); if (arr.Length < 1) return invalid; var nvc = new NameValueCollection(); foreach (var a in arr) { var kv = a.Split(new[] {"="}, StringSplitOptions.RemoveEmptyEntries); if (kv.Length != 2) continue; nvc.Add(kv[0], kv[1]); } foreach (var key in Ajax.MarkerInfoReq) { if (nvc[key]!=null) continue; invalid.EMsg = string.Format("param {0} is missing",key); return invalid; } try { var id = nvc[Ajax.id]; var sid = nvc[Ajax.sid] == null ? 1 : int.Parse(nvc[Ajax.sid]); // values are validated there return MarkerInfo(id,sid); } catch (Exception ex) { invalid.EMsg = string.Format("Parsing error param: {0}", ex.Message); } return invalid; }
// Post public JsonMarkerInfoReply MarkerInfo(string id, int sendid) { var sw = new Stopwatch(); sw.Start(); var uid = int.Parse(id); var marker = MemoryDatabase.GetPoints().Data.SingleOrDefault(i => i.I == uid); if(marker==null) { return new JsonMarkerInfoReply { Id = id, Content = "Marker could not be found", Rid = sendid, Msec = Sw(sw) }; } var reply = new JsonMarkerInfoReply { Rid = sendid, }; reply.BuildContent(marker); reply.Msec = Sw(sw); return reply; }