| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Linq.Expressions;
 
- using InABox.Core;
 
- namespace Comal.Classes
 
- {
 
-     [Caption("Roster")]
 
-     public class EmployeeRoster : Entity, IRemotable, IPersistent, INumericAutoIncrement<EmployeeRoster>, IOneToMany<Employee>,
 
-         ILicense<TimeManagementLicense>
 
-     {
 
-         private static readonly Dictionary<string, Func<EmployeeRoster, TimeSpan>> times = new  Dictionary<string, Func<EmployeeRoster, TimeSpan>>()
 
-         {
 
-             { "Start", x => x.Start },
 
-             { "Finish", x => x.Finish },
 
-             { "Break", x => x.Break },
 
-             { "Start2", x => x.Start2 },
 
-             { "Finish2", x => x.Finish2 },
 
-             { "Break2", x => x.Break2 }
 
-         };
 
-         [NullEditor]
 
-         public EmployeeLink Employee { get; set; }
 
-         [IntegerEditor(Alignment = Alignment.MiddleCenter, Editable = Editable.Disabled)]
 
-         [EditorSequence(1)]
 
-         [Caption("Day")]
 
-         public int Day { get; set; }
 
-         [TextBoxEditor(Editable = Editable.Disabled, Width = 150)]
 
-         [EditorSequence(2)]
 
-         public string Description { get; set; }
 
-         [CheckBoxEditor]
 
-         [EditorSequence(3)]
 
-         [Caption("Rostered On?")]
 
-         public bool Enabled { get; set; }
 
-         [TimeOfDayEditor(Format = "hh:mm", Width = 70)]
 
-         [EditorSequence(4)]
 
-         public TimeSpan Start { get; set; }
 
-         [TimeOfDayEditor(Format = "hh:mm", Width = 70)]
 
-         [EditorSequence(5)]
 
-         public TimeSpan Finish { get; set; }
 
-         [DurationEditor(Format = "hh:mm", Visible = Visible.Default, Editable = Editable.Enabled, Width = 70)]
 
-         [EditorSequence(6)]
 
-         public TimeSpan Break { get; set; }
 
-         [CheckBoxEditor]
 
-         [EditorSequence(7)]
 
-         [Caption("Split")]
 
-         public bool SplitShift { get; set; }
 
-         [TimeOfDayEditor(Format = "hh:mm", Width = 70)]
 
-         [EditorSequence(8)]
 
-         [Caption("Start 2")]
 
-         public TimeSpan Start2 { get; set; }
 
-         [TimeOfDayEditor(Format = "hh:mm", Width = 70)]
 
-         [EditorSequence(9)]
 
-         [Caption("Finish 2")]
 
-         public TimeSpan Finish2 { get; set; }
 
-         [DurationEditor(Format = "hh:mm", Visible = Visible.Default, Editable = Editable.Enabled, Width = 70)]
 
-         [EditorSequence(10)]
 
-         [Caption("Break 2")]
 
-         public TimeSpan Break2 { get; set; }
 
-         [EditorSequence(11)]
 
-         public EmployeeActivityLink UsualActivity { get; set; }
 
-         [DoubleEditor(Format = "F2", Visible = Visible.Default, Editable = Editable.Disabled, Summary = Summary.Sum, Width = 70,
 
-             Alignment = Alignment.MiddleCenter)]
 
-         [EditorSequence(12)]
 
-         [Caption("Total")]
 
-         public double Duration { get; set; }
 
-         public Expression<Func<EmployeeRoster, int>> AutoIncrementField()
 
-         {
 
-             return x => x.Day;
 
-         }
 
-         public Filter<EmployeeRoster> AutoIncrementFilter()
 
-         {
 
-             return new Filter<EmployeeRoster>(x => x.Employee.ID).IsEqualTo(Employee.ID);
 
-         }
 
-         protected override void Init()
 
-         {
 
-             base.Init();
 
-             Employee = new EmployeeLink();
 
-             UsualActivity = new EmployeeActivityLink();
 
-         }
 
-         protected override void DoPropertyChanged(string name, object before, object after)
 
-         {
 
-             base.DoPropertyChanged(name, before, after);
 
-             if (times.ContainsKey(name))
 
-                 Duration = RecalculateTimes(name, (TimeSpan)after);
 
-         }
 
-         private double RecalculateTimes(string name, TimeSpan after)
 
-         {
 
-             double result = 0.0F;
 
-             result = GetTime("Finish", name, after) - (GetTime("Start", name, after) + GetTime("Break", name, after));
 
-             result = result + GetTime("Finish2", name, after) - (GetTime("Start2", name, after) + GetTime("Break2", name, after));
 
-             return result;
 
-         }
 
-         private double GetTime(string column, string name, TimeSpan after)
 
-         {
 
-             if (string.Equals(column, name))
 
-                 return after.TotalHours;
 
-             return times[column].Invoke(this).TotalHours;
 
-         }
 
-     }
 
- }
 
 
  |