305 lines
11 KiB
C#
305 lines
11 KiB
C#
|
|
using Ease.Core.Model;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
|
|
namespace HRM.BO
|
|
{
|
|
//public interface ISetupManager
|
|
//{
|
|
// void FillMe(ID id);
|
|
// List<SetupDetail> SetupDetails { get; set; }
|
|
// EmployeeSetupParameter ApplicableParameters(Employee Employee);
|
|
// List<EmployeeSetupParameter> ApplicableParameters(List<Employee> employees);
|
|
//}
|
|
public class EmployeeSetupParameter //<T> where T: TermParameter
|
|
{
|
|
public EmployeeSetupParameter(EnumParameterSetup setup)
|
|
{
|
|
Employee = null;
|
|
//_parameterIDs = new List<int>();
|
|
//_setup = setup;
|
|
}
|
|
//public Employeeshort Employee { get; set; }
|
|
public List<int> ParameterIDs { get; set; }
|
|
public Employee Employee { get; set; }
|
|
private EnumParameterSetup _setup;
|
|
|
|
//public List<T> GetParameters<T>() where T : ObjectTemplate, ISetupManager
|
|
//{
|
|
// List<T> temp = new List<T>();
|
|
// foreach (int i in _parameterIDs)
|
|
// {
|
|
// ConstructorInfo cInfo = typeof(T).GetConstructor(new Type[] { });
|
|
// T obj = (T)cInfo.Invoke(null);
|
|
// obj.FillMe(ID.FromInteger(i));
|
|
// temp.Add(obj);
|
|
// }
|
|
// return temp;
|
|
//}
|
|
|
|
}
|
|
public class SetupManager
|
|
{
|
|
private string _ConfigSection = string.Empty;
|
|
private ConfigReader m_oReader = null;
|
|
private string m_sStatus = string.Empty;
|
|
private List<SetupDetail> _SelectedSetupdetails = null;
|
|
private List<SetupDetail> _SavedSetupdetails = null;
|
|
private List<SetupDetail> _UsedSetupdetails = null;
|
|
private List<SetupDetail> _RemainingSetupDetails = null;
|
|
private EnumParameterSetup _setupparameter;
|
|
public SetupManager()
|
|
{
|
|
_SavedSetupdetails = new List<SetupDetail>();
|
|
_UsedSetupdetails = new List<SetupDetail>();
|
|
_SelectedSetupdetails = new List<SetupDetail>();
|
|
_RemainingSetupDetails = new List<SetupDetail>();
|
|
m_oReader = null;
|
|
_ConfigSection = string.Empty;
|
|
_setupparameter = EnumParameterSetup.None;
|
|
}
|
|
|
|
public SetupManager(EnumParameterSetup setup, string configSection)
|
|
{
|
|
_SavedSetupdetails = new List<SetupDetail>();
|
|
_UsedSetupdetails = new List<SetupDetail>();
|
|
_SelectedSetupdetails = new List<SetupDetail>();
|
|
_RemainingSetupDetails = new List<SetupDetail>();
|
|
_ConfigSection = configSection;
|
|
//m_oReader = new ConfigReader(_ConfigSection); //this needs to be called in bl
|
|
_setupparameter = setup;
|
|
}
|
|
|
|
//public void SetParameter(EnumParameterSetup setup, string configSection, ID setupID, ID objectID)
|
|
//{
|
|
// _ConfigSection = configSection;
|
|
// _setupparameter = setup;
|
|
// _UsedSetupdetails = SetupDetail.GetUsedParameters(_setupparameter, objectID.Integer);
|
|
|
|
// if (setupID.IsUnassigned == false)
|
|
// {
|
|
// _SavedSetupdetails = SetupDetail.GetUsedParameters(_setupparameter, setupID.Integer, objectID.Integer);
|
|
// foreach (SetupDetail item in _SavedSetupdetails)
|
|
// {
|
|
// int index = SetupDetail.GetIndex(m_oReader.Details, item.TranID.Integer, item.TranType);
|
|
// if (index > -1)
|
|
// {
|
|
// m_oReader.Details[index].IsSelected = true;
|
|
// _RemainingSetupDetails.Add(m_oReader.Details[index]);
|
|
// }
|
|
// else throw new ServiceException("root item not found to saved item");
|
|
// }
|
|
// }
|
|
|
|
// bool found = false;
|
|
// foreach (SetupDetail detail in m_oReader.Details)
|
|
// {
|
|
// found = false;
|
|
// foreach (SetupDetail udetail in _UsedSetupdetails)
|
|
// {
|
|
// if (udetail.TranType == detail.TranType && udetail.TranID.Integer == detail.TranID.Integer)
|
|
// {
|
|
// found = true;
|
|
// break;
|
|
// }
|
|
// }
|
|
// if (!found) _RemainingSetupDetails.Add(detail);
|
|
// }
|
|
//}
|
|
//public static List<int> ApplicableParametersForReport(Employee oEmp, List<EnmSetupManagerTranType> setupTypes, List<SetupDetail> details)
|
|
//{
|
|
// List<int> parametersID = new List<int>();
|
|
// if (setupTypes == null) return parametersID;
|
|
|
|
// foreach (EnmSetupManagerTranType type in setupTypes)
|
|
// {
|
|
// ID nTranID = SetupDetail.GetTranID(oEmp, type);
|
|
// if (nTranID == null) continue;
|
|
// if (nTranID.IsUnassigned == true) continue;
|
|
|
|
// var setupIds = (from detail in details
|
|
// where detail.TranType == type
|
|
// && detail.TranID == nTranID
|
|
// select detail.SetupID).Distinct();
|
|
// foreach (var id in setupIds)
|
|
// parametersID.Add(id.Integer);
|
|
// }
|
|
// return parametersID;
|
|
//}
|
|
//public static List<int> ApplicableParameters(Employee oEmp, EnumParameterSetup setup)
|
|
//{
|
|
// List<int> parametersID = new List<int>();
|
|
|
|
|
|
// List<EnmSetupManagerTranType> setupTypes = SetupDetail.GetTypes(setup);
|
|
// if (setupTypes == null) return parametersID;
|
|
|
|
// List<SetupDetail> details = SetupDetail.GetParameters(setup);
|
|
|
|
// foreach (EnmSetupManagerTranType type in setupTypes)
|
|
// {
|
|
// ID nTranID = SetupDetail.GetTranID(oEmp, type);
|
|
// if (nTranID== null) continue;
|
|
// if(nTranID.IsUnassigned==true )continue;
|
|
|
|
// var setupIds = (from detail in details
|
|
// where detail.TranType == type
|
|
// && detail.TranID == nTranID
|
|
// select detail.SetupID).Distinct();
|
|
// foreach (var id in setupIds)
|
|
// parametersID.Add(id.Integer);
|
|
// }
|
|
// return parametersID;
|
|
//}
|
|
|
|
//public static List<int> ApplicableParameters2(Employee oEmp, EnumParameterSetup setup, List<EnmSetupManagerTranType> setupTypes, List<SetupDetail> details)
|
|
//{
|
|
// List<int> parametersID = new List<int>();
|
|
// if (setupTypes == null) return parametersID;
|
|
|
|
|
|
|
|
// foreach (EnmSetupManagerTranType type in setupTypes)
|
|
// {
|
|
// ID nTranID = SetupDetail.GetTranID(oEmp, type);
|
|
// if (nTranID == null) continue;
|
|
// if (nTranID.IsUnassigned == true) continue;
|
|
|
|
// var setupIds = (from detail in details
|
|
// where detail.TranType == type
|
|
// && detail.TranID == nTranID
|
|
// select detail.SetupID).Distinct();
|
|
// foreach (var id in setupIds)
|
|
// parametersID.Add(id.Integer);
|
|
// }
|
|
// return parametersID;
|
|
//}
|
|
//public List<int> GetObjectID(string setupIDs, int objectID,
|
|
// EnumParameterSetup setup, EnmSetupManagerTranType type)
|
|
//{
|
|
// SetupDetail odetail = new SetupDetail();
|
|
// List<SetupDetail> setupDetails = SetupDetail.Service.GetUsedParameters(setup, setupIDs, objectID);
|
|
// List<int> temp = new List<int>();
|
|
// foreach (SetupDetail item in setupDetails)
|
|
// {
|
|
// temp.Add(item.TranID.Integer);
|
|
// }
|
|
// return temp;
|
|
//}
|
|
|
|
public static List<int> ApplicableParameters(Employee oEmp,
|
|
EnumParameterSetup setup, List<EnmSetupManagerTranType> setupTypes
|
|
, List<SetupDetail> details)
|
|
{
|
|
List<int> parametersID = new List<int>();
|
|
|
|
if (setupTypes == null) return parametersID;
|
|
foreach (EnmSetupManagerTranType type in setupTypes)
|
|
{
|
|
int nTranID = SetupDetail.GetTranID(oEmp, type);
|
|
if (nTranID == 0) continue;
|
|
|
|
var setupIds = (from detail in details
|
|
where detail.TranType == type
|
|
&& detail.TranID == nTranID
|
|
select detail.SetupID).Distinct();
|
|
if (setupIds != null)
|
|
{
|
|
foreach (var id in setupIds)
|
|
parametersID.Add(id);
|
|
}
|
|
}
|
|
return parametersID;
|
|
}
|
|
|
|
|
|
public List<SetupDetail> GetSetupDetails
|
|
{
|
|
get
|
|
{
|
|
return _RemainingSetupDetails;
|
|
}
|
|
}
|
|
public List<SetupDetail> SelectedSetupDetails
|
|
{
|
|
get
|
|
{
|
|
_SelectedSetupdetails.Clear();
|
|
foreach (SetupDetail detail in m_oReader.Details)
|
|
{
|
|
if (detail.IsSelected)
|
|
{
|
|
_SelectedSetupdetails.Add(detail);
|
|
}
|
|
}
|
|
return _SelectedSetupdetails;
|
|
}
|
|
}
|
|
public List<SetupDetail> SavedSetupDetails
|
|
{
|
|
get
|
|
{
|
|
return _SavedSetupdetails;
|
|
}
|
|
}
|
|
public EnumParameterSetup SetupFor
|
|
{
|
|
get
|
|
{
|
|
return _setupparameter ;
|
|
}
|
|
}
|
|
public bool IsSelected
|
|
{
|
|
get
|
|
{
|
|
bool found;
|
|
m_sStatus = "OK";
|
|
foreach (EnmSetupManagerTranType type in m_oReader.EnumTypes)
|
|
{
|
|
found = false;
|
|
foreach (SetupDetail detail in m_oReader.Details)
|
|
{
|
|
if (detail.TranType == type && detail.IsSelected == true)
|
|
{
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!found)
|
|
{
|
|
m_sStatus = "No " + type.ToString() + " is selected.";
|
|
return found;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
public string StatusMessage
|
|
{
|
|
get
|
|
{
|
|
return m_sStatus;
|
|
}
|
|
}
|
|
public int TotalTypes
|
|
{
|
|
get
|
|
{
|
|
return m_oReader.TotalTypes;
|
|
}
|
|
}
|
|
public List<string> GetTypes
|
|
{
|
|
get
|
|
{
|
|
return m_oReader.Types;
|
|
}
|
|
}
|
|
}
|
|
}
|