58 lines
1.8 KiB
C#
58 lines
1.8 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// Method intended to be called from the MapsAPI
|
|
/// </summary>
|
|
/// <param name="addressURL">The address at which the </param>
|
|
public void callBackMethod(String addressURL)
|
|
{
|
|
if (OnCallBackMethodCalled != null)
|
|
OnCallBackMethodCalled(addressURL);
|
|
}
|
|
|
|
|
|
public String getDisplayedVehicles(int offset, int count)
|
|
{
|
|
Utils.WriteLine("getDisplayedVehiclesCALLBACK", ConsoleColor.Red);
|
|
|
|
List<Vehicle> allDisplayedVehicles = new List<Vehicle>();
|
|
try
|
|
{
|
|
var result = MainForm2.vehicleHT.Values.Cast<Vehicle>().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;
|
|
}
|
|
}
|