public void updateCurrentLoc() { var _context = new Context(); var readings = new List<GPSReading>(); try { readings = _context.GPSReadings.ToList(); } catch (Exception e) { Trace.WriteLine("exception thrown when reading gps readings from context! "); } var lulist = new List<locupdate>(); foreach (GPSReading reading in readings) { var lu = new locupdate { RouteNumber = reading.RouteNumber, Address = reading.Address }; lulist.Add(lu); } string json = JsonConvert.SerializeObject(lulist); Clients.updatelocs(json); }
public static void Update() { var _context = new Context(); List<SMJob> smjobs = _context.SMJobs.ToList(); //Trace.WriteLine("smjobs count = "+ smjobs.Count); IHubContext hub2 = GlobalHost.ConnectionManager.GetHubContext<Smjob>(); string json2 = JsonConvert.SerializeObject(smjobs); hub2.Clients.update(json2); List<GPSReading> readings = _context.GPSReadings.ToList(); var lulist = new List<locupdate>(); foreach (GPSReading reading in readings) { var lu = new locupdate { RouteNumber = reading.RouteNumber, Address = reading.Address }; //Trace.WriteLine("rn =" + lu.RouteNumber); lulist.Add(lu); } string json = JsonConvert.SerializeObject(lulist); hub2.Clients.updatelocs(json); }