CEL_Payroll/Payroll.BO/Attendence/Shift.cs

373 lines
8.7 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
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<string>("Code", _code, value);
_code = value;
}
}
#endregion
#region Name : string
private string _name;
public string Name
{
get { return _name; }
set
{
base.OnPropertyChange<string>("Name", _name, value);
_name = value;
}
}
#endregion
#region InTime : DateTime
private DateTime _inTime;
public DateTime InTime
{
get { return _inTime; }
set
{
base.OnPropertyChange<DateTime>("InTime", _inTime, value);
_inTime = value;
}
}
#endregion
#region outTime : DateTime
private DateTime _outTime;
public DateTime OutTime
{
get { return _outTime; }
set
{
base.OnPropertyChange<DateTime>("outTime", _outTime, value);
_outTime = value;
}
}
#endregion
#region hasAbsentTime : bool
private bool _hasAbsentTime;
public bool hasAbsentTime
{
get { return _hasAbsentTime; }
set
{
base.OnPropertyChange<bool>("hasAbsentTime", _hasAbsentTime, value);
_hasAbsentTime = value;
}
}
#endregion
#region AbsentTime : DateTime
private DateTime _absentTime;
public DateTime AbsentTime
{
get { return _absentTime; }
set
{
base.OnPropertyChange<DateTime>("absentTime", _absentTime, value);
_absentTime = value;
}
}
#endregion
#region lateCalcualtion : double
private double _lateCalcualtion;
public double LateCalcualtion
{
get { return _lateCalcualtion; }
set
{
base.OnPropertyChange<double>("lateCalcualtion", _lateCalcualtion, value);
_lateCalcualtion = value;
}
}
#endregion
#region DelayCalcualtion : double
private double _delayCalcualtion;
public double DelayCalcualtion
{
get { return _delayCalcualtion; }
set
{
base.OnPropertyChange<double>("delayCalcualtion", _delayCalcualtion, value);
_delayCalcualtion = value;
}
}
#endregion
#region earlyExitBefore : double
private double _earlyExitBefore;
public double EarlyExitBefore
{
get { return _earlyExitBefore; }
set
{
base.OnPropertyChange<double>("EarlyExitBefore", _earlyExitBefore, value);
_earlyExitBefore = value;
}
}
#endregion
#region Minimum OTHour : double
private double _minimumOTHour;
public double MinimumOTHour
{
get { return _minimumOTHour; }
set
{
base.OnPropertyChange<double>("MinimumOTHour", _minimumOTHour, value);
_minimumOTHour = value;
}
}
#endregion
#region isOverlapingDay : bool
private bool _isOverlapingDay;
public bool IsOverlapingDay
{
get { return _isOverlapingDay; }
set
{
base.OnPropertyChange<bool>("isOverlapingDay", _isOverlapingDay, value);
_isOverlapingDay = value;
}
}
#endregion
#region ShiftType : EnumWorkPlanGroup
private EnumWorkPlanGroup _shiftType;
public EnumWorkPlanGroup ShiftType
{
get { return _shiftType; }
set
{
//base.OnPropertyChange<EnumWorkPlanDayType>("ShiftType", _shiftType, value);
_shiftType = value;
}
}
#endregion
#region ShortName : string
private string _shortName;
public string ShortName
{
get { return _shortName; }
set
{
base.OnPropertyChange<string>("ShortName", _shortName, value);
_shortName = value;
}
}
#endregion
#region Service Factory IShiftService : IShiftService
internal static IShiftService Service
{
get { return Services.Factory.CreateService<IShiftService>(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<Shift> Get()
{
#region Cache Header
ObjectsTemplate<Shift> shifts = _cache["Get"] as ObjectsTemplate<Shift>;
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<Shift> Get(bool isCounterClock)
{
#region Cache Header
ObjectsTemplate<Shift> shifts = _cache["Get", isCounterClock] as ObjectsTemplate<Shift>;
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<Shift> Get();
ObjectsTemplate<Shift> Get(bool isCounterClock);
ID Save(Shift item);
void Delete(ID id);
bool IsExist(string shiftCode, string shortName);
}
#endregion
}