CEL_Payroll/Payroll.BO/EERS/EERS.cs

449 lines
14 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.CoreV35;
using Ease.CoreV35.Model;
using Ease.CoreV35.Caching;
using System.Data.Linq.Mapping;
using System.Data;
using System.IO;
namespace Payroll.BO
{
#region EERS
[Serializable]
public class EERS : BasicBaseObject
{
string sApplicationID = "";
#region Constructor
public EERS()
{
_sapplicationID = string.Empty;
_sLastName = string.Empty;
_sFirstName = string.Empty;
_sLogInID = string.Empty;
_sRITSID = string.Empty;
_sGEIDID = string.Empty;
_sApplicationFunctionTitleCode = string.Empty;
_sApplicationFunctionTCDescription = string.Empty;
_sSOEID = string.Empty;
_sSecondLevelEntDes = string.Empty;
_sExternalDrillDownCode = string.Empty;
_sSequenceField = string.Empty;
_sISAContactID = string.Empty;
_sCMPProductID = string.Empty;
_sFunctionalIDIndicatorCode = string.Empty;
_nAttributeFlag = 0;
_nEnvironmentFlag = 0;
}
#endregion
#region Properties
#region ApplicationID : string
private string _sapplicationID;
public string ApplicationID
{
get { return _sapplicationID; }
set
{
base.OnPropertyChange<string>("applicationID", _sapplicationID, value);
_sapplicationID = value;
}
}
#endregion
#region LastName : string
private string _sLastName;
public string LastName
{
get { return _sLastName; }
set
{
base.OnPropertyChange<string>("LastName", _sLastName, value);
_sLastName = value;
}
}
#endregion
#region FirstName : string
private string _sFirstName;
public string FirstName
{
get { return _sFirstName; }
set
{
base.OnPropertyChange<string>("firstName", _sFirstName, value);
_sFirstName = value;
}
}
#endregion
#region LogInID : string
private string _sLogInID;
public string LogInID
{
get { return _sLogInID; }
set
{
base.OnPropertyChange<string>("logInID", _sLogInID, value);
_sLogInID = value;
}
}
#endregion
#region RITSID : string
private string _sRITSID;
public string RITSID
{
get { return _sRITSID; }
set
{
base.OnPropertyChange<string>("rITSID", _sRITSID, value);
_sRITSID = value;
}
}
#endregion
#region GEID : string
private string _sGEIDID;
public string GEID
{
get { return _sGEIDID; }
set
{
base.OnPropertyChange<string>("gEID", _sGEIDID, value);
_sGEIDID = value;
}
}
#endregion
#region AFTitleCode : string
private string _sApplicationFunctionTitleCode;
public string AFTitleCode
{
get { return _sApplicationFunctionTitleCode; }
set
{
base.OnPropertyChange<string>("aFTitleCode", _sApplicationFunctionTitleCode, value);
_sApplicationFunctionTitleCode = value;
}
}
#endregion
#region AFTitleCodeDescription : string
private string _sApplicationFunctionTCDescription;
public string AFTitleCodeDescription
{
get { return _sApplicationFunctionTCDescription; }
set
{
base.OnPropertyChange<string>("aFTitleCodeDescription", _sApplicationFunctionTCDescription, value);
_sApplicationFunctionTCDescription = value;
}
}
#endregion
#region SOEID : string
private string _sSOEID;
public string SOEID
{
get { return _sSOEID; }
set
{
base.OnPropertyChange<string>("sOEID", _sSOEID, value);
_sSOEID = value;
}
}
#endregion
#region SecondLevelEntDes : string
private string _sSecondLevelEntDes;
public string SecondLevelEntDes
{
get { return _sSecondLevelEntDes; }
set
{
base.OnPropertyChange<string>("secondLevelEntDes", _sSecondLevelEntDes, value);
_sSecondLevelEntDes = value;
}
}
#endregion
#region ExternalDrillDownCode : string
private string _sExternalDrillDownCode;
public string ExternalDrillDownCode
{
get { return _sExternalDrillDownCode; }
set
{
base.OnPropertyChange<string>("externalDrillDownCode", _sExternalDrillDownCode, value);
_sExternalDrillDownCode = value;
}
}
#endregion
#region SequenceField : string
private string _sSequenceField;
public string SequenceField
{
get { return _sSequenceField; }
set
{
base.OnPropertyChange<string>("sequenceField", _sSequenceField, value);
_sSequenceField = value;
}
}
#endregion
#region ISAContactID : string
private string _sISAContactID;
public string ISAContactID
{
get { return _sISAContactID; }
set
{
base.OnPropertyChange<string>("iSAContactID", _sISAContactID, value);
_sISAContactID = value;
}
}
#endregion
#region CMPProductID : string
private string _sCMPProductID;
public string CMPProductID
{
get { return _sCMPProductID; }
set
{
base.OnPropertyChange<string>("cMPProductID", _sCMPProductID, value);
_sCMPProductID = value;
}
}
#endregion
#region FunctionalIDIndicatorCode : string
private string _sFunctionalIDIndicatorCode;
public string FunctionalIDIndicatorCode
{
get { return _sFunctionalIDIndicatorCode; }
set
{
base.OnPropertyChange<string>("functionalIDIndicatorCode", _sFunctionalIDIndicatorCode, value);
_sFunctionalIDIndicatorCode = value;
}
}
#endregion
#region AttributeFlag : int
private int _nAttributeFlag;
public int AttributeFlag
{
get { return _nAttributeFlag; }
set
{
base.OnPropertyChange<int>("attributeFlag", _nAttributeFlag, value);
_nAttributeFlag = value;
}
}
#endregion
#region EnvironmentFlag : int
private int _nEnvironmentFlag;
public int EnvironmentFlag
{
get { return _nEnvironmentFlag; }
set
{
base.OnPropertyChange<int>("environmentFlag", _nEnvironmentFlag, value);
_nEnvironmentFlag = value;
}
}
#endregion
#endregion
#region Functions
public DataTable Get()
{
sApplicationID = System.Configuration.ConfigurationSettings.AppSettings["EERS"];
ObjectsTemplate<User> oUsers = User.Get(EnumSystemType.Desktop);
ObjectsTemplate<Employee> oEmployees = Employee.GetForSuperUser();
ObjectsTemplate<Role> oRoles = Role.Get(EnumStatus.Regardless);
ObjectsTemplate<UserRole> oUserRoles = UserRole.Get();
DataTable dt = new DataTable();
DataRow dr = null;
dt.Columns.Add("ApplicationID");
dt.Columns.Add("LastName");
dt.Columns.Add("FirstName");
dt.Columns.Add("LogInID");
dt.Columns.Add("RITSID");
dt.Columns.Add("GEID");
dt.Columns.Add("AFTitleCode");
dt.Columns.Add("AFTitleCodeDescription");
dt.Columns.Add("SOEID");
dt.Columns.Add("SecondLevelEntDes");
dt.Columns.Add("ExternalDrillDownCode");
dt.Columns.Add("SequenceField");
dt.Columns.Add("ISAContactID");
dt.Columns.Add("CMPProductID");
dt.Columns.Add("FunctionalIDIndicatorCode");
dt.Columns.Add("AttributeFlag");
dt.Columns.Add("EnvironmentFlag");
//Add rest of the columns
foreach (User obj in oUsers)
{
List<UserRole> orls =oUserRoles.FindAll(delegate(UserRole r) { return r.UserID == obj.ID; });
foreach (UserRole ur in orls)
{
dr = dt.NewRow();
dr["ApplicationID"] = sApplicationID;
dr["LastName"] = "";
dr["FirstName"] = obj.Name;
dr["LogInID"] = obj.LoginID;
dr["RITSID"] = "";
Employee oEmployee = oEmployees.Find(delegate(Employee emp) { return emp.EmployeeNo.ToString() == obj.LoginID; });
dr["GEID"] =oEmployee==null?"": oEmployee.EmployeeNo;
Role oRole = oRoles.Find(delegate(Role r) { return r.ID.Integer == ur.RoleID; });
dr["AFTitleCode"] = oRole.Code;
dr["AFTitleCodeDescription"] = oRole.Name;
dr["SOEID"] = oEmployee == null ? "" : oEmployee.GlobalID;
dr["SecondLevelEntDes"] = oRole.Description;
dr["ExternalDrillDownCode"] = "";
dr["SequenceField"] = "";
dr["ISAContactID"] = "";
dr["CMPProductID"] = "";
dr["FunctionalIDIndicatorCode"] = "";
dr["AttributeFlag"] = "";
dr["EnvironmentFlag"] = "";
dt.Rows.Add(dr);
}
}
return dt;
}
public bool ExportEERSFile()
{
bool IsExported = true;
StringBuilder sb = new StringBuilder();
DataTable dt = this.Get();
#region Add headers
sb.Append("ApplicationID");
sb.Append("\t");
sb.Append("LastName");
sb.Append("\t");
sb.Append("FirstName");
sb.Append("\t");
sb.Append("LogInID");
sb.Append("\t");
sb.Append("RITSID");
sb.Append("\t");
sb.Append("GEID");
sb.Append("\t");
sb.Append("AFTitleCode");
sb.Append("\t");
sb.Append("AFTitleCodeDescription");
sb.Append("\t");
sb.Append("SOEID");
sb.Append("\t");
sb.Append("SecondLevelEntDes");
sb.Append("\t");
sb.Append("ExternalDrillDownCode");
sb.Append("\t");
sb.Append("SequenceField");
sb.Append("\t");
sb.Append("ISAContactID");
sb.Append("\t");
sb.Append("CMPProductID");
sb.Append("\t");
sb.Append("FunctionalIDIndicatorCode");
sb.Append("\t");
sb.Append("AttributeFlag");
sb.Append("\t");
sb.Append("EnvironmentFlag");
#endregion
sb.Append(Environment.NewLine);
#region Fill Values
foreach (DataRow dr in dt.Rows)
{
sb.Append(dr["ApplicationID"]);
sb.Append("\t");
sb.Append(dr["LastName"]);
sb.Append("\t");
sb.Append(dr["FirstName"]);
sb.Append("\t");
sb.Append(dr["LogInID"]);
sb.Append("\t");
sb.Append(dr["RITSID"]);
sb.Append("\t");
sb.Append(dr["GEID"]);
sb.Append("\t");
sb.Append(dr["AFTitleCode"]);
sb.Append("\t");
sb.Append(dr["AFTitleCodeDescription"]);
sb.Append("\t");
sb.Append(dr["SOEID"]);
sb.Append("\t");
sb.Append(dr["SecondLevelEntDes"]);
sb.Append("\t");
sb.Append(dr["ExternalDrillDownCode"]);
sb.Append("\t");
sb.Append(dr["SequenceField"]);
sb.Append("\t");
sb.Append(dr["ISAContactID"]);
sb.Append("\t");
sb.Append(dr["CMPProductID"]);
sb.Append("\t");
sb.Append(dr["FunctionalIDIndicatorCode"]);
sb.Append("\t");
sb.Append(dr["AttributeFlag"]);
sb.Append("\t");
sb.Append(dr["EnvironmentFlag"]);
sb.Append(Environment.NewLine);
}
#endregion
try
{
PhotoPath oItem = new PhotoPath();
ObjectsTemplate<PhotoPath> oItems = new ObjectsTemplate<PhotoPath>();
oItems = PhotoPath.Get();
if (oItems.Count > 0)
{
oItem = oItems[0];
if (oItem.ERRSFilePath == "")
IsExported = false;
else
{
string sFileName = oItem.ERRSFilePath + "\\ERRS" + sApplicationID + ".txt";
if (File.Exists(sFileName))
{
File.Delete(sFileName);
}
File.WriteAllText(sFileName, sb.ToString());
}
}
else
IsExported = false;
}
catch (Exception exp)
{
throw new Exception(exp.Message);
}
return IsExported;
}
#endregion
}
#endregion
}