123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- namespace comal.timesheets
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class EquipmentTasksList : ContentPage
- {
- List<EquipmentTaskListViewItem> items = new List<EquipmentTaskListViewItem>();
- Guid EquipmentID = Guid.Empty;
- public EquipmentTasksList(Guid equipmentid)
- {
- InitializeComponent();
- NavigationPage.SetHasBackButton(this, false);
- EquipmentID = equipmentid;
- }
- private void BackBtn_Clicked(object sender, EventArgs e)
- {
- Navigation.PopAsync();
- }
- protected override void OnAppearing()
- {
- LoadItems(EquipmentID);
- base.OnAppearing();
- }
- private void LoadItems(Guid id)
- {
- CoreTable table = new Client<Kanban>().Query(new Filter<Kanban>(x => x.Equipment.ID).IsEqualTo(id),
- new Columns<Kanban>(
- x => x.ID, //0
- x => x.Number, //1
- x => x.Title, //2
- x => x.Description, //3
- x => x.Completed, //4
- x => x.EmployeeLink.Name, //5
- x => x.Attachments //6
- ),
- new SortOrder<Kanban>(x => x.Completed, SortDirection.Descending));
- if (table.Rows.Any())
- {
- items.Clear();
- foreach (CoreRow row in table.Rows)
- {
- List<object> list = row.Values;
- if (list[0] == null) list[0] = Guid.Empty;
- if (list[1] == null) list[1] = 0;
- if (list[2] == null) list[2] = "";
- if (list[3] == null) list[3] = "";
- if (list[4] == null) list[4] = DateTime.MinValue;
- if (list[5] == null) list[5] = "";
- if (list[6] == null) list[6] = 0;
- EquipmentTaskListViewItem item = new EquipmentTaskListViewItem
- {
- ID = Guid.Parse(list[0].ToString()),
- Number = "Task " + list[1].ToString(),
- Title = list[2].ToString(),
- Description = CoreUtils.StripHTML(list[3].ToString()),
- Completed = DateTime.Parse(list[4].ToString()) == DateTime.MinValue ? "Open" : "Completed: " + DateTime.Parse(list[4].ToString()).ToString("dd MMM yy"),
- ImageVisible = int.Parse(list[6].ToString()) > 0,
- DescriptionVisible = !string.IsNullOrWhiteSpace(list[3].ToString()) ? true : false
- };
- if (!string.IsNullOrWhiteSpace(item.Description))
- {
- item.ExtraRowHeight = new GridLength(1, GridUnitType.Auto);
- item.DescriptionVisible = true;
- }
- item.ExtraColumnWidth = item.ImageVisible ? 35 : 0;
- if (item.Completed == "Open")
- items.Insert(0, item);
- else
- items.Add(item);
- }
- listView.ItemsSource = null;
- listView.ItemsSource = items;
- }
- }
- private async void Kanban_Tapped(object sender, EventArgs e)
- {
- EquipmentTaskListViewItem item = listView.SelectedItem as EquipmentTaskListViewItem;
- if (!item.ImageVisible)
- return;
- CoreTable table = new Client<KanbanDocument>().Query(new Filter<KanbanDocument>(x => x.EntityLink.ID).IsEqualTo(item.ID),
- new Columns<KanbanDocument>(x => x.DocumentLink.FileName, x => x.DocumentLink.ID));
- if (table.Rows.Any())
- {
- Dictionary<string, Guid> filenameIDS = new Dictionary<string, Guid>();
- foreach (CoreRow row in table.Rows)
- {
- List<object> list = row.Values;
- if (list[0] != null && list[1] != null)
- {
- filenameIDS.Add(list[0].ToString(), Guid.Parse(list[1].ToString()));
- }
- }
- if (filenameIDS.Count > 0)
- {
- PDFList pdflist = new PDFList(filenameIDS, true);
- Navigation.PushAsync(pdflist);
- }
- }
- }
- }
- public class EquipmentTaskListViewItem
- {
- public Guid ID { get; set; }
- public string Number { get; set; }
- public string Title { get; set; }
- public string Description { get; set; }
- public string Employee { get; set; }
- public string Completed { get; set; }
- public string ImageSource { get; set; }
- public bool ImageVisible { get; set; }
- public bool DescriptionVisible { get; set; }
- public double ExtraColumnWidth { get; set; }
- public GridLength ExtraRowHeight { get; set; }
- public EquipmentTaskListViewItem()
- {
- ID = Guid.Empty;
- Number = "";
- Title = "";
- Description = "";
- Employee = "";
- Completed = "";
- ImageSource = "paperclip.png";
- ImageVisible = false;
- DescriptionVisible = false;
- ExtraColumnWidth = 0;
- ExtraRowHeight = new GridLength(0, GridUnitType.Absolute);
- }
- }
- }
|