217 lines
5.6 KiB
C#
217 lines
5.6 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Ease.CoreV35.Caching;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
|
|||
|
namespace Payroll.BO
|
|||
|
{
|
|||
|
#region ShiftRotation
|
|||
|
|
|||
|
[Serializable]
|
|||
|
public class ShiftRotation : BasicBaseObject
|
|||
|
{
|
|||
|
#region Cache Store
|
|||
|
|
|||
|
private static Cache _cache = new Cache(typeof(ShiftRotation));
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Constructor
|
|||
|
|
|||
|
public ShiftRotation()
|
|||
|
{
|
|||
|
_shiftID = null;
|
|||
|
_workPlanType = EnumWorkPlanGroup.Counter_Clock_1;
|
|||
|
_status = EnumStatus.Active;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Input validator
|
|||
|
public string[] InputValidator()
|
|||
|
{
|
|||
|
string[] sErrorString = new string[2];
|
|||
|
|
|||
|
if (this.ShiftID.Integer <= 0)
|
|||
|
{
|
|||
|
sErrorString[0] = "ID can not be empty";
|
|||
|
sErrorString[1] = "ID";
|
|||
|
return sErrorString;
|
|||
|
}
|
|||
|
|
|||
|
sErrorString = null;
|
|||
|
return sErrorString;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region Properties
|
|||
|
#region ShiftID : ID
|
|||
|
|
|||
|
private ID _shiftID;
|
|||
|
public ID ShiftID
|
|||
|
{
|
|||
|
get { return _shiftID; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<ID>("ShiftID", _shiftID, value);
|
|||
|
_shiftID = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Type : ID
|
|||
|
|
|||
|
private EnumWorkPlanGroup _workPlanType;
|
|||
|
public EnumWorkPlanGroup WorkPlanType
|
|||
|
{
|
|||
|
get { return _workPlanType; }
|
|||
|
set
|
|||
|
{
|
|||
|
_workPlanType = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Shift : Shift
|
|||
|
|
|||
|
private Shift _shift;
|
|||
|
public Shift Shift
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_shift == null && _shiftID.Integer > 0)
|
|||
|
{
|
|||
|
_shift = new Shift();
|
|||
|
_shift = Shift.Get(_shiftID);
|
|||
|
}
|
|||
|
return this._shift;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_shift = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
public string ShortName
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (Shift == null) return "";
|
|||
|
return this._shift.ShortName;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#region Service Factory IShiftRotationService : IShiftRotationService
|
|||
|
|
|||
|
internal static IShiftRotationService Service
|
|||
|
{
|
|||
|
get { return Services.Factory.CreateService<IShiftRotationService>(typeof(IShiftRotationService)); }
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Functions
|
|||
|
|
|||
|
public static ShiftRotation Get(ID nID)
|
|||
|
{
|
|||
|
ShiftRotation oShiftRotation = null;
|
|||
|
#region Cache Header
|
|||
|
oShiftRotation = (ShiftRotation)_cache["Get", nID];
|
|||
|
if (oShiftRotation != null)
|
|||
|
return oShiftRotation;
|
|||
|
#endregion
|
|||
|
oShiftRotation = ShiftRotation.Service.Get(nID);
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oShiftRotation, "Get", nID);
|
|||
|
#endregion
|
|||
|
return oShiftRotation;
|
|||
|
}
|
|||
|
public static ObjectsTemplate<ShiftRotation> Get(EnumWorkPlanGroup workgrouptype)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<ShiftRotation> shiftRotations = _cache["Get"] as ObjectsTemplate<ShiftRotation>;
|
|||
|
if (shiftRotations != null)
|
|||
|
return shiftRotations;
|
|||
|
#endregion
|
|||
|
try
|
|||
|
{
|
|||
|
shiftRotations = Service.Get(workgrouptype);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(shiftRotations, "Get");
|
|||
|
#endregion
|
|||
|
return shiftRotations;
|
|||
|
}
|
|||
|
|
|||
|
public static int GetIndex(ObjectsTemplate<ShiftRotation> shitrotationcol, ID shiftid)
|
|||
|
{
|
|||
|
int index = 0;
|
|||
|
foreach (ShiftRotation item in shitrotationcol)
|
|||
|
{
|
|||
|
if (item.ShiftID == shiftid)
|
|||
|
return index;
|
|||
|
index = index + 1;
|
|||
|
}
|
|||
|
|
|||
|
throw new ServiceException("Shift not found in the shift rotaion table in database");
|
|||
|
return index;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public ID Save()
|
|||
|
{
|
|||
|
this.SetAuditTrailProperties();
|
|||
|
return ShiftRotation.Service.Save(this);
|
|||
|
}
|
|||
|
public void Delete(ID id)
|
|||
|
{
|
|||
|
ShiftRotation.Service.Delete(id);
|
|||
|
}
|
|||
|
public static ObjectsTemplate<ShiftRotation> Get(EnumStatus status)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<ShiftRotation> shiftRotations = _cache["Get", status] as ObjectsTemplate<ShiftRotation>;
|
|||
|
if (shiftRotations != null)
|
|||
|
return shiftRotations;
|
|||
|
#endregion
|
|||
|
try
|
|||
|
{
|
|||
|
shiftRotations = Service.Get(status);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(shiftRotations, "Get", status);
|
|||
|
#endregion
|
|||
|
return shiftRotations;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IShiftRotation Service
|
|||
|
|
|||
|
public interface IShiftRotationService
|
|||
|
{
|
|||
|
ShiftRotation Get(ID id);
|
|||
|
ObjectsTemplate<ShiftRotation> Get(EnumWorkPlanGroup workGroupType);
|
|||
|
ID Save(ShiftRotation item);
|
|||
|
void Delete(ID id);
|
|||
|
ObjectsTemplate<ShiftRotation> Get(EnumStatus status);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|