EchoTex_Payroll/HRM.BO/Workflow/WFSetup.cs
2024-10-14 10:01:49 +06:00

703 lines
24 KiB
C#

using Ease.Core.DataAccess;
using Ease.Core.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Reflection;
namespace HRM.BO
{
#region WFSetup
public class WFSetup : BasicBaseObject
{
#region Constructor
public WFSetup()
{
_wfTypeId = 0;
WFSetupRules = null;
}
#endregion
#region Property
//#region Property WFSetupID : ID
//private int _wfSetupId;
//public int WFSetupID
//{
// get { return _wfSetupId; }
// set { _wfSetupId = value; }
//}
//#endregion
#region Property WFTypeId : ID
private int _wfTypeId;
public int WFTypeId
{
get { return _wfTypeId; }
set { _wfTypeId = value; }
}
#endregion
#region WFRuleDetailDesignation : WFRuleDetailDesignation
//private List<WFRuleDetailDesignation> _wfDetailDesigs;
//public List<WFRuleDetailDesignation> WFDetailDesigs
//{
// get
// {
// if (_wfDetailDesigs == null)
// _wfDetailDesigs = Service.Get4WFRuleDD(this.ID);
// return _wfDetailDesigs;
// }
// set
// {
// _wfDetailDesigs = value;
// }
//}
#endregion
#region WFRuleDetailNode : WFRuleDetailNode
//private List<WFRuleDetailNode> _wfRuleNodes;
//public List<WFRuleDetailNode> WFRuleNodes
//{
// get
// {
// if (_wfRuleNodes == null)
// _wfRuleNodes = Service.Get4WFRuleNode(this.ID);
// return _wfRuleNodes;
// }
// set
// {
// _wfRuleNodes = value;
// }
//}
#endregion
#region WFRuleDetailOS : WFRuleDetailOS
//private List<WFRuleDetailOS> _wfRuleDOSs;
//public List<WFRuleDetailOS> WFRuleDOSs
//{
// get
// {
// if (_wfRuleDOSs == null )
// {
// _wfRuleDOSs = Service.Get4WFRuleDetailOS(this.ID);
// }
// return _wfRuleDOSs;
// }
// set
// {
// _wfRuleDOSs = value;
// }
//}
#endregion
public List<WFSetupRule> WFSetupRules { get; set; }
//#region WFSetupRule : WFSetupRule
//private List<WFSetupRule> _wfSetupRules;
//public List<WFSetupRule> WFSetupRules
//{
// get
// {
// if (_wfSetupRules == null && this.int != null && this.ID.IsUnassigned == false)
// {
// _wfSetupRules = Service.Get4WFSetupRule(this.ID);
// }
// return _wfSetupRules;
// }
// set
// {
// _wfSetupRules = value;
// }
//}
//#endregion
public WFType WFType { get; set; }
//#region WFType : WFType
//private WFType _wfType;
//public WFType WFType
//{
// get
// {
// if (_wfType == null) _wfType = WFType.Get(_wfTypeId);
// return _wfType;
// }
// set
// {
// _wfType = value;
// }
//}
public bool UseOrganogram { get; set; }
//#endregion
#endregion
//#region Functions
//#region Save
//public int Save()
//{
// base.SetAuditTrailProperties();
// return WFSetup.Service.Save(this);
//}
//#endregion
//#region Delete
//public void Delete()
//{
// WFSetup.Service.Delete(ID);
//}
//#endregion
//public bool IsInitiator(OrganogramBasic ogNode)
//{
// return (this.GetNodeRules(ogNode).Count > 0);
//}
//#region Get
//public WFSetupRule GetNodeRule(OrganogramBasic ogNode)
//{
// List<WFSetupRule> oRules = this.GetNodeRules(ogNode);
// WFSetupRule oRule = null;
// int nMaxPriority = -1;
// foreach (WFSetupRule oItem in oRules)
// {
// if (oItem.Priority > nMaxPriority)
// {
// oRule = oItem;
// nMaxPriority = oItem.Priority;
// }
// }
// return oRule;
//}
//public WFSetupRule GetRule(int RuleID)
//{
// WFSetupRule oRule = null;
// foreach (WFSetupRule oItem in this.WFSetupRules)
// {
// if (oItem.ID.Integer == RuleID.Integer)
// {
// return oItem;
// }
// }
// return oRule;
//}
//public List<OrganogramBasic>[] GetFullPath(WFSetupRule oRule, int nTier, OrganogramBasic ogNode)
//{
// List<OrganogramBasic>[] oPaths = null;
// switch (oRule.WFRuleType)
// {
// case EnumWFRuleType.StraightAuthority:
// if (oRule.StAuthorityLevel - nTier > 0)
// {
// oPaths = new List<OrganogramBasic>[oRule.StAuthorityLevel - (nTier + 1)];
// oPaths[0] = new List<OrganogramBasic>();
// oPaths[0].Add(ogNode);
// for (int i = 1; i < oRule.StAuthorityLevel - nTier; i++)
// {
// oPaths[i] = new List<OrganogramBasic>();
// oPaths[i].Add(oPaths[i - 1][0].Parent);
// }
// }
// break;
// case EnumWFRuleType.FixedOGNode:
// case EnumWFRuleType.Designation:
// case EnumWFRuleType.OrganizationStructure:
// List<OrganogramBasic> oP;
// oPaths = new List<OrganogramBasic>[oRule.LevelDepth - (nTier + 1)];
// oPaths[0].Add(ogNode);
// for (int i = nTier; i <= oRule.LevelDepth - (nTier + 1); i++)
// {
// oP = Approvers(oRule, ogNode, i);
// foreach (OrganogramBasic oItem in oP)
// {
// oPaths[i].Add(oItem);
// }
// }
// break;
// default:
// break;
// }
// return oPaths;
//}
//public List<OrganogramBasic>[] GetFullPath(OrganogramBasic ogNode)
//{
// WFSetupRule oRule = this.GetNodeRule(ogNode);
// List<OrganogramBasic>[] oPaths = null; // = new HR.BO.OrgChart.RAHierarchyNodes();
// switch (oRule.WFRuleType)
// {
// case EnumWFRuleType.StraightAuthority:
// oPaths = new List<OrganogramBasic>[oRule.StAuthorityLevel + 1];
// oPaths[0] = new List<OrganogramBasic>();
// oPaths[0].Add(ogNode);
// for (int i = 1; i <= oRule.StAuthorityLevel; i++)
// {
// oPaths[i] = new List<OrganogramBasic>();
// oPaths[i].Add(oPaths[i - 1][0].Parent);
// }
// break;
// case EnumWFRuleType.FixedOGNode:
// case EnumWFRuleType.Designation:
// case EnumWFRuleType.OrganizationStructure:
// List<OrganogramBasic> oP;
// oPaths = new List<OrganogramBasic>[oRule.LevelDepth + 1];
// oPaths[0] = new List<OrganogramBasic>();
// oPaths[0].Add(ogNode);
// for (int i = 1; i <= oRule.LevelDepth; i++)
// {
// oP = Approvers(oRule, ogNode, i);
// foreach (OrganogramBasic oItem in oP)
// {
// oPaths[i] = new List<OrganogramBasic>();
// oPaths[i].Add(oItem);
// }
// }
// break;
// case EnumWFRuleType.Manual:
// oPaths = new List<OrganogramBasic>[oRule.LevelDepth + 1];
// oPaths[0] = new List<OrganogramBasic>();
// oPaths[0].Add(ogNode);
// for (int i = 1; i < oRule.LevelDepth; i++)
// {
// List<OrganogramBasic> oPM = Approvers(oRule, oPaths[i - 1][0], i+1);
// oPaths[i] = new List<OrganogramBasic>();
// foreach (OrganogramBasic oItem in oPM)
// {
// oPaths[i].Add(oItem);
// }
// }
// break;
// default:
// break;
// }
// return oPaths;
//}
//public List<OrganogramBasic>[] GetFullPathOnTier(WFSetupRule oRule, int nTier, OrganogramBasic ogNode)
//{
// List<OrganogramBasic>[] oPaths;
// if (nTier > 0)
// {
// oPaths = new List<OrganogramBasic>[nTier];
// oPaths[0] = new List<OrganogramBasic>();
// oPaths[0].Add(ogNode);
// for (int i = 1; i < nTier; i++)
// {
// oPaths[i] = new List<OrganogramBasic>();
// oPaths[i].Add(oPaths[i - 1][0].Parent);
// }
// }
// else
// {
// List<OrganogramBasic> oP = null;
// oPaths = new List<OrganogramBasic>[oRule.LevelDepth - 1];
// oPaths[0].Add(ogNode);
// for (int i = nTier; i <= oRule.LevelDepth; i++)
// {
// oP = Approvers(oRule, ogNode, i);
// foreach (OrganogramBasic oItem in oP)
// {
// oPaths[i].Add(oItem);
// }
// }
// }
// return oPaths;
//}
//public OrganogramBasic InitiatorToTierNode(OrganogramBasic oInitiatorNode, WFSetupRule oRule, int nTier)
//{
// List<OrganogramBasic>[] oPaths = null;
// switch (oRule.WFRuleType)
// {
// case EnumWFRuleType.StraightAuthority:
// oPaths = new List<OrganogramBasic>[nTier];
// oPaths[0] = new List<OrganogramBasic>();
// oPaths[0].Add(oInitiatorNode);
// for (int i = 1; i < nTier; i++)
// {
// oPaths[i] = new List<OrganogramBasic>();
// oPaths[i].Add(oPaths[i - 1][0].Parent);
// }
// break;
// case EnumWFRuleType.FixedOGNode:
// case EnumWFRuleType.Designation:
// case EnumWFRuleType.OrganizationStructure:
// case EnumWFRuleType.Manual:
// List<OrganogramBasic> oP;
// oPaths = new List<OrganogramBasic>[nTier];
// oPaths[0] = new List<OrganogramBasic>();
// oPaths[0].Add(oInitiatorNode);
// for (int i = 1; i < nTier; i++)
// {
// oP = Approvers(oRule, oPaths[i - 1][0], i);
// oPaths[i] = new List<OrganogramBasic>();
// foreach (OrganogramBasic oItem in oP)
// {
// oPaths[i].Add(oItem);
// }
// }
// break;
// default:
// break;
// }
// return oPaths[nTier - 1][0];
//}
//public List<OrganogramBasic> Approvers(WFSetupRule oRule, OrganogramBasic ogNode, int ntier)
//{
// List<OrganogramBasic> oApprovarNodes = new List<OrganogramBasic>();
// switch (oRule.WFRuleType)
// {
// case EnumWFRuleType.StraightAuthority:
// if (oRule.IsRAuthority == false)
// {
// if (ogNode.Parent == null) throw new ServiceException("Approver Organogram position/node is vacant. please assign an employee at the postion first.");
// if (ogNode.Parent.EmployeeAssigned) //if LM node vacant find matrix line(Acting authority). Chapal
// oApprovarNodes.Add(ogNode.Parent);
// else
// {
// List<OrganogramBasic> oMatLines = ogNode.Parent.GetAthorities(EnumAuthorityType.Reporting);
// if (oMatLines != null)
// {
// foreach (OrganogramBasic oNode in oMatLines)
// {
// if (oNode.EmployeeAssigned == true)
// {
// oApprovarNodes.Add(oNode);
// }
// }
// }
// }
// }
// else
// {
// List<OrganogramBasic> rpau = ogNode.GetAthorities(EnumAuthorityType.Reporting);
// foreach (OrganogramBasic og in rpau)
// {
// oApprovarNodes.Add(og);
// }
// }
// break;
// case EnumWFRuleType.OrganizationStructure:
// oApprovarNodes = oRule.Approver(ogNode, ntier);
// break;
// case EnumWFRuleType.FixedOGNode:
// oApprovarNodes = oRule.Approver(ogNode, ntier);
// break;
// case EnumWFRuleType.Designation:
// oApprovarNodes = oRule.Approver(ogNode, ntier);
// break;
// case EnumWFRuleType.Manual:
// oApprovarNodes = oRule.Approver(ogNode, ntier);
// break;
// default:
// break;
// }
// return oApprovarNodes;
//}
//public List<WFSetupRule> GetNodeRules(OrganogramBasic ogNode)
//{
// List<WFSetupRule> oselectedRules = new List<WFSetupRule>();
// foreach (WFSetupRule oItem in this.WFSetupRules)
// {
// switch (oItem.WFRuleType)
// {
// case EnumWFRuleType.StraightAuthority:
// if (oItem.WFRuleDeatilDesignations.Count > 0 && oItem.WFRuleDeatilOSs.Count > 0)
// {
// if (WFRuleDetailDesignation.IsInitiator(oItem.WFRuleDeatilDesignations, ogNode.DesignationID) == true &&
// WFRuleDetailOS.IsInitiator(oItem.WFRuleDeatilOSs, ogNode.DepartmentID) == true)
// {
// oselectedRules.Add(oItem);
// }
// }
// else if (oItem.WFRuleDeatilDesignations.Count > 0)
// {
// if (WFRuleDetailDesignation.IsInitiator(oItem.WFRuleDeatilDesignations,
// ogNode.DesignationID) == true) oselectedRules.Add(oItem);
// }
// else if (oItem.WFRuleDeatilOSs.Count > 0)
// {
// if (WFRuleDetailOS.IsInitiator(oItem.WFRuleDeatilOSs,
// ogNode.DepartmentID) == true) oselectedRules.Add(oItem);
// }
// else oselectedRules.Add(oItem);
// break;
// case EnumWFRuleType.OrganizationStructure:
// if (WFRuleDetailOS.IsInitiator(oItem.WFRuleDeatilOSs, ogNode.DesignationID) == true)
// {
// oselectedRules.Add(oItem);
// }
// break;
// case EnumWFRuleType.Designation:
// if (WFRuleDetailDesignation.IsInitiator(oItem.WFRuleDeatilDesignations, ogNode.DesignationID) == true)
// {
// oselectedRules.Add(oItem);
// }
// break;
// case EnumWFRuleType.FixedOGNode:
// if (WFRuleDetailNode.IsInitiator(oItem.WFRuleDetailNodes, ogNode.ID))
// {
// oselectedRules.Add(oItem);
// }
// break;
// case EnumWFRuleType.Manual:
// if (WFRuleDetailManual.IsInitiator(oItem.WFRuleDetailManual, ogNode.ID))
// {
// oselectedRules.Add(oItem);
// }
// break;
// default:
// break;
// }
// }
// return oselectedRules;
//}
//public static WFSetup GetByWFTypeID(int nType)
//{
// WFSetup WFSetup = null;
// #region Cache Header
// WFSetup = (WFSetup)_cache["Get", nType];
// if (WFSetup != null)
// return WFSetup;
// #endregion
// WFSetup = WFSetup.Service.GetByWFTypeID(nType);
// #region Cache Footer
// _cache.Add(WFSetup, "Get", nType);
// #endregion
// return WFSetup;
//}
//public static WFSetup Get(int nID)
//{
// WFSetup wfSetup = null;
// #region Cache Header
// wfSetup = (WFSetup)_cache["Get", nID];
// if (wfSetup != null)
// return wfSetup;
// #endregion
// wfSetup = WFSetup.Service.Get(nID);
// #region Cache Footer
// _cache.Add(wfSetup, "Get", nID);
// #endregion
// return wfSetup;
//}
//public static List<WFSetup> Get()
//{
// #region Cache Header
// List<WFSetup> wfSetup = _cache["Get"] as List<WFSetup>;
// if (wfSetup != null)
// return wfSetup;
// #endregion
// try
// {
// wfSetup = Service.Get();
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(wfSetup, "Get");
// #endregion
// return wfSetup;
//}
//public static List<WFRuleDetailDesignation> Get4WFRuleDD(int wfRuleDetailID)
//{
// #region Cache Header
// List<WFRuleDetailDesignation> oWFRuleDetailDesignation = _cache["Get4WFRuleDD", wfRuleDetailID] as List<WFRuleDetailDesignation>;
// if (oWFRuleDetailDesignation != null)
// return oWFRuleDetailDesignation;
// #endregion
// try
// {
// oWFRuleDetailDesignation = Service.Get4WFRuleDD(wfRuleDetailID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oWFRuleDetailDesignation, "Get4WFRuleDD", wfRuleDetailID);
// #endregion
// return oWFRuleDetailDesignation;
//}
//public static List<WFRuleDetailNode> Get4WFRuleNode(int wfRuleNodeID)
//{
// #region Cache Header
// List<WFRuleDetailNode> oWFRuleNode = _cache["Get4WFRuleNode", wfRuleNodeID] as List<WFRuleDetailNode>;
// if (oWFRuleNode != null)
// return oWFRuleNode;
// #endregion
// try
// {
// oWFRuleNode = Service.Get4WFRuleNode(wfRuleNodeID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oWFRuleNode, "Get4WFRuleNode", wfRuleNodeID);
// #endregion
// return oWFRuleNode;
//}
//public static List<WFRuleDetailManual> Get4WFRuleManual(int wfRuleNodeID)
//{
// List<WFRuleDetailManual> oWFRuleNode = null;
// try
// {
// oWFRuleNode = Service.Get4WFRuleDetailManual(wfRuleNodeID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// return oWFRuleNode;
//}
//public static List<WFSetupRule> Get4WFSetupRule(int wfSetupRuleID)
//{
// #region Cache Header
// List<WFSetupRule> oWFSetupRule = _cache["Get4WFSetupRule", wfSetupRuleID] as List<WFSetupRule>;
// if (oWFSetupRule != null)
// return oWFSetupRule;
// #endregion
// try
// {
// oWFSetupRule = Service.Get4WFSetupRule(wfSetupRuleID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oWFSetupRule, "Get4WFSetupRule", wfSetupRuleID);
// #endregion
// return oWFSetupRule;
//}
//public static List<WFRuleDetailOS> Get4WFRuleDetailOS(int osID)
//{
// #region Cache Header
// List<WFRuleDetailOS> oWFRuleDetailOS = _cache["Get4WFRuleDetailOS", osID] as List<WFRuleDetailOS>;
// if (oWFRuleDetailOS != null)
// return oWFRuleDetailOS;
// #endregion
// try
// {
// oWFRuleDetailOS = Service.Get4WFRuleDetailOS(osID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oWFRuleDetailOS, "Get4WFRuleDetailOS", osID);
// #endregion
// return oWFRuleDetailOS;
//}
//#endregion
//public bool CheckPriority(int PriorityLevel)
//{
// foreach (WFSetupRule oItem in this.WFSetupRules)
// {
// if (oItem.Priority == PriorityLevel)
// {
// return true;
// }
// }
// return false;
//}
//#endregion
//#region Service Factory
//internal static IWFSetupService Service
//{
// get { return Services.Factory.CreateService<IWFSetupService>(typeof(IWFSetupService)); }
//}
//#endregion
}
#endregion
#region Interface
public interface IWFSetupService
{
WFSetup Get(int id);
WFSetup GetByWFTypeID(int nType);
List<WFSetup> Get();
List<WFRuleDetailDesignation> Get4WFRuleDD(int ruleid);
List<WFRuleDetailNode> Get4WFRuleNode(int ruleId);
List<WFSetupRule> Get4WFSetupRule(int id);
List<WFRuleDetailOS> Get4WFRuleDetailOS(int ruleid);
List<WFRuleDetailManual> Get4WFRuleDetailManual(int ruleid);
int Save(WFSetup item);
void Delete(int Id);
}
#endregion
}