| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- using System;
- using System.Collections.ObjectModel;
- using System.Drawing;
- using Comal.Classes;
- using InABox.Core;
- using InABox.Mobile;
- using Color = Xamarin.Forms.Color;
- namespace PRS.Mobile
- {
- public class AssignmentShell : Shell<AssignmentModel, Assignment>
- {
- protected override void ConfigureColumns(ShellColumns<AssignmentModel, Assignment> columns)
- {
- columns
- .Map(nameof(EmployeeID), x => x.EmployeeLink.ID)
- .Map(nameof(Number), x => x.Number)
- .Map(nameof(Title), x => x.Title)
- .Map(nameof(Description), x => x.Description)
- .Map(nameof(Date), x => x.Date)
- .Map(nameof(BookedStart), x => x.Booked.Start)
- .Map(nameof(BookedDuration), x => x.Booked.Duration)
- .Map(nameof(BookedFinish), x => x.Booked.Finish)
- .Map(nameof(ActualStart), x => x.Actual.Start)
- .Map(nameof(ActualDuration), x => x.Actual.Duration)
- .Map(nameof(ActualFinish), x => x.Actual.Finish)
- .Map(nameof(Completed), x => x.Completed)
- .Map(nameof(JobID), x => x.JobLink.ID)
- .Map(nameof(JobNumber), x => x.JobLink.JobNumber)
- .Map(nameof(JobName), x => x.JobLink.Name)
- .Map(nameof(Latitude), x => x.JobLink.SiteAddress.Location.Latitude)
- .Map(nameof(Longitude), x => x.JobLink.SiteAddress.Location.Longitude)
- .Map(nameof(TaskID), x => x.Task.ID)
- .Map(nameof(TaskNumber), x => x.Task.Number)
- .Map(nameof(TaskName), x => x.Task.Title)
- .Map(nameof(ActivityID), x => x.ActivityLink.ID)
- .Map(nameof(ActivityCode), x => x.ActivityLink.Code)
- .Map(nameof(ActivityDescription), x => x.ActivityLink.Description)
- .Map(nameof(ActivityColor), x => x.ActivityLink.Color)
- .Map(nameof(DeliveryID), x => x.Delivery.ID);
- }
- public String Title
- {
- get => Get<String>();
- set => Set(value);
- }
-
- public Guid EmployeeID
- {
- get => Get<Guid>();
- set => Set(value);
- }
-
- public int Number
- {
- get => Get<int>();
- set => Set(value);
- }
- public String Description
- {
- get => Get<String>();
- set => Set(value);
- }
-
- public double Latitude
- {
- get => Get<double>();
- set => Set(value);
- }
-
- public double Longitude
- {
- get => Get<double>();
- set => Set(value);
- }
- public DateTime Completed
- {
- get => Get<DateTime>();
- set => Set(value);
- }
- public Guid DeliveryID
- => Get<Guid>();
-
- #region Date & Time
- public DateTime Date
- {
- get => Get<DateTime>();
- set => Set(value);
- }
- public TimeSpan ActualStart
- {
- get => Get<TimeSpan>();
- set => Set(value);
- }
- public TimeSpan ActualDuration
- {
- get => Get<TimeSpan>();
- set => Set(value);
- }
-
- public TimeSpan ActualFinish
- {
- get => Get<TimeSpan>();
- set => Set(value);
- }
- public TimeSpan BookedStart
- {
- get => Get<TimeSpan>();
- set => Set(value);
- }
- public TimeSpan BookedDuration
- {
- get => Get<TimeSpan>();
- set => Set(value);
- }
- public TimeSpan BookedFinish
- {
- get => Get<TimeSpan>();
- set => Set(value);
- }
-
- #endregion
-
- #region Job Settings
-
- public Guid JobID
- {
- get => Get<Guid>();
- set => Set(value);
- }
-
- public String JobNumber
- {
- get => Get<String>();
- set
- {
- Set(value,false);
- DoPropertyChanged(nameof(JobDisplay));
- }
- }
-
- public String JobName
- {
- get => Get<String>();
- set
- {
- Set(value,false);
- DoPropertyChanged(nameof(JobDisplay));
- }
- }
-
- #endregion
-
- #region Task Settings
-
- public Guid TaskID
- {
- get => Get<Guid>();
- set => Set(value);
- }
-
- public int TaskNumber
- {
- get => Get<int>();
- set
- {
- Set(value,false);
- DoPropertyChanged(nameof(TaskDisplay));
- }
- }
-
- public String TaskName
- {
- get => Get<String>();
- set
- {
- Set(value,false);
- DoPropertyChanged(nameof(TaskDisplay));
- }
- }
-
- #endregion
-
- #region Activity Code
-
- public Guid ActivityID
- {
- get => Get<Guid>();
- set => Set(value);
- }
-
- public String ActivityCode
- {
- get => Get<String>();
- set
- {
- Set(value,false);
- DoPropertyChanged(nameof(ActivityDisplay));
- }
- }
-
- public String ActivityDescription
- {
- get => Get<String>();
- set
- {
- Set(value,false);
- DoPropertyChanged(nameof(ActivityDisplay));
- }
- }
-
- public String ActivityColor
- {
- get => Get<String>();
- set
- {
- Set(value,false);
- DoPropertyChanged(nameof(ActivityDisplay));
- }
- }
-
- #endregion
- #region Calculated Fields
-
- public String JobDisplay => JobID != Guid.Empty
- ? $"{JobNumber}: {JobName}"
- : "(No Job Selected)";
-
- public String ActivityDisplay => ActivityID != Guid.Empty
- ? $"{ActivityCode}: {ActivityDescription}"
- : "(No Activity Selected)";
-
- public String TaskDisplay => TaskID != Guid.Empty
- ? $"{TaskNumber}: {TaskName}"
- : "(No Task Selected)";
-
- public String Subject => string.Format("{0}{1} {2}",
- Number,
- JobID != Guid.Empty ? $"({JobNumber})" : "",
- Title
- );
-
- public bool IsCompleted => !Completed.IsEmpty();
-
- public DateTime StartTime => Date.Add(Assignment.EffectiveTime(ActualStart, BookedStart).Floor(TimeSpan.FromMinutes(5)));
- public DateTime EndTime => Date.Add(Assignment.EffectiveTime(ActualFinish, BookedFinish).Ceiling(TimeSpan.FromMinutes(5)));
-
- public Color BackgroundColor => !String.IsNullOrWhiteSpace(ActivityColor)
- ? Color.FromHex(ActivityColor)
- : Color.Silver;
-
- public Color TextColor => Color.Black;
-
- public ObservableCollection<object> ResourceIds => new ObservableCollection<object>() { EmployeeID };
-
- public PointF Coordinates => new PointF(
- (float)(Longitude),
- (float)(Latitude)
- );
-
- #endregion
-
- }
- }
|