EchoTex_Payroll/HRM.BO/Attendance/ShiftRotation.cs

361 lines
12 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.Core;
namespace HRM.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 = 0;
_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 int _shiftID;
public int 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 WorkPlanGroupType : EnumWorkPlanGroupType
//private EnumWorkPlanGroup _workPlanGroupType;
//public EnumWorkPlanGroup WorkPlanGroupType
//{
// get { return _workPlanGroupType; }
// set
// {
// //base.OnPropertyChange<short>("WorkPlanGroupType", (short)_workPlanGroupType, (short)value);
// _workPlanGroupType = value;
// }
//}
//#endregion
#region Shift : Shift
private Shift _shift;
public int payrollTypeID
{ get; set; }
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 ShiftShortName
{ get;set;
}
public string WorkPlanGroupName
{
get
{
switch (this._workPlanType)
{
case EnumWorkPlanGroup.Fixed:
return "Fixed";
case EnumWorkPlanGroup.Counter_Clock_1:
return "Counter_Clock_1";
case EnumWorkPlanGroup.Counter_Clock_2:
return "Counter_Clock_2";
case EnumWorkPlanGroup.Counter_Clock_3:
return "Counter_Clock_3";
case EnumWorkPlanGroup.Counter_Clock_4:
return "Counter_Clock_4";
case EnumWorkPlanGroup.Counter_Clock_5:
return "Counter_Clock_5";
case EnumWorkPlanGroup.Counter_Clock_6:
return "Counter_Clock_6";
case EnumWorkPlanGroup.Counter_Clock_7:
return "Counter_Clock_7";
case EnumWorkPlanGroup.Counter_Clock_8:
return "Counter_Clock_8";
case EnumWorkPlanGroup.Double_Shift_1:
return "Double_Shift_1";
case EnumWorkPlanGroup.Double_Shift_2:
return "Double_Shift_2";
case EnumWorkPlanGroup.Double_Shift_3:
return "Double_Shift_3";
case EnumWorkPlanGroup.Double_Shift_4:
return "Double_Shift_4";
case EnumWorkPlanGroup.Two_Days_Shift_1:
return "Two_Days_Shift_1";
case EnumWorkPlanGroup.Two_Days_Shift_2:
return "Two_Days_Shift_2";
case EnumWorkPlanGroup.Three_Days_Shift_1:
return "Three_Days_Shift_1";
case EnumWorkPlanGroup.Three_Days_Shift_2:
return "Three_Days_Shift_2";
default:
return "NONE";
}
}
}
//#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(EnumWorkPlanGroupType 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 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 ShiftRotation Get(EnumWorkPlanGroup workgrouptype, int sequence)
//{
// ShiftRotation oShiftRotation = null;
// #region Cache Header
// oShiftRotation = (ShiftRotation)_cache["Get", sequence];
// if (oShiftRotation != null)
// return oShiftRotation;
// #endregion
// oShiftRotation = ShiftRotation.Service.Get(workgrouptype, sequence);
// #region Cache Footer
// _cache.Add(oShiftRotation, "Get", sequence);
// #endregion
// return oShiftRotation;
//}
//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 static int NextShift(List<ShiftRotation> shitrotationcol, int shiftid)
{
int index = 0;
index = shitrotationcol.FindIndex(x => x.ShiftID == shiftid);
if (index == -1) throw new Exception("Shift not found in the shift rotaion table in database");
if (index == shitrotationcol.Count - 1) index = 0;
else index = index + 1;
return shitrotationcol[index].ShiftID;
}
public int NextShiftID(List<ShiftRotation> shiftRotations)
{
int index = 0;
index = shiftRotations.FindIndex(x => x.ShiftID == this.ShiftID);
if (index == -1)
throw new Exception("Shift not found in the shift rotaion table in database");
if (index == shiftRotations.Count - 1)
index = 0;
else
index = index + 1;
return shiftRotations[index].ShiftID;
}
//public static ID NextShift(ObjectsTemplate<ShiftRotation> shitrotationcol, ID shiftid)
//{
// int index = 0;
// index = shitrotationcol.FindIndex(x => x.ShiftID.Integer == shiftid.Integer);
// if (index == -1) throw new ServiceException("Shift not found in the shift rotaion table in database");
// if (index == shitrotationcol.Count - 1) index = 0;
// else index = index + 1;
// return shitrotationcol[index].ShiftID;
//}
//public int NextShiftID(List<ShiftRotation> shiftRotations)
//{
// int index = 0;
// index = shiftRotations.FindIndex(x => x.ShiftID.Integer == this.ShiftID.Integer);
// if (index == -1)
// throw new ServiceException("Shift not found in the shift rotaion table in database");
// if (index == shiftRotations.Count - 1)
// index = 0;
// else
// index = index + 1;
// return shiftRotations[index].ShiftID.Integer;
//}
//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(int id);
List<ShiftRotation> Get(EnumWorkPlanGroup workgrouptype);
int Save(ShiftRotation item);
void Delete(int id);
List<ShiftRotation> Get(EnumStatus status, int payrolltypeid);
ShiftRotation Get(EnumWorkPlanGroup workgrouptype, int sequence);
}
#endregion
}