123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- using XF.Material.Forms.UI.Dialogs;
- namespace comal.timesheets
- {
-
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class EquipmentDetailsPage : BasePage
- {
- private EquipmentDetailModel _model = null;
-
- public EquipmentDetailsPage(Guid equipmentid)
- {
- InitializeComponent();
-
- _model = new EquipmentDetailModel(App.Data,
- () => new Filter<Equipment>(x => x.ID).IsEqualTo(equipmentid)
- , $"{equipmentid}.equipment");
- _model.Load(() => BindingContext = _model);
- }
-
- public EquipmentDetailsPage(EquipmentDetailModel model)
- {
- _model = model;
- InitializeComponent();
- BindingContext = model;
- }
- protected override void OnAppearing()
- {
- base.OnAppearing();
- App.Bluetooth.Disabled = true;
- }
- protected override void OnDisappearing()
- {
- App.Bluetooth.Disabled = false;
- base.OnDisappearing();
- }
-
- #region Button Presses
-
- private void ViewSpecificationSheet_Clicked(object sender, EventArgs e)
- {
- ImageViewer viewer = new ImageViewer(_model.Item.SpecificationSheet);
- Navigation.PushAsync(viewer);
- }
- private void ViewDocsBtn_Clicked(object sender, EventArgs e)
- {
- PDFList list = new PDFList() { Documents = _model.Documents, AllowPrintShare = true};
- Navigation.PushAsync(list);
- }
- private void ViewTasksBtn_Clicked(object sender, EventArgs e)
- {
- EquipmentTasksList equipmentTasksList = new EquipmentTasksList()
- {
- Equipment = _model
- };
- Navigation.PushAsync(equipmentTasksList);
- }
- private async void EditOpenTask_Click(object sender, EventArgs e)
- {
- Guid? kanbanid = ((sender as Button)?.CommandParameter as EquipmentKanbanShell)?.KanbanID;
- if (!kanbanid.HasValue)
- {
- await DisplayAlert("Error", "Cannot Find Kanban ID", "OK");
- return;
- }
- using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Loading"))
- {
- KanbanForm form = new KanbanForm();
- CoreTable formTable = new Client<KanbanForm>().Query(new Filter<KanbanForm>(x => x.Parent.ID).IsEqualTo(kanbanid));
- if (formTable.Rows.Any())
- {
- form = formTable.Rows.FirstOrDefault().ToObject<KanbanForm>();
- }
- if (form.ID == Guid.Empty)
- {
- DisplayAlert("Error", "No form found for this task - please check the task", "Cancel");
- return;
- }
- CoreTable table2 = new Client<DigitalFormLayout>().Query(
- new Filter<DigitalFormLayout>(x => x.Type).IsEqualTo(DFLayoutType.Mobile).And(x => x.Active).IsEqualTo(true).And(x => x.Form.Description).IsEqualTo(form.Form.Description),
- new Columns<DigitalFormLayout>(x => x.Description, x => x.ID, x => x.Code, x => x.Form.AppliesTo, x => x.Form.ID, x => x.Layout),
- new SortOrder<DigitalFormLayout>(x => x.Description)
- );
- if (table2.Rows.Any())
- {
- CoreRow row = table2.Rows.FirstOrDefault();
- DigitalFormLayout layout = row.ToObject<DigitalFormLayout>();
- }
- }
- }
-
- #endregion
- private async void UnlockKey()
- {
- String error = "";
- using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Please Wait..."))
- {
- String macaddress = "84:CC:A8:2E:95:8A";
- Guid service = Guid.Parse("7555408C-9414-EB46-C0AC-A72EB4CD80D8");
- Guid characteristic = Guid.Parse("432B917A-EB17-289B-285A-2657419B46C7");
- String key = "9ffe2145-f6c7-4f84-8908-d7003f237fe5";
- try
- {
- await App.Bluetooth.UnlockDigitalKey(
- macaddress,
- service,
- characteristic,
- key
- );
- }
- catch (Exception e)
- {
- error = e.Message;
- }
- }
- if (!String.IsNullOrWhiteSpace(error))
- await DisplayAlert("Error Unlocking Device!", error, "OK");
-
- }
- private async void DigitalKey_Tapped(object sender, EventArgs e)
- {
- UnlockKey();
- }
- }
- }
|