using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35.Caching; using Ease.CoreV35.Model; namespace Payroll.BO { public delegate void ListChanged(); #region Shift [Serializable] public class Shift : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(Shift)); #endregion #region Constructor public Shift() { _code = string.Empty; _name = string.Empty; _inTime = DateTime.MinValue; _outTime = DateTime.MinValue; _absentTime = DateTime.MinValue; _lateCalcualtion = 0; _delayCalcualtion = 0; _earlyExitBefore = 0; _minimumOTHour = 0; _hasAbsentTime = false; _isOverlapingDay = false; _shortName = string.Empty; _shiftType = EnumWorkPlanGroup.Fixed; } #endregion #region Properties #region Code : string private string _code; public string Code { get { return _code; } set { base.OnPropertyChange("Code", _code, value); _code = value; } } #endregion #region Name : string private string _name; public string Name { get { return _name; } set { base.OnPropertyChange("Name", _name, value); _name = value; } } #endregion #region InTime : DateTime private DateTime _inTime; public DateTime InTime { get { return _inTime; } set { base.OnPropertyChange("InTime", _inTime, value); _inTime = value; } } #endregion #region outTime : DateTime private DateTime _outTime; public DateTime OutTime { get { return _outTime; } set { base.OnPropertyChange("outTime", _outTime, value); _outTime = value; } } #endregion #region hasAbsentTime : bool private bool _hasAbsentTime; public bool hasAbsentTime { get { return _hasAbsentTime; } set { base.OnPropertyChange("hasAbsentTime", _hasAbsentTime, value); _hasAbsentTime = value; } } #endregion #region AbsentTime : DateTime private DateTime _absentTime; public DateTime AbsentTime { get { return _absentTime; } set { base.OnPropertyChange("absentTime", _absentTime, value); _absentTime = value; } } #endregion #region lateCalcualtion : double private double _lateCalcualtion; public double LateCalcualtion { get { return _lateCalcualtion; } set { base.OnPropertyChange("lateCalcualtion", _lateCalcualtion, value); _lateCalcualtion = value; } } #endregion #region DelayCalcualtion : double private double _delayCalcualtion; public double DelayCalcualtion { get { return _delayCalcualtion; } set { base.OnPropertyChange("delayCalcualtion", _delayCalcualtion, value); _delayCalcualtion = value; } } #endregion #region earlyExitBefore : double private double _earlyExitBefore; public double EarlyExitBefore { get { return _earlyExitBefore; } set { base.OnPropertyChange("EarlyExitBefore", _earlyExitBefore, value); _earlyExitBefore = value; } } #endregion #region Minimum OTHour : double private double _minimumOTHour; public double MinimumOTHour { get { return _minimumOTHour; } set { base.OnPropertyChange("MinimumOTHour", _minimumOTHour, value); _minimumOTHour = value; } } #endregion #region isOverlapingDay : bool private bool _isOverlapingDay; public bool IsOverlapingDay { get { return _isOverlapingDay; } set { base.OnPropertyChange("isOverlapingDay", _isOverlapingDay, value); _isOverlapingDay = value; } } #endregion #region ShiftType : EnumWorkPlanGroup private EnumWorkPlanGroup _shiftType; public EnumWorkPlanGroup ShiftType { get { return _shiftType; } set { //base.OnPropertyChange("ShiftType", _shiftType, value); _shiftType = value; } } #endregion #region ShortName : string private string _shortName; public string ShortName { get { return _shortName; } set { base.OnPropertyChange("ShortName", _shortName, value); _shortName = value; } } #endregion #region Service Factory IShiftService : IShiftService internal static IShiftService Service { get { return Services.Factory.CreateService(typeof(IShiftService)); } } #endregion #endregion #region Functions public static Shift Get(ID nID) { Shift oShift = null; #region Cache Header oShift = (Shift)_cache["Get", nID]; if (oShift != null) return oShift; #endregion oShift = Shift.Service.Get(nID); #region Cache Footer _cache.Add(oShift, "Get", nID); #endregion return oShift; } public static Shift Get(string shiftName) { Shift oShift = null; #region Cache Header oShift = (Shift)_cache["Get", shiftName]; if (oShift != null) return oShift; #endregion oShift = Shift.Service.Get(shiftName); #region Cache Footer _cache.Add(oShift, "Get", shiftName); #endregion return oShift; } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate shifts = _cache["Get"] as ObjectsTemplate; if (shifts != null) return shifts; #endregion try { shifts = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(shifts, "Get"); #endregion return shifts; } public static ObjectsTemplate Get(bool isCounterClock) { #region Cache Header ObjectsTemplate shifts = _cache["Get", isCounterClock] as ObjectsTemplate; if (shifts != null) return shifts; #endregion try { shifts = Service.Get(isCounterClock); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(shifts, "Get", isCounterClock); #endregion return shifts; } public ID Save() { this.SetAuditTrailProperties(); return Shift.Service.Save(this); } public void Delete() { Shift.Service.Delete(ID); } public bool IsExist(string shiftCode, string shortName) { return Shift.Service.IsExist(shiftCode, shortName); } #endregion } #endregion #region IShift Service public interface IShiftService { Shift Get(ID id); Shift Get(string shiftName); ObjectsTemplate Get(); ObjectsTemplate Get(bool isCounterClock); ID Save(Shift item); void Delete(ID id); bool IsExist(string shiftCode, string shortName); } #endregion }