|
@@ -3,9 +3,11 @@ using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using System.ComponentModel;
|
|
|
using System.Drawing;
|
|
|
+using System.Globalization;
|
|
|
using System.Linq;
|
|
|
using System.Runtime.CompilerServices;
|
|
|
using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
using System.Windows.Input;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
using Comal.Classes;
|
|
@@ -13,6 +15,8 @@ using ExCSS;
|
|
|
using InABox.Clients;
|
|
|
using InABox.Configuration;
|
|
|
using InABox.Core;
|
|
|
+using InABox.DynamicGrid;
|
|
|
+using InABox.Wpf;
|
|
|
using InABox.WPF;
|
|
|
using Syncfusion.UI.Xaml.Diagram;
|
|
|
using Syncfusion.UI.Xaml.Maps;
|
|
@@ -21,113 +25,196 @@ using Point = System.Windows.Point;
|
|
|
|
|
|
namespace PRSDesktop;
|
|
|
|
|
|
-public class MapMarker
|
|
|
+public abstract class AbstractMapMarker
|
|
|
{
|
|
|
- public string Name { get; set; } = "Hi There";
|
|
|
public string Label { get; set; } = "";
|
|
|
public string Longitude { get; set; }
|
|
|
public string Latitude { get; set; }
|
|
|
}
|
|
|
|
|
|
+public class SiteMapMarker : AbstractMapMarker
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+public class AssetMapMarker : AbstractMapMarker { }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+public class GeoFenceImageConverter : AbstractConverter<GPSLocationType, BitmapImage?>
|
|
|
+{
|
|
|
+
|
|
|
+ private Dictionary<GPSLocationType, BitmapImage?> _images = new()
|
|
|
+ {
|
|
|
+ { GPSLocationType.Office, PRSDesktop.Resources.mapmarker.AsBitmapImage() },
|
|
|
+ { GPSLocationType.Supplier, PRSDesktop.Resources.supplier.AsBitmapImage() },
|
|
|
+ { GPSLocationType.Employee, PRSDesktop.Resources.employee.AsBitmapImage() },
|
|
|
+ { GPSLocationType.Job, PRSDesktop.Resources.project.AsBitmapImage() },
|
|
|
+ };
|
|
|
+
|
|
|
+ public override BitmapImage? Convert(GPSLocationType value)
|
|
|
+ {
|
|
|
+ if (_images.TryGetValue(value, out var image))
|
|
|
+ return image;
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
|
|
|
{
|
|
|
- private EquipmentGroup[]? _groups;
|
|
|
- private Equipment[]? _items;
|
|
|
- private EquipmentGroup? _selectedGroup;
|
|
|
- private string? _search;
|
|
|
+ private EquipmentGroup[]? _equipmentGroups;
|
|
|
+ private Equipment[]? _equipment;
|
|
|
+ private EquipmentGroup? _selectedEquipmentGroup;
|
|
|
+ private System.Tuple<GPSLocationType?, string> _selectedSiteType;
|
|
|
+ private GeoFence? _selectedSite;
|
|
|
+ private string? _equipmentSearch;
|
|
|
private DateTime _date = DateTime.Today;
|
|
|
- private Equipment? _selectedItem;
|
|
|
+ private Equipment? _selectedEquipment;
|
|
|
private ObservableCollection<Point>? _waypoints;
|
|
|
private Point _center;
|
|
|
private double _radius;
|
|
|
- private GeoFence[]? _geofences;
|
|
|
+ private GeoFence[]? _sites;
|
|
|
private ObservableCollection<MapElement> _elements;
|
|
|
- private ObservableCollection<MapMarker>? _sites;
|
|
|
-
|
|
|
- public EquipmentGroup[]? Groups
|
|
|
+ private ObservableCollection<AbstractMapMarker>? _markers;
|
|
|
+
|
|
|
+ #region Equipment
|
|
|
+
|
|
|
+ public EquipmentGroup[]? EquipmentGroups
|
|
|
{
|
|
|
- get => _groups;
|
|
|
- set => SetField(ref _groups, value);
|
|
|
+ get => _equipmentGroups;
|
|
|
+ set => SetField(ref _equipmentGroups, value);
|
|
|
}
|
|
|
|
|
|
- public EquipmentGroup? SelectedGroup
|
|
|
+ public EquipmentGroup? SelectedEquipmentGroup
|
|
|
{
|
|
|
- get => _selectedGroup;
|
|
|
+ get => _selectedEquipmentGroup;
|
|
|
set
|
|
|
{
|
|
|
- SetField(ref _selectedGroup, value);
|
|
|
- SelectedItem = null;
|
|
|
+ if (value == _selectedEquipmentGroup)
|
|
|
+ return;
|
|
|
+ SetField(ref _selectedEquipmentGroup, value);
|
|
|
+ SelectedEquipment = null;
|
|
|
SaveSettings();
|
|
|
- OnPropertyChanged(nameof(Visible));
|
|
|
+ OnPropertyChanged(nameof(VisibleEquipment));
|
|
|
+ ReloadLocations();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public Equipment[]? Items
|
|
|
+ public Equipment[]? Equipment
|
|
|
{
|
|
|
- get => _items;
|
|
|
- set => SetField(ref _items, value);
|
|
|
+ get => _equipment;
|
|
|
+ set => SetField(ref _equipment, value);
|
|
|
}
|
|
|
-
|
|
|
- public GeoFence[]? GeoFences
|
|
|
+
|
|
|
+ public string? EquipmentSearch
|
|
|
{
|
|
|
- get => _geofences;
|
|
|
+ get => _equipmentSearch;
|
|
|
set
|
|
|
{
|
|
|
- _fencesMap.Clear();
|
|
|
- if (value is not null)
|
|
|
+ SetField(ref _equipmentSearch, value);
|
|
|
+ OnPropertyChanged(nameof(VisibleEquipment));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Equipment[]? VisibleEquipment => Equipment?.Where(x =>
|
|
|
+ (
|
|
|
+ (Equals(SelectedEquipmentGroup?.ID,CoreUtils.FullGuid)
|
|
|
+ || Equals(x.GroupLink.ID,SelectedEquipmentGroup?.ID)
|
|
|
+ ) && (
|
|
|
+ string.IsNullOrEmpty(EquipmentSearch)
|
|
|
+ || x.Code.Contains(EquipmentSearch,StringComparison.CurrentCultureIgnoreCase)
|
|
|
+ || x.Description.Contains(EquipmentSearch,StringComparison.CurrentCultureIgnoreCase)
|
|
|
+ )
|
|
|
+ )).ToArray();
|
|
|
+
|
|
|
+ public Equipment? SelectedEquipment
|
|
|
+ {
|
|
|
+ get => _selectedEquipment;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetField(ref _selectedEquipment, value);
|
|
|
+ if (value != null)
|
|
|
{
|
|
|
- foreach (var fence in value ?? [])
|
|
|
- _fencesMap[fence] = Serialization.Deserialize<GeoFenceDefinition>(fence.Geofence) ?? new GeoFenceDefinition();
|
|
|
+ SelectedSite = null;
|
|
|
+ ReloadLocations();
|
|
|
}
|
|
|
- SetField(ref _geofences, value);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private Dictionary<GeoFence,GeoFenceDefinition> _fencesMap = new();
|
|
|
|
|
|
- public string? Search
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region Sites
|
|
|
+
|
|
|
+ public System.Tuple<GPSLocationType?, string>[] SiteTypes =>
|
|
|
+ [
|
|
|
+ new System.Tuple<GPSLocationType?, string>(null, "All Sites"),
|
|
|
+ new System.Tuple<GPSLocationType?, string>(GPSLocationType.Office, "Office Location"),
|
|
|
+ new System.Tuple<GPSLocationType?, string>(GPSLocationType.Job, "Job Sites"),
|
|
|
+ new System.Tuple<GPSLocationType?, string>(GPSLocationType.Supplier, "Suppliers")
|
|
|
+ ];
|
|
|
+
|
|
|
+ public System.Tuple<GPSLocationType?, string> SelectedSiteType
|
|
|
{
|
|
|
- get => _search;
|
|
|
+ get => _selectedSiteType;
|
|
|
set
|
|
|
{
|
|
|
- SetField(ref _search, value);
|
|
|
- OnPropertyChanged(nameof(Visible));
|
|
|
+ SetField(ref _selectedSiteType, value);
|
|
|
+ SaveSettings();
|
|
|
+ OnPropertyChanged(nameof(VisibleSites));
|
|
|
+ SelectedSite = null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public Equipment[]? Visible => Items?.Where(x =>
|
|
|
- x.GroupLink.ID == (SelectedGroup?.ID ?? CoreUtils.FullGuid)
|
|
|
- && (
|
|
|
- string.IsNullOrEmpty(Search)
|
|
|
- || x.Code.Contains(Search,StringComparison.CurrentCultureIgnoreCase)
|
|
|
- || x.Description.Contains(Search,StringComparison.CurrentCultureIgnoreCase)
|
|
|
- )
|
|
|
- ).ToArray();
|
|
|
-
|
|
|
-
|
|
|
- public DateTime Date
|
|
|
+ public GeoFence[]? Sites
|
|
|
{
|
|
|
- get => _date;
|
|
|
+ get => _sites;
|
|
|
set
|
|
|
{
|
|
|
- SetField(ref _date, value);
|
|
|
- ReloadLocations();
|
|
|
- OnPropertyChanged(nameof(Visible));
|
|
|
+ _sitesMap.Clear();
|
|
|
+ if (value is not null)
|
|
|
+ {
|
|
|
+ foreach (var site in value ?? [])
|
|
|
+ _sitesMap[site] = Serialization.Deserialize<GeoFenceDefinition>(site.Geofence) ?? new GeoFenceDefinition();
|
|
|
+ }
|
|
|
+ SetField(ref _sites, value);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public GeoFence[]? VisibleSites => Sites?
|
|
|
+ .Where(x => (_selectedSiteType?.Item1 == null) || Equals(x.Type, _selectedSiteType?.Item1))
|
|
|
+ .ToArray();
|
|
|
+
|
|
|
+
|
|
|
+ private Dictionary<GeoFence,GeoFenceDefinition> _sitesMap = new();
|
|
|
|
|
|
- public Equipment? SelectedItem
|
|
|
+ public GeoFence? SelectedSite
|
|
|
+ {
|
|
|
+ get => _selectedSite;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetField(ref _selectedSite, value);
|
|
|
+
|
|
|
+ if (value != null)
|
|
|
+ {
|
|
|
+ SelectedEquipment = null;
|
|
|
+ CenterMap(value, null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ public DateTime Date
|
|
|
{
|
|
|
- get => _selectedItem;
|
|
|
+ get => _date;
|
|
|
set
|
|
|
{
|
|
|
- SetField(ref _selectedItem, value);
|
|
|
+ SetField(ref _date, value);
|
|
|
ReloadLocations();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void CenterMap()
|
|
|
+ private void CenterMap(GeoFence? site, IEnumerable<Point>? points)
|
|
|
{
|
|
|
var nwLon = double.MaxValue;
|
|
|
var nwLat = double.MinValue;
|
|
@@ -135,18 +222,18 @@ public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
|
|
|
var seLat = double.MaxValue;
|
|
|
|
|
|
|
|
|
- var points = new List<Point>();
|
|
|
+ var allpoints = new List<Point>();
|
|
|
|
|
|
- if (_waypoints != null)
|
|
|
- points.AddRange(_waypoints);
|
|
|
+ if (points != null)
|
|
|
+ allpoints.AddRange(points);
|
|
|
|
|
|
- if (_geofences != null)
|
|
|
+ if (site != null)
|
|
|
{
|
|
|
- foreach (var geofence in _fencesMap.Where(x=>x.Key.Type == GPSLocationType.Office))
|
|
|
- points.AddRange(geofence.Value.Coordinates.Select(x => new Point(x.Latitude, x.Longitude)));
|
|
|
+ foreach (var fence in _sitesMap.Where(x=>x.Key == site))
|
|
|
+ allpoints.AddRange(fence.Value.Coordinates.Select(x => new Point(x.Latitude, x.Longitude)));
|
|
|
}
|
|
|
|
|
|
- foreach (var point in points)
|
|
|
+ foreach (var point in allpoints)
|
|
|
{
|
|
|
var lat = point.X;
|
|
|
var lon = point.Y;
|
|
@@ -165,13 +252,15 @@ public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
|
|
|
Center = new Point(cLat, cLon);
|
|
|
var c = new Location { Latitude = cLat, Longitude = cLon };
|
|
|
var nw = new Location { Latitude = nwLat, Longitude = nwLon };
|
|
|
- Radius = Math.Max(1.0, c.DistanceTo(nw, UnitOfLength.Kilometers) / 2.0F);
|
|
|
+ Radius = Math.Max(0.25, c.DistanceTo(nw, UnitOfLength.Kilometers) / 2.0F);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void ReloadLocations()
|
|
|
{
|
|
|
- var trackerids = Visible?.Select(x => x.TrackerLink.ID).ToArray() ?? [];
|
|
|
+ var trackerids = VisibleEquipment?.Select(x => x.TrackerLink.ID).ToArray() ?? [];
|
|
|
+ var selected = SelectedEquipment?.TrackerLink.ID ?? CoreUtils.FullGuid;
|
|
|
+
|
|
|
Client.Query(
|
|
|
new Filter<GPSTrackerLocation>(x=>x.Tracker.ID).InList(trackerids)
|
|
|
.And(x => x.Location.Timestamp).IsGreaterThanOrEqualTo(Date.Date)
|
|
@@ -187,50 +276,66 @@ public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
|
|
|
{
|
|
|
Dispatcher.BeginInvoke(() =>
|
|
|
{
|
|
|
- Point[]? others = null;
|
|
|
+ GPSTrackerLocation[] pings = [];
|
|
|
if (data is null)
|
|
|
{
|
|
|
- EquipmentColorConverter.Pings = [];
|
|
|
+ EquipmentColorConverter.Pings = pings;
|
|
|
Waypoints = null;
|
|
|
- Sites = null;
|
|
|
+ Markers = null;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- EquipmentColorConverter.Pings = data.ToArray<GPSTrackerLocation>();
|
|
|
- others = data.Rows
|
|
|
- .Where(r => r.Get<GPSTrackerLocation,Guid>(c=>c.Tracker.ID) != (SelectedItem?.TrackerLink.ID ?? CoreUtils.FullGuid))
|
|
|
- .Select(r => new Point()
|
|
|
+ List<AbstractMapMarker> markers = new();
|
|
|
+
|
|
|
+ pings = data.ToArray<GPSTrackerLocation>();
|
|
|
+ EquipmentColorConverter.Pings = pings;
|
|
|
+
|
|
|
+ var otherassets = pings
|
|
|
+ .Where(x=>x.Tracker.ID != selected)
|
|
|
+ .GroupBy(x => x.Tracker.ID)
|
|
|
+ .Where(x=>x.Any())
|
|
|
+ .Select(x=>x.Last()
|
|
|
+ );
|
|
|
+
|
|
|
+ var assetmarkers = new List<AssetMapMarker>();
|
|
|
+
|
|
|
+ foreach (var asset in otherassets)
|
|
|
+ {
|
|
|
+ var eq = _equipment?.FirstOrDefault(e=>e.TrackerLink.ID == asset.Tracker.ID);
|
|
|
+ if (eq != null)
|
|
|
+ {
|
|
|
+ var marker = new AssetMapMarker()
|
|
|
{
|
|
|
- X = r.Get<GPSTrackerLocation, double>(c => c.Location.Latitude),
|
|
|
- Y = r.Get<GPSTrackerLocation, double>(c => c.Location.Longitude)
|
|
|
- }
|
|
|
- ).ToArray();
|
|
|
+ Latitude = $"{asset.Location.Latitude}",
|
|
|
+ Longitude = $"{asset.Location.Longitude}",
|
|
|
+ Label = $"{eq.Code}\n{eq.Description}\nLast seen: {asset.Location.Timestamp}"
|
|
|
+ };
|
|
|
+ markers.Add(marker);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var waypoints = pings
|
|
|
+ .Where(x => x.Tracker.ID == selected)
|
|
|
+ .ToArray();
|
|
|
|
|
|
- var locations = data.Rows
|
|
|
- .Where(r => r.Get<GPSTrackerLocation,Guid>(c=>c.Tracker.ID) == (SelectedItem?.TrackerLink.ID ?? CoreUtils.FullGuid))
|
|
|
- .Select(r => new Point(
|
|
|
- r.Get<GPSTrackerLocation, double>(c => c.Location.Latitude),
|
|
|
- r.Get<GPSTrackerLocation, double>(c => c.Location.Longitude)
|
|
|
- )
|
|
|
- )?.ToArray() ?? [];
|
|
|
- Waypoints = new ObservableCollection<Point>(locations);
|
|
|
+ Waypoints = new ObservableCollection<Point>(waypoints.Select(x => new Point(x.Location.Latitude, x.Location.Longitude)));
|
|
|
|
|
|
- Dictionary<GeoFence, MapMarker> sites = new Dictionary<GeoFence, MapMarker>();
|
|
|
+ var sites = new Dictionary<GeoFence, SiteMapMarker>();
|
|
|
GeoFence? curFence = null;
|
|
|
|
|
|
- foreach (var row in data.Rows.Where(r => r.Get<GPSTrackerLocation,Guid>(c=>c.Tracker.ID) == (SelectedItem?.TrackerLink.ID ?? CoreUtils.FullGuid)))
|
|
|
+ foreach (var waypoint in waypoints)
|
|
|
{
|
|
|
- var time = $"{row.Get<GPSTrackerLocation, DateTime>(c => c.Location.Timestamp):h:mm tt}";
|
|
|
- var geopoint = new GeoPoint(row.Get<GPSTrackerLocation, double>(c => c.Location.Latitude), row.Get<GPSTrackerLocation, double>(c => c.Location.Longitude));
|
|
|
+ var time = $"{waypoint.Location.Timestamp:h:mm tt}";
|
|
|
+ var geopoint = new GeoPoint(waypoint.Location.Latitude, waypoint.Location.Longitude);
|
|
|
bool bFound = false;
|
|
|
|
|
|
- foreach (var geofence in _fencesMap)
|
|
|
+ foreach (var geofence in _sitesMap)
|
|
|
{
|
|
|
|
|
|
if (geofence.Value.Contains(geopoint))
|
|
|
{
|
|
|
if (!sites.ContainsKey(geofence.Key))
|
|
|
- sites[geofence.Key] = new MapMarker()
|
|
|
+ sites[geofence.Key] = new SiteMapMarker()
|
|
|
{
|
|
|
Latitude = $"{geopoint.Latitude}",
|
|
|
Longitude = $"{geopoint.Longitude}"
|
|
@@ -250,7 +355,7 @@ public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
|
|
|
}
|
|
|
else
|
|
|
timelist.Add($"{time} - {time}");
|
|
|
-
|
|
|
+
|
|
|
sites[geofence.Key].Label = string.Join("\n", timelist);
|
|
|
curFence = geofence.Key;
|
|
|
bFound = true;
|
|
@@ -260,12 +365,13 @@ public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
|
|
|
if (!bFound)
|
|
|
curFence = null;
|
|
|
}
|
|
|
- Sites = new ObservableCollection<MapMarker>(sites.Values);
|
|
|
-
|
|
|
+ markers.AddRange(sites.Values);
|
|
|
+
|
|
|
+ Markers = new ObservableCollection<AbstractMapMarker>(markers);
|
|
|
}
|
|
|
- OnPropertyChanged(nameof(Visible));
|
|
|
- RecalculateLayers(others);
|
|
|
- CenterMap();
|
|
|
+ OnPropertyChanged(nameof(VisibleEquipment));
|
|
|
+ RecalculateLayers();
|
|
|
+ CenterMap(_sites?.FirstOrDefault(x=>x.Type == GPSLocationType.Office), pings.Select(x=>new Point(x.Location.Latitude, x.Location.Longitude)));
|
|
|
});
|
|
|
}
|
|
|
);
|
|
@@ -278,12 +384,12 @@ public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
|
|
|
set => SetField(ref _elements, value);
|
|
|
}
|
|
|
|
|
|
- private void RecalculateLayers(Point[]? markers)
|
|
|
+ private void RecalculateLayers()
|
|
|
{
|
|
|
var elements = new ObservableCollection<MapElement>();
|
|
|
- if (_geofences?.Any() == true)
|
|
|
+ if (_sites?.Any() == true)
|
|
|
{
|
|
|
- foreach (var geofence in _geofences)
|
|
|
+ foreach (var geofence in _sites)
|
|
|
{
|
|
|
var definition = Serialization.Deserialize<GeoFenceDefinition>(geofence.Geofence) ?? new GeoFenceDefinition();
|
|
|
var polygon = new MapPolygon()
|
|
@@ -300,23 +406,7 @@ public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (markers?.Any() == true)
|
|
|
- {
|
|
|
- foreach (var marker in markers.Distinct())
|
|
|
- {
|
|
|
- var circle = new MapCircle()
|
|
|
- {
|
|
|
- Center = marker,
|
|
|
- Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Magenta) { Opacity = 0.2 },
|
|
|
- Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black),
|
|
|
- StrokeThickness = 0,
|
|
|
- Radius = 10
|
|
|
- };
|
|
|
- elements.Add(circle);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
if (_waypoints?.Any( ) == true)
|
|
|
{
|
|
|
var line = new MapPolyline()
|
|
@@ -357,10 +447,10 @@ public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
|
|
|
|
|
|
public ICommand RefreshCommand { get; set; }
|
|
|
|
|
|
- public ObservableCollection<MapMarker>? Sites
|
|
|
+ public ObservableCollection<AbstractMapMarker>? Markers
|
|
|
{
|
|
|
- get => _sites;
|
|
|
- set => SetField(ref _sites, value);
|
|
|
+ get => _markers;
|
|
|
+ set => SetField(ref _markers, value);
|
|
|
}
|
|
|
|
|
|
public ObservableCollection<Point>? Waypoints
|
|
@@ -390,13 +480,18 @@ public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
|
|
|
|
|
|
public void SaveSettings()
|
|
|
{
|
|
|
- Settings.GroupID = _selectedGroup?.ID ?? Guid.Empty;
|
|
|
- Settings.ItemID = _selectedItem?.ID ?? Guid.Empty;
|
|
|
+ if (bRefreshing)
|
|
|
+ return;
|
|
|
+ Settings.GeofenceType = _selectedSiteType.Item1;
|
|
|
+ Settings.GroupID = _selectedEquipmentGroup?.ID ?? Guid.Empty;
|
|
|
new UserConfiguration<LiveMapsSettings>().Save(Settings);
|
|
|
}
|
|
|
|
|
|
+ private bool bRefreshing = false;
|
|
|
+
|
|
|
public void Refresh()
|
|
|
{
|
|
|
+
|
|
|
MultiQuery query = new MultiQuery();
|
|
|
|
|
|
query.Add(new Filter<GeoFence>().All());
|
|
@@ -421,6 +516,7 @@ public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
|
|
|
.Add(x=>x.GroupLink.Thumbnail.ID)
|
|
|
.Add(x=>x.TrackerLink.ID)
|
|
|
.Add(x=>x.TrackerLink.Location.Timestamp)
|
|
|
+ .Add(x=>x.TrackerLink.Location.Address)
|
|
|
.Add(x=>x.TrackerLink.DeviceID)
|
|
|
.Add(x=>x.TrackerLink.BatteryLevel)
|
|
|
);
|
|
@@ -428,6 +524,7 @@ public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
|
|
|
{
|
|
|
Dispatcher.BeginInvoke(() =>
|
|
|
{
|
|
|
+ bRefreshing = true;
|
|
|
foreach (var row in query.Get<Document>().Rows)
|
|
|
{
|
|
|
var img = ImageUtils.LoadImage(row.Get<Document, byte[]>(x => x.Data));
|
|
@@ -436,11 +533,20 @@ public class LiveMapsPanelViewModel : DependencyObject, INotifyPropertyChanged
|
|
|
// EquipmentThumbnailConverter.Cache = query.Get<Document>()
|
|
|
// .ToDictionary<Document, Guid, BitmapImage?>(x => x.ID,
|
|
|
// x => ImageUtils.LoadImage(x.Data));
|
|
|
- GeoFences = query.Get<GeoFence>().ToArray<GeoFence>();
|
|
|
- Groups = query.Get<EquipmentGroup>().ToArray<EquipmentGroup>();
|
|
|
- SelectedGroup = _groups?.FirstOrDefault(x=>x.ID == _selectedGroup?.ID);
|
|
|
- Items = query.Get<Equipment>().ToArray<Equipment>();
|
|
|
- SelectedItem = _items?.FirstOrDefault(x=>x.ID == _selectedItem?.ID);
|
|
|
+ Sites = query.Get<GeoFence>().ToArray<GeoFence>();
|
|
|
+ SelectedSiteType = SiteTypes.FirstOrDefault(x => x.Item1 == Settings.GeofenceType) ?? SiteTypes.First();
|
|
|
+ SelectedSite = null;
|
|
|
+
|
|
|
+ var groups = query.Get<EquipmentGroup>().ToList<EquipmentGroup>();
|
|
|
+ groups.Insert(0,new EquipmentGroup() { ID = CoreUtils.FullGuid, Description="(All Groups)"});
|
|
|
+ EquipmentGroups = groups.ToArray();
|
|
|
+ SelectedEquipmentGroup = EquipmentGroups?.FirstOrDefault(x=>x.ID == Settings.GroupID);
|
|
|
+
|
|
|
+ Equipment = query.Get<Equipment>().ToArray<Equipment>();
|
|
|
+ SelectedEquipment = null;
|
|
|
+
|
|
|
+ bRefreshing = false;
|
|
|
+ ReloadLocations();
|
|
|
});
|
|
|
});
|
|
|
}
|