3183 lines
166 KiB
C#
3183 lines
166 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.IO;
|
|||
|
using System.Xml;
|
|||
|
using System.Xml.Linq;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Ease.CoreV35.Utility;
|
|||
|
using System.Xml.XPath;
|
|||
|
using System.Net;
|
|||
|
using Org.BouncyCastle.Bcpg.OpenPgp;
|
|||
|
using Org.BouncyCastle.Bcpg;
|
|||
|
using Org.BouncyCastle.Utilities.IO;
|
|||
|
|
|||
|
namespace Payroll.BO
|
|||
|
{
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///Process Flow
|
|||
|
/// 1. Read the XML file from the target location using intigration_setup object
|
|||
|
/// 2. Read New joining employee and update object. Increase the success List.
|
|||
|
/// 3. Read properties changes
|
|||
|
/// 3.1 if basic object are exist in the payroll database, increase Error List
|
|||
|
/// 3.2 Find the appropiate Life_cycle_Event and increase the Emp_Life_cycle collection. Increase success List
|
|||
|
/// 3.3 Use const-center Department lookup
|
|||
|
/// 4. If error list contains any item, save the items and exit process
|
|||
|
/// 5. If there is no item in error list, save the targets (objects) items
|
|||
|
/// 5.1 if error occured in saving an item, exit the process and save the reason in Error list
|
|||
|
/// 6. Save the Success List
|
|||
|
/// 7. Cut the source file XML and store it into backup folder.
|
|||
|
/// 8. Mail the success & Error list
|
|||
|
/// </summary>
|
|||
|
|
|||
|
[Serializable]
|
|||
|
public class SAPInterface
|
|||
|
{
|
|||
|
//private ObjectsTemplate<SAPDataProcess> _processerrorList=new ObjectsTemplate<SAPDataProcess>();
|
|||
|
// private string XML_FILE_NAME =string.Empty;
|
|||
|
|
|||
|
#region declarations
|
|||
|
|
|||
|
SAPDataProcess _SAPDProcess = new SAPDataProcess();
|
|||
|
|
|||
|
//SAPDataProcess _SucccessList = new SAPDataProcess();
|
|||
|
//SAPDataProcess _ErrorList = new SAPDataProcess();
|
|||
|
private ObjectsTemplate<EmpLifeCycle> _EmpLifeCycles;
|
|||
|
//private ObjectsTemplate<Employee> _newEmployeeList;
|
|||
|
//private ObjectsTemplate<EmpLifeCycle> _newEmpLifeCycle;
|
|||
|
//private ObjectsTemplate<EmployeeBankAccount> _newEmpBankAccount;
|
|||
|
|
|||
|
//private ObjectsTemplate<EmpLifeCycle> _EmpLifeCycles;
|
|||
|
private IntigrationSetup _IntigrationSetup = null;
|
|||
|
private ObjectsTemplate<Employee> _Employees = null;
|
|||
|
private ObjectsTemplate<Religion> _Religions = null;
|
|||
|
private ObjectsTemplate<Grade> _Grades = null;
|
|||
|
private ObjectsTemplate<Designation> _Designations = null;
|
|||
|
private ObjectsTemplate<Costcenter> _Costcenters = null;
|
|||
|
private ObjectsTemplate<Bank> _Banks = null;
|
|||
|
private ObjectsTemplate<EmployeeBankAccount> _EmployeeBankAccounts = null;
|
|||
|
private ObjectsTemplate<Branch> _Branchs = null;
|
|||
|
private ObjectsTemplate<CRGDepartmentLookup> _CRGDepartmentLookup = null;
|
|||
|
private ObjectsTemplate<Location> _Locations = null;
|
|||
|
private ObjectsTemplate<EmployeeStatus> _EmployeeStatuss = null;
|
|||
|
|
|||
|
private ObjectsTemplate<SAPDataProcessDetail> _ErrorList = new ObjectsTemplate<SAPDataProcessDetail>();
|
|||
|
private ObjectsTemplate<SAPDataProcessDetail> _SucccessList = new ObjectsTemplate<SAPDataProcessDetail>();
|
|||
|
EnumSendMail SendMailNotification = EnumSendMail.None;
|
|||
|
|
|||
|
MailSender MS = null;
|
|||
|
|
|||
|
private int _newEmpID;
|
|||
|
private string _sEmpNo = string.Empty;
|
|||
|
|
|||
|
Employee _Employee = null;
|
|||
|
SAPDataDump _SAPDataDump = null;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Constructor
|
|||
|
|
|||
|
public SAPInterface()
|
|||
|
{
|
|||
|
_newEmpID = 100001;
|
|||
|
_IntigrationSetup = IntigrationSetup.Get();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Public Functions
|
|||
|
|
|||
|
//public SAPDataProcess Process_Old()
|
|||
|
//{
|
|||
|
// try
|
|||
|
// {
|
|||
|
// _Employees = Employee.GetAllEmps();
|
|||
|
// _EmpLifeCycles = new ObjectsTemplate<EmpLifeCycle>();
|
|||
|
// _EmpLifeCycles = EmpLifeCycle.Get(EnumStatus.Regardless);
|
|||
|
// _Religions = Religion.Get(EnumStatus.Active);
|
|||
|
// _Grades = Grade.Get(EnumStatus.Active);
|
|||
|
// _Designations = Designation.GetWithSapCode(EnumStatus.Active);
|
|||
|
// _Costcenters = Costcenter.Get();
|
|||
|
// _Banks = Bank.Get();
|
|||
|
// _Branchs = Branch.Get(EnumStatus.Active);
|
|||
|
// _EmployeeBankAccounts = new ObjectsTemplate<EmployeeBankAccount>();
|
|||
|
// _CRGDepartmentLookup = CRGDepartmentLookup.Get();
|
|||
|
// _Locations = Location.Get();
|
|||
|
// _IntigrationSetup = IntigrationSetup.Get();
|
|||
|
// _EmployeeStatuss = EmployeeStatus.Get();
|
|||
|
// _newEmployeeList = new ObjectsTemplate<Employee>();
|
|||
|
// _newEmpLifeCycle = new ObjectsTemplate<EmpLifeCycle>();
|
|||
|
// _newEmpBankAccount = new ObjectsTemplate<EmployeeBankAccount>();
|
|||
|
// DownloadXMLFilesFromFTP();
|
|||
|
// RaedXMLFiles();
|
|||
|
|
|||
|
// //foreach (Employee emp in _newEmployeeList)
|
|||
|
// //{
|
|||
|
// // if (!_Employees.Where(obj => obj.EmployeeNo == emp.EmployeeNo).Any())
|
|||
|
// // {
|
|||
|
// // emp.LocationID = ID.FromInteger(4);
|
|||
|
// // }
|
|||
|
// //}
|
|||
|
|
|||
|
// foreach (EmpLifeCycle empLife in _newEmpLifeCycle)
|
|||
|
// {
|
|||
|
// if (empLife.EmployeeID.Integer > 100000) // New employee must have Grade & basic Salary
|
|||
|
// {
|
|||
|
// if (empLife.LocationID == null)
|
|||
|
// {
|
|||
|
// // Set Default or create Error
|
|||
|
// Employee emp = _newEmployeeList.Where(obj => obj.ID.Integer == empLife.EmployeeID.Integer).SingleOrDefault();
|
|||
|
// if (emp != null) emp.LocationID = ID.FromInteger(4);
|
|||
|
// empLife.LocationID = ID.FromInteger(4);
|
|||
|
// }
|
|||
|
// if (empLife.GradeID == null || empLife.BasicSalary == null)
|
|||
|
// {
|
|||
|
// _sEmpNo = string.Empty;
|
|||
|
// Employee oEmployee = _newEmployeeList.Where(e => e.ID == empLife.EmployeeID).SingleOrDefault();
|
|||
|
// AddProcessStatus(EnumSAPProcessStatus.Error, oEmployee, "New Joining Employee without Grade Or Basic Salary");
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// if (empLife.GradeID == null || empLife.BasicSalary == null)
|
|||
|
// {
|
|||
|
// Employee oEmployee = _Employees.Where(e => e.ID == empLife.EmployeeID).SingleOrDefault();
|
|||
|
|
|||
|
// if (oEmployee.GradeID == null || oEmployee.BasicSalary == 0)
|
|||
|
// {
|
|||
|
// AddProcessStatus(EnumSAPProcessStatus.Error, oEmployee, "Employee without Grade Or Basic Salary");
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// return _SAPDProcess;
|
|||
|
// }
|
|||
|
// catch (Exception ex)
|
|||
|
// {
|
|||
|
// throw new ServiceException(ex.Message);
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
public SAPDataProcess Process(FileInfo oFile)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
_Employees = Employee.GetAllEmps();
|
|||
|
_EmpLifeCycles = new ObjectsTemplate<EmpLifeCycle>();
|
|||
|
_EmpLifeCycles = EmpLifeCycle.Get(EnumStatus.Regardless);
|
|||
|
_Religions = Religion.Get(EnumStatus.Active);
|
|||
|
_Grades = Grade.GetAllPayrollTypes(EnumStatus.Active);
|
|||
|
_Designations = Designation.GetWithSapCode(EnumStatus.Active);
|
|||
|
_Costcenters = Costcenter.Get();
|
|||
|
_Banks = Bank.Get();
|
|||
|
_Branchs = Branch.Get(EnumStatus.Active);
|
|||
|
_EmployeeBankAccounts = new ObjectsTemplate<EmployeeBankAccount>();
|
|||
|
_CRGDepartmentLookup = CRGDepartmentLookup.Get();
|
|||
|
_Locations = Location.Get();
|
|||
|
_EmployeeStatuss = EmployeeStatus.Get();
|
|||
|
//_newEmployeeList = new ObjectsTemplate<Employee>();
|
|||
|
//_newEmpLifeCycle = new ObjectsTemplate<EmpLifeCycle>();
|
|||
|
//_newEmpBankAccount = new ObjectsTemplate<EmployeeBankAccount>();
|
|||
|
_SAPDProcess = new SAPDataProcess();
|
|||
|
|
|||
|
// 'false' for testing only.
|
|||
|
if (SAPDataProcess.IsFileSuccessfullyRead(oFile.Name))
|
|||
|
{
|
|||
|
_sEmpNo = string.Empty;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "File : " + oFile.Name + " was successfully read previously.Please check why it was given again");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ReadXMLFile(oFile.FullName);
|
|||
|
|
|||
|
_SAPDProcess.SAPDataDumps.ForEach(m => m.FileName = oFile.Name);
|
|||
|
|
|||
|
foreach (EmpLifeCycle empLife in _SAPDProcess.SAPEmpLifeCycles)
|
|||
|
{
|
|||
|
if (empLife.EmployeeID.Integer > 100000) // New employee must have Grade & basic Salary
|
|||
|
{
|
|||
|
if (empLife.LocationID == null)
|
|||
|
{
|
|||
|
// Set Default or create Error
|
|||
|
Employee emp = _SAPDProcess.SAPEmployees.Where(obj => obj.ID.Integer == empLife.EmployeeID.Integer).SingleOrDefault();
|
|||
|
if (emp != null) emp.LocationID = ID.FromInteger(4);
|
|||
|
empLife.LocationID = ID.FromInteger(4);
|
|||
|
}
|
|||
|
if (!(empLife.GradeID == null && empLife.BasicSalary == null) && (empLife.GradeID == null || empLife.BasicSalary == null))
|
|||
|
{
|
|||
|
_sEmpNo = string.Empty;
|
|||
|
Employee oEmployee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(e => e.ID == empLife.EmployeeID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (empLife.GradeID != null)
|
|||
|
{
|
|||
|
empLife.BasicSalary = 1.0;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee Basic Salary Set to Default Value 1.0 for ");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Grade defaultGrade = _Grades
|
|||
|
.Where(g => g.Code.Trim().ToUpper() == "N/A".Trim().ToUpper())
|
|||
|
.SingleOrDefault();
|
|||
|
if (defaultGrade == null)
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, oEmployee, "Could not find Default Grade \'N/A\' for ");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
empLife.GradeID = defaultGrade.ID;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Employee Grade Set to Default Grade \'{0}\' for ", defaultGrade.Code));
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
//AddProcessStatus(EnumSAPProcessStatus.Error, oEmployee, "New Joining Employee without Grade Or Basic Salary");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (!(empLife.GradeID == null && empLife.BasicSalary == null) && (empLife.GradeID == null || empLife.BasicSalary == null))
|
|||
|
{
|
|||
|
Employee oEmployee = _Employees
|
|||
|
.Where(e => e.ID == empLife.EmployeeID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
|
|||
|
if (empLife.GradeID != null)
|
|||
|
{
|
|||
|
if (oEmployee.BasicSalary == 0)
|
|||
|
{
|
|||
|
empLife.BasicSalary = 1.0;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee Basic Salary Set to Default Value 1.0 for ");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
empLife.BasicSalary = oEmployee.BasicSalary;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (oEmployee.GradeID == null || oEmployee.GradeID.IsUnassigned)
|
|||
|
{
|
|||
|
Grade defaultGrade = _Grades
|
|||
|
.Where(g => g.Code.Trim().ToUpper() == "N/A".Trim().ToUpper())
|
|||
|
.SingleOrDefault();
|
|||
|
if (defaultGrade == null)
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, oEmployee, "Could not find Default Grade \'N/A\' for ");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
empLife.GradeID = defaultGrade.ID;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Employee Grade Set to Default Grade \'{0}\' for ", defaultGrade.Code));
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
empLife.GradeID = oEmployee.GradeID;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return _SAPDProcess;
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
throw new ServiceException(ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public List<FileInfo> GetDownloadedFileInfos()
|
|||
|
{
|
|||
|
//DeleteXMLFilesFromLocal();
|
|||
|
DownloadXMLFilesFromFTP();
|
|||
|
|
|||
|
List<FileInfo> oFiles = new DirectoryInfo(_IntigrationSetup.ReadFilePath)
|
|||
|
.GetFiles("*.xml", SearchOption.TopDirectoryOnly)
|
|||
|
.OrderBy(f => f.Name)
|
|||
|
.ToList();
|
|||
|
return oFiles;
|
|||
|
}
|
|||
|
|
|||
|
public void DeleteXMLFilesFromFTP()
|
|||
|
{
|
|||
|
List<string> filesToDelete = GetAllFileListFromAnFTPPath();
|
|||
|
foreach (var item in filesToDelete)
|
|||
|
{
|
|||
|
DeleteFromFTP(item);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void DeleteXMLFilesFromLocal()
|
|||
|
{
|
|||
|
string[] files = Directory.GetFiles(_IntigrationSetup.ReadFilePath, "*.xml", SearchOption.TopDirectoryOnly);
|
|||
|
foreach (string xmlFile in files)
|
|||
|
{
|
|||
|
File.Delete(xmlFile);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public string GetXMLFileNamesFromLocal()
|
|||
|
{
|
|||
|
string commaSeparatedFileNames;
|
|||
|
string[] files = Directory.GetFiles(_IntigrationSetup.ReadFilePath, "*.xml", SearchOption.TopDirectoryOnly);
|
|||
|
|
|||
|
for (int i = 0; i < files.Length; i++)
|
|||
|
{
|
|||
|
string[] str = files[i].Split('\\');
|
|||
|
files[i] = str[str.Length - 1];
|
|||
|
}
|
|||
|
|
|||
|
commaSeparatedFileNames = string.Join(",", files);
|
|||
|
return commaSeparatedFileNames;
|
|||
|
}
|
|||
|
|
|||
|
public void MoveXMLFilesToBackup()
|
|||
|
{
|
|||
|
string[] files = Directory.GetFiles(_IntigrationSetup.ReadFilePath, "*.xml", SearchOption.TopDirectoryOnly);
|
|||
|
foreach (string xmlName in files)
|
|||
|
{
|
|||
|
SaveFileToBackUp(xmlName);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public EnumSendMail SendMail(SAPDataProcess oSApDProcess)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
EnumSendMail oSendMailNotification = EnumSendMail.None;
|
|||
|
MS = new MailSender();
|
|||
|
MS.AddCC(_IntigrationSetup.NotifyEmail.Trim());
|
|||
|
|
|||
|
if (oSApDProcess != null)
|
|||
|
{
|
|||
|
if (oSApDProcess.ErrorList.Count > 0)
|
|||
|
{
|
|||
|
MS.Body = @"Dear All,<br/>
|
|||
|
Uploading SAP Employee information failed and generated <b>Errors</b>.<br/><br/>
|
|||
|
The error list is given below: <br/> ";
|
|||
|
|
|||
|
MS.Body += oSApDProcess.ErrorList.Aggregate(new StringBuilder(),
|
|||
|
(sb, el) => sb.Append(el.Description + " <br/> "),
|
|||
|
sb => sb.ToString());
|
|||
|
|
|||
|
MS.Subject = "SAP Process data upload Failed.";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
MS.Body = @"Dear All,<br/>
|
|||
|
Uploading SAP Employee information successfully completed.<br/><br/>
|
|||
|
The success list is given below: <br/> ";
|
|||
|
|
|||
|
MS.Body += oSApDProcess.SuccessList.Aggregate(new StringBuilder(),
|
|||
|
(sb, el) => sb.Append(el.Description + " <br/> "),
|
|||
|
sb => sb.ToString());
|
|||
|
|
|||
|
MS.Subject = "SAP Process data upload Succeded.";
|
|||
|
|
|||
|
}
|
|||
|
//oSendMailNotification = MS.SendMailNovartisSAP();
|
|||
|
}
|
|||
|
return oSendMailNotification;
|
|||
|
}
|
|||
|
catch (Exception Ex)
|
|||
|
{
|
|||
|
throw new Exception(Ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Private Functions
|
|||
|
|
|||
|
private void RefreshNewJoiner(XElement oXElement)
|
|||
|
{
|
|||
|
#region Employee Name,Birthdate,Gender,Maritial_Status and Religion Code Update
|
|||
|
|
|||
|
//var oEmployees = oXElement.Elements("IDOC").Elements("E1PLOGI").Elements("E1PITYP")
|
|||
|
// .Elements("E1P0002")
|
|||
|
// .Where(elmnt => ((string)elmnt.Element("ENDDA")) == "99991231");
|
|||
|
|
|||
|
var oEmployees = oXElement.Descendants("E1P0002")
|
|||
|
.Where(elmnt => ((string)elmnt.Element("ENDDA")) == "99991231");
|
|||
|
|
|||
|
var oJoiningDates = oXElement.Descendants("E1P0000")
|
|||
|
.Where(elmnt => (((string)elmnt.Element("MASSN") == "ZR")
|
|||
|
|| ((string)elmnt.Element("MASSN") == "Z1")
|
|||
|
|| ((string)elmnt.Element("MASSN") == "Z0")
|
|||
|
)
|
|||
|
&& ((string)elmnt.Element("ENDDA") == "99991231")
|
|||
|
);
|
|||
|
|
|||
|
var oPayrollTypeOutSources = oXElement.Descendants("E1P0001")
|
|||
|
.Where(elmnt => ((string)elmnt.Element("MASSN") == "Z9") && ((string)elmnt.Element("ENDDA") == "99991231"));
|
|||
|
|
|||
|
//var oPayrollTypeExternals = oXElement.Descendants("E1P0001")
|
|||
|
// .Where(elmnt => (((string)elmnt.Element("MASSN") == "Z6") || ((string)elmnt.Element("MASSN") == "Z7")) && ((string)elmnt.Element("ENDDA") == "99991231"));
|
|||
|
|
|||
|
var oPayrollTypeFixeds = oXElement.Descendants("E1P0001")
|
|||
|
.Where(elmnt => ((string)elmnt.Element("PERSG") == "6") && ((string)elmnt.Element("ENDDA") == "99991231"));
|
|||
|
|
|||
|
foreach (XElement xEle in oEmployees)
|
|||
|
{
|
|||
|
string sEmpNo = (string)xEle.Element("PERNR");
|
|||
|
string sLastName = (string)xEle.Element("NACHN");
|
|||
|
string sFirstName = (string)xEle.Element("VORNA");
|
|||
|
string sBirthdate = (string)xEle.Element("GBDAT");
|
|||
|
string sReligionCode = (string)xEle.Element("KONFE");
|
|||
|
string sGender = (string)xEle.Element("GESCH");
|
|||
|
string sMaritialStatus = (string)xEle.Element("FAMST");
|
|||
|
string sHiringDate = null;
|
|||
|
|
|||
|
// if (sEmpNo.StartsWith("869")) continue;
|
|||
|
|
|||
|
XElement joinElmnt = oJoiningDates
|
|||
|
.Where(elmnt => ((string)elmnt.Element("PERNR")) == sEmpNo)
|
|||
|
.OrderByDescending(elmnt => elmnt.Element("MASSN"))
|
|||
|
.FirstOrDefault();
|
|||
|
|
|||
|
sHiringDate = joinElmnt == null ? null : (string)joinElmnt.Element("BEGDA");
|
|||
|
|
|||
|
|
|||
|
Employee oEmployee = _Employees
|
|||
|
.Where(oEmp => oEmp.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oEmployee == null)
|
|||
|
{
|
|||
|
#region Refresh Employee New Joinner
|
|||
|
|
|||
|
_Employee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(e => e.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (_Employee == null)
|
|||
|
{
|
|||
|
|
|||
|
_Employee = new Employee();
|
|||
|
_SAPDataDump = new SAPDataDump();
|
|||
|
_Employee.SetObjectID(_newEmpID);
|
|||
|
_SAPDataDump.EmployeeID = ID.FromInteger(_newEmpID);
|
|||
|
|
|||
|
_newEmpID = _newEmpID + 1;
|
|||
|
_Employee.EmployeeNo = sEmpNo;
|
|||
|
|
|||
|
#region Needs Change
|
|||
|
|
|||
|
if (sEmpNo.StartsWith("869"))
|
|||
|
{
|
|||
|
_Employee.PayrollTypeID = ID.FromInteger(2);
|
|||
|
if (oPayrollTypeOutSources.Any(xE => xE.Element("PERNR").ToString() == sEmpNo))
|
|||
|
{
|
|||
|
_Employee.CategoryID = ID.FromInteger(4);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_Employee.CategoryID = ID.FromInteger(2);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_Employee.PayrollTypeID = ID.FromInteger(1);
|
|||
|
|
|||
|
if (oPayrollTypeFixeds.Any(xE => xE.Element("PERNR").ToString() == sEmpNo))
|
|||
|
{
|
|||
|
_Employee.CategoryID = ID.FromInteger(3);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_Employee.CategoryID = ID.FromInteger(1);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
_SAPDataDump.FirstName = sFirstName == null ? _SAPDataDump.FirstName : sFirstName;
|
|||
|
_SAPDataDump.LastName = sLastName == null ? _SAPDataDump.LastName : sLastName;
|
|||
|
|
|||
|
|
|||
|
if ((sFirstName != null && sFirstName != string.Empty) || (sLastName != null && sLastName != string.Empty))
|
|||
|
{
|
|||
|
_Employee.Name = (sFirstName + " " + sLastName).Trim();
|
|||
|
}
|
|||
|
|
|||
|
if (sBirthdate != null && sBirthdate != string.Empty)
|
|||
|
{
|
|||
|
_Employee.BirthDate = Convert.ToDateTime(sBirthdate.Substring(0, 4) + "-" +
|
|||
|
sBirthdate.Substring(4, 2) + "-" +
|
|||
|
sBirthdate.Substring(6, 2));
|
|||
|
_SAPDataDump.BirthDate = _Employee.BirthDate;
|
|||
|
}
|
|||
|
|
|||
|
if (sHiringDate != null && sHiringDate != string.Empty)
|
|||
|
{
|
|||
|
_Employee.JoiningDate = Convert.ToDateTime(sHiringDate.Substring(0, 4) + "-" +
|
|||
|
sHiringDate.Substring(4, 2) + "-" +
|
|||
|
sHiringDate.Substring(6, 2));
|
|||
|
_SAPDataDump.JoiningDate = _Employee.JoiningDate;
|
|||
|
if (_Employee.JoiningDate > SystemInformation.CurrentSysInfo.NextPayProcessDate)
|
|||
|
{
|
|||
|
_Employee.Status = EnumEmployeeStatus.Waitingforjoin;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, _Employee, "Employee Joining Date not given for ");
|
|||
|
}
|
|||
|
|
|||
|
if (sReligionCode != null && sReligionCode != string.Empty)
|
|||
|
{
|
|||
|
Religion oReligion = _Religions
|
|||
|
.Where(oItem => oItem.Code.Trim().ToUpper() == sReligionCode.Trim().ToUpper())
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oReligion != null)
|
|||
|
{
|
|||
|
_Employee.ReligionID = oReligion.ID;
|
|||
|
_SAPDataDump.ReligionCode = oReligion.Code;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, _Employee, "Religion Code: " + sReligionCode.Trim() + " not found in basic information for ");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Religion oReligion = _Religions
|
|||
|
.Where(oItem => oItem.Name.ToUpper() == "N/A")
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oReligion != null)
|
|||
|
{
|
|||
|
_Employee.ReligionID = oReligion.ID;
|
|||
|
_SAPDataDump.ReligionCode = oReligion.Code;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, _Employee, "Religion Code \'N/A\' not defined. Employee no. ");
|
|||
|
}
|
|||
|
//AddProcessStatus(EnumSAPProcessStatus.Error, _Employee, "Religion Code not found in basic information for ");
|
|||
|
}
|
|||
|
|
|||
|
if (sGender != null && sGender != string.Empty)
|
|||
|
{
|
|||
|
switch ((EnumGender)Convert.ToInt16(sGender))
|
|||
|
{
|
|||
|
case EnumGender.None:
|
|||
|
_Employee.Gender = EnumGender.None;
|
|||
|
_SAPDataDump.Gender = EnumGender.None;
|
|||
|
break;
|
|||
|
case EnumGender.Male:
|
|||
|
_Employee.Gender = EnumGender.Male;
|
|||
|
_SAPDataDump.Gender = EnumGender.Male;
|
|||
|
break;
|
|||
|
case EnumGender.Female:
|
|||
|
_Employee.Gender = EnumGender.Female;
|
|||
|
_SAPDataDump.Gender = EnumGender.Female;
|
|||
|
break;
|
|||
|
case EnumGender.Other:
|
|||
|
_Employee.Gender = EnumGender.Other;
|
|||
|
_SAPDataDump.Gender = EnumGender.Other;
|
|||
|
break;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (sMaritialStatus != null && sMaritialStatus != string.Empty)
|
|||
|
{
|
|||
|
switch (Convert.ToInt16(sMaritialStatus))
|
|||
|
{
|
|||
|
case 0:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
break;
|
|||
|
case 1:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.Married;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.Married;
|
|||
|
break;
|
|||
|
case 2:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.Widow;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.Widow;
|
|||
|
break;
|
|||
|
case 3:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.Divorced;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.Divorced;
|
|||
|
break;
|
|||
|
default:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
if (_SAPDProcess.ErrorList.Count == 0)
|
|||
|
{
|
|||
|
//_newEmployeeList.Add(_Employee);
|
|||
|
_SAPDProcess.SAPEmployees.Add(_Employee);
|
|||
|
_SAPDProcess.SAPDataDumps.Add(_SAPDataDump);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Employee added successfully for ");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
else
|
|||
|
{
|
|||
|
_SAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == _Employee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
_SAPDataDump.FirstName = sFirstName == null ? _SAPDataDump.FirstName : sFirstName;
|
|||
|
_SAPDataDump.LastName = sLastName == null ? _SAPDataDump.LastName : sLastName;
|
|||
|
|
|||
|
|
|||
|
if ((sFirstName != null && sFirstName != string.Empty) || (sLastName != null && sLastName != string.Empty))
|
|||
|
{
|
|||
|
_Employee.Name = (sFirstName + " " + sLastName).Trim();
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Employee Name Changed for ");
|
|||
|
}
|
|||
|
|
|||
|
if (sBirthdate != null && sBirthdate != string.Empty)
|
|||
|
{
|
|||
|
_Employee.BirthDate = Convert.ToDateTime(sBirthdate.Substring(0, 4) + "-" +
|
|||
|
sBirthdate.Substring(4, 2) + "-" +
|
|||
|
sBirthdate.Substring(6, 2));
|
|||
|
_SAPDataDump.BirthDate = _Employee.BirthDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Birth Date Changed for ");
|
|||
|
}
|
|||
|
|
|||
|
if (sHiringDate != null && sHiringDate != string.Empty)
|
|||
|
{
|
|||
|
Convert.ToDateTime(sHiringDate.Substring(0, 4) + "-" +
|
|||
|
sHiringDate.Substring(4, 2) + "-" +
|
|||
|
sHiringDate.Substring(6, 2));
|
|||
|
_SAPDataDump.JoiningDate = _Employee.JoiningDate;
|
|||
|
if (_Employee.JoiningDate > SystemInformation.CurrentSysInfo.NextPayProcessDate)
|
|||
|
{
|
|||
|
_Employee.Status = EnumEmployeeStatus.Waitingforjoin;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (sReligionCode != null && sReligionCode != string.Empty)
|
|||
|
{
|
|||
|
Religion oReligion = _Religions
|
|||
|
.Where(oItem => oItem.Code.Trim().ToUpper() == sReligionCode.Trim().ToUpper())
|
|||
|
.SingleOrDefault();
|
|||
|
if (oReligion != null)
|
|||
|
{
|
|||
|
_Employee.ReligionID = oReligion.ID;
|
|||
|
_SAPDataDump.ReligionCode = oReligion.Code;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, _Employee, "Religion Code: " + sReligionCode.Trim() + " not found in basic information for ");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (sGender != null && sGender != string.Empty)
|
|||
|
{
|
|||
|
switch ((EnumGender)Convert.ToInt16(sGender))
|
|||
|
{
|
|||
|
case EnumGender.None:
|
|||
|
_Employee.Gender = EnumGender.None;
|
|||
|
_SAPDataDump.Gender = EnumGender.None;
|
|||
|
break;
|
|||
|
case EnumGender.Male:
|
|||
|
_Employee.Gender = EnumGender.Male;
|
|||
|
_SAPDataDump.Gender = EnumGender.Male;
|
|||
|
break;
|
|||
|
case EnumGender.Female:
|
|||
|
_Employee.Gender = EnumGender.Female;
|
|||
|
_SAPDataDump.Gender = EnumGender.Female;
|
|||
|
break;
|
|||
|
case EnumGender.Other:
|
|||
|
_Employee.Gender = EnumGender.Other;
|
|||
|
_SAPDataDump.Gender = EnumGender.Other;
|
|||
|
break;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if (sMaritialStatus != null && sMaritialStatus != string.Empty)
|
|||
|
{
|
|||
|
switch (Convert.ToInt16(sMaritialStatus))
|
|||
|
{
|
|||
|
case 0:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
break;
|
|||
|
case 1:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.Married;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.Married;
|
|||
|
break;
|
|||
|
case 2:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.Widow;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.Widow;
|
|||
|
break;
|
|||
|
case 3:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.Divorced;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.Divorced;
|
|||
|
break;
|
|||
|
default:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
if (_SAPDProcess.ErrorList.Count == 0)
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Empolyee updated successfully for ");
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
#region Refresh Old Employee
|
|||
|
|
|||
|
|
|||
|
if (!_SAPDProcess.SAPEmployees
|
|||
|
.Where(e => e.EmployeeNo == sEmpNo)
|
|||
|
.Any()) // Employee Found In DataBase but Not in new Employee List
|
|||
|
{
|
|||
|
_Employee = oEmployee;
|
|||
|
_Employee.EmployeeNo = sEmpNo;
|
|||
|
|
|||
|
_SAPDataDump = new SAPDataDump();
|
|||
|
_SAPDataDump.EmployeeID = _Employee.ID;
|
|||
|
|
|||
|
_SAPDataDump.FirstName = sFirstName == null ? _SAPDataDump.FirstName : sFirstName;
|
|||
|
_SAPDataDump.LastName = sLastName == null ? _SAPDataDump.LastName : sLastName;
|
|||
|
|
|||
|
|
|||
|
if ((sFirstName != null && sFirstName != string.Empty) || (sLastName != null && sLastName != string.Empty))
|
|||
|
{
|
|||
|
_Employee.Name = (sFirstName + " " + sLastName).Trim();
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Employee name changed for ");
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
if (sBirthdate != null && sBirthdate != string.Empty)
|
|||
|
{
|
|||
|
_Employee.BirthDate = Convert.ToDateTime(sBirthdate.Substring(0, 4) + "-" +
|
|||
|
sBirthdate.Substring(4, 2) + "-" +
|
|||
|
sBirthdate.Substring(6, 2));
|
|||
|
_SAPDataDump.BirthDate = _Employee.BirthDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Birth Date Changed for ");
|
|||
|
}
|
|||
|
|
|||
|
if (sHiringDate != null && sHiringDate != string.Empty)
|
|||
|
{
|
|||
|
_Employee.JoiningDate = Convert.ToDateTime(sHiringDate.Substring(0, 4) + "-" +
|
|||
|
sHiringDate.Substring(4, 2) + "-" +
|
|||
|
sHiringDate.Substring(6, 2));
|
|||
|
_SAPDataDump.JoiningDate = _Employee.JoiningDate;
|
|||
|
if (_Employee.JoiningDate > SystemInformation.CurrentSysInfo.NextPayProcessDate)
|
|||
|
{
|
|||
|
_Employee.Status = EnumEmployeeStatus.Waitingforjoin;
|
|||
|
}
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Joining date changed for ");
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
if (sReligionCode != null && sReligionCode != string.Empty)
|
|||
|
{
|
|||
|
Religion oReligion = _Religions
|
|||
|
.Where(oItem => oItem.Code.Trim().ToUpper() == sReligionCode.Trim().ToUpper())
|
|||
|
.SingleOrDefault();
|
|||
|
if (oReligion != null)
|
|||
|
{
|
|||
|
_Employee.ReligionID = oReligion.ID;
|
|||
|
_SAPDataDump.ReligionCode = oReligion.Code;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Religion changed for ");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, _Employee, "Religion Code: " + sReligionCode.Trim() + " not found in basic information for ");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (sGender != null && sGender != string.Empty)
|
|||
|
{
|
|||
|
switch ((EnumGender)Convert.ToInt16(sGender))
|
|||
|
{
|
|||
|
case EnumGender.None:
|
|||
|
_Employee.Gender = EnumGender.None;
|
|||
|
_SAPDataDump.Gender = EnumGender.None;
|
|||
|
break;
|
|||
|
case EnumGender.Male:
|
|||
|
_Employee.Gender = EnumGender.Male;
|
|||
|
_SAPDataDump.Gender = EnumGender.Male;
|
|||
|
break;
|
|||
|
case EnumGender.Female:
|
|||
|
_Employee.Gender = EnumGender.Female;
|
|||
|
_SAPDataDump.Gender = EnumGender.Female;
|
|||
|
break;
|
|||
|
case EnumGender.Other:
|
|||
|
_Employee.Gender = EnumGender.Other;
|
|||
|
_SAPDataDump.Gender = EnumGender.Other;
|
|||
|
break;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Gender changed for ");
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if (sMaritialStatus != null && sMaritialStatus != string.Empty)
|
|||
|
{
|
|||
|
switch (Convert.ToInt16(sMaritialStatus))
|
|||
|
{
|
|||
|
case 0:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
break;
|
|||
|
case 1:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.Married;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.Married;
|
|||
|
break;
|
|||
|
case 2:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.Widow;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.Widow;
|
|||
|
break;
|
|||
|
case 3:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.Divorced;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.Divorced;
|
|||
|
break;
|
|||
|
default:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
break;
|
|||
|
}
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Maritial status changed for ");
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Employee data Successfully updated for ");
|
|||
|
//_newEmployeeList.Add(_Employee);
|
|||
|
_SAPDProcess.SAPEmployees.Add(_Employee);
|
|||
|
_SAPDProcess.SAPDataDumps.Add(_SAPDataDump);
|
|||
|
|
|||
|
}
|
|||
|
else // Employee Found In DataBase and Also in new Employee List
|
|||
|
{
|
|||
|
|
|||
|
_Employee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(e => e.EmployeeNo == sEmpNo)
|
|||
|
.Single();
|
|||
|
_Employee.EmployeeNo = sEmpNo;
|
|||
|
|
|||
|
_SAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == _Employee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
|
|||
|
_SAPDataDump.FirstName = sFirstName == null ? _SAPDataDump.FirstName : sFirstName;
|
|||
|
_SAPDataDump.LastName = sLastName == null ? _SAPDataDump.LastName : sLastName;
|
|||
|
|
|||
|
|
|||
|
if ((sFirstName != null && sFirstName != string.Empty) || (sLastName != null && sLastName != string.Empty))
|
|||
|
{
|
|||
|
_Employee.Name = (sFirstName + " " + sLastName).Trim();
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Employee name changed for ");
|
|||
|
}
|
|||
|
|
|||
|
if (sBirthdate != null && sBirthdate != string.Empty)
|
|||
|
{
|
|||
|
|
|||
|
//DateTime sBD = Convert.ToDateTime(sBirthdate,"dd MMM yyyy");
|
|||
|
_Employee.BirthDate = Convert.ToDateTime(sBirthdate.Substring(0, 4) + "-" +
|
|||
|
sBirthdate.Substring(4, 2) + "-" +
|
|||
|
sBirthdate.Substring(6, 2));
|
|||
|
_SAPDataDump.BirthDate = _Employee.BirthDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Birthday changed for ");
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if (sHiringDate != null && sHiringDate != string.Empty)
|
|||
|
{
|
|||
|
_Employee.JoiningDate = Convert.ToDateTime(sHiringDate.Substring(0, 4) + "-" +
|
|||
|
sHiringDate.Substring(4, 2) + "-" +
|
|||
|
sHiringDate.Substring(6, 2));
|
|||
|
_SAPDataDump.JoiningDate = _Employee.JoiningDate;
|
|||
|
if (_Employee.JoiningDate > SystemInformation.CurrentSysInfo.NextPayProcessDate)
|
|||
|
{
|
|||
|
_Employee.Status = EnumEmployeeStatus.Waitingforjoin;
|
|||
|
}
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Joining date changed for ");
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
if (sReligionCode != null && sReligionCode != string.Empty)
|
|||
|
{
|
|||
|
Religion oReligion = _Religions
|
|||
|
.Where(oItem => oItem.Code.Trim().ToUpper() == sReligionCode.Trim().ToUpper())
|
|||
|
.SingleOrDefault();
|
|||
|
if (oReligion != null)
|
|||
|
{
|
|||
|
_Employee.ReligionID = oReligion.ID;
|
|||
|
_SAPDataDump.ReligionCode = oReligion.Code;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Religion changed for ");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, _Employee, "Religion Code: " + sReligionCode.Trim() + " not found in basic information for ");
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (sGender != null && sGender != string.Empty)
|
|||
|
{
|
|||
|
switch ((EnumGender)Convert.ToInt16(sGender))
|
|||
|
{
|
|||
|
case EnumGender.None:
|
|||
|
_Employee.Gender = EnumGender.None;
|
|||
|
_SAPDataDump.Gender = EnumGender.None;
|
|||
|
break;
|
|||
|
case EnumGender.Male:
|
|||
|
_Employee.Gender = EnumGender.Male;
|
|||
|
_SAPDataDump.Gender = EnumGender.Male;
|
|||
|
break;
|
|||
|
case EnumGender.Female:
|
|||
|
_Employee.Gender = EnumGender.Female;
|
|||
|
_SAPDataDump.Gender = EnumGender.Female;
|
|||
|
break;
|
|||
|
case EnumGender.Other:
|
|||
|
_Employee.Gender = EnumGender.Other;
|
|||
|
_SAPDataDump.Gender = EnumGender.Other;
|
|||
|
break;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Gender changed for ");
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if (sMaritialStatus != null && sMaritialStatus != string.Empty)
|
|||
|
{
|
|||
|
switch (Convert.ToInt16(sMaritialStatus))
|
|||
|
{
|
|||
|
case 0:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
break;
|
|||
|
case 1:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.Married;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.Married;
|
|||
|
break;
|
|||
|
case 2:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.Widow;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.Widow;
|
|||
|
break;
|
|||
|
case 3:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.Divorced;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.Divorced;
|
|||
|
break;
|
|||
|
default:
|
|||
|
_Employee.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
_SAPDataDump.MaritalStatus = EnumMaritalStatus.UnMarried;
|
|||
|
break;
|
|||
|
}
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Maritial status changed for ");
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Employee data Successfully updated for ");
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region GlobalID Update
|
|||
|
|
|||
|
//var oGDDBIDs = oXElement.Elements("IDOC").Elements("E1PLOGI").Elements("E1PITYP")
|
|||
|
// .Elements("E1P0105")
|
|||
|
// .Where(elmnt => ((string)elmnt.Element("SUBTY")) == "0001");
|
|||
|
|
|||
|
var oGDDBIDs = oXElement.Descendants("E1P0105")
|
|||
|
.Where(elmnt => ((string)elmnt.Element("SUBTY")) == "0001");
|
|||
|
|
|||
|
foreach (XElement xEle in oGDDBIDs)
|
|||
|
{
|
|||
|
string sEmpNo = (string)xEle.Element("PERNR");
|
|||
|
_sEmpNo = sEmpNo;
|
|||
|
string sGlobalID = (string)xEle.Element("USRID");
|
|||
|
//if (sEmpNo.StartsWith("869")) continue;
|
|||
|
_Employee = _SAPDProcess.SAPEmployees.Where(e => e.EmployeeNo == sEmpNo).SingleOrDefault();
|
|||
|
if (_Employee != null)
|
|||
|
{
|
|||
|
_SAPDataDump = _SAPDProcess.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == _Employee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (sGlobalID != null && sGlobalID != string.Empty)
|
|||
|
{
|
|||
|
_Employee.GlobalID = sGlobalID;
|
|||
|
_SAPDataDump.GDDBID = sGlobalID;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Global ID changed for ");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_Employee = _Employees.Where(oEmp => oEmp.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (_Employee != null)
|
|||
|
{
|
|||
|
_SAPDataDump = new SAPDataDump();
|
|||
|
_SAPDataDump.EmployeeID = _Employee.ID;
|
|||
|
if (sGlobalID != null && sGlobalID != string.Empty)
|
|||
|
{
|
|||
|
_Employee.GlobalID = sGlobalID;
|
|||
|
_SAPDataDump.GDDBID = sGlobalID;
|
|||
|
//_newEmployeeList.Add(_Employee);
|
|||
|
_SAPDProcess.SAPEmployees.Add(_Employee);
|
|||
|
_SAPDProcess.SAPDataDumps.Add(_SAPDataDump);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Global ID changed for ");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee not found while updating GlobalID for ");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Email Update
|
|||
|
|
|||
|
//var oEmails = oXElement.Elements("IDOC").Elements("E1PLOGI").Elements("E1PITYP")
|
|||
|
// .Elements("E1P0105")
|
|||
|
// .Where(elmnt => ((string)elmnt.Element("SUBTY") == "0010") && ((string)elmnt.Element("ENDDA") == "99991231"));
|
|||
|
|
|||
|
var oEmails = oXElement.Descendants("E1P0105")
|
|||
|
.Where(elmnt => ((string)elmnt.Element("SUBTY") == "0010") && ((string)elmnt.Element("ENDDA") == "99991231"));
|
|||
|
|
|||
|
|
|||
|
foreach (XElement xEle in oEmails)
|
|||
|
{
|
|||
|
string sEmpNo = (string)xEle.Element("PERNR");
|
|||
|
_sEmpNo = sEmpNo;
|
|||
|
string sEmailAddress = (string)xEle.Element("USRID_LONG");
|
|||
|
//if (sEmpNo.StartsWith("869")) continue;
|
|||
|
|
|||
|
_Employee = _SAPDProcess.SAPEmployees.Where(e => e.EmployeeNo == sEmpNo).SingleOrDefault();
|
|||
|
if (_Employee != null)
|
|||
|
{
|
|||
|
_SAPDataDump = _SAPDProcess.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == _Employee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (sEmailAddress != null && sEmailAddress != string.Empty)
|
|||
|
{
|
|||
|
_Employee.EmailAddress = sEmailAddress;
|
|||
|
_SAPDataDump.EmailAddress = sEmailAddress;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Email address changed for ");
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_Employee = _Employees.Where(oEmp => oEmp.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (_Employee != null)
|
|||
|
{
|
|||
|
_SAPDataDump = new SAPDataDump();
|
|||
|
_SAPDataDump.EmployeeID = _Employee.ID;
|
|||
|
if (sEmailAddress != null && sEmailAddress != string.Empty)
|
|||
|
{
|
|||
|
_Employee.EmailAddress = sEmailAddress;
|
|||
|
_SAPDataDump.EmailAddress = sEmailAddress;
|
|||
|
//_newEmployeeList.Add(_Employee);
|
|||
|
_SAPDProcess.SAPEmployees.Add(_Employee);
|
|||
|
_SAPDProcess.SAPDataDumps.Add(_SAPDataDump);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, _Employee, "Email address changed for ");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee not found while updating Email Address for ");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
private void RefreshEmpLifeCycle(XElement oXElement)
|
|||
|
{
|
|||
|
DateTime dEffectDate = DateTime.MinValue;
|
|||
|
|
|||
|
#region Employee Confirmation Data Update
|
|||
|
|
|||
|
//var oEmpConfirm = oXElement.Elements("IDOC").Elements("E1PLOGI").Elements("E1PITYP")
|
|||
|
// .Elements("E1P0019")
|
|||
|
// .Where(elmnt => ((string)elmnt.Element("SUBTY")) == "01");
|
|||
|
var oEmpConfirm = oXElement.Descendants("E1P0019")
|
|||
|
.Where(elmnt => ((string)elmnt.Element("SUBTY")) == "01");
|
|||
|
|
|||
|
foreach (XElement xEle in oEmpConfirm)
|
|||
|
{
|
|||
|
string sEmpNo = (string)xEle.Element("PERNR");
|
|||
|
_sEmpNo = sEmpNo;
|
|||
|
string sEmpConfrimDate = (string)xEle.Element("TERMN");
|
|||
|
Employee oEmployee = null;
|
|||
|
if (sEmpNo.StartsWith("869")) continue;
|
|||
|
if (sEmpConfrimDate != null)
|
|||
|
{
|
|||
|
DateTime confirmDate = Convert.ToDateTime(sEmpConfrimDate.Substring(0, 4) + "-" +
|
|||
|
sEmpConfrimDate.Substring(4, 2) + "-" +
|
|||
|
sEmpConfrimDate.Substring(6, 2));
|
|||
|
|
|||
|
oEmployee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(o => o.EmployeeID == oEmployee.ID)
|
|||
|
.Single();
|
|||
|
oSAPDataDump.ConfirmationDate = confirmDate;
|
|||
|
EmpLifeCycle
|
|||
|
oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
|
|||
|
oEmpLifeCycle.EffectDate = confirmDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Confirm date changed for ");
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
oEmpLifeCycleItem.EffectDate = confirmDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Confirm date changed for ");
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oEmployee = _Employees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oSAPDataDump != null)
|
|||
|
{
|
|||
|
oSAPDataDump.ConfirmationDate = confirmDate;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oSAPDataDump = new SAPDataDump();
|
|||
|
oSAPDataDump.EmployeeID = oEmployee.ID;
|
|||
|
oSAPDataDump.ConfirmationDate = confirmDate;
|
|||
|
_SAPDProcess.SAPDataDumps.Add(oSAPDataDump);
|
|||
|
}
|
|||
|
|
|||
|
EmpLifeCycle
|
|||
|
oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
oEmpLifeCycle.EffectDate = confirmDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Confirm date changed for ");
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
oEmpLifeCycleItem.EffectDate = confirmDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Confirm date changed for ");
|
|||
|
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, oEmployee, "Employee not found while updates Confirm date ");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Employee Discontinue Data and Discontinue Type Update
|
|||
|
|
|||
|
//var oEmpDiscontinue = oXElement.Elements("IDOC").Elements("E1PLOGI").Elements("E1PITYP")
|
|||
|
// .Elements("E1P0000")
|
|||
|
// .Where(elmnt => ((string)elmnt.Element("MASSN")) == "ZZ");
|
|||
|
|
|||
|
var oEmpDiscontinue = oXElement.Descendants("E1P0000")
|
|||
|
.Where(elmnt => ((string)elmnt.Element("MASSN")) == "ZZ");
|
|||
|
|
|||
|
foreach (XElement xEle in oEmpDiscontinue)
|
|||
|
{
|
|||
|
|
|||
|
string sEmpNo = (string)xEle.Element("PERNR");
|
|||
|
_sEmpNo = sEmpNo;
|
|||
|
string sEmpDiscontinueDate = (string)xEle.Element("BEGDA");
|
|||
|
string sDiscontinueType = (string)xEle.Element("STAT2");
|
|||
|
//if (sEmpNo.StartsWith("869")) continue;
|
|||
|
Employee oEmployee = null;
|
|||
|
if (sEmpDiscontinueDate != null)
|
|||
|
{
|
|||
|
DateTime discontinueDate = Convert.ToDateTime(sEmpDiscontinueDate.Substring(0, 4) + "-" +
|
|||
|
sEmpDiscontinueDate.Substring(4, 2) + "-" +
|
|||
|
sEmpDiscontinueDate.Substring(6, 2));
|
|||
|
oEmployee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(o => o.EmployeeID == oEmployee.ID)
|
|||
|
.Single();
|
|||
|
oSAPDataDump.DiscontinueEffectDate = discontinueDate;
|
|||
|
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (sDiscontinueType != null)
|
|||
|
{
|
|||
|
switch (Convert.ToInt16(sDiscontinueType))
|
|||
|
{
|
|||
|
case 0:
|
|||
|
oEmpLifeCycle.Status = EnumEmployeeStatus.Discontinued;
|
|||
|
oEmpLifeCycle.IsDiscontinue = true;
|
|||
|
oEmpLifeCycle.EffectDate = discontinueDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee status changed to Discontinued for ");
|
|||
|
break;
|
|||
|
|
|||
|
case 1:
|
|||
|
oEmpLifeCycle.Status = EnumEmployeeStatus.Withheld;
|
|||
|
oEmpLifeCycle.IsDiscontinue = true;
|
|||
|
oEmpLifeCycle.EffectDate = discontinueDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee Status changed to Withheld for ");
|
|||
|
break;
|
|||
|
// case 3:
|
|||
|
// oEmpLifeCycle.Status = EnumEmployeeStatus.Live;
|
|||
|
// oEmpLifeCycle.EffectDate = discontinueDate;
|
|||
|
// AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee Status changed for ");
|
|||
|
// break;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
if (sDiscontinueType != null)
|
|||
|
{
|
|||
|
switch (Convert.ToInt16(sDiscontinueType))
|
|||
|
{
|
|||
|
case 0:
|
|||
|
oEmpLifeCycleItem.Status = EnumEmployeeStatus.Discontinued;
|
|||
|
oEmpLifeCycleItem.IsDiscontinue = true;
|
|||
|
oEmpLifeCycleItem.EffectDate = discontinueDate;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee status changed to Discontinued for ");
|
|||
|
break;
|
|||
|
|
|||
|
case 1:
|
|||
|
oEmpLifeCycleItem.Status = EnumEmployeeStatus.Withheld;
|
|||
|
oEmpLifeCycleItem.IsDiscontinue = true;
|
|||
|
oEmpLifeCycleItem.EffectDate = discontinueDate;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee Status changed to Withheld for ");
|
|||
|
break;
|
|||
|
// case 3:
|
|||
|
// oEmpLifeCycleItem.Status = EnumEmployeeStatus.Live;
|
|||
|
// oEmpLifeCycleItem.EffectDate = discontinueDate;
|
|||
|
// oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
// oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
// AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Confirm date changed for ");
|
|||
|
// _newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
// _SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
// AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee Status changed for ");
|
|||
|
// break;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oEmployee = _Employees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oSAPDataDump != null)
|
|||
|
{
|
|||
|
oSAPDataDump.DiscontinueEffectDate = discontinueDate;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oSAPDataDump = new SAPDataDump();
|
|||
|
oSAPDataDump.EmployeeID = oEmployee.ID;
|
|||
|
oSAPDataDump.DiscontinueEffectDate = discontinueDate;
|
|||
|
_SAPDProcess.SAPDataDumps.Add(oSAPDataDump);
|
|||
|
}
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (sDiscontinueType != null)
|
|||
|
{
|
|||
|
switch (Convert.ToInt16(sDiscontinueType))
|
|||
|
{
|
|||
|
case 0:
|
|||
|
oEmpLifeCycle.Status = EnumEmployeeStatus.Discontinued;
|
|||
|
oEmpLifeCycle.IsDiscontinue = true;
|
|||
|
oEmpLifeCycle.EffectDate = discontinueDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee status changed to Discontinued for ");
|
|||
|
break;
|
|||
|
|
|||
|
case 1:
|
|||
|
oEmpLifeCycle.Status = EnumEmployeeStatus.Withheld;
|
|||
|
oEmpLifeCycle.IsDiscontinue = true;
|
|||
|
oEmpLifeCycle.EffectDate = discontinueDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee Status changed to Withheld for ");
|
|||
|
break;
|
|||
|
// case 3:
|
|||
|
// oEmpLifeCycle.Status = EnumEmployeeStatus.Live;
|
|||
|
// oEmpLifeCycle.EffectDate = discontinueDate;
|
|||
|
// AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee Status changed for ");
|
|||
|
// break;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
if (sDiscontinueType != null)
|
|||
|
{
|
|||
|
switch (Convert.ToInt16(sDiscontinueType))
|
|||
|
{
|
|||
|
case 0:
|
|||
|
oEmpLifeCycleItem.Status = EnumEmployeeStatus.Discontinued;
|
|||
|
oEmpLifeCycleItem.IsDiscontinue = true;
|
|||
|
oEmpLifeCycleItem.EffectDate = discontinueDate;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee status changed to Discontinued for ");
|
|||
|
break;
|
|||
|
|
|||
|
case 1:
|
|||
|
oEmpLifeCycleItem.Status = EnumEmployeeStatus.Withheld;
|
|||
|
oEmpLifeCycleItem.IsDiscontinue = true;
|
|||
|
oEmpLifeCycleItem.EffectDate = discontinueDate;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee Status changed to Withheld for ");
|
|||
|
break;
|
|||
|
// case 3:
|
|||
|
// oEmpLifeCycleItem.Status = EnumEmployeeStatus.Live;
|
|||
|
// oEmpLifeCycleItem.EffectDate = discontinueDate;
|
|||
|
// oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
// oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
// AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Confirm date changed for ");
|
|||
|
// _newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
// _SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
// AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Employee Status changed for ");
|
|||
|
// break;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee not found while updating status for ");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Employee Rehire
|
|||
|
|
|||
|
//var oEmpRehire = oXElement.Elements("IDOC").Elements("E1PLOGI").Elements("E1PITYP")
|
|||
|
// .Elements("E1P0000")
|
|||
|
// .Where(elmnt => ((string)elmnt.Element("MASSN")) == "Z3");
|
|||
|
|
|||
|
var oEmpRehire = oXElement.Descendants("E1P0000")
|
|||
|
.Where(elmnt => ((string)elmnt.Element("MASSN")) == "Z3");
|
|||
|
|
|||
|
foreach (XElement xEle in oEmpRehire)
|
|||
|
{
|
|||
|
|
|||
|
string sEmpNo = (string)xEle.Element("PERNR");
|
|||
|
_sEmpNo = sEmpNo;
|
|||
|
string sEmpRehireDate = (string)xEle.Element("BEGDA");
|
|||
|
//if (sEmpNo.StartsWith("869")) continue;
|
|||
|
//string sDiscontinueType = (string)xEle.Element("STAT2");
|
|||
|
Employee oEmployee = null;
|
|||
|
if (sEmpRehireDate != null)
|
|||
|
{
|
|||
|
DateTime rehireDate = Convert.ToDateTime(sEmpRehireDate.Substring(0, 4) + "-" +
|
|||
|
sEmpRehireDate.Substring(4, 2) + "-" +
|
|||
|
sEmpRehireDate.Substring(6, 2));
|
|||
|
oEmployee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(o => o.EmployeeID == oEmployee.ID)
|
|||
|
.Single();
|
|||
|
oSAPDataDump.ReHiringDate = rehireDate;
|
|||
|
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
|
|||
|
//oEmpLifeCycle.IsReHire = true;
|
|||
|
oEmpLifeCycle.EffectDate = rehireDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Rehired Employee on {0} with ID ", rehireDate.ToString("dd MMM yyyy")));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
//oEmpLifeCycle.IsReHire = true;
|
|||
|
oEmpLifeCycleItem.EffectDate = rehireDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Rehired Employee on {0} with ID ", rehireDate.ToString("dd MMM yyyy")));
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oEmployee = _Employees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oSAPDataDump != null)
|
|||
|
{
|
|||
|
oSAPDataDump.DiscontinueEffectDate = rehireDate;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oSAPDataDump = new SAPDataDump();
|
|||
|
oSAPDataDump.EmployeeID = oEmployee.ID;
|
|||
|
oSAPDataDump.DiscontinueEffectDate = rehireDate;
|
|||
|
_SAPDProcess.SAPDataDumps.Add(oSAPDataDump);
|
|||
|
}
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
//oEmpLifeCycle.IsReHire = true;
|
|||
|
oEmpLifeCycle.EffectDate = rehireDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Rehired Employee on {0} with ID ", rehireDate.ToString("dd MMM yyyy")));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
//oEmpLifeCycleItem.IsReHire = true;
|
|||
|
oEmpLifeCycleItem.EffectDate = rehireDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Rehired Employee on {0} with ID ", rehireDate.ToString("dd MMM yyyy")));
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee not found while updating status for ");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Employee Designation ,CC Data Update
|
|||
|
|
|||
|
|
|||
|
//var oEmpDesigCC = oXElement.Elements("IDOC").Elements("E1PLOGI").Elements("E1PITYP")
|
|||
|
// .Elements("E1P0001")
|
|||
|
// .Where(elmnt => ((string)elmnt.Element("ENDDA") == "99991231")
|
|||
|
// && ((string)elmnt.Element("PLANS") != "99999999"));
|
|||
|
var oEmpDesigCC = oXElement.Descendants("E1P0001")
|
|||
|
.Where(elmnt => ((string)elmnt.Element("ENDDA") == "99991231")
|
|||
|
&& ((string)elmnt.Element("PLANS") != "99999999"));
|
|||
|
|
|||
|
foreach (XElement xEle in oEmpDesigCC)
|
|||
|
{
|
|||
|
string sEmpNo = (string)xEle.Element("PERNR");
|
|||
|
_sEmpNo = sEmpNo;
|
|||
|
string sEmpDesignation = (string)xEle.Element("PLANS");
|
|||
|
string sEpCCCode = (string)xEle.Element("KOSTL");
|
|||
|
string sEffectDate = (string)xEle.Element("BEGDA");
|
|||
|
|
|||
|
//if (sEmpNo.StartsWith("869")) continue;
|
|||
|
dEffectDate = sEffectDate == null ?
|
|||
|
DateTime.MinValue :
|
|||
|
Convert.ToDateTime(sEffectDate.Substring(0, 4) + "-" +
|
|||
|
sEffectDate.Substring(4, 2) + "-" +
|
|||
|
sEffectDate.Substring(6, 2));
|
|||
|
|
|||
|
#region CostCenter Update
|
|||
|
|
|||
|
Employee oEmployee = null;
|
|||
|
if (sEpCCCode != null)
|
|||
|
{
|
|||
|
Costcenter oCC = _Costcenters
|
|||
|
.Where(oCCItem => oCCItem.Code == sEpCCCode)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oCC != null)
|
|||
|
{
|
|||
|
CRGDepartmentLookup oCRG = _CRGDepartmentLookup
|
|||
|
.Where(oCCItem => oCCItem.CrgID == oCC.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oCRG != null)
|
|||
|
{
|
|||
|
oEmployee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null) // if Employee found in new Employee List
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
oSAPDataDump.CostCenterCode = sEpCCCode;
|
|||
|
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (oEmpLifeCycle.Status == EnumEmployeeStatus.Discontinued) continue;
|
|||
|
oEmpLifeCycle.EffectDate = sEffectDate == null ? oEmpLifeCycle.EffectDate : dEffectDate;
|
|||
|
oEmpLifeCycle.CostCenterID = oCRG.CrgID;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Cost Center changed to {0} for ", sEpCCCode));
|
|||
|
|
|||
|
oEmpLifeCycle.DepartmentID = oCRG.DepartmentID;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Department changed for ");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.CostCenterID = oCRG.CrgID;
|
|||
|
oEmpLifeCycleItem.DepartmentID = oCRG.DepartmentID;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Cost Center changed to {0} for ", sEpCCCode));
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Department changed for ");
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oEmployee = _Employees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null) // Employee Found in Database
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oSAPDataDump != null)
|
|||
|
{
|
|||
|
oSAPDataDump.CostCenterCode = sEpCCCode;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oSAPDataDump = new SAPDataDump();
|
|||
|
oSAPDataDump.EmployeeID = oEmployee.ID;
|
|||
|
oSAPDataDump.CostCenterCode = sEpCCCode;
|
|||
|
_SAPDProcess.SAPDataDumps.Add(oSAPDataDump);
|
|||
|
}
|
|||
|
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (oEmpLifeCycle.Status == EnumEmployeeStatus.Discontinued) continue;
|
|||
|
oEmpLifeCycle.EffectDate = sEffectDate == null ? oEmpLifeCycle.EffectDate : dEffectDate;
|
|||
|
oEmpLifeCycle.CostCenterID = oCRG.CrgID;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Cost Center changed to {0} for ", sEpCCCode));
|
|||
|
oEmpLifeCycle.DepartmentID = oCRG.DepartmentID;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Department changed for ");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.CostCenterID = oCRG.CrgID;
|
|||
|
oEmpLifeCycleItem.DepartmentID = oCRG.DepartmentID;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Cost Center changed to {0} for ", sEpCCCode));
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee not found while updating Costcenter and Designation for ID ");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Department code not found in Cost Center and Department Lookup for Cost center code:" + sEpCCCode + " for EmployeeNo ");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Cost center code:" + sEpCCCode + " not found for ");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Designation Update
|
|||
|
|
|||
|
Designation oDesignation = null;
|
|||
|
if (sEmpDesignation != null)
|
|||
|
{
|
|||
|
oDesignation = _Designations
|
|||
|
.Where(e => e.SapDesCodes
|
|||
|
.Exists(q => q.SAPCode == sEmpDesignation))
|
|||
|
.SingleOrDefault();
|
|||
|
if (oDesignation != null)
|
|||
|
{
|
|||
|
oEmployee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null) // Employee Found in new Employee List
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(o => o.EmployeeID == oEmployee.ID)
|
|||
|
.Single();
|
|||
|
oSAPDataDump.DesignationCode = sEmpDesignation;
|
|||
|
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (oEmpLifeCycle.Status == EnumEmployeeStatus.Discontinued) continue;
|
|||
|
oEmpLifeCycle.DesignationID = oDesignation.ID;
|
|||
|
oEmpLifeCycle.EffectDate = sEffectDate == null ? oEmpLifeCycle.EffectDate : dEffectDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Designation changed to {0} for ", oDesignation.Code));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.DesignationID = oDesignation.ID;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Designation changed to {0} for ", oDesignation.Code));
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oEmployee = _Employees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oSAPDataDump != null)
|
|||
|
{
|
|||
|
oSAPDataDump.DesignationCode = sEmpDesignation;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oSAPDataDump = new SAPDataDump();
|
|||
|
oSAPDataDump.EmployeeID = oEmployee.ID;
|
|||
|
oSAPDataDump.DesignationCode = sEmpDesignation;
|
|||
|
_SAPDProcess.SAPDataDumps.Add(oSAPDataDump);
|
|||
|
}
|
|||
|
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (oEmpLifeCycle.Status == EnumEmployeeStatus.Discontinued) continue;
|
|||
|
oEmpLifeCycle.DesignationID = oDesignation.ID;
|
|||
|
oEmpLifeCycle.EffectDate = sEffectDate == null ? oEmpLifeCycle.EffectDate : dEffectDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Designation changed to {0} for ", oDesignation.Code));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.DesignationID = oDesignation.ID;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Designation changed to {0} for ", oDesignation.Code));
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee not found while updating Designation for ");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
else
|
|||
|
{
|
|||
|
if (sEmpNo.StartsWith("869"))
|
|||
|
{
|
|||
|
oDesignation = _Designations
|
|||
|
.Where(e => e.Name.Trim().ToUpper() == "EXTERNAL")
|
|||
|
.SingleOrDefault();
|
|||
|
if (oDesignation != null)
|
|||
|
{
|
|||
|
oEmployee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null) // Employee Found in new Employee List
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
|
|||
|
if (oEmployee.ID.Integer > 100000) // If Employee is new
|
|||
|
{
|
|||
|
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(o => o.EmployeeID == oEmployee.ID)
|
|||
|
.Single();
|
|||
|
oSAPDataDump.DesignationCode = sEmpDesignation;
|
|||
|
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (oEmpLifeCycle.Status == EnumEmployeeStatus.Discontinued) continue;
|
|||
|
oEmpLifeCycle.DesignationID = oDesignation.ID;
|
|||
|
oEmpLifeCycle.EffectDate = sEffectDate == null ? oEmpLifeCycle.EffectDate : dEffectDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Designation changed to {0} for ", oDesignation.Code));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.DesignationID = oDesignation.ID;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Designation changed to {0} for ", oDesignation.Code));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oEmployee = _Employees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
// Because it is an old Employee so
|
|||
|
// Designation should not be set to EXTERNAL
|
|||
|
continue;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee not found while updating Designation for ");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Default Designation Code: \'EXTERNAL\' Not found in Payroll for ");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee Designation Code: " + sEmpDesignation + " Not found in Payroll for ");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Employee Location
|
|||
|
|
|||
|
//var oEmpLocations = oXElement.Elements("IDOC").Elements("E1PLOGI").Elements("E1PITYP")
|
|||
|
// .Elements("Y1PAXX_9008WA01");
|
|||
|
var oEmpLocations = oXElement.Descendants("Y1PAXX_9008WA01");
|
|||
|
|
|||
|
|
|||
|
foreach (XElement xEle in oEmpLocations)
|
|||
|
{
|
|||
|
string sEmpNo = (string)xEle.Element("PERNR");
|
|||
|
_sEmpNo = sEmpNo;
|
|||
|
string sEmpLocation = (string)xEle.Element("YBFO");
|
|||
|
string sEffectDate = (string)xEle.Element("AEDTM");
|
|||
|
//if (sEmpNo.StartsWith("869")) continue;
|
|||
|
dEffectDate = sEffectDate == null ?
|
|||
|
DateTime.MinValue :
|
|||
|
Convert.ToDateTime(sEffectDate.Substring(0, 4) + "-" +
|
|||
|
sEffectDate.Substring(4, 2) + "-" +
|
|||
|
sEffectDate.Substring(6, 2));
|
|||
|
Employee oEmployee = null;
|
|||
|
|
|||
|
|
|||
|
Location oLocation = null;
|
|||
|
if (sEmpLocation != null)
|
|||
|
{
|
|||
|
oLocation = _Locations
|
|||
|
.Where(oLocItem => oLocItem.Name.Trim().ToUpper() == sEmpLocation.Trim().ToUpper())
|
|||
|
.OrderByDescending(x => x.Tier)
|
|||
|
.Take(1)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oLocation != null)
|
|||
|
{
|
|||
|
oEmployee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy) continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(o => o.EmployeeID == oEmployee.ID)
|
|||
|
.Single();
|
|||
|
oSAPDataDump.LocationCode = sEmpLocation;
|
|||
|
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (oEmpLifeCycle.Status == EnumEmployeeStatus.Discontinued) continue;
|
|||
|
oEmpLifeCycle.LocationID = oLocation.ID;
|
|||
|
oEmpLifeCycle.EffectDate = sEffectDate == null ? oEmpLifeCycle.EffectDate : dEffectDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Location changed to {0} for ", sEmpLocation.Trim()));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.LocationID = oLocation.ID;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Location changed to {0} for ", sEmpLocation.Trim()));
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oEmployee = _Employees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oSAPDataDump != null)
|
|||
|
{
|
|||
|
oSAPDataDump.LocationCode = sEmpLocation;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oSAPDataDump = new SAPDataDump();
|
|||
|
oSAPDataDump.EmployeeID = oEmployee.ID;
|
|||
|
oSAPDataDump.LocationCode = sEmpLocation;
|
|||
|
_SAPDProcess.SAPDataDumps.Add(oSAPDataDump);
|
|||
|
}
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (oEmpLifeCycle.Status == EnumEmployeeStatus.Discontinued) continue;
|
|||
|
oEmpLifeCycle.LocationID = oLocation.ID;
|
|||
|
oEmpLifeCycle.EffectDate = sEffectDate == null ? oEmpLifeCycle.EffectDate : dEffectDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Location changed to {0} for ", sEmpLocation.Trim()));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.LocationID = oLocation.ID;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Location changed to {0} for ", sEmpLocation.Trim()));
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee not found while updating Location for ");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oLocation = _Locations
|
|||
|
.Where(oLocItem => oLocItem.Name.Trim().ToUpper() == "Location_Error".Trim().ToUpper())
|
|||
|
.OrderByDescending(x => x.Tier)
|
|||
|
.Take(1)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
oEmployee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(o => o.EmployeeID == oEmployee.ID)
|
|||
|
.Single();
|
|||
|
oSAPDataDump.LocationCode = sEmpLocation;
|
|||
|
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (oEmpLifeCycle.Status == EnumEmployeeStatus.Discontinued) continue;
|
|||
|
oEmpLifeCycle.LocationID = oLocation.ID;
|
|||
|
oEmpLifeCycle.EffectDate = sEffectDate == null ? oEmpLifeCycle.EffectDate : dEffectDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee
|
|||
|
, String.Format("Location Not found: \'{0}\',Set to Default Location: \'{1}\' for ", sEmpLocation.Trim(), oLocation.Name.Trim()));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.LocationID = oLocation.ID;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee
|
|||
|
, String.Format("Location Not found: \'{0}\',Set to Default Location: \'{1}\' for ", sEmpLocation.Trim(), oLocation.Name.Trim()));
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oEmployee = _Employees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oSAPDataDump != null)
|
|||
|
{
|
|||
|
oSAPDataDump.LocationCode = sEmpLocation;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oSAPDataDump = new SAPDataDump();
|
|||
|
oSAPDataDump.EmployeeID = oEmployee.ID;
|
|||
|
oSAPDataDump.LocationCode = sEmpLocation;
|
|||
|
_SAPDProcess.SAPDataDumps.Add(oSAPDataDump);
|
|||
|
}
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (oEmpLifeCycle.Status == EnumEmployeeStatus.Discontinued) continue;
|
|||
|
oEmpLifeCycle.LocationID = oLocation.ID;
|
|||
|
oEmpLifeCycle.EffectDate = sEffectDate == null ? oEmpLifeCycle.EffectDate : dEffectDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee
|
|||
|
, String.Format("Location Not found: \'{0}\',Set to Default Location: \'{1}\' for ", sEmpLocation.Trim(), oLocation.Name.Trim()));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.LocationID = oLocation.ID;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee
|
|||
|
, String.Format("Location Not found: \'{0}\',Set to Default Location: \'{1}\' for ", sEmpLocation.Trim(), oLocation.Name.Trim()));
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
|
|||
|
}
|
|||
|
//Error Generate
|
|||
|
//AddProcessStatus(EnumSAPProcessStatus.Error, oEmployee, "Life Cycle Employee not found.");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee not found while updating Location for ");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Bank data update
|
|||
|
|
|||
|
//var oEmpBank = oXElement.Elements("IDOC").Elements("E1PLOGI").Elements("E1PITYP")
|
|||
|
// .Elements("E1P0009");
|
|||
|
var oEmpBank = oXElement.Descendants("E1P0009");
|
|||
|
|
|||
|
foreach (XElement xEle in oEmpBank)
|
|||
|
{
|
|||
|
string sEmpNo = (string)xEle.Element("PERNR");
|
|||
|
_sEmpNo = sEmpNo;
|
|||
|
string sEmpBranchCode = (string)xEle.Element("BANKL");
|
|||
|
string sEmpACNo = (string)xEle.Element("BANKN");
|
|||
|
string sEffectDate = (string)xEle.Element("BEGDA");
|
|||
|
//if (sEmpNo.StartsWith("869")) continue;
|
|||
|
if (sEmpBranchCode != null)
|
|||
|
{
|
|||
|
Branch oBranch = _Branchs
|
|||
|
.Where(oItem => oItem.Code == sEmpBranchCode)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
Employee oEmployee = null;
|
|||
|
if (oBranch != null)
|
|||
|
{
|
|||
|
Bank oBank = _Banks
|
|||
|
.Where(oItem => oItem.ID == oBranch.BankID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
oEmployee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(o => o.EmployeeID == oEmployee.ID)
|
|||
|
.Single();
|
|||
|
oSAPDataDump.BankCode = sEmpBranchCode;
|
|||
|
oSAPDataDump.BankAccountNo = sEmpACNo;
|
|||
|
EmployeeBankAccount
|
|||
|
oEmpBankAccount = _EmployeeBankAccounts
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oEmpBankAccount != null)
|
|||
|
{
|
|||
|
oEmpBankAccount.BranchID = oBranch.ID;
|
|||
|
|
|||
|
if (sEmpACNo != null)
|
|||
|
{
|
|||
|
oEmpBankAccount.AccountNo = sEmpACNo;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Account Number changed to {0} for ", sEmpACNo));
|
|||
|
}
|
|||
|
if (sEffectDate != null)
|
|||
|
{
|
|||
|
oEmpBankAccount.EffectDate = Convert.ToDateTime(sEffectDate.Substring(0, 4) + "-" +
|
|||
|
sEffectDate.Substring(4, 2) + "-" +
|
|||
|
sEffectDate.Substring(6, 2));
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Bank effect date changed to {0} for ", oEmpBankAccount.EffectDate.ToString("dd MMM yyyy")));
|
|||
|
}
|
|||
|
oEmpBankAccount.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpBankAccount.IsSapProcess = true;
|
|||
|
//_newEmpBankAccount.Add(oEmpBankAccount);
|
|||
|
_SAPDProcess.EmpBankAccounts.Add(oEmpBankAccount);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmployeeBankAccount oBankAccount = new EmployeeBankAccount();
|
|||
|
oBankAccount.BranchID = oBranch.ID;
|
|||
|
|
|||
|
if (sEmpACNo != null)
|
|||
|
{
|
|||
|
oBankAccount.AccountNo = sEmpACNo;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Account Number changed to {0} for ", sEmpACNo));
|
|||
|
}
|
|||
|
|
|||
|
if (sEffectDate != null)
|
|||
|
{
|
|||
|
oBankAccount.EffectDate = Convert.ToDateTime(sEffectDate.Substring(0, 4) + "-" +
|
|||
|
sEffectDate.Substring(4, 2) + "-" +
|
|||
|
sEffectDate.Substring(6, 2));
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Bank effect date changed to {0} for ", oBankAccount.EffectDate.ToString("dd MMM yyyy")));
|
|||
|
|
|||
|
}
|
|||
|
//AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Successfully add bank account history. ");
|
|||
|
oBankAccount.EmployeeID = oEmployee.ID;
|
|||
|
//oBankAccount.IsSapProcess = true;
|
|||
|
//_newEmpBankAccount.Add(oBankAccount);
|
|||
|
_SAPDProcess.EmpBankAccounts.Add(oBankAccount);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oEmployee = _Employees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oSAPDataDump != null)
|
|||
|
{
|
|||
|
oSAPDataDump.BankCode = sEmpBranchCode;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oSAPDataDump = new SAPDataDump();
|
|||
|
oSAPDataDump.EmployeeID = oEmployee.ID;
|
|||
|
oSAPDataDump.BankCode = sEmpBranchCode;
|
|||
|
_SAPDProcess.SAPDataDumps.Add(oSAPDataDump);
|
|||
|
}
|
|||
|
|
|||
|
EmployeeBankAccount
|
|||
|
oEmpBankAccount = _EmployeeBankAccounts
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpBankAccount != null)
|
|||
|
{
|
|||
|
oEmpBankAccount.BranchID = oBranch.ID;
|
|||
|
|
|||
|
if (sEmpACNo != null)
|
|||
|
{
|
|||
|
oEmpBankAccount.AccountNo = sEmpACNo;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Account Number changed to {0} for ", sEmpACNo));
|
|||
|
}
|
|||
|
if (sEffectDate != null)
|
|||
|
{
|
|||
|
oEmpBankAccount.EffectDate = Convert.ToDateTime(sEffectDate.Substring(0, 4) + "-" +
|
|||
|
sEffectDate.Substring(4, 2) + "-" +
|
|||
|
sEffectDate.Substring(6, 2));
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Bank effect date changed to {0} for ", oEmpBankAccount.EffectDate.ToString("dd MMM yyyy")));
|
|||
|
|
|||
|
}
|
|||
|
oEmpBankAccount.EmployeeID = oEmployee.ID;
|
|||
|
// oEmpBankAccount.IsSapProcess = true;
|
|||
|
//_newEmpBankAccount.Add(oEmpBankAccount);
|
|||
|
_SAPDProcess.EmpBankAccounts.Add(oEmpBankAccount);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmployeeBankAccount oBankAccount = new EmployeeBankAccount();
|
|||
|
oBankAccount.BranchID = oBranch.ID;
|
|||
|
|
|||
|
if (sEmpACNo != null)
|
|||
|
{
|
|||
|
oBankAccount.AccountNo = sEmpACNo;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Account Number changed to {0} for ", sEmpACNo));
|
|||
|
}
|
|||
|
|
|||
|
if (sEffectDate != null)
|
|||
|
{
|
|||
|
oBankAccount.EffectDate = Convert.ToDateTime(sEffectDate.Substring(0, 4) + "-" +
|
|||
|
sEffectDate.Substring(4, 2) + "-" +
|
|||
|
sEffectDate.Substring(6, 2));
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Bank effect date changed to {0} for ", oBankAccount.EffectDate.ToString("dd MMM yyyy")));
|
|||
|
}
|
|||
|
//AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Successfully add bank account history. ");
|
|||
|
oBankAccount.EmployeeID = oEmployee.ID;
|
|||
|
//oBankAccount.IsSapProcess = true;
|
|||
|
//_newEmpBankAccount.Add(oBankAccount);
|
|||
|
_SAPDProcess.EmpBankAccounts.Add(oBankAccount);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee not found while updating Bank for ");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Branch Code:" + sEmpBranchCode + " not found in Payroll for ");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Employee Grades Data Update
|
|||
|
|
|||
|
//var oEmpGrades = oXElement.Elements("IDOC").Elements("E1PLOGI").Elements("E1PITYP")
|
|||
|
// .Elements("Y1PAXX_9006IR01");
|
|||
|
var oEmpGrades = oXElement.Descendants("Y1PAXX_9006IR01");
|
|||
|
|
|||
|
|
|||
|
foreach (XElement xEle in oEmpGrades)
|
|||
|
{
|
|||
|
Grade oGrade = null;
|
|||
|
Employee oEmployee = null;
|
|||
|
string sEmpNo = (string)xEle.Element("PERNR");
|
|||
|
_sEmpNo = sEmpNo;
|
|||
|
string sEmpGrade = (string)xEle.Element("YLJOB_LEVEL");
|
|||
|
string sEffectDate = (string)xEle.Element("BEGDA");
|
|||
|
if (sEmpNo.StartsWith("869")) continue;
|
|||
|
dEffectDate = sEffectDate == null ?
|
|||
|
DateTime.MinValue :
|
|||
|
Convert.ToDateTime(sEffectDate.Substring(0, 4) + "-" +
|
|||
|
sEffectDate.Substring(4, 2) + "-" +
|
|||
|
sEffectDate.Substring(6, 2));
|
|||
|
if (sEmpGrade != null)
|
|||
|
{
|
|||
|
oGrade = _Grades
|
|||
|
.Where(oGradeItem => oGradeItem.Code.Trim().ToUpper() == sEmpGrade.Trim().ToUpper())
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oGrade != null)
|
|||
|
{
|
|||
|
oEmployee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(o => o.EmployeeID == oEmployee.ID)
|
|||
|
.Single();
|
|||
|
oSAPDataDump.LocalJobGrade = sEmpGrade;
|
|||
|
|
|||
|
EmpLifeCycle
|
|||
|
oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (oEmpLifeCycle.Status == EnumEmployeeStatus.Discontinued) continue;
|
|||
|
oEmpLifeCycle.GradeID = oGrade.ID;
|
|||
|
oEmpLifeCycle.EffectDate = sEffectDate == null ? oEmpLifeCycle.EffectDate : dEffectDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Grade changed to {0} for ", sEmpGrade.Trim()));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.GradeID = oGrade.ID;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Grade changed to {0} for ", sEmpGrade.Trim()));
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
oEmployee = _Employees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oSAPDataDump != null)
|
|||
|
{
|
|||
|
oSAPDataDump.LocalJobGrade = sEmpGrade;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oSAPDataDump = new SAPDataDump();
|
|||
|
oSAPDataDump.EmployeeID = oEmployee.ID;
|
|||
|
oSAPDataDump.LocalJobGrade = sEmpGrade;
|
|||
|
_SAPDProcess.SAPDataDumps.Add(oSAPDataDump);
|
|||
|
}
|
|||
|
EmpLifeCycle
|
|||
|
oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (oEmpLifeCycle.Status == EnumEmployeeStatus.Discontinued) continue;
|
|||
|
oEmpLifeCycle.GradeID = oGrade.ID;
|
|||
|
oEmpLifeCycle.EffectDate = sEffectDate == null ? oEmpLifeCycle.EffectDate : dEffectDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Grade changed to {0} for ", sEmpGrade.Trim()));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
oEmpLifeCycleItem.GradeID = oGrade.ID;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, String.Format("Grade changed to {0} for ", sEmpGrade.Trim()));
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee not found while updating Grade for ");
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//Error Generate
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Grade code:" + sEmpGrade + " not found for ");
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Update Basic Salary
|
|||
|
|
|||
|
//var oEmpBasicSalary = oXElement.Elements("IDOC").Elements("E1PLOGI").Elements("E1PITYP")
|
|||
|
// .Elements("E1P0014")
|
|||
|
// .Where(elmnt => ((string)elmnt.Element("SUBTY")) == "8000");
|
|||
|
var oEmpBasicSalary = oXElement.Descendants("E1P0014")
|
|||
|
.Where(elmnt => ((string)elmnt.Element("SUBTY")) == "8000"
|
|||
|
&& ((string)elmnt.Element("ENDDA")) == "99991231");
|
|||
|
foreach (XElement xEle in oEmpBasicSalary)
|
|||
|
{
|
|||
|
string sEmpNo = (string)xEle.Element("PERNR");
|
|||
|
string sBasicSalary = (string)xEle.Element("BETRG");
|
|||
|
string sEffectDate = (string)xEle.Element("BEGDA");
|
|||
|
_sEmpNo = sEmpNo;
|
|||
|
if (sEmpNo.StartsWith("869")) continue;
|
|||
|
dEffectDate = sEffectDate == null ?
|
|||
|
DateTime.MinValue :
|
|||
|
Convert.ToDateTime(sEffectDate.Substring(0, 4) + "-" +
|
|||
|
sEffectDate.Substring(4, 2) + "-" +
|
|||
|
sEffectDate.Substring(6, 2));
|
|||
|
|
|||
|
Employee oEmployee = _SAPDProcess.SAPEmployees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
//Employee tempEmp;
|
|||
|
//if ((tempEmp = _Employees
|
|||
|
// .Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
// .SingleOrDefault()) != null)
|
|||
|
//{
|
|||
|
// if (tempEmp.BasicSalary > Convert.ToDouble(sBasicSalary))
|
|||
|
// {
|
|||
|
// AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee BasicSalary was less than current basic salary for ");
|
|||
|
// continue;
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(o => o.EmployeeID == oEmployee.ID)
|
|||
|
.Single();
|
|||
|
oSAPDataDump.BasicSalary = Convert.ToDouble(sBasicSalary);
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycleItem != null)
|
|||
|
{
|
|||
|
if (oEmpLifeCycleItem.Status == EnumEmployeeStatus.Discontinued) continue;
|
|||
|
if (sBasicSalary != null)
|
|||
|
{
|
|||
|
oEmpLifeCycleItem.BasicSalary = Convert.ToDouble(sBasicSalary);
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Basic salary changed for ");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
if (sBasicSalary != null)
|
|||
|
{
|
|||
|
oEmpLifeCycleItem.BasicSalary = Convert.ToDouble(sBasicSalary);
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Basic salary changed for ");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
oEmployee = _Employees
|
|||
|
.Where(oEmpItem => oEmpItem.EmployeeNo == sEmpNo)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
|
|||
|
|
|||
|
if (oEmployee != null)
|
|||
|
{
|
|||
|
|
|||
|
//if (oEmployee.BasicSalary > Convert.ToDouble(sBasicSalary))
|
|||
|
//{
|
|||
|
// AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee BasicSalary was less than current basic salary for ");
|
|||
|
// continue;
|
|||
|
//}
|
|||
|
|
|||
|
if (oEmployee.Status == EnumEmployeeStatus.Secondy)
|
|||
|
continue;
|
|||
|
SAPDataDump oSAPDataDump = _SAPDProcess
|
|||
|
.SAPDataDumps
|
|||
|
.Where(oItem => oItem.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
if (oSAPDataDump != null)
|
|||
|
{
|
|||
|
oSAPDataDump.BasicSalary = Convert.ToDouble(sBasicSalary);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oSAPDataDump = new SAPDataDump();
|
|||
|
oSAPDataDump.EmployeeID = oEmployee.ID;
|
|||
|
oSAPDataDump.BasicSalary = Convert.ToDouble(sBasicSalary);
|
|||
|
_SAPDProcess.SAPDataDumps.Add(oSAPDataDump);
|
|||
|
}
|
|||
|
EmpLifeCycle oEmpLifeCycle = _SAPDProcess.SAPEmpLifeCycles
|
|||
|
.Where(obj => obj.EmployeeID == oEmployee.ID)
|
|||
|
.SingleOrDefault();
|
|||
|
if (oEmpLifeCycle != null)
|
|||
|
{
|
|||
|
if (oEmpLifeCycle.Status == EnumEmployeeStatus.Discontinued) continue;
|
|||
|
if (sBasicSalary != null)
|
|||
|
{
|
|||
|
oEmpLifeCycle.BasicSalary = Convert.ToDouble(sBasicSalary);
|
|||
|
oEmpLifeCycle.EffectDate = sEffectDate == null ? oEmpLifeCycle.EffectDate : dEffectDate;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Basic salary changed for ");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpLifeCycle oEmpLifeCycleItem = new EmpLifeCycle();
|
|||
|
if (sBasicSalary != null)
|
|||
|
{
|
|||
|
oEmpLifeCycleItem.BasicSalary = Convert.ToDouble(sBasicSalary);
|
|||
|
oEmpLifeCycleItem.EmployeeID = oEmployee.ID;
|
|||
|
//oEmpLifeCycleItem.IsSapProcess = true;
|
|||
|
oEmpLifeCycleItem.EffectDate = sEffectDate == null ? oEmpLifeCycleItem.EffectDate : dEffectDate;
|
|||
|
//_newEmpLifeCycle.Add(oEmpLifeCycleItem);
|
|||
|
_SAPDProcess.SAPEmpLifeCycles.Add(oEmpLifeCycleItem);
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Success, oEmployee, "Basic salary changed for ");
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "Employee not found while updating BasicSalary for ");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void AssignLifeCycleEvent()
|
|||
|
{
|
|||
|
if (_SAPDProcess != null)
|
|||
|
{
|
|||
|
foreach (EmpLifeCycle oEmpLifeCycle in _SAPDProcess.SAPEmpLifeCycles)
|
|||
|
{
|
|||
|
|
|||
|
if (!_EmpLifeCycles
|
|||
|
.Where(obj => obj.EmployeeID == oEmpLifeCycle.EmployeeID)
|
|||
|
.Any())
|
|||
|
{
|
|||
|
#region Joining
|
|||
|
EmployeeStatus oEmpStatus = _EmployeeStatuss.Find(delegate(EmployeeStatus oEmpItem) { return oEmpItem.ID == ID.FromInteger(100); });
|
|||
|
oEmpLifeCycle.StatusDetailID = oEmpStatus.ID;
|
|||
|
oEmpLifeCycle.Status = oEmpStatus.EmpStatus;
|
|||
|
oEmpLifeCycle.Description = "Joining by SAP";
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
else
|
|||
|
{
|
|||
|
//EmpLifeCycle oPrvEmpLCycle = _EmpLifeCycles.Find(delegate(EmpLifeCycle oEmpItem) { return oEmpItem.EmployeeID == oEmpLifeCycle.EmployeeID; });
|
|||
|
if (oEmpLifeCycle.IsDiscontinue != null && oEmpLifeCycle.IsDiscontinue == true)
|
|||
|
{
|
|||
|
EmployeeStatus oEmpStatus = _EmployeeStatuss.Find(delegate(EmployeeStatus oEmpItem) { return oEmpItem.ID == ID.FromInteger(102); });
|
|||
|
oEmpLifeCycle.StatusDetailID = oEmpStatus.ID;
|
|||
|
oEmpLifeCycle.Status = oEmpStatus.EmpStatus;
|
|||
|
oEmpLifeCycle.Description = "Discontinued By SAP";
|
|||
|
|
|||
|
}
|
|||
|
//else if (oEmpLifeCycle.IsReHire != null && oEmpLifeCycle.IsReHire == true)
|
|||
|
//{
|
|||
|
// EmployeeStatus oEmpStatus = _EmployeeStatuss.Find(delegate(EmployeeStatus oEmpItem) { return oEmpItem.ID == ID.FromInteger(103); });
|
|||
|
// oEmpLifeCycle.StatusDetailID = oEmpStatus.ID;
|
|||
|
// oEmpLifeCycle.Status = oEmpStatus.EmpStatus;
|
|||
|
// oEmpLifeCycle.Description = "Rehired By SAP";
|
|||
|
//}
|
|||
|
else
|
|||
|
{
|
|||
|
EmployeeStatus oEmpStatus = _EmployeeStatuss.Find(delegate(EmployeeStatus oEmpItem) { return oEmpItem.ID == ID.FromInteger(101); });
|
|||
|
oEmpLifeCycle.StatusDetailID = oEmpStatus.ID;
|
|||
|
oEmpLifeCycle.Status = oEmpStatus.EmpStatus;
|
|||
|
oEmpLifeCycle.Description = "Updated By SAP";
|
|||
|
}
|
|||
|
//#region Grade & Basic Salary Change
|
|||
|
|
|||
|
//if (oPrvEmpLCycle.BasicSalary != oEmpLifeCycle.BasicSalary && oPrvEmpLCycle.GradeID != oEmpLifeCycle.GradeID)
|
|||
|
//{
|
|||
|
// EmployeeStatus oEmpStatus = _EmployeeStatuss.Find(delegate(EmployeeStatus oEmpItem) { return oEmpItem.ID == ID.FromInteger(2); });
|
|||
|
// oEmpLifeCycle.StatusDetailID = oEmpStatus.ID;
|
|||
|
// oEmpLifeCycle.Status = oEmpStatus.EmpStatus;
|
|||
|
// oEmpLifeCycle.Description = "Promotion";
|
|||
|
//}
|
|||
|
|
|||
|
//#endregion
|
|||
|
|
|||
|
//#region Basic Salary Change
|
|||
|
|
|||
|
//else if (oPrvEmpLCycle.BasicSalary != oEmpLifeCycle.BasicSalary)
|
|||
|
//{
|
|||
|
// EmployeeStatus oEmpStatus = _EmployeeStatuss.Find(delegate(EmployeeStatus oEmpItem) { return oEmpItem.ID == ID.FromInteger(4); });
|
|||
|
// oEmpLifeCycle.StatusDetailID = oEmpStatus.ID;
|
|||
|
// oEmpLifeCycle.Status = oEmpStatus.EmpStatus;
|
|||
|
// oEmpLifeCycle.Description = "Salary Revised";
|
|||
|
// oEmpLifeCycle.Status = EnumEmployeeStatus.Live;
|
|||
|
//}
|
|||
|
//#endregion
|
|||
|
|
|||
|
//#region Grade,Location,CostCenter,Designation Change
|
|||
|
//else if (oPrvEmpLCycle.GradeID != oEmpLifeCycle.GradeID || oPrvEmpLCycle.LocationID != oEmpLifeCycle.LocationID || oPrvEmpLCycle.CostCenterID != oEmpLifeCycle.CostCenterID || oPrvEmpLCycle.DesignationID != oEmpLifeCycle.DesignationID)
|
|||
|
//{
|
|||
|
// EmployeeStatus oEmpStatus = _EmployeeStatuss.Find(delegate(EmployeeStatus oEmpItem) { return oEmpItem.ID == ID.FromInteger(14); });
|
|||
|
// oEmpLifeCycle.StatusDetailID = oEmpStatus.ID;
|
|||
|
// oEmpLifeCycle.Status = oEmpStatus.EmpStatus;
|
|||
|
// oEmpLifeCycle.Description = "Transfer";
|
|||
|
|
|||
|
//}
|
|||
|
//#endregion
|
|||
|
|
|||
|
//#region Confirmation
|
|||
|
////if (oPrvEmpLCycle.EffectDate != oEmpLifeCycle.EffectDate)
|
|||
|
////{
|
|||
|
//// EmployeeStatus oEmpStatus = _EmployeeStatuss.Find(delegate(EmployeeStatus oEmpItem) { return oEmpItem.ID == ID.FromInteger(27); });
|
|||
|
//// oEmpLifeCycle.StatusDetailID = oEmpStatus.ID;
|
|||
|
//// oEmpLifeCycle.Status = oEmpStatus.EmpStatus;
|
|||
|
//// oEmpLifeCycle.Description = "Confirmation";
|
|||
|
////}
|
|||
|
//#endregion
|
|||
|
|
|||
|
//#region Discontinue Type
|
|||
|
|
|||
|
////if (oPrvEmpLCycle.Status != oEmpLifeCycle.Status)
|
|||
|
////{
|
|||
|
//// if(oEmpLifeCycle.Status==EnumEmployeeStatus.Withheld)
|
|||
|
//// {
|
|||
|
//// }
|
|||
|
//// else if (oEmpLifeCycle.Status == EnumEmployeeStatus.Discontinued)
|
|||
|
//// {
|
|||
|
//// }
|
|||
|
//// //oEmpLifeCycle.Status = oPrvEmpLCycle.Status;
|
|||
|
////}
|
|||
|
//#endregion
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void SaveFileToBackUp(string xmlFileName)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
string sSourceFileName = string.Empty;
|
|||
|
string sDestinationFileName = string.Empty;
|
|||
|
string[] sFileName = null;
|
|||
|
|
|||
|
if (_IntigrationSetup != null)
|
|||
|
{
|
|||
|
sSourceFileName = xmlFileName;
|
|||
|
sFileName = sSourceFileName.Split('\\');
|
|||
|
sDestinationFileName = _IntigrationSetup.StoreFilePath + "\\" + sFileName[sFileName.Length - 1];
|
|||
|
}
|
|||
|
|
|||
|
if (File.Exists(xmlFileName))
|
|||
|
{
|
|||
|
|
|||
|
File.Copy(sSourceFileName, sDestinationFileName, true);
|
|||
|
File.Delete(sSourceFileName);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
throw new Exception("Please check the file location..");
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
throw new Exception(ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void ReadXMLFiles()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (_IntigrationSetup != null)
|
|||
|
{
|
|||
|
string[] files = Directory.GetFiles(_IntigrationSetup.ReadFilePath, "*.xml", SearchOption.TopDirectoryOnly);
|
|||
|
|
|||
|
|
|||
|
var oFiles = new DirectoryInfo(_IntigrationSetup.ReadFilePath)
|
|||
|
.GetFiles("*.xml", SearchOption.TopDirectoryOnly)
|
|||
|
.OrderBy(f => f.Name)
|
|||
|
.ToList();
|
|||
|
|
|||
|
//Array.Sort(files);
|
|||
|
|
|||
|
if (oFiles != null && oFiles.Count() > 0)
|
|||
|
{
|
|||
|
foreach (FileInfo ofile in oFiles)
|
|||
|
{
|
|||
|
if (SAPDataProcess.IsFileSuccessfullyRead(ofile.Name))
|
|||
|
{
|
|||
|
_sEmpNo = string.Empty;
|
|||
|
AddProcessStatus(EnumSAPProcessStatus.Error, null, "File : " + ofile.Name + " was successfully read previously.Please check why it was given again");
|
|||
|
continue;
|
|||
|
}
|
|||
|
ReadXMLFile(ofile.FullName);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
else
|
|||
|
{
|
|||
|
throw new Exception("There is no file in:" + _IntigrationSetup.ReadFilePath);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception Ex)
|
|||
|
{
|
|||
|
throw new Exception(Ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void ReadXMLFile(string xmlFileName)
|
|||
|
{
|
|||
|
if (File.Exists(xmlFileName))
|
|||
|
{
|
|||
|
XElement xelement = null;
|
|||
|
xelement = XElement.Load(xmlFileName);
|
|||
|
RefreshNewJoiner(xelement);
|
|||
|
RefreshEmpLifeCycle(xelement);
|
|||
|
AssignLifeCycleEvent();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
throw new Exception("Please check the file location..");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private SAPDataProcess SAPProcessStatus(DateTime dProcessDate, EnumSAPProcessStatus nProcessStatus, string sProcessTime, ID nProcessBy, EnumSendMail nMailStatus)
|
|||
|
{
|
|||
|
_SAPDProcess.ProcessDate = DateTime.Now;
|
|||
|
_SAPDProcess.ProcessStatus = EnumSAPProcessStatus.Success;
|
|||
|
_SAPDProcess.ProcessTime = _SAPDProcess.ProcessDate.ToString("hh:mm tt");
|
|||
|
_SAPDProcess.ProcessBy = Payroll.BO.SystemInformation.CurrentSysInfo.ModifiedBy;
|
|||
|
_SAPDProcess.MailCompleted = EnumSendMail.None;
|
|||
|
return _SAPDProcess;
|
|||
|
}
|
|||
|
|
|||
|
public void AddProcessStatus(EnumSAPProcessStatus nStatus, Employee oEmp, string remarks)
|
|||
|
{
|
|||
|
if (oEmp != null)
|
|||
|
{
|
|||
|
|
|||
|
if (nStatus == EnumSAPProcessStatus.Error)
|
|||
|
{
|
|||
|
SAPDataProcessDetail oSAPProcessDetail = new SAPDataProcessDetail();
|
|||
|
oSAPProcessDetail.EmployeeNo = oEmp.EmployeeNo;
|
|||
|
oSAPProcessDetail.Name = oEmp.Name;
|
|||
|
oSAPProcessDetail.DataType = "";
|
|||
|
oSAPProcessDetail.Description = remarks + oEmp.EmployeeNo + "," + oEmp.Name;
|
|||
|
_ErrorList.Add(oSAPProcessDetail);
|
|||
|
_SAPDProcess.ErrorList.Add(oSAPProcessDetail);
|
|||
|
}
|
|||
|
else if (nStatus == EnumSAPProcessStatus.Success)
|
|||
|
{
|
|||
|
SAPDataProcessDetail oSAPProcessDetail = new SAPDataProcessDetail();
|
|||
|
oSAPProcessDetail.EmployeeNo = oEmp.EmployeeNo;
|
|||
|
oSAPProcessDetail.Name = oEmp.Name;
|
|||
|
oSAPProcessDetail.DataType = "";
|
|||
|
oSAPProcessDetail.Description = remarks + oEmp.EmployeeNo + "," + oEmp.Name;
|
|||
|
_SucccessList.Add(oSAPProcessDetail);
|
|||
|
_SAPDProcess.SuccessList.Add(oSAPProcessDetail);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (nStatus == EnumSAPProcessStatus.Error)
|
|||
|
{
|
|||
|
SAPDataProcessDetail oSAPProcessDetail = new SAPDataProcessDetail();
|
|||
|
oSAPProcessDetail.EmployeeNo = _sEmpNo;
|
|||
|
oSAPProcessDetail.Name = "";
|
|||
|
oSAPProcessDetail.DataType = "";
|
|||
|
oSAPProcessDetail.Description = remarks + _sEmpNo;
|
|||
|
_ErrorList.Add(oSAPProcessDetail);
|
|||
|
_SAPDProcess.ErrorList.Add(oSAPProcessDetail);
|
|||
|
|
|||
|
}
|
|||
|
else if (nStatus == EnumSAPProcessStatus.Success)
|
|||
|
{
|
|||
|
SAPDataProcessDetail oSAPProcessDetail = new SAPDataProcessDetail();
|
|||
|
oSAPProcessDetail.EmployeeNo = _sEmpNo;
|
|||
|
oSAPProcessDetail.Name = "";
|
|||
|
oSAPProcessDetail.DataType = "";
|
|||
|
oSAPProcessDetail.Description = remarks + _sEmpNo;
|
|||
|
_SucccessList.Add(oSAPProcessDetail);
|
|||
|
_SAPDProcess.SuccessList.Add(oSAPProcessDetail);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#region Downloading Files from an FTP Server
|
|||
|
|
|||
|
private void DownloadXMLFilesFromFTP()
|
|||
|
{
|
|||
|
List<string> filesToDownload = GetAllFileListFromAnFTPPath();
|
|||
|
string tempDestinationPath = string.Empty;
|
|||
|
try
|
|||
|
{
|
|||
|
tempDestinationPath = System.IO.Path.Combine(_IntigrationSetup.ReadFilePath, "Out");
|
|||
|
System.IO.Directory.CreateDirectory(tempDestinationPath);
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
throw new Exception("threw from Creationg Out directory");
|
|||
|
}
|
|||
|
try
|
|||
|
{
|
|||
|
DownloadListedFilesFromFTP(filesToDownload, tempDestinationPath);
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
|
|||
|
throw new Exception("threw from Downloading files to out");
|
|||
|
}
|
|||
|
try
|
|||
|
{
|
|||
|
DecryptFiles(filesToDownload, tempDestinationPath);
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
|
|||
|
throw new Exception("threw from Decrypting files");
|
|||
|
}
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
System.IO.Directory.Delete(tempDestinationPath, true);
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
|
|||
|
throw new Exception("threw from deleting temporary file Out");
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private List<string> GetAllFileListFromAnFTPPath()
|
|||
|
{
|
|||
|
List<string> filesToDownload = new List<string>();
|
|||
|
WebResponse response;
|
|||
|
FtpWebRequest ftp;
|
|||
|
try
|
|||
|
{
|
|||
|
ftp = (FtpWebRequest)FtpWebRequest.Create(new Uri(_IntigrationSetup.FTPFilePath));
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
throw new Exception("Threw from Creating FtpRequest");
|
|||
|
}
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
ftp.Credentials = new NetworkCredential(_IntigrationSetup.FTPUserName, _IntigrationSetup.FTPPassword);
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
throw new Exception("Threw from Getting Network Credentials");
|
|||
|
}
|
|||
|
try
|
|||
|
{
|
|||
|
ftp.Method = WebRequestMethods.Ftp.ListDirectory;
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
throw new Exception("Threw from Listing Directory");
|
|||
|
}
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
response = ftp.GetResponse();
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
throw new Exception("Threw from Listing Directory");
|
|||
|
}
|
|||
|
try
|
|||
|
{
|
|||
|
StreamReader reader = new StreamReader(response.GetResponseStream());
|
|||
|
string line = reader.ReadLine();
|
|||
|
while (line != null)
|
|||
|
{
|
|||
|
filesToDownload.Add(line);
|
|||
|
line = reader.ReadLine();
|
|||
|
}
|
|||
|
reader.Close();
|
|||
|
response.Close();
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
throw new Exception("Threw from Reading List");
|
|||
|
}
|
|||
|
|
|||
|
return filesToDownload;
|
|||
|
}
|
|||
|
|
|||
|
private void DownloadListedFilesFromFTP(List<string> filesToDownload, string tempDestFilePath)
|
|||
|
{
|
|||
|
foreach (string fileName in filesToDownload)
|
|||
|
{
|
|||
|
FtpWebRequest reqFTP;
|
|||
|
|
|||
|
FileStream outputStream = new FileStream(tempDestFilePath + "\\" + fileName, FileMode.Create);
|
|||
|
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(_IntigrationSetup.FTPFilePath + "/" + fileName));
|
|||
|
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
|
|||
|
reqFTP.UseBinary = true;
|
|||
|
reqFTP.Credentials = new NetworkCredential(_IntigrationSetup.FTPUserName, _IntigrationSetup.FTPPassword);
|
|||
|
FtpWebResponse ftpresponse = (FtpWebResponse)reqFTP.GetResponse();
|
|||
|
Stream ftpStream = ftpresponse.GetResponseStream();
|
|||
|
long cl = ftpresponse.ContentLength;
|
|||
|
int bufferSize = 2048;
|
|||
|
int readCount;
|
|||
|
byte[] buffer = new byte[bufferSize];
|
|||
|
|
|||
|
readCount = ftpStream.Read(buffer, 0, bufferSize);
|
|||
|
while (readCount > 0)
|
|||
|
{
|
|||
|
outputStream.Write(buffer, 0, readCount);
|
|||
|
readCount = ftpStream.Read(buffer, 0, bufferSize);
|
|||
|
}
|
|||
|
ftpStream.Close();
|
|||
|
outputStream.Close();
|
|||
|
ftpresponse.Close();
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Decrypt DownLoaded File
|
|||
|
|
|||
|
private void DecryptFiles(List<string> fileNamesToDecrypt, string tempDestFilePath)
|
|||
|
{
|
|||
|
foreach (string fileName in fileNamesToDecrypt)
|
|||
|
{
|
|||
|
DecryptFile(tempDestFilePath, _IntigrationSetup.ReadFilePath, _IntigrationSetup.PrivateKeyFilePath, fileName);
|
|||
|
}
|
|||
|
}
|
|||
|
private void DecryptFile(string sourceFilePath, string destinationFilePath, string privateKeyFilePath, string fileName)
|
|||
|
{
|
|||
|
Stream filestream = new FileStream(sourceFilePath + "\\" + fileName, FileMode.Open, FileAccess.Read);
|
|||
|
Decrypt(filestream, destinationFilePath + "\\" + fileName, privateKeyFilePath);
|
|||
|
filestream.Close();
|
|||
|
}
|
|||
|
private void Decrypt(Stream input, string outputpath, String privateKeyPath)
|
|||
|
{
|
|||
|
input = PgpUtilities.GetDecoderStream(input);
|
|||
|
try
|
|||
|
{
|
|||
|
PgpObjectFactory pgpObjF = new PgpObjectFactory(input);
|
|||
|
PgpEncryptedDataList enc;
|
|||
|
PgpObject obj = pgpObjF.NextPgpObject();
|
|||
|
if (obj is PgpEncryptedDataList)
|
|||
|
{
|
|||
|
enc = (PgpEncryptedDataList)obj;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
enc = (PgpEncryptedDataList)pgpObjF.NextPgpObject();
|
|||
|
}
|
|||
|
|
|||
|
var akp = new Org.BouncyCastle.Crypto.AsymmetricKeyParameter(true);
|
|||
|
|
|||
|
|
|||
|
|
|||
|
PgpPrivateKey privKey = GetPrivateKey(privateKeyPath);
|
|||
|
|
|||
|
|
|||
|
PgpPublicKeyEncryptedData pbe = enc.GetEncryptedDataObjects().Cast<PgpPublicKeyEncryptedData>().First();
|
|||
|
Stream clear;
|
|||
|
clear = pbe.GetDataStream(privKey);
|
|||
|
PgpObjectFactory plainFact = new PgpObjectFactory(clear);
|
|||
|
PgpObject message = plainFact.NextPgpObject();
|
|||
|
if (message is PgpCompressedData)
|
|||
|
{
|
|||
|
PgpCompressedData cData = (PgpCompressedData)message;
|
|||
|
Stream compDataIn = cData.GetDataStream();
|
|||
|
PgpObjectFactory o = new PgpObjectFactory(compDataIn);
|
|||
|
message = o.NextPgpObject();
|
|||
|
if (message is PgpOnePassSignatureList)
|
|||
|
{
|
|||
|
message = o.NextPgpObject();
|
|||
|
PgpLiteralData Ld = null;
|
|||
|
Ld = (PgpLiteralData)message;
|
|||
|
Stream output = File.Create(outputpath + "\\" + Ld.FileName);
|
|||
|
Stream unc = Ld.GetInputStream();
|
|||
|
Streams.PipeAll(unc, output);
|
|||
|
output.Close();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
PgpLiteralData Ld = null;
|
|||
|
Ld = (PgpLiteralData)message;
|
|||
|
//Stream output = File.Create(outputpath + "\\" + Ld.FileName);
|
|||
|
Stream output = File.Create(outputpath);
|
|||
|
Stream unc = Ld.GetInputStream();
|
|||
|
Streams.PipeAll(unc, output);
|
|||
|
output.Close();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
private PgpPrivateKey GetPrivateKey(string privateKeyPath)
|
|||
|
{
|
|||
|
using (Stream keyIn = File.OpenRead(privateKeyPath))
|
|||
|
using (Stream inputStream = PgpUtilities.GetDecoderStream(keyIn))
|
|||
|
{
|
|||
|
PgpSecretKeyRingBundle secretKeyRingBundle = new PgpSecretKeyRingBundle(inputStream);
|
|||
|
|
|||
|
PgpSecretKey key = null;
|
|||
|
foreach (PgpSecretKeyRing kRing in secretKeyRingBundle.GetKeyRings())
|
|||
|
{
|
|||
|
foreach (PgpSecretKey secretKey in kRing.GetSecretKeys())
|
|||
|
{
|
|||
|
PgpPrivateKey privKey = secretKey.ExtractPrivateKey("HRCoreBD2013".ToCharArray());
|
|||
|
|
|||
|
return privKey;
|
|||
|
//if (privKey.Key.GetType() ==
|
|||
|
// typeof(Org.BouncyCastle.Crypto.Parameters.ElGamalPrivateKeyParameters))
|
|||
|
////Org.BouncyCastle.Crypto.Parameters.ElGamalPrivateKeyParameters
|
|||
|
//{
|
|||
|
// return privKey;
|
|||
|
//}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete Files From
|
|||
|
|
|||
|
public void DeleteFromFTP(string fileName)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
//string uri = "ftp://" + ftpServerIP + "/" + fileName;
|
|||
|
FtpWebRequest reqFTP;
|
|||
|
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(_IntigrationSetup.FTPFilePath + "/" + fileName));
|
|||
|
|
|||
|
reqFTP.Credentials = new NetworkCredential(_IntigrationSetup.FTPUserName, _IntigrationSetup.FTPPassword);
|
|||
|
reqFTP.KeepAlive = false;
|
|||
|
reqFTP.Method = WebRequestMethods.Ftp.DeleteFile;
|
|||
|
|
|||
|
string result = String.Empty;
|
|||
|
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
|
|||
|
long size = response.ContentLength;
|
|||
|
Stream datastream = response.GetResponseStream();
|
|||
|
StreamReader sr = new StreamReader(datastream);
|
|||
|
result = sr.ReadToEnd();
|
|||
|
sr.Close();
|
|||
|
datastream.Close();
|
|||
|
response.Close();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
throw ex;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
}
|