using Newtonsoft.Json; using Safedispatch_4_0; using SafeMobileLib; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Dispatcher.maptab { class ChromiumCallBack { /// /// Method intended to be called from the MapsAPI /// /// The address at which the public void callBackMethod(String addressURL) { if (OnCallBackMethodCalled != null) OnCallBackMethodCalled(addressURL); } public String getDisplayedVehicles(int offset, int count) { Utils.WriteLine("getDisplayedVehiclesCALLBACK", ConsoleColor.Red); List allDisplayedVehicles = new List(); try { var result = MainForm2.vehicleHT.Values.Cast().Where(d => d.is_displayed).OrderBy(d=> d.lastActivityTime).ThenBy(d => d.busName).ToList(); if (offset > result.Count) ; if (result.Count < offset + count) ; else if (result.Count > offset + count) result = result.GetRange(offset, count); else result = result.GetRange(offset, offset - count); String json = JsonConvert.SerializeObject(result); return json; } catch(Exception ex) { Utils.WriteLine("getDisplayedVehicles EXCEPTION: " + ex.ToString(), ConsoleColor.Red); } return ""; } public delegate void CallBackMethodCalled(String addressURL); public event CallBackMethodCalled OnCallBackMethodCalled; } }