using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35; using Ease.CoreV35.Model; using Ease.CoreV35.DataAccess; using Ease.CoreV35.Caching; using System.Data.Linq.Mapping; using System.Data; namespace Payroll.BO { #region OrganogramEmployee [Serializable] public class OrganogramEmployee : AuditTrailBase { #region Cache Store private static Cache _cache = new Cache(typeof(OrganogramEmployee)); #endregion #region Constructor public OrganogramEmployee() { //_organEmpID = null; _nodeID = null; _employeeID = null; _assignDate = DateTime.MinValue; } #endregion #region Property //#region OrganEmpID : ID //private ID _organEmpID; //public ID OrganEmpID //{ // get { return _organEmpID; } // set // { // base.OnPropertyChange("organEmpID", _organEmpID, value); // _organEmpID = value; // } //} //#endregion #region nodeID : ID private ID _nodeID; public ID NodeID { get { return _nodeID; } set { base.OnPropertyChange("nodeID", _nodeID, value); _nodeID = value; } } #endregion #region employeeID : ID private ID _employeeID; public ID EmployeeID { get { return _employeeID; } set { base.OnPropertyChange("employeeID", _employeeID, value); _employeeID = value; } } #endregion #region employee : Employee private Employee _employee; public Employee Employee { get { if (_employeeID.Integer > 0 && _employee == null) { _employee = new Employee(); _employee = Employee.Get(_employeeID); } return this._employee; } set { _employee = value; } } #endregion #region assignDate : DateTime private DateTime _assignDate; public DateTime AssignDate { get { return _assignDate; } set { base.OnPropertyChange("assignDate", _assignDate, value); _assignDate = value; } } #endregion private OrganogramBasic _position; public OrganogramBasic Position { get { if (_nodeID != null && !_nodeID.IsUnassigned) { if (_nodeID.Integer > 0 && _position == null) { _position = new OrganogramBasic(); _position = OrganogramBasic.Get(_nodeID); } } return this._position; } set { _position = value; } } #region Service Factory IOrganogramEmployee : IOrganogramEmployee internal static IOrganogramEmployeeService Service { get { return Services.Factory.CreateService(typeof(IOrganogramEmployeeService)); } } #endregion #endregion #region Functions public ID Save() { base.SetAuditTrailProperties(); return OrganogramEmployee.Service.Save(this); } internal static void SaveEmp(ObjectsTemplate _organEmps) { OrganogramEmployee.Service.SaveEmp(_organEmps); } public void Delete() { OrganogramEmployee.Service.Delete(ID); } public static ObjectsTemplate Get(ID nodeID) { ObjectsTemplate oOrganEmp = null; #region Cache Header oOrganEmp = (ObjectsTemplate)_cache["Get", nodeID]; if (oOrganEmp != null) return oOrganEmp; #endregion oOrganEmp = OrganogramEmployee.Service.Get(nodeID); #region Cache Footer _cache.Add(oOrganEmp, "Get", nodeID); #endregion return oOrganEmp; } public static ObjectsTemplate GetByEmp(ID empID) { ObjectsTemplate oOrganEmp = null; #region Cache Header oOrganEmp = (ObjectsTemplate)_cache["GetByEmp", empID]; if (oOrganEmp != null) return oOrganEmp; #endregion oOrganEmp = OrganogramEmployee.Service.GetByEmp(empID); #region Cache Footer _cache.Add(oOrganEmp, "GetByEmp", empID); #endregion return oOrganEmp; } public static ObjectsTemplate GetByPositionType(EnumOGPositionType enPositionType) { ObjectsTemplate oOrganEmp = null; #region Cache Header oOrganEmp = (ObjectsTemplate)_cache["GetByPositionType", enPositionType]; if (oOrganEmp != null) return oOrganEmp; #endregion oOrganEmp = OrganogramEmployee.Service.GetByPositionType(enPositionType); #region Cache Footer _cache.Add(oOrganEmp, "GetByPositionType", enPositionType); #endregion return oOrganEmp; } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate oOrganEmp = _cache["Get"] as ObjectsTemplate; if (oOrganEmp != null) return oOrganEmp; #endregion try { oOrganEmp = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(oOrganEmp, "Get"); #endregion return oOrganEmp; } #endregion } #endregion #region IOrganogramEmployeeService public interface IOrganogramEmployeeService { ID Save(OrganogramEmployee OrganEmp); void Delete(ID id); ObjectsTemplate Get(ID nodeID); ObjectsTemplate GetByEmp(ID empID); ObjectsTemplate GetByPositionType(EnumOGPositionType enPositionType); ObjectsTemplate Get(); void SaveEmp(ObjectsTemplate _organEmps); } #endregion }