12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Xamarin.Forms;
- using Comal.Classes;
- using InABox.Core;
- using InABox.Clients;
- using System.Threading.Tasks;
- using XF.Material.Forms.UI.Dialogs;
- namespace comal.timesheets
- {
- public class EquipmentModel
- {
- public string ID { get; set; }
- public String Description { get; set; }
- }
- public partial class BTInfoPage : ContentPage
- {
- public BTInfoPage()
- {
- InitializeComponent();
- NavigationPage.SetHasBackButton(this, false);
- ToolbarItems.Clear();
- ToolbarItems.Add(new ToolbarItem("Back", "", () =>
- {
- Navigation.PopAsync();
- }));
- Title = "Site Equipment";
- TimeStamp.Text = String.Format("{0:dd/MM/yy hh:mm:ss tt}", App.Bluetooth,TimeStamp);
-
- }
- protected override async void OnAppearing()
- {
- base.OnAppearing();
- await LoadData();
- }
- private async Task LoadData()
- {
- using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Loading Data"))
- {
- List<EquipmentModel> equipmodels = new List<EquipmentModel>();
- CoreTable trackers = new Client<GPSTracker>().Query(null, new Columns<GPSTracker>(x => x.ID, x => x.DeviceID), null);
- CoreTable equip = new Client<Equipment>().Query(
- new Filter<Equipment>(x => x.TrackerLink.ID).IsNotEqualTo(Guid.Empty),
- new Columns<Equipment>(x => x.TrackerLink.ID, x => x.Code, x => x.Description),
- new SortOrder<Equipment>(x => x.Code)
- );
- if (App.Bluetooth.Devices != null)
- {
- foreach (String id in App.Bluetooth.Devices)
- //foreach (DataRow tracker in trackers.Rows)
- {
- CoreRow tracker = trackers.Rows.FirstOrDefault(r => r.Get<GPSTrackerLocation, String>(x => x.DeviceID) == id);
- if (tracker != null)
- {
- EquipmentModel model = new EquipmentModel()
- {
- ID = id,
- Description = "Unallocated"
- };
- CoreRow equiprow = equip.Rows.FirstOrDefault(r => r.Get<Equipment, Guid>(x => x.TrackerLink.ID) == tracker.Get<GPSTracker, Guid>(x => x.ID));
- if (equiprow != null)
- model.Description = equiprow.Get<Equipment, String>(x => x.Description);
- equipmodels.Add(model);
- }
- }
- }
- Device.BeginInvokeOnMainThread(
- () =>
- {
- EquipList.ItemsSource = null;
- EquipList.ItemsSource = equipmodels;
- }
- );
- }
- }
- }
- }
|