1242 lines
55 KiB
C#
1242 lines
55 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Configuration;
|
|||
|
using System.Data;
|
|||
|
using System.Globalization;
|
|||
|
using System.IO;
|
|||
|
using System.Linq;
|
|||
|
using System.Net;
|
|||
|
using System.Net.Http.Headers;
|
|||
|
using System.Runtime.CompilerServices;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using AutoMapper.Configuration;
|
|||
|
using Ease.Core;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Google.Protobuf.WellKnownTypes;
|
|||
|
using HRM.BO;
|
|||
|
using HRM.DA;
|
|||
|
using Microsoft.AspNetCore.Authorization;
|
|||
|
using Microsoft.AspNetCore.Http;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using Microsoft.AspNetCore.StaticFiles;
|
|||
|
using Microsoft.Extensions.Configuration;
|
|||
|
using Newtonsoft.Json;
|
|||
|
using NPOI.POIFS.Crypt.Dsig;
|
|||
|
using NPOI.SS.Formula.Functions;
|
|||
|
using Org.BouncyCastle.Bcpg.Sig;
|
|||
|
using Payroll.BO;
|
|||
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|||
|
using IConfiguration = Microsoft.Extensions.Configuration.IConfiguration;
|
|||
|
|
|||
|
namespace HRM.UI.Controllers
|
|||
|
{
|
|||
|
[ApiController]
|
|||
|
[Route("api/DataIntergration")]
|
|||
|
[Authorize]
|
|||
|
public class DataIntergrationController : Controller
|
|||
|
{
|
|||
|
private List<UploadErrorOrSuccess> _errorList;
|
|||
|
List<DataIntegration> _oHRDataUploads = null;
|
|||
|
List<SuccessorErrorList> _oErrorList = null;
|
|||
|
List<Employee> _oEmployeeCollection = null;
|
|||
|
List<Department> _oDepartments = null;
|
|||
|
List<EmployeeStatus> _oEmployeeStatus = null;
|
|||
|
List<Designation> _oDesignations = null;
|
|||
|
List<Location> _oLocations = new List<Location>();
|
|||
|
List<Employee> _oEmployees = new List<Employee>();
|
|||
|
List<Bank> _oBanks = new List<Bank>();
|
|||
|
List<Branch> _oBranchs = new List<Branch>();
|
|||
|
List<Religion> _oReligions = new List<Religion>();
|
|||
|
List<Category> _oCategories = new List<Category>();
|
|||
|
List<Grade> _oGrades = new List<Grade>();
|
|||
|
List<SuccessorErrorList> _oSuccessOrErrorList = null;
|
|||
|
// List<Employee> _oEmployeeCollection = new List<Employee>();
|
|||
|
#region Declerations
|
|||
|
|
|||
|
private readonly IDepartmentService _departmentService;
|
|||
|
private readonly ILocationService _locationService;
|
|||
|
private readonly IBankService _bankService;
|
|||
|
private readonly IConfiguration _config;
|
|||
|
private readonly IBranchService _branchService;
|
|||
|
private readonly IEmployeeService _employeeService;
|
|||
|
private readonly IDesignationService _designationService;
|
|||
|
private readonly IDataIntergrationRequestService _dataIntergrationRequestService;
|
|||
|
private readonly IClaimBalaceService _claimBalaceService;
|
|||
|
private readonly IApiIntegrationService _apiIntegrationService;
|
|||
|
private readonly IPayrollTypeService _payrollTypeService;
|
|||
|
|
|||
|
|
|||
|
List<DataIntergrationIndividualAllowance> _oIADataUploads = null;
|
|||
|
List<ComnpData> _oIADataUploadItems = null;
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Constructor
|
|||
|
|
|||
|
public DataIntergrationController(IConfiguration config,
|
|||
|
IDepartmentService departmentService,
|
|||
|
ILocationService locationService,
|
|||
|
IBankService bankService,
|
|||
|
IEmployeeService employeeService,
|
|||
|
IBranchService branchService,
|
|||
|
IDesignationService desinationService,
|
|||
|
IDataIntergrationRequestService dataIntergrationRequestService,
|
|||
|
IClaimBalaceService claimBalaceService,
|
|||
|
IApiIntegrationService apiIntegrationService,
|
|||
|
IPayrollTypeService payrollTypeService)
|
|||
|
{
|
|||
|
_config = config;
|
|||
|
_departmentService = departmentService;
|
|||
|
_locationService = locationService;
|
|||
|
_bankService = bankService;
|
|||
|
_employeeService = employeeService;
|
|||
|
_branchService = branchService;
|
|||
|
// _wfMovementTranService = wfMovementTranService;
|
|||
|
_designationService = desinationService;
|
|||
|
_claimBalaceService = claimBalaceService;
|
|||
|
_dataIntergrationRequestService = dataIntergrationRequestService;
|
|||
|
_apiIntegrationService = apiIntegrationService;
|
|||
|
_payrollTypeService = payrollTypeService;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Functions
|
|||
|
|
|||
|
|
|||
|
[HttpGet("getBudgetDataAllowance")]
|
|||
|
public ActionResult getBudgetDataAllowance()
|
|||
|
{
|
|||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
DataSet ds = new DataSet();
|
|||
|
try
|
|||
|
{
|
|||
|
ds = _dataIntergrationRequestService.GetBudgetDataAllowance((int)currentUser.PayrollTypeID);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
}
|
|||
|
|
|||
|
return Ok(ds);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
[HttpGet("getBudgetData")]
|
|||
|
public ActionResult getBudgetData()
|
|||
|
{
|
|||
|
DataSet ds = new DataSet();
|
|||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
try
|
|||
|
{
|
|||
|
ds = _dataIntergrationRequestService.GetBudgetData((int)currentUser.PayrollTypeID);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
}
|
|||
|
|
|||
|
return Ok(ds);
|
|||
|
}
|
|||
|
|
|||
|
[HttpGet("getSuccessorErrorData/{batchId}")]
|
|||
|
public ActionResult GetSuccessorErrorData(string batchId)
|
|||
|
{
|
|||
|
DataSet ds = new DataSet();
|
|||
|
try
|
|||
|
{
|
|||
|
ds = _dataIntergrationRequestService.GetSuccessorErrorData(batchId);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
}
|
|||
|
|
|||
|
return Ok(ds);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
[HttpPost]
|
|||
|
[Route("dataintergration")]
|
|||
|
[AllowAnonymous]
|
|||
|
public ActionResult dataintergration([FromBody] DataIntegrationHeader data)
|
|||
|
{
|
|||
|
IntregraionReponse returnItem = new IntregraionReponse();
|
|||
|
try
|
|||
|
{
|
|||
|
_dataIntergrationRequestService.SaveBulkRequest(_oHRDataUploads);
|
|||
|
_oHRDataUploads = data.Items;
|
|||
|
CheckFieldValidation();
|
|||
|
if (_oErrorList.Count > 0)
|
|||
|
{
|
|||
|
foreach (var item in _oErrorList)
|
|||
|
{
|
|||
|
item.Type = EnumDataIntegrationType.EmployeeBasic;
|
|||
|
}
|
|||
|
_dataIntergrationRequestService.BulkSave(_oErrorList);
|
|||
|
throw new Exception("There occurs some errors while validating data");
|
|||
|
}
|
|||
|
_dataIntergrationRequestService.ImportEmpBasicInfo(_oHRDataUploads, 1, 1);
|
|||
|
//var response = new IntregraionReponse()
|
|||
|
//{
|
|||
|
// ReturnCode = HttpStatusCode.OK.ToString(),
|
|||
|
// ReturnName = "OK",
|
|||
|
// InternalError = ex.Message,
|
|||
|
// Details = _oErrorList
|
|||
|
//};
|
|||
|
|
|||
|
return Ok();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
var response = new IntregraionReponse()
|
|||
|
{
|
|||
|
ReturnCode = HttpStatusCode.InternalServerError.ToString(),
|
|||
|
ReturnName = "Internal Server Error",
|
|||
|
InternalError = ex.Message,
|
|||
|
Details = _oErrorList
|
|||
|
};
|
|||
|
return StatusCode(500, response);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[HttpGet]
|
|||
|
[Route("employeebasicintegrationapi/{empNo}")]
|
|||
|
public async Task<IActionResult> employeebasicintegrationapi(string empNo)
|
|||
|
{
|
|||
|
IntregraionReponse returnItem = new IntregraionReponse();
|
|||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
DataIntegrationHeader data = null;
|
|||
|
string ErrorString = "";
|
|||
|
PayrollType payrollType = null;
|
|||
|
try
|
|||
|
{
|
|||
|
payrollType = this._payrollTypeService.Get((int)currentUser.PayrollTypeID);
|
|||
|
var token = await _apiIntegrationService.GetAccessTokenAsync();
|
|||
|
if (token != null)
|
|||
|
{
|
|||
|
data = new DataIntegrationHeader();
|
|||
|
data = await _apiIntegrationService.GetMasterDataAsync(token.access_token);
|
|||
|
data.Items.ForEach(x => { x.payrolltypeid =(int) currentUser.PayrollTypeID; });
|
|||
|
}
|
|||
|
empNo = GlobalFunctions.GetApiDefaultData(empNo);
|
|||
|
if (empNo.Length >0)
|
|||
|
{
|
|||
|
string[] emps = empNo.Split(',');
|
|||
|
List<DataIntegration> items = new List<DataIntegration>();
|
|||
|
foreach (var ep in emps)
|
|||
|
{
|
|||
|
var existemp = data.Items.FirstOrDefault(x => x.EmployeeNo == ep);
|
|||
|
if (existemp != null) items.Add(existemp);
|
|||
|
}
|
|||
|
data.Items = items;
|
|||
|
}
|
|||
|
|
|||
|
List<DataIntegration> TempItems = new List<DataIntegration>();
|
|||
|
if (data != null)
|
|||
|
{
|
|||
|
if (data.Items.Count > 0)
|
|||
|
{
|
|||
|
// TempItems = data.Items.Where(x => x.EmployeeNo == "103" || x.EmployeeNo == "1953").ToList();
|
|||
|
TempItems = data.Items.Where(x => (x.Company.ToLower().Trim().Replace(" ", "") == payrollType.Description.ToLower().Trim().Replace(" ", "")) &&
|
|||
|
(x.CategoryCode == "1" || x.CategoryCode == "2")).ToList();
|
|||
|
foreach (var item in TempItems)
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.CategoryCode))
|
|||
|
{
|
|||
|
item.CategoryCode = item.CategoryCode.PadLeft(3, '0');
|
|||
|
}
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(item.ReligionCode) && string.IsNullOrEmpty(item.Religion))
|
|||
|
{
|
|||
|
item.Religion = "Unknown";
|
|||
|
item.ReligionCode = "005";
|
|||
|
}
|
|||
|
|
|||
|
//if (string.IsNullOrEmpty(item.EmailAddress)){
|
|||
|
// item.EmailAddress = "dummy@yahoo.com";
|
|||
|
//}
|
|||
|
}
|
|||
|
_oHRDataUploads = TempItems;
|
|||
|
}
|
|||
|
}
|
|||
|
ErrorString = "Error in saving Raw-Data";
|
|||
|
string batchID = _dataIntergrationRequestService.SaveBulkRequest(_oHRDataUploads);
|
|||
|
ErrorString = "Error in validating Raw-Data";
|
|||
|
CheckFieldValidation();
|
|||
|
|
|||
|
if (_oErrorList != null && _oErrorList.Count > 0)
|
|||
|
{
|
|||
|
foreach (var item in _oErrorList)
|
|||
|
{
|
|||
|
item.Type = EnumDataIntegrationType.EmployeeBasic;
|
|||
|
item.BatchId = batchID;
|
|||
|
}
|
|||
|
ErrorString = "Error in Saving Error List";
|
|||
|
_dataIntergrationRequestService.BulkSave(_oErrorList);
|
|||
|
return Ok(_oHRDataUploads);
|
|||
|
}
|
|||
|
|
|||
|
ErrorString = "Error in Processing Data";
|
|||
|
_dataIntergrationRequestService.ImportEmpBasicInfo(_oHRDataUploads, (int)currentUser.PayrollTypeID, currentUser.UserID);
|
|||
|
_dataIntergrationRequestService.getErrorORSuccessList().ForEach(item =>
|
|||
|
{
|
|||
|
item.Type = EnumDataIntegrationType.EmployeeBasic;
|
|||
|
item.BatchId = batchID;
|
|||
|
});
|
|||
|
|
|||
|
var errrorList = _dataIntergrationRequestService.getErrorORSuccessList().FindAll(x=>x.Status == EnumSAPProcessStatus.Error);
|
|||
|
var successList = _dataIntergrationRequestService.getErrorORSuccessList().FindAll(x => x.Status == EnumSAPProcessStatus.Success);
|
|||
|
|
|||
|
#region
|
|||
|
////successList
|
|||
|
if (errrorList.Count == 0)
|
|||
|
{
|
|||
|
if (successList.Count > 0)
|
|||
|
{
|
|||
|
ErrorString = "Error in updating/inserting employee...";
|
|||
|
_dataIntergrationRequestService.Save((int)currentUser.PayrollTypeID,
|
|||
|
currentUser.UserID, EnumRegularDataUpload.EmployeeWithBasic);
|
|||
|
ErrorString = "Error in success list employee...";
|
|||
|
_dataIntergrationRequestService.BulkSave(successList);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ErrorString = "Error in saving Final Error list";
|
|||
|
_dataIntergrationRequestService.BulkSave(errrorList);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
return Ok(_oHRDataUploads);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
var response = new IntregraionReponse()
|
|||
|
{
|
|||
|
ReturnCode = HttpStatusCode.InternalServerError.ToString(),
|
|||
|
ReturnName = "Internal Server Error",
|
|||
|
InternalError = ErrorString + " : " + ex.Message,
|
|||
|
Details = _oErrorList
|
|||
|
};
|
|||
|
return StatusCode(500, response);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
[HttpGet]
|
|||
|
[Route("IndividualAllowanceApi/{empNo}")]
|
|||
|
public async Task<IActionResult> IndividualAllowanceApi(string empNo)
|
|||
|
{
|
|||
|
IntregraionReponse returnItem = new IntregraionReponse();
|
|||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
try
|
|||
|
{
|
|||
|
//var filePath = Path.Combine(Directory.GetCurrentDirectory(), "data", "allowancedata.json");
|
|||
|
//if (!System.IO.File.Exists(filePath))
|
|||
|
//{
|
|||
|
// return NotFound("The JSON file could not be found.");
|
|||
|
//}
|
|||
|
|
|||
|
_oEmployeeStatus = new EmployeeStatusService().GetByUserID(currentUser.UserID);
|
|||
|
var token = await _apiIntegrationService.GetAccessTokenAsync();
|
|||
|
var data = new IndividualAllowanceModel();
|
|||
|
|
|||
|
if (token != null)
|
|||
|
{
|
|||
|
data = await _apiIntegrationService.GetConpensationDataAsync(token.access_token);
|
|||
|
}
|
|||
|
empNo = GlobalFunctions.GetApiDefaultData(empNo);
|
|||
|
if (empNo.Length > 0)
|
|||
|
{
|
|||
|
string[] emps = empNo.Split(',');
|
|||
|
List<EmployeeData> items = new List<EmployeeData>();
|
|||
|
foreach (var ep in emps)
|
|||
|
{
|
|||
|
var existemp = data.row.FirstOrDefault(x => x.EMPLOYEE_NO == ep);
|
|||
|
if (existemp != null) items.Add(existemp);
|
|||
|
}
|
|||
|
data.row = items;
|
|||
|
}
|
|||
|
|
|||
|
DataIntergrationIndividualAllowanceHeader ds = new DataIntergrationIndividualAllowanceHeader();
|
|||
|
ds.Items = new List<DataIntergrationIndividualAllowance>();
|
|||
|
int nCount = 1;
|
|||
|
List<Employee> oemps = new EmployeeService().GetAllEmps((int)currentUser.PayrollTypeID);
|
|||
|
List<Category> categories = new CategoryService().Get(EnumStatus.Regardless,
|
|||
|
(int)currentUser.PayrollTypeID);
|
|||
|
|
|||
|
var cats = categories.FindAll(x => x.Code == "001" || x.Code == "002");
|
|||
|
foreach (var row in data.row)
|
|||
|
{
|
|||
|
DataIntergrationIndividualAllowance di = new DataIntergrationIndividualAllowance();
|
|||
|
di.EmployeeNo = row.EMPLOYEE_NO;
|
|||
|
if(di.EmployeeNo == "20")
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
di.RowNo = nCount;
|
|||
|
di.Items = new List<ComnpData>();
|
|||
|
foreach (var compdata in row.COMP_DATA)
|
|||
|
{
|
|||
|
if (compdata != null)
|
|||
|
{
|
|||
|
if (compdata.ITEM_NAME.Replace(" ", "").ToLower() == "basicsalary") continue;
|
|||
|
ComnpData temp = new ComnpData();
|
|||
|
temp.ItemName = compdata.ITEM_NAME;
|
|||
|
temp.BenifitCode = compdata.ITEM_CODE;
|
|||
|
temp.FromDate = compdata.FROM_DATE;
|
|||
|
|
|||
|
temp.ToDate = IsValidDate(compdata.TO_DATE, "yyyy-MM-dd") ? compdata.TO_DATE : "";
|
|||
|
temp.Amount = compdata.AMOUNT;
|
|||
|
di.Items.Add(temp);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
nCount++;
|
|||
|
if (di.Items != null && di.Items.Count > 0)
|
|||
|
{
|
|||
|
var empitem = oemps.FirstOrDefault(x => x.EmployeeNo == di.EmployeeNo);
|
|||
|
if (empitem != null)
|
|||
|
{
|
|||
|
var cat = cats.FirstOrDefault(x => x.ID == empitem.CategoryID);
|
|||
|
if (cat != null)
|
|||
|
ds.Items.Add(di);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
_oIADataUploads = ds.Items;
|
|||
|
ds.Items.ForEach(x => { x.payrolltypeid = (int)currentUser.PayrollTypeID; });
|
|||
|
string batchID= _dataIntergrationRequestService.BulkSaveIndividualAllowance(ds.Items);
|
|||
|
|
|||
|
CheckIndividualAllowanceFieldValidation();
|
|||
|
if (_oErrorList.Count > 0)
|
|||
|
{
|
|||
|
foreach (var item in _oErrorList)
|
|||
|
{
|
|||
|
item.Type = EnumDataIntegrationType.IndividualAllowance;
|
|||
|
item.BatchId = batchID;
|
|||
|
}
|
|||
|
_dataIntergrationRequestService.BulkSave(_oErrorList);
|
|||
|
return Ok(_oIADataUploadItems);
|
|||
|
}
|
|||
|
|
|||
|
_dataIntergrationRequestService.ImportEmpIndividualAllowanceDeduction((int)currentUser.PayrollTypeID,
|
|||
|
EnumAllowOrDeduct.Allowance, ds.Items,empNo);
|
|||
|
var errorList = _dataIntergrationRequestService.getErrorORSuccessList().FindAll(x => x.Status == EnumSAPProcessStatus.Error); ;
|
|||
|
var successList = _dataIntergrationRequestService.getErrorORSuccessList().FindAll(x => x.Status == EnumSAPProcessStatus.Success); ;
|
|||
|
if (errorList.Count > 0)
|
|||
|
{
|
|||
|
errorList.ForEach(x => {
|
|||
|
x.BatchId = batchID;
|
|||
|
x.Type = EnumDataIntegrationType.IndividualAllowance;
|
|||
|
});
|
|||
|
_dataIntergrationRequestService.BulkSave(errorList);
|
|||
|
}
|
|||
|
else if (successList.Count > 0)
|
|||
|
{
|
|||
|
successList.ForEach(x => {
|
|||
|
x.BatchId = batchID;
|
|||
|
x.Type = EnumDataIntegrationType.IndividualAllowance;
|
|||
|
});
|
|||
|
|
|||
|
_dataIntergrationRequestService.BulkSave(successList);
|
|||
|
}
|
|||
|
return Ok(_oIADataUploadItems);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
//internal method error
|
|||
|
return StatusCode(500, ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static bool IsValidDate(string dateInput, string format)
|
|||
|
{
|
|||
|
DateTime dateValue;
|
|||
|
bool isValid = DateTime.TryParse(dateInput, out dateValue);
|
|||
|
if (isValid)
|
|||
|
{
|
|||
|
if (dateValue.Year > 2050) // Restrict dates beyond 2050
|
|||
|
{
|
|||
|
isValid = false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return isValid;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private void Save()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
_employeeService.SaveIntegration(this._oEmployeeCollection, 1, DateTime.Now, DateTime.Now);
|
|||
|
// new Employee().BulkSave(_oErrorList);
|
|||
|
}
|
|||
|
catch (Exception exp)
|
|||
|
{
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
private void CheckFieldValidation()
|
|||
|
{
|
|||
|
_oErrorList = new List<SuccessorErrorList>();
|
|||
|
SuccessorErrorList oItem = new SuccessorErrorList();
|
|||
|
int nCount = 1;
|
|||
|
foreach (DataIntegration item in _oHRDataUploads)
|
|||
|
{
|
|||
|
if (string.IsNullOrEmpty(item.EmployeeNo))
|
|||
|
AddStatus(nCount, item.EmployeeNo, "EmployeeNo is not found", EnumSAPProcessStatus.Error);
|
|||
|
else
|
|||
|
{
|
|||
|
if (item.EmployeeNo.Length > 10)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "EmployeeNo exceeds 6-digits", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(item.EmployeeName))
|
|||
|
AddStatus(nCount, item.EmployeeNo, "EmployeeName is not found", EnumSAPProcessStatus.Error);
|
|||
|
else
|
|||
|
{
|
|||
|
if (item.EmployeeName.Length > 150)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "EmployeeName exceeds 150-digits", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(item.FathersName))
|
|||
|
{
|
|||
|
if (item.FathersName.Length > 150)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "FathersName exceeds 150-digits", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(item.Designation))
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Designation is not found", EnumSAPProcessStatus.Error);
|
|||
|
else
|
|||
|
{
|
|||
|
if (item.Designation.Length > 200)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Designation exceeds 200-digits", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
|
|||
|
//if (item.GlobalID.Length > 20)
|
|||
|
// AddStatus(nCount, item.EmployeeNo, "Global ID's length is greater then 20 characters.", EnumSAPProcessStatus.Error);
|
|||
|
|
|||
|
//if (!string.IsNullOrEmpty(item.PreviousEmployeeNo))
|
|||
|
//{
|
|||
|
// if (item.PreviousEmployeeNo.Length > 6)
|
|||
|
// AddStatus(nCount, item.EmployeeNo, "PreviousEmployeeNo is not in 6-digits", EnumSAPProcessStatus.Error);
|
|||
|
//}
|
|||
|
|
|||
|
if (item.ContractChangeEndDate != null && Convert.ToDateTime(item.ContractChangeEndDate) == DateTime.MinValue)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "ContractChangeEndDate is not valid date.", EnumSAPProcessStatus.Error);
|
|||
|
|
|||
|
if (item.DateOfBirth == null)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "DateOfBirth is not found", EnumSAPProcessStatus.Error);
|
|||
|
if (Convert.ToDateTime(item.DateOfBirth) == DateTime.MinValue)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "DateOfBirth is not valid date.", EnumSAPProcessStatus.Error);
|
|||
|
|
|||
|
if (item.DateOfJoining != null)
|
|||
|
{ //AddStatus(nCount, item.EmployeeNo, "DateOfJoining is not found", EnumSAPProcessStatus.Error);
|
|||
|
if (Convert.ToDateTime(item.DateOfJoining) == DateTime.MinValue)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "DateOfJoining is not valid date.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
|
|||
|
//if (string.IsNullOrEmpty(item.EmailAddress))
|
|||
|
//{
|
|||
|
// AddStatus(nCount, item.EmployeeNo, "Email Address is Missing.", EnumSAPProcessStatus.Error);
|
|||
|
//}
|
|||
|
if (string.IsNullOrEmpty(item.Category))
|
|||
|
{
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Category is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// Category oObj = _oCategories.Find(x => x.Name == item.Category);
|
|||
|
// if (oObj == null)
|
|||
|
// AddStatus(nCount, item.EmployeeNo, "Category is not valid.", EnumSAPProcessStatus.Error);
|
|||
|
//}
|
|||
|
if (string.IsNullOrEmpty(item.Religion))
|
|||
|
{
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Religion Can not be Empty.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
////else
|
|||
|
//{
|
|||
|
// Religion oObj = _oReligions.Find(x => x.Name == item.Religion);
|
|||
|
// if (oObj == null)
|
|||
|
// AddStatus(nCount, item.EmployeeNo, "Religion is not valid.", EnumSAPProcessStatus.Error);
|
|||
|
//}
|
|||
|
if (string.IsNullOrEmpty(item.Gender))
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Gender Can not be Empty.", EnumSAPProcessStatus.Error);
|
|||
|
else
|
|||
|
{
|
|||
|
if (item.Gender.ToLower() == "male" || item.Gender.ToLower() == "female") { }
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Gender is not valid. It should be Male or Female", EnumSAPProcessStatus.Error);
|
|||
|
|
|||
|
}
|
|||
|
if (item.TIN.Length > 50)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "TIN exceeds 50 character.", EnumSAPProcessStatus.Error);
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(item.IsForeignExpatriate))
|
|||
|
item.IsForeignExpatriate = "FALSE";
|
|||
|
else
|
|||
|
{
|
|||
|
if (item.IsForeignExpatriate.ToUpper() == "TRUE" || item.IsForeignExpatriate.ToUpper() == "FALSE") { }
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "IsForeignExpatriate is not valid.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(item.Grade))
|
|||
|
{
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Grade is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// Grade oObj = _oGrades.Find(x => x.Name == item.Grade);
|
|||
|
// if (oObj == null)
|
|||
|
// AddStatus(nCount, item.EmployeeNo, "Grade is not valid.", EnumSAPProcessStatus.Error);
|
|||
|
//}
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(item.BasicSalary))
|
|||
|
{
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Basic Salary is empty.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (Convert.ToDouble(item.BasicSalary) <= 0)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Basic salary should greater than 0.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
|
|||
|
//else
|
|||
|
//{
|
|||
|
// if (item.SALARY_CHANGE_TYPE != "Joining" && item.SALARY_CHANGE_TYPE != "Promotion"
|
|||
|
// && item.SALARY_CHANGE_TYPE != "Confirmation" && item.SALARY_CHANGE_TYPE != "Annual Increment"
|
|||
|
// && item.SALARY_CHANGE_TYPE != "Salary Revised" && item.SALARY_CHANGE_TYPE != "Other")
|
|||
|
// AddStatus(nCount, item.EmployeeNo, "Salary Change Type is not recognized.It must be like (Joining,Promotion,Confirmation,Annual Increment,Salary Revised,Other)", EnumSAPProcessStatus.Error);
|
|||
|
//}
|
|||
|
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(item.SubUnit))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.Unit))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.SubSection))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.Section))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.Department))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.Division))
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Division is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Department is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Section is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Sub Section is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Unit is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else if (!string.IsNullOrEmpty(item.Unit))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.SubSection))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.Section))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.Department))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.Division))
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Division is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Department is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Section is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Sub Section is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else if (!string.IsNullOrEmpty(item.SubSection))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.Section))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.Department))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.Division))
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Division is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Department is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Section is not found.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else if (!string.IsNullOrEmpty(item.Section))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.Department))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.SubDepartment))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.Division))
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Division is empty.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "SubDepartment is empty.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Department is empty.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else if (!string.IsNullOrEmpty(item.Department))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(item.Division))
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Division is empty.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(item.Division))
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Division Name is empty.", EnumSAPProcessStatus.Error);
|
|||
|
else
|
|||
|
{
|
|||
|
if (item.Division.Length > 100)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Division Name is greater then 100 characters.", EnumSAPProcessStatus.Error);
|
|||
|
if (item.Division.Length == 0)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Empty Division is not allowed.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(item.Department))
|
|||
|
{
|
|||
|
if (item.Department.Length > 100)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Department Name is greater then 100 characters.", EnumSAPProcessStatus.Error);
|
|||
|
if (item.Department.Length == 0)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Empty Department is not allowed.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(item.Section))
|
|||
|
{
|
|||
|
if (item.Section.Length > 100)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Section Name is greater then 100 characters.", EnumSAPProcessStatus.Error);
|
|||
|
if (item.Section.Length == 0)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Empty Section is not allowed.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(item.SubDepartment))
|
|||
|
{
|
|||
|
if (item.SubDepartment.Length > 100)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "SubDepartment Name is greater then 100 characters.", EnumSAPProcessStatus.Error);
|
|||
|
if (item.SubDepartment.Length == 0)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Empty SubDepartment is not allowed.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(item.Unit))
|
|||
|
{
|
|||
|
if (item.Unit.Length > 100)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Unit Name is greater then 100 characters.", EnumSAPProcessStatus.Error);
|
|||
|
if (item.Unit.Length == 0)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Empty Unit is not allowed.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(item.SubUnit))
|
|||
|
{
|
|||
|
if (item.SubUnit.Length > 100)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "SubUnit Name is greater then 100 characters.", EnumSAPProcessStatus.Error);
|
|||
|
if (item.SubUnit.Length == 0)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Empty SubUnit is not allowed.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
if (string.IsNullOrEmpty(item.Zone))
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Zone Name is empty.", EnumSAPProcessStatus.Error);
|
|||
|
else
|
|||
|
{
|
|||
|
if (item.Zone.Length > 100)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Zone Name is greater then 100 characters.", EnumSAPProcessStatus.Error);
|
|||
|
if (item.Zone.Length == 0)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Empty Zone is not allowed.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
if (string.IsNullOrEmpty(item.Location))
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Location Name is empty.", EnumSAPProcessStatus.Error);
|
|||
|
else
|
|||
|
{
|
|||
|
if (item.Location.Length > 100)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Location Name is greater then 100 characters.", EnumSAPProcessStatus.Error);
|
|||
|
if (item.Location.Length == 0)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Empty Location is not allowed.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
if (item.SalaryAccountNumber != "")
|
|||
|
{
|
|||
|
if (item.SalaryBank == "" || item.SalaryBranch == "")
|
|||
|
{
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Bank or branch can't be empty", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
|
|||
|
if (item.SALARY_ACCOUNT_EFFECT_DATE == "")
|
|||
|
{
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Salary Account Add/Change Effect Date can't be Empty", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
DateTime dDate = DateTime.Now;
|
|||
|
if (DateTime.TryParse(item.SALARY_ACCOUNT_EFFECT_DATE, out dDate) == false)
|
|||
|
{
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Invalid Salary Account effect Date", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// if(ptype.LastPayProcessDate <= dDate)
|
|||
|
//}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(item.LIFE_CYCLE_EVENT))
|
|||
|
{
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Life Cycle Event can't be Empty", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
if (string.IsNullOrEmpty(item.LIFE_CYCLE_EVENT))
|
|||
|
{
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Life Cycle Event can't be Empty", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// var isExist = _oEmployeeStatus.Find(x => x.Description.ToLower().Trim().Replace(" ", "") == item.LIFE_CYCLE_EVENT.ToLower().Trim().Replace(" ", ""));
|
|||
|
// if (isExist == null)
|
|||
|
// AddStatus(nCount, item.EmployeeNo, "invalid Event", EnumSAPProcessStatus.Error);
|
|||
|
//}
|
|||
|
if (item.BasicSalaryEffectDate == null || item.BasicSalaryEffectDate == "")
|
|||
|
AddStatus(nCount, item.EmployeeNo, "BasicSalaryEffectDate is not found", EnumSAPProcessStatus.Error);
|
|||
|
//if (Convert.ToDateTime(item.BasicSalaryEffectDate) == DateTime.MinValue)
|
|||
|
// AddStatus(nCount, item.EmployeeNo, "BasicSalaryEffectDate is not valid date.", EnumSAPProcessStatus.Error);
|
|||
|
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(item.SALARY_CHANGE_TYPE))
|
|||
|
{
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Salary Change Type is empty.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
|
|||
|
//if (item.AssignmentChangeDate == "")
|
|||
|
//{
|
|||
|
// AddStatus(nCount, item.EmployeeNo, "Event Date can't be Empty", EnumSAPProcessStatus.Error);
|
|||
|
//}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// DateTime dDate = DateTime.Now;
|
|||
|
// if (DateTime.TryParse(item.AssignmentChangeDate,out dDate) == false)
|
|||
|
// {
|
|||
|
// AddStatus(nCount, item.EmployeeNo, "Invalid Event Date", EnumSAPProcessStatus.Error);
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
nCount++;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void AddStatus(int nCount, string sEmployeeNo, string sMessege, EnumSAPProcessStatus eStstus)
|
|||
|
{
|
|||
|
SuccessorErrorList item = new SuccessorErrorList();
|
|||
|
item.RowNo = nCount;
|
|||
|
item.EmployeeNo = sEmployeeNo;
|
|||
|
item.Message = sMessege;
|
|||
|
item.Status = eStstus;
|
|||
|
item.UploadDate = DateTime.Now;
|
|||
|
item.UploadDate = DateTime.Now;
|
|||
|
_oErrorList.Add(item);
|
|||
|
}
|
|||
|
|
|||
|
private void CreateBasicData()
|
|||
|
{
|
|||
|
string ss = "";
|
|||
|
try
|
|||
|
{
|
|||
|
int nParentID = 0;
|
|||
|
int nTier = 0;
|
|||
|
foreach (DataIntegration item in _oHRDataUploads)
|
|||
|
{
|
|||
|
//ss = item.EmployeeNo;
|
|||
|
//if (item.EmployeeNo == "3615")
|
|||
|
// ss = "3615";
|
|||
|
nParentID = 0;
|
|||
|
if (!string.IsNullOrEmpty(item.Division))
|
|||
|
{
|
|||
|
Department dep = _oDepartments.Find(x => x.Name.ToLower().Trim() == item.Division.ToLower().Trim());
|
|||
|
if (dep == null)
|
|||
|
{
|
|||
|
dep = new Department();
|
|||
|
dep.Code = item.Division.Substring(0, 2) + "_" + DateTime.Now.Year.ToString() + "_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString();
|
|||
|
dep.Name = item.Division;
|
|||
|
dep.ParentID = null;
|
|||
|
dep.Tier = 1;
|
|||
|
dep.Status = EnumStatus.Active;
|
|||
|
_departmentService.Save(dep);
|
|||
|
_oDepartments.Add(dep);
|
|||
|
nParentID = dep.ID;
|
|||
|
nTier = 1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
//dep.Tier = 1;
|
|||
|
//dep.Save();
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(item.Department))
|
|||
|
{
|
|||
|
Department dep = _oDepartments.Find(x => x.Name.ToLower().Trim() == item.Department.ToLower().Trim());
|
|||
|
if (dep == null)
|
|||
|
{
|
|||
|
dep = new Department();
|
|||
|
dep.Code = item.Department.Substring(0, 2) + "_" + DateTime.Now.Year.ToString() + "_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString();
|
|||
|
dep.Name = item.Department;
|
|||
|
dep.ParentID = nParentID;
|
|||
|
|
|||
|
//dep.RCCode = item.RCCode;
|
|||
|
dep.Tier = 2;
|
|||
|
dep.Status = EnumStatus.Active;
|
|||
|
_departmentService.Save(dep);
|
|||
|
_oDepartments.Add(dep);
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//dep.ParentID = nParentID;
|
|||
|
//dep.Tier = 2;
|
|||
|
//dep.Save();
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(item.Section))
|
|||
|
{
|
|||
|
Department dep = _oDepartments.Find(x => x.Name.ToLower().Trim() == item.Section.ToLower().Trim());
|
|||
|
if (dep == null)
|
|||
|
{
|
|||
|
dep = new Department();
|
|||
|
dep.Code = item.Section.Substring(0, 2) + "_" + DateTime.Now.Year.ToString() + "_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString();
|
|||
|
dep.Name = item.Section;
|
|||
|
dep.ParentID = nParentID;
|
|||
|
dep.Tier = 3;
|
|||
|
dep.Status = EnumStatus.Active;
|
|||
|
_departmentService.Save(dep);
|
|||
|
_oDepartments.Add(dep);
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//dep.ParentID = nParentID;
|
|||
|
//dep.Tier = 3;
|
|||
|
//dep.Save();
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(item.SubSection))
|
|||
|
{
|
|||
|
Department dep = _oDepartments.Find(x => x.Name.ToLower().Trim() == item.SubSection.ToLower().Trim());
|
|||
|
if (dep == null)
|
|||
|
{
|
|||
|
dep = new Department();
|
|||
|
dep.Code = item.SubSection.Substring(0, 2) + "_" + DateTime.Now.Year.ToString() + "_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString();
|
|||
|
dep.Name = item.SubSection;
|
|||
|
dep.ParentID = nParentID;
|
|||
|
dep.Tier = 4;
|
|||
|
|
|||
|
dep.Status = EnumStatus.Active;
|
|||
|
_departmentService.Save(dep);
|
|||
|
_oDepartments.Add(dep);
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//dep.ParentID = nParentID;
|
|||
|
//dep.Tier = 4;
|
|||
|
//dep.Save();
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(item.Unit))
|
|||
|
{
|
|||
|
Department dep = _oDepartments.Find(x => x.Name == item.Unit);
|
|||
|
if (dep == null)
|
|||
|
{
|
|||
|
dep = new Department();
|
|||
|
dep.Code = item.Unit.Substring(0, 2) + "_" + DateTime.Now.Year.ToString() + "_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString();
|
|||
|
dep.Name = item.Unit;
|
|||
|
dep.ParentID = nParentID;
|
|||
|
dep.Tier = 5;
|
|||
|
dep.Status = EnumStatus.Active;
|
|||
|
_departmentService.Save(dep);
|
|||
|
_oDepartments.Add(dep);
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//dep.ParentID = nParentID;
|
|||
|
//dep.Tier = 5;
|
|||
|
//dep.Save();
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(item.SubUnit))
|
|||
|
{
|
|||
|
Department dep = _oDepartments.Find(x => x.Name == item.SubUnit);
|
|||
|
if (dep == null)
|
|||
|
{
|
|||
|
dep = new Department();
|
|||
|
dep.Code = item.SubUnit.Substring(0, 2) + "_" + DateTime.Now.Year.ToString() + "_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString();
|
|||
|
dep.Name = item.SubUnit;
|
|||
|
dep.ParentID = nParentID;
|
|||
|
dep.Tier = 6;
|
|||
|
dep.Status = EnumStatus.Active;
|
|||
|
_departmentService.Save(dep);
|
|||
|
_oDepartments.Add(dep);
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//dep.ParentID = nParentID;
|
|||
|
//dep.Tier = 6;
|
|||
|
//dep.Save();
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
}
|
|||
|
nParentID = 0;
|
|||
|
if (!string.IsNullOrEmpty(item.Zone))
|
|||
|
{
|
|||
|
Location dep = _oLocations.Find(x => x.Name == item.Zone);
|
|||
|
if (dep == null)
|
|||
|
{
|
|||
|
dep = new Location();
|
|||
|
dep.Code = item.ZoneCode;
|
|||
|
dep.Name = item.Zone;
|
|||
|
dep.ParentID = null;
|
|||
|
dep.Status = EnumStatus.Active;
|
|||
|
dep.Tier = nTier + 1;
|
|||
|
nTier = dep.Tier;
|
|||
|
_locationService.Save(dep);
|
|||
|
_oLocations.Add(dep);
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
dep.ParentID = nParentID;
|
|||
|
_locationService.Save(dep);
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(item.Location))
|
|||
|
{
|
|||
|
Location dep = _oLocations.Find(x => x.Name == item.Location);
|
|||
|
if (dep == null)
|
|||
|
{
|
|||
|
dep = new Location();
|
|||
|
dep.Code = item.LocationCode;
|
|||
|
dep.Name = item.Location;
|
|||
|
dep.ParentID = nParentID;
|
|||
|
dep.Tier = nTier + 1;
|
|||
|
nTier = dep.Tier;
|
|||
|
dep.Status = EnumStatus.Active;
|
|||
|
_locationService.Save(dep);
|
|||
|
_oLocations.Add(dep);
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
dep.ParentID = nParentID;
|
|||
|
_locationService.Save(dep);
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
}
|
|||
|
nParentID = 0;
|
|||
|
nTier = 0;
|
|||
|
if (!string.IsNullOrEmpty(item.SalaryBank))
|
|||
|
{
|
|||
|
Bank dep = _oBanks.Find(x => x.Name == item.SalaryBank);
|
|||
|
if (dep == null)
|
|||
|
{
|
|||
|
dep = new Bank();
|
|||
|
dep.Code = item.SalaryBankCode;
|
|||
|
dep.Name = item.SalaryBank;
|
|||
|
dep.Status = EnumStatus.Active;
|
|||
|
_bankService.Save(dep);
|
|||
|
_oBanks.Add(dep);
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
else
|
|||
|
nParentID = dep.ID;
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(item.SalaryBranch))
|
|||
|
{
|
|||
|
Branch dep = _oBranchs.Find(x => x.Name == item.SalaryBranch);
|
|||
|
if (dep == null)
|
|||
|
{
|
|||
|
dep = new Branch();
|
|||
|
dep.Code = item.SalaryBranchCode;
|
|||
|
dep.Name = item.SalaryBranch;
|
|||
|
dep.Status = EnumStatus.Active;
|
|||
|
dep.BankID = nParentID;
|
|||
|
_branchService.Save(dep);
|
|||
|
_oBranchs.Add(dep);
|
|||
|
}
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(item.Designation))
|
|||
|
{
|
|||
|
Designation dep = _oDesignations.Find(x => x.Name == item.Designation);
|
|||
|
if (dep == null)
|
|||
|
{
|
|||
|
dep = new Designation();
|
|||
|
dep.Code = item.Designation.Substring(0, 2);
|
|||
|
dep.Name = item.Designation;
|
|||
|
dep.Status = EnumStatus.Active;
|
|||
|
_designationService.Save(dep);
|
|||
|
_oDesignations.Add(dep);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch
|
|||
|
{
|
|||
|
ss = ss;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
private int GetGradeChangeType2(string sName)
|
|||
|
{
|
|||
|
int nType = 0;
|
|||
|
if (sName.ToLower() == "joining")
|
|||
|
{
|
|||
|
nType = 5;
|
|||
|
}
|
|||
|
else if (sName.ToLower() == "promotion")
|
|||
|
{
|
|||
|
nType = 6;
|
|||
|
}
|
|||
|
else if (sName.ToLower() == "confirmation")
|
|||
|
{
|
|||
|
nType = 3;
|
|||
|
}
|
|||
|
else if (sName.ToLower() == "annual increment")
|
|||
|
{
|
|||
|
nType = 7;
|
|||
|
}
|
|||
|
else if (sName.ToLower() == "salary revised")
|
|||
|
{
|
|||
|
nType = 8;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
nType = 18;
|
|||
|
}
|
|||
|
return nType;
|
|||
|
}
|
|||
|
private int GetGradeChangeType(string sName)
|
|||
|
{
|
|||
|
int nType = 0;
|
|||
|
if (sName.ToLower() == "joining")
|
|||
|
{
|
|||
|
nType = 5;
|
|||
|
}
|
|||
|
else if (sName.ToLower() == "promotion")
|
|||
|
{
|
|||
|
nType = 6;
|
|||
|
}
|
|||
|
else if (sName.ToLower() == "confirmation")
|
|||
|
{
|
|||
|
nType = 3;
|
|||
|
}
|
|||
|
else if (sName.ToLower() == "annual increment")
|
|||
|
{
|
|||
|
nType = 7;
|
|||
|
}
|
|||
|
else if (sName.ToLower() == "salary revised")
|
|||
|
{
|
|||
|
nType = 8;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
nType = 23;
|
|||
|
}
|
|||
|
return nType;
|
|||
|
}
|
|||
|
|
|||
|
private void CheckIndividualAllowanceFieldValidation()
|
|||
|
{
|
|||
|
_oErrorList = new List<SuccessorErrorList>();
|
|||
|
SuccessorErrorList oItem = new SuccessorErrorList();
|
|||
|
int nCount = 0;
|
|||
|
List<Branch> branches = new BranchService().Get(EnumStatus.Regardless, 1);
|
|||
|
List<Bank> banks = new BankService().Get();
|
|||
|
foreach (DataIntergrationIndividualAllowance item in _oIADataUploads)
|
|||
|
{
|
|||
|
nCount = item.RowNo;
|
|||
|
if (string.IsNullOrEmpty(item.EmployeeNo))
|
|||
|
AddStatus(nCount, item.EmployeeNo, "EmployeeNo is not found", EnumSAPProcessStatus.Error);
|
|||
|
else
|
|||
|
{
|
|||
|
if (item.EmployeeNo.Length > 10)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "EmployeeNo exceeds 10-digits", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
|
|||
|
if (item.Items == null)
|
|||
|
{
|
|||
|
AddStatus(nCount, item.EmployeeNo, "From Date is not found", EnumSAPProcessStatus.Error);
|
|||
|
AddStatus(nCount, item.EmployeeNo, "To Date is not found", EnumSAPProcessStatus.Error);
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Item Code is Missing.", EnumSAPProcessStatus.Error);
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Item Name is Missing.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
foreach (var comnpData in item.Items)
|
|||
|
{
|
|||
|
if (comnpData.FromDate == null)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "From Date is not found", EnumSAPProcessStatus.Error);
|
|||
|
if (Convert.ToDateTime(comnpData.FromDate) == DateTime.MinValue)
|
|||
|
AddStatus(nCount, item.EmployeeNo, "From Date is not valid date.", EnumSAPProcessStatus.Error);
|
|||
|
|
|||
|
//if (comnpData.ToDate == null)
|
|||
|
// AddStatus(nCount, item.EmployeeNo, "To Date is not found", EnumSAPProcessStatus.Error);
|
|||
|
//if (Convert.ToDateTime(comnpData.ToDate) == DateTime.MinValue)
|
|||
|
// AddStatus(nCount, item.EmployeeNo, "To Date is not valid date.", EnumSAPProcessStatus.Error);
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(comnpData.BenifitCode))
|
|||
|
{
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Item Code is Missing.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
if (string.IsNullOrEmpty(comnpData.ItemName))
|
|||
|
{
|
|||
|
AddStatus(nCount, item.EmployeeNo, "Item Name is Missing.", EnumSAPProcessStatus.Error);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
// nCount++;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|