using System; using InABox.Core; namespace Comal.Classes { [UserTracking("GPS Tracking")] public class GPSTracker : Entity, IPersistent, IRemotable, ILicense, IExportable, IImportable { [EditorSequence(1)] [UniqueCodeEditor(Editable = Editable.Enabled)] public string DeviceID { get; set; } [EditorSequence(2)] [TextBoxEditor] public string Description { get; set; } [EditorSequence(3)] [EntityRelationship(DeleteAction.SetNull)] public GPSTrackerTypeLink Type { get; set; } [EditorSequence(4)] [EnumLookupEditor(typeof(GPSTrackerDeviceType), LookupWidth = 150)] public GPSTrackerDeviceType DeviceType { get; set; } [EditorSequence(5)] [DurationEditor] [Caption("Min Time")] public TimeSpan TimeThreshold { get; set; } [EditorSequence(6)] [IntegerEditor] [Caption("Min Distance (m)")] public int DistanceThreshhold { get; set; } [EditorSequence(7)] [EntityRelationship(DeleteAction.SetNull)] public EquipmentLink Equipment { get; set; } [EditorSequence(8)] [EntityRelationship(DeleteAction.SetNull)] public JobTrackerLink JobTracker { get; set; } [EditorSequence("Additional", 1)] [DoubleEditor] public double BatteryLevel { get; set; } [EditorSequence("Additional", 2)] [DoubleEditor] public double Hours { get; set; } [EditorSequence("Additional", 3)] [DoubleEditor] public double Distance { get; set; } [EditorSequence("Additional", 4)] [DoubleEditor] public double Counter1 { get; set; } [EditorSequence("Additional", 5)] [DoubleEditor] public double Counter2 { get; set; } [EditorSequence("Additional", 6)] [DoubleEditor] public double Counter3 { get; set; } [EditorSequence("Additional", 7)] [DoubleEditor] public double Counter4 { get; set; } [EditorSequence("Additional", 8)] [DoubleEditor] public double Counter5 { get; set; } public Location Location { get; set; } protected override void Init() { base.Init(); DeviceType = GPSTrackerDeviceType.Unknown; DistanceThreshhold = 100; TimeThreshold = new TimeSpan(0, 2, 0); Location = new Location(); Equipment = new EquipmentLink(); JobTracker = new JobTrackerLink(); Type = new GPSTrackerTypeLink(); } public override string ToString() { return string.Format("{0}: {1} ({2})", DeviceID, Description, DeviceType); } protected override void DoPropertyChanged(string name, object before, object after) { base.DoPropertyChanged(name, before, after); if (string.Equals(name, "DeviceType")) { DistanceThreshhold = GPSTrackerDeviceDefaults.Distance[(GPSTrackerDeviceType)after]; TimeThreshold = GPSTrackerDeviceDefaults.Time[(GPSTrackerDeviceType)after]; } } } }