using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.IO; using System.Linq; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; using AutoMapper.Configuration; 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 IConfiguration = Microsoft.Extensions.Configuration.IConfiguration; using iTextSharp.text.pdf; using iTextSharp.text.pdf.parser; using NPOI.HPSF; using System.Text.RegularExpressions; using static System.Runtime.InteropServices.JavaScript.JSType; using Path = System.IO.Path; using static iTextSharp.text.pdf.AcroFields; using System.Reflection; using MySqlX.XDevAPI.Common; using Microsoft.AspNetCore.Http.HttpResults; using UglyToad.PdfPig; using UglyToad.PdfPig.Content; using UglyToad.PdfPig.XObjects; using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource; using Array = System.Array; using static HRM.BO.RecJobTracking; using MySqlX.XDevAPI; using NPOI.POIFS.Crypt.Dsig; // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 namespace HRM.UI.Controllers { [ApiController] [Route("api/Recruitment")] [Authorize] public class RecruitmentController : Controller { #region Declerations private readonly ICVService _cvService; private readonly IHeadCountApprovalRequestService _headCountApprovalRequestService; private readonly IInternalRecruitmentService _internalRecruitmentService; private readonly ICandidateService _candidateService; private readonly IRecruitementProcessService _recruitementProcessService; private readonly IRecruitmentLettersService _recruitementLettterService; private readonly IConfiguration _config; private readonly IEmployeeService _employeeService; private readonly IErCircularService _erCircularService; private readonly IErAppliedApplicantService _erAppliedApplicantService; private readonly IErCVService _ercvService; private readonly IRecJobTrackingService _recJobTrackingService; private readonly IEducationLevelService _educationLevelService; private readonly IDisciplineService _disciplineService; private readonly IInterviewAssessmentKPIService _interviewAssessmentKPIService; private static string _filePath = @"ClientApp\Documents\"; private static string _generatedPath = @"ClientApp\Documents\"; #endregion #region Constructor public RecruitmentController(IConfiguration config, ICVService cvService, IHeadCountApprovalRequestService headCountService, IInternalRecruitmentService internalRecruitmentService, ICandidateService candidateService, IRecruitementProcessService recruitementProcessService, IEmployeeService employeeService , IRecruitmentLettersService recruitementLettterService, IErCircularService erCircularService, IErAppliedApplicantService erAppliedApplicantService, IRecJobTrackingService recJobTrackingService, IEducationLevelService educationLevelService, IDisciplineService disciplineService, IErCVService ercvService, IInterviewAssessmentKPIService interviewAssessmentKPIService) { _config = config; _cvService = cvService; _headCountApprovalRequestService = headCountService; _internalRecruitmentService = internalRecruitmentService; _candidateService = candidateService; this._recruitementProcessService = recruitementProcessService; this._recruitementLettterService = recruitementLettterService; _employeeService = employeeService; _erCircularService = erCircularService; _erAppliedApplicantService = erAppliedApplicantService; _ercvService = ercvService; _recJobTrackingService = recJobTrackingService; this._educationLevelService = educationLevelService; this._disciplineService = disciplineService; _interviewAssessmentKPIService = interviewAssessmentKPIService; } #endregion [HttpGet] [Route("getCVById/{cvId}")] public ActionResult getCVById(int cvID) { CV oCV = new CV(); try { oCV = _cvService.Get(cvID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oCV); } [HttpPost] [Route("getCVsByIds")] public ActionResult getCVsByIds(dynamic cvIds) { List oCVs = new List(); List cvids = Newtonsoft.Json.JsonConvert.DeserializeObject>(cvIds.ToString()); string strIDs = ""; cvids.ForEach(x => { strIDs = strIDs + x + ","; }); try { if (strIDs.Length > 0) { strIDs = strIDs.Substring(0, strIDs.Length - 1); oCVs = _cvService.GetCVByIDs(strIDs); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oCVs); } [HttpGet] [Route("getFileAttachments/{cvID}")] public ActionResult getFileAttachments(int cvID) { List attachments = null; try { attachments = _cvService.GetAllAttachments(cvID, EnumFileType.CV); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(attachments); } [HttpGet] [Route("dtGetCVByID/{cvId}")] public ActionResult dtGetCVByID(int cvID) { DataTable oCV = new DataTable(); try { oCV = _cvService.dtGetCVByID(cvID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oCV); } //getAllCV getAllCV [Route("getAllCV")] public ActionResult getAllCV() { List oCVs = new List(); try { oCVs = _cvService.Get(); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oCVs); } //getAllOnlyCV [Route("getAllOnlyCV")] public ActionResult getAllOnlyCV() { List oCVs = new List(); try { oCVs = _cvService.getAllOnlyCV(); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oCVs); } [Route("getCVs")] public ActionResult getCVs() { List oCVs = new List(); try { oCVs = _cvService.GetCVs(); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oCVs); } [Route("getCvInfo/{name}/{mobile}/{email}/{institute}/{degreeTitleId}")] public ActionResult getCvInfo(string name, string mobile, string email, string institute, int degreeTitleId) { name = (name == "undefined" || name == "null") ? string.Empty : name; email = (email == "undefined" || email == "null") ? string.Empty : email; mobile = (mobile == "undefined" || mobile == "null") ? string.Empty : mobile; institute = (institute == "undefined" || institute == "null") ? string.Empty : institute; List oCVs = new List(); try { oCVs = _cvService.GetCVs(name, email, mobile, institute, degreeTitleId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oCVs); } [Route("getOnlinePortalCVs/{requisitionID}")] public ActionResult GetOnlinePortalCVs(int requisitionID) { List oCVs = new List(); try { oCVs = _cvService.GetOnlinePortalCVs(requisitionID); //if(oCVs != null) //{ // foreach(var item in oCVs) // { // item.Details = "Name: " + item.Name + Environment.NewLine + "Mobile: " + item.Mobile + Environment.NewLine + "Email: " + item.Email + Environment.NewLine + "Expected Salary: "; // if(item.AllEduQualifications != null && item.AllEduQualifications.Count > 0) // { // foreach(var education in item.AllEduQualifications) // { // var educationalDetail = "Degree Name: "+ education.EducationLevels.Find(x=>x.ID == education.DegreeTitleID).Description // } // } // } //} } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oCVs); } [HttpGet] [Route("getAllSearchedCV/{name}/{email}/{mobile}")] public ActionResult GetAllSearchedCV(string name, string email, string mobile) { name = (name == "undefined" || name == "null") ? string.Empty : name; email = (email == "undefined" || email == "null") ? string.Empty : email; mobile = (mobile == "undefined" || mobile == "null") ? string.Empty : mobile; List cvs = new List(); try { cvs = _cvService.GetAllSearchedCV(name, email, mobile, null, null); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(cvs); } [HttpGet] [Route("GetByCvSearch/{name}/{email}/{mobile}")] public ActionResult GetByCvSearch(string name, string email, string mobile) { name = (name == "undefined" || name == "null") ? string.Empty : name; email = (email == "undefined" || email == "null") ? string.Empty : email; mobile = (mobile == "undefined" || mobile == "null") ? string.Empty : mobile; List cvs = new List(); try { cvs = _cvService.GetByCvSearch(name, email, mobile); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(cvs); } [HttpPost] [Route("saveHeadCount")] public ActionResult saveHeadCount(HeadCountApprovalRequest ob) { try { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); ob.CreatedBy = currentUser.UserID; ob.RequestDate = Ease.Core.Utility.Global.DateFunctions.LastDateOfYear(ob.RequestDate); _headCountApprovalRequestService.Save(ob); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpPost] [Route("saveHeadCountsData")] public ActionResult saveHeadCountsData(List items) { try { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); foreach (var item in items) { item.CreatedBy = currentUser.UserID; item.CategoryID = null; } _headCountApprovalRequestService.SaveAuto(items); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpPost] [Route("deleteHeadCount")] public ActionResult deleteHeadCount(HeadCountApprovalRequest ob) { try { _headCountApprovalRequestService.Delete(ob.ID); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpPost] [Route("deleteCv")] public ActionResult deleteCv(CV ob) { try { _cvService.Delete(ob); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpPost] [Route("deleteReceuitmentCv")] public ActionResult deleteReceuitmentCv(CV ob) { try { _candidateService.DeleteCandidateCVCollection(ob.CandidateID); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpGet] [Route("getAllHeadCount")] public ActionResult getAllHeadCount() { List oHeadCountApprovalRequests = new List(); try { oHeadCountApprovalRequests = _headCountApprovalRequestService.Get(); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oHeadCountApprovalRequests); } [HttpGet] [Route("getApprovdRecruitmentPicker/{approvalStatus}/{onBoardStatus}")] public ActionResult getApprovdRecruitmentPicker(EnumRequisitionApprovalStatus? approvalStatus, string onBoardStatus) { List oInternalRecuitmentList = new List(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); List grades = new GradeService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); List designations = new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); List departments = new DepartmentService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); List locations = new LocationService().Get(EnumStatus.Active, (int)currentUser.PayrollTypeID); onBoardStatus = (onBoardStatus == "undefined" || onBoardStatus == "null") ? string.Empty : onBoardStatus; try { oInternalRecuitmentList = _internalRecruitmentService.GetApprovedRequisitionsPicker(approvalStatus, onBoardStatus); if (oInternalRecuitmentList != null && oInternalRecuitmentList.Count > 0) { oInternalRecuitmentList.ForEach(x => { var grd = grades.FirstOrDefault(d => d.ID == x.GradeId); if (grd != null) x.GradeCode = grd.Code; var designation = designations.FirstOrDefault(d => d.ID == x.DesignationId); if (designation != null) x.DesignationName = designation.Name; var department = departments.FirstOrDefault(d => d.ID == x.DepartmentId); if (department != null) { x.DepartmentCode = department.Code; x.DepartmentName = department.Name; } var location = locations.FirstOrDefault(d => d.ID == x.LocationId); if (location != null) { x.LocationName = location.Name; } x.RequisitionApprovalStatusString = EnumHelper.GetEnumDescription(x.RequisitionApprovalStatus); }); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oInternalRecuitmentList); } [HttpPost] [Route("saveInternalRecruitment")] public ActionResult SaveInternalRecruitment(InternalRecruitment item) { //var connectionString = _config.GetConnectionString("DbContextSettings:ConnectionString"); // string connectionString = Startup string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; //string connectionString = ""; int ans; var isNew = item.ID <= 0; CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); if (isNew) { item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; } else { item.ModifiedBy = currentUser.UserID; item.ModifiedDate = DateTime.Today; } try { ans = _internalRecruitmentService.Save(item, connectionString); if (ans > 0 && currentUser.EmployeeID != null && item.RequisitionApprovalStatus == EnumRequisitionApprovalStatus.Not_Initiated) { _internalRecruitmentService.InitiateRecruitmentRequisitionWorkFlow(item, (int)currentUser.EmployeeID, item.CreatedBy); } if (ans > 0 && item.RequisitionApprovalStatus == EnumRequisitionApprovalStatus.Approved) { _internalRecruitmentService.UpdateRequisitionApproveStatusAdmin(item, item.CreatedBy); } if (item.IRFileAttacments != null && item.IRFileAttacments.Count > 0) { foreach (var file in item.IRFileAttacments) { if (System.IO.File.Exists(file.FilePath)) { System.IO.File.Delete(file.FilePath); } } } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ans); } [HttpPost] [Route("InitiateOfferLetterWorkFlow")] public ActionResult InitiateOfferLetterWorkFlow(InternalRecruitment item) { //var connectionString = _config.GetConnectionString("DbContextSettings:ConnectionString"); // string connectionString = Startup CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { _internalRecruitmentService.InitiateOfferLetterWorkFlow(item, item.offLttrAppRaiseEmpID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpPost] [Route("ApproveOfferLetter")] public ActionResult ApproveOfferLetter(WFMovementTran otran) { //var connectionString = _config.GetConnectionString("DbContextSettings:ConnectionString"); // string connectionString = Startup CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); otran.FromEmployeeID = (int)currentUser.EmployeeID; try { _internalRecruitmentService.ApproveOfferLetter(otran); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpPost] [Route("ApproveRequisition")] public ActionResult ApproveRequisition(WFMovementTran otran) { //var connectionString = _config.GetConnectionString("DbContextSettings:ConnectionString"); // string connectionString = Startup CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); otran.FromEmployeeID = (int)currentUser.EmployeeID; try { _internalRecruitmentService.ApproveRecruitmentRequisition(otran); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpGet] [Route("getAllInternalRecruitment/{fromDate}/{toDate}/{type}")] public ActionResult getAllInternalRecruitment(DateTime? fromDate, DateTime? toDate, int type) { List oInternalRecuitmentList = new List(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); List grades = new GradeService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); List designations = new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); List departments = new DepartmentService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); EnumInternalRecruitmentType stype = (EnumInternalRecruitmentType)type; try { oInternalRecuitmentList = _internalRecruitmentService.Get(fromDate, toDate, stype); if (oInternalRecuitmentList != null && oInternalRecuitmentList.Count > 0) { oInternalRecuitmentList.ForEach(x => { var grd = grades.FirstOrDefault(d => d.ID == x.GradeId); if (grd != null) x.GradeCode = grd.Code; var designation = designations.FirstOrDefault(d => d.ID == x.DesignationId); if (designation != null) x.DesignationName = designation.Name; var department = departments.FirstOrDefault(d => d.ID == x.DepartmentId); if (department != null) x.DepartmentCode = department.Code; }); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oInternalRecuitmentList); } [HttpGet] [Route("getemployeeWiseRecruitment/{fromDate}/{toDate}/{type}")] public ActionResult getemployeeWiseRecruitment(DateTime? fromDate, DateTime? toDate, int type) { List oInternalRecuitmentList = new List(); List finalList = new List(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); List grades = new GradeService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); List designations = new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); List departments = new DepartmentService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); EnumInternalRecruitmentType stype = (EnumInternalRecruitmentType)type; try { oInternalRecuitmentList = _internalRecruitmentService.Get(fromDate, toDate, stype); if (oInternalRecuitmentList != null && oInternalRecuitmentList.Count > 0) { oInternalRecuitmentList.ForEach(x => { var grd = grades.FirstOrDefault(d => d.ID == x.GradeId); if (grd != null) x.GradeCode = grd.Code; var designation = designations.FirstOrDefault(d => d.ID == x.DesignationId); if (designation != null) x.DesignationName = designation.Name; var department = departments.FirstOrDefault(d => d.ID == x.DepartmentId); if (department != null) x.DepartmentCode = department.Code; }); } finalList = oInternalRecuitmentList.Where(y => y.RaisedBy == currentUser.UserID).ToList(); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(finalList); } [HttpGet] [Route("getInternalRecruitmentByID/{recruitmentId}")] public ActionResult getInternalRecruitmentByID(int recruitmentId) { InternalRecruitment oInternalRecuitment = new InternalRecruitment(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); List grades = new GradeService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); List designations = new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); List departments = new DepartmentService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); try { oInternalRecuitment = _internalRecruitmentService.Get(recruitmentId); if (oInternalRecuitment != null) { var grd = grades.FirstOrDefault(d => d.ID == oInternalRecuitment.GradeId); if (grd != null) oInternalRecuitment.GradeCode = grd.Code; var designation = designations.FirstOrDefault(d => d.ID == oInternalRecuitment.DesignationId); if (designation != null) oInternalRecuitment.DesignationName = designation.Name; var department = departments.FirstOrDefault(d => d.ID == oInternalRecuitment.DepartmentId); if (department != null) oInternalRecuitment.DepartmentCode = department.Code; oInternalRecuitment.IREmployees = new List(); oInternalRecuitment.IREmployees = _internalRecruitmentService.GetIREmployeess(recruitmentId); oInternalRecuitment.IRFileAttacments = new List(); oInternalRecuitment.IRFileAttacments = _internalRecruitmentService.GetIRFileAttachments(recruitmentId); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oInternalRecuitment); } [HttpPost] [Route("get-download-file")] [AllowAnonymous] [IgnoreAntiforgeryToken] [ProducesResponseType(StatusCodes.Status200OK)] public async Task GetDownloadFile(dynamic data) { string contentType = ""; var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); try { List IRFileAttacments = new List(); IRFileAttacments = _internalRecruitmentService.GetIRFileAttachmentbyID((int)item.id, (int)item.fileId); Stream memory = new MemoryStream(); if (IRFileAttacments != null && IRFileAttacments.Count > 0) { byte[] buffer = new byte[16 * 1024]; contentType = GetFileType(IRFileAttacments[0].OriginalFileName); buffer = IRFileAttacments[0].FileAsByteArray; return File(buffer, contentType, IRFileAttacments[0].OriginalFileName); } else { throw new Exception("File Download error"); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } } [HttpPost] [Route("get-download-file-cv")] [AllowAnonymous] [IgnoreAntiforgeryToken] [ProducesResponseType(StatusCodes.Status200OK)] public async Task GetDownloadFileCV(dynamic data) { string contentType = ""; var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); try { List IRFileAttacments = new List(); IRFileAttacments = _internalRecruitmentService.GetIRFileAttachmentbyIDCV((int)item.id, (int)item.fileId, EnumFileType.CV); Stream memory = new MemoryStream(); if (IRFileAttacments != null && IRFileAttacments.Count > 0) { byte[] buffer = new byte[16 * 1024]; contentType = GetFileType(IRFileAttacments[0].OriginalFileName); buffer = IRFileAttacments[0].FileAsByteArray; return File(buffer, contentType, IRFileAttacments[0].OriginalFileName); } else { throw new Exception("File Download error"); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } } [HttpPost] [Route("get-file-type")] [AllowAnonymous] [IgnoreAntiforgeryToken] [ProducesResponseType(StatusCodes.Status200OK)] public string GetFileType(string originalFileName) { //var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); //string fileName = (string)item["fileName"].ToObject(); string fileName = originalFileName; string contentType; new FileExtensionContentTypeProvider().TryGetContentType(fileName, out contentType); return contentType ?? "application/octet-stream"; } [HttpPost] [Route("saveCV")] public ActionResult saveCV(CV ob) { try { //string connectionString = ""; CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); ob.CreatedBy = currentUser.UserID; string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; if (ob != null) { if (ob.ID <= 0 && ob.CVProfilePhoto.PreviousFileTobase64 != null) { string[] items = ob.CVProfilePhoto.PreviousFileTobase64.Split(new char[] { ',', ' ' }, StringSplitOptions.None); byte[] newBytes = Convert.FromBase64String(items[1]); ob.CVProfilePhoto.FileAsByteArray = newBytes; } } _cvService.Save(ob, connectionString); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpPost] [Route("saveErCV")] public ActionResult saveErCV(ErCV ob) { try { //string connectionString = ""; CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); ob.CreatedBy = currentUser.UserID; ob.UserID = currentUser.UserID; string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; if (ob != null) { if (ob.ID <= 0 && ob.ErCVProfilePhoto.PreviousFileTobase64 != null) { string[] items = ob.ErCVProfilePhoto.PreviousFileTobase64.Split(new char[] { ',', ' ' }, StringSplitOptions.None); byte[] newBytes = Convert.FromBase64String(items[1]); ob.ErCVProfilePhoto.FileAsByteArray = newBytes; } } _ercvService.Save(ob, connectionString); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpPost] [Route("saveMultipleCV")] public ActionResult saveMultipleCV(List cvs) { List allCVs = new List(); try { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); foreach (var item in cvs) { var isNew = item.ID <= 0; if (isNew) { item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; } else { item.ModifiedBy = currentUser.UserID; item.ModifiedDate = DateTime.Today; } } string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; allCVs = _cvService.SaveCVs(cvs, connectionString); if (allCVs != null) { foreach (var item in cvs) { if (item.IRFileAttacments != null && item.IRFileAttacments.Count > 0) { foreach (var file in item.IRFileAttacments) { if (System.IO.File.Exists(file.FilePath)) { System.IO.File.Delete(file.FilePath); } } } } } } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(allCVs); } [HttpGet] [Route("GetCVByIDs/{cvIds}")] public ActionResult GetCVByID(string cvIds) { List allCVs = new List(); try { allCVs = _cvService.GetCVByIDs(cvIds); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(allCVs); } [HttpPost] [Route("saveCVSort")] public ActionResult saveCVSort(List cvsorts) { // List allCVs = new List(); try { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); foreach (var item in cvsorts) { var isNew = item.ID <= 0; if (isNew) { item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; } else { item.ModifiedBy = currentUser.UserID; item.ModifiedDate = DateTime.Today; } } //string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; _cvService.SaveCVSort(cvsorts); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpPost] [Route("UpdateCandidateAndSaveCvSort")] public ActionResult UpdateCandidateAndSaveCvSort(dynamic data) { List cvsorts = new List(); var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); cvsorts = items["cvSorts"] == null ? null : (List)items["cvSorts"].ToObject>(); CV cv = null; //cv = items["cv"] == null ? null : (CV)items["cv"].ToObject(); try { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); foreach (var item in cvsorts) { var isNew = item.ID <= 0; if (isNew) { item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; } else { item.ModifiedBy = currentUser.UserID; item.ModifiedDate = DateTime.Today; } } //string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; if (cv != null) { //Candidate candidate = new Candidate(); //candidate = _candidateService.GetCanditatebyCvID(cv.ID, cv.PositionID); //if (candidate != null) //{ // candidate.PrimarySelected = true; // _candidateService.UpdateSelection(candidate); //} } _cvService.SaveCVSort(cvsorts); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpGet] [Route("getPrevCvSort/{requisitionId}")] public ActionResult GetPrevCvSort(int requisitionId) { List cvsorts = new List(); try { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); cvsorts = _cvService.GetCVSortByrequisitionID(requisitionId); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(cvsorts); } //private string GetContentType(string path) //{ // var provider = new FileExtensionContentTypeProvider(); // string contentType; // if (!provider.TryGetContentType(path, out contentType)) // { // contentType = "application/octet-stream"; // } // return contentType; //} [HttpGet] [Route("getRecruitementSteps/{recruitementID}")] public ActionResult getRecruitementSteps(int recruitementID) { List obs = new List(); try { obs = this._recruitementProcessService.GetRecruitementSteps(recruitementID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } [HttpGet] [Route("GetRecruitementStepsWithSession/{recruitementID}")] public ActionResult GetRecruitementStepsWithSession(int recruitementID) { List obs = new List(); try { obs = this._recruitementProcessService.GetRecruitementStepsWithSession(recruitementID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } [HttpGet] [Route("getRecruitementStep/{stepid}")] public ActionResult getRecruitementStep(int stepid) { RecruitementStep obs; try { obs = this._recruitementProcessService.GetRStep(stepid); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } [HttpGet] [Route("getRecruitementStepBySerial/{recruitementid}/{stepSerial}")] public ActionResult getRecruitementStepBySerial(int recruitementid, int stepSerial) { RecruitementStep obs; try { obs = this._recruitementProcessService.GetRStep(recruitementid, stepSerial); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } [HttpGet] [Route("getSessionActiveCandidatesByStepID/{StepID}")] public ActionResult getSessionActiveCandidatesByStepID(int StepID) { List obs = new List(); try { obs = this._recruitementProcessService.getSessionActiveCandidatesByStepID(StepID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } [HttpGet] [Route("getInterviewSessions/{requsitionID}")] public ActionResult getInterviewSessions(int requsitionID) { List obs = new List(); try { obs = this._recruitementProcessService.GetInterveiwSessions(requsitionID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } // Ess Function [HttpGet] [Route("getCurrentEmpInterviewSessions/{BoardMemberEntryStatus}")] public ActionResult getCurrentEmpInterviewSessions(EnumBaordMemberMarkEntryStatus BoardMemberEntryStatus) { List obs = new List(); DataTable otable = null; CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { otable = this._recruitementProcessService.GetInterveiwSessionsByBoardMember((int)currentUser.EmployeeID, BoardMemberEntryStatus); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(otable); } // void SaveMembersMarkByMemberID(InterviewSession session); // List GetInterveiwSessionsByBoardMember(int employeeid, EnumBaordMemberMarkEntryStatus MarkEntrystatus); [HttpPost] [Route("CompleteMembersMarkByMember")] public ActionResult CompleteMembersMarkByMember(InterviewSession item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; try { this._recruitementProcessService.CompleteMembersMarkByMember(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpPost] [Route("SaveMembersMarkByMember")] public ActionResult SaveMembersMarkByMember(InterviewSession item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; try { this._recruitementProcessService.SaveMembersMarkByMember(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpGet] [Route("getInterviewSession/{interviewSessionID}")] public ActionResult getInterviewSession(int interviewSessionID) { InterviewSession obs = null; try { obs = this._recruitementProcessService.GetInterveiwSession(interviewSessionID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } [HttpGet] [Route("GetmemberWiseMarkBySetpID/{StepID}")] public ActionResult GetmemberWiseMarkBySetpID(int StepID) { List obs = null; try { obs = this._recruitementProcessService.GetmemberWiseMarkBySetpID(StepID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } [HttpGet] [Route("GetmemberWiseMarkBySessionID/{SessionID}")] public ActionResult GetmemberWiseMarkBySessionID(int SessionID) { List obs = null; try { obs = this._recruitementProcessService.GetmemberWiseMarkBySessionID(SessionID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } [HttpPost] [Route("DeleteStep")] public ActionResult DeleteStep(RecruitementStep item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { this._recruitementProcessService.DeleteStep(item.ID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpPost] [Route("SaveRecruitementSteps")] public ActionResult SaveRecruitementSteps(List items) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); RecruitementProcess pr = this._recruitementProcessService.GetByRequisitionID(items[0].requisitionID); if (pr == null) { pr = new RecruitementProcess(); pr.requisitionID = items[0].requisitionID; pr.StartDate = items[0].StartDate; pr.EndDate = items[items.Count - 1].EndDate; pr.CreatedBy = currentUser.UserID; pr.CreatedDate = DateTime.Today; pr.ProcessStatus = EnumRecruitementProcess.None; } else { pr.requisitionID = items[0].requisitionID; pr.ModifiedBy = currentUser.UserID; pr.ModifiedDate = DateTime.Today; } pr.Steps = new List(); pr.Steps.InsertRange(0, items); try { this._recruitementProcessService.Save(pr); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(pr.Steps); } [HttpPost] [Route("SaveInterviewSession")] public ActionResult SaveInterviewSession(InterviewSession item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; try { this._recruitementProcessService.SaveInterviewSession(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(item); } [HttpPost] [Route("SendInteviewSessionMail")] public ActionResult SendInteviewSessionMail(InterviewSession item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; try { this._recruitementProcessService.SendMailInThread(item); this._recruitementProcessService.UpdateInterviewStartDate(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpPost] [Route("DeleteUserCvSort")] public ActionResult DeleteUserCvSort(UserCvSort item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { _cvService.DeleteUserCvsort(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpPost] [Route("CancelInteviewSession")] public ActionResult CancelInteviewSession(InterviewSession item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; try { this._recruitementProcessService.CancelInterViewSession(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpPost] [Route("RescheduleInteviewSession")] public ActionResult RescheduleInteviewSession(InterviewSession item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; try { this._recruitementProcessService.RescheduleInterViewSession(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpPost] [Route("SaveMemberWiseMark")] public ActionResult SaveMemberWiseMark(InterviewSession session) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); foreach (MemberWiseMark item in session.BoadMemberWiseMarks) { if (item.IsNew == true) { item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; } else { item.ModifiedBy = currentUser.UserID; item.ModifiedDate = DateTime.Today; } } try { this._recruitementProcessService.SaveMemberWiseMark(session); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpPost] [Route("CompleteSessionStatus")] public ActionResult CompleteSessionStatus(InterviewSession item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { this._recruitementProcessService.CompleteInterviewSession(item); //updateJobUpdateErecruitment(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } public void updateJobUpdateErecruitment(InterviewSession item) { List appliedApplicnt = new List(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); RecruitementStep currentStep; try { currentStep = new RecruitementStep(); currentStep = this._recruitementProcessService.GetRStep(item.requitementStepID); appliedApplicnt = _erAppliedApplicantService.GetApplicantInfoByRecruitmentID(currentStep.requisitionID).ToList(); if (currentStep != null) { foreach (var tempItem in item.Candidates) { ErJobupdate jobUpdate = new ErJobupdate(); CV cv = new CV(); cv = _cvService.Get(tempItem.cvid); ErCV ercv = new ErCV(); ercv = _ercvService.Get((int)cv.ErCvID); jobUpdate.UserID = ercv.UserID; jobUpdate.JobID = appliedApplicnt.Where(x => x.UserID == ercv.UserID).FirstOrDefault().JobID; jobUpdate.Remarks = tempItem.isSelected ? "On " + item.interviewDate.ToString("dd MMMM yyyy") + ", You have selected for " + currentStep.getStepName() : "On " + item.interviewDate.ToString("dd MMMM yyyy") + ", You have not selected for " + currentStep.getStepName(); jobUpdate.UpdateDate = DateTime.Now; jobUpdate.UpdatedBy = EnumActorType.Admin; jobUpdate.AppliedApplicantID = appliedApplicnt.Where(x => x.UserID == ercv.UserID).FirstOrDefault().ID; _erAppliedApplicantService.Save(jobUpdate); } } } catch (Exception ex) { StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } } [HttpPost] [Route("CompleteRecruitementStep")] public ActionResult CompleteRecruitementStep(RecruitementStep item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { this._recruitementProcessService.CompleteRecruitementStep(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpPost] [Route("SaveRecruitementLetters")] public ActionResult SaveRecruitementLetters(List items) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); foreach (RecruitmentLetters item in items) { item.CreatedDate = DateTime.Today; item.CreatedBy = currentUser.UserID; } try { this._recruitementLettterService.Save(items); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpGet] [Route("GetRecruitementRellters/{requisitionID}")] public ActionResult GetRecruitementRellters(int requisitionID) { List obs = null; try { obs = this._recruitementLettterService.GetbyRequisitionID(requisitionID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } [HttpGet("getBudgetHeadCount/{departmentId}/{designationId}/{positionDate}")] public ActionResult GetCurrentHeadCount(int departmentId, int designationId, DateTime positionDate) { int empCount = 0; try { empCount = _headCountApprovalRequestService.GetBudgetedHeadCount(departmentId, designationId, positionDate); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(empCount); } [HttpGet("getBudgetHeadCountByRequisitionID/{positionDate}")] public ActionResult GetBudgetedHeadCountByrequisitionID(DateTime positionDate) { List obs = new List(); try { obs = _headCountApprovalRequestService.GetBudgetedHeadCountByrequisitionID(positionDate); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } #region Assign Candidate [HttpGet] [Route("getCandidateByProcessid/{pId}")] public ActionResult getCandidateByProcessid(int pID) { List obs = new List(); try { obs = _candidateService.GetCanditates(pID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } [HttpPost] [Route("saveCandidates")] public ActionResult saveCandidates(List items) { try { string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; _candidateService.Save(items, connectionString); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpPost] [Route("saveCandidatesforRecruitment")] public ActionResult saveCandidatesforRecruitment(List items) { try { // string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; _candidateService.SaveCandidateAnDUpdateCV(items); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpPost] [Route("updateCVOnInitiateDone")] public ActionResult UpdateCVOnInitiateDone(List items) { try { // string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; _candidateService.UpdateCVOnInitiateDone(items); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpPost] [Route("saveUserCVSort")] public ActionResult saveUserCVSort(UserCvSort item) { try { var isNew = item.ID <= 0; CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); if (isNew) { item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; } else { item.ModifiedBy = currentUser.UserID; item.ModifiedDate = DateTime.Today; } // string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; _cvService.SaveUserCVSort(item); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpGet] [Route("updatePrimarySelection")] public ActionResult updatePrimarySelection(int candidateId) { try { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; _candidateService.UpdatePrimarySelection(candidateId); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpGet] [Route("getFilesByCVId/{cId}")] public ActionResult getFilesByCVId(int cId) { List obs = new List(); try { obs = _cvService.GetCVAttachmentbyID(cId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } [HttpGet] [Route("dtGetRecruitmentbyCVSort")] public ActionResult dtGetRecruitmentbyCVSort() { Employee ohrEmp = null; List sortItems = new List(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); if (currentUser.EmployeeID == null) { return StatusCode(StatusCodes.Status500InternalServerError, "Employee Not Found"); } // DataTable oCV = new DataTable(); try { sortItems = _cvService.dtGetRecruitmentbyCVSort((int)currentUser.EmployeeID); //foreach(DataRow item in oCV.Rows) //{ // int recid = Convert.ToInt32(item["cvSortID"].ToString()); // int recid = item["cvSortID"] is DBNull ? 0 : Convert.ToInt32(item["cvSortID"].ToString()); //} } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(sortItems); } [HttpGet] [Route("dtCVSortDetails/{positionID}")] public ActionResult dtCVSortDetails(int positionID) { Employee ohrEmp = null; List sortItems = new List(); try { sortItems = _cvService.dtCVSortDetails(positionID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(sortItems); } [HttpGet] [Route("getPreciousCV/{positionId}")] public ActionResult GetPreciousCV(int positionId) { List allCVs = new List(); try { allCVs = _cvService.GetPreviousCVbyRequisitionID(positionId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(allCVs); } [HttpGet] [Route("IsRequisitionComplete/{positionId}")] public ActionResult IsRequisitionComplete(int positionId) { bool isComplete; try { isComplete = _cvService.IsRequisitionComplete(positionId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(isComplete); } [HttpGet] [Route("updateCompleteStatus/{positionId}")] public ActionResult UpdateCompleteStatus(int positionId) { try { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); if (currentUser.EmployeeID == null) { return StatusCode(StatusCodes.Status500InternalServerError, "Employee Not Found"); } _cvService.UpdateCompleteStatus(positionId, (int)currentUser.EmployeeID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("updateReqCompleteStatus/{positionId}")] public ActionResult UpdateReqCompleteStatus(int positionId) { try { _internalRecruitmentService.UpdateCompleteStatus(positionId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("getEmployeesRequisitionID/{requisitionID}")] public ActionResult getEmployeesRequisitionID(int requisitionID) { List obs = new List(); try { obs = _employeeService.GetEmployeesRequisitionID(requisitionID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(obs); } #endregion [HttpPost] [Route("saveRecruitmentPublish")] public ActionResult SaveRecruitmentPublish(ErCircular item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; item.ModifiedBy = currentUser.UserID; item.ModifiedDate = DateTime.Today; try { _erCircularService.Save(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("getJobDetailsbyRecruitmentID/{recruitmentId}")] public ActionResult getJobDetailsbyRecruitmentID(int recruitmentId) { List appliedApplicants = new List(); try { appliedApplicants = _erAppliedApplicantService.GetApplicantInfoByRecruitmentID(recruitmentId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(appliedApplicants); } [HttpGet] [Route("getErCvByUserId/{userId}/{recruitmentId}")] public ActionResult getErCvByUserId(int userId, int recruitmentId) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); ErCV ercv = null; CV cv = null; try { ercv = _ercvService.GetErCvByUserID(userId); var isCvAlreadyCreated = _cvService.GetByCvSearch(null, ercv.Email, null); if (ercv != null && (isCvAlreadyCreated== null || isCvAlreadyCreated.Count==0)) { cv = new CV(); cv.FirstName = ercv.FirstName; cv.LastName = ercv.LastName; cv.Name = ercv.FirstName + " " + ercv.LastName; cv.Email = ercv.Email; cv.Mobile = ercv.Mobile; cv.Designation = ercv.Designation; cv.PresentAddress = ercv.PresentAddress; cv.PermanentAddress = ercv.PermanentAddress; cv.Gender = ercv.Gender; cv.MaritalStatus = ercv.MaritalStatus; cv.ReligionID = ercv.ReligionID; cv.SortStatus = ercv.SortStatus; cv.ErCvID = ercv.ID; cv.CreatedBy = currentUser.UserID; cv.CreatedDate = DateTime.Now; cv.PositionID = recruitmentId; if (ercv.AllExperiences != null && ercv.AllExperiences.Count > 0) { cv.AllExperiences = new List(); foreach (var item in ercv.AllExperiences) { var experience = new CVExperience(); experience.Employeer = item.Employeer; experience.ContactPerson = item.ContactPerson; experience.Address = item.Address; experience.Industry = item.Industry; experience.FromDate = item.FromDate; experience.ToDate = item.ToDate; experience.Telephone = item.Telephone; experience.RoleDefination = item.RoleDefination; cv.AllExperiences.Add(experience); } } if (ercv.AllEduQualifications != null && ercv.AllEduQualifications.Count > 0) { cv.AllEduQualifications = new List(); foreach (var item in ercv.AllEduQualifications) { var education = new CVEducation(); education.DegreeTitleID = item.DegreeTitleID; education.DegreeTitle = item.DegreeTitle; education.DisciplineID = item.DisciplineID; education.BoardID = item.BoardID; education.Boar = item.Boar; education.Name = item.Name; education.PassingYear = item.PassingYear; education.ResultID = item.ResultID; education.CGPA = item.CGPA; education.OutOF = item.OutOF; education.IsHighest = item.IsHighest; education.InstituteName = item.InstituteName; cv.AllEduQualifications.Add(education); } } if (ercv.CVReferences != null && ercv.CVReferences.Count > 0) { cv.CVReferences = new List(); foreach (var item in ercv.CVReferences) { var reference = new CVReference(); reference.Name = item.Name; reference.Occupation = item.Occupation; reference.Relation = item.Relation; reference.Address = item.Address; reference.Email = item.Email; reference.Telephone = item.Telephone; reference.Mobile = item.Mobile; cv.CVReferences.Add(reference); } } if (ercv.CVTrainings != null && ercv.CVTrainings.Count > 0) { cv.CVTrainings = new List(); foreach (var item in ercv.CVTrainings) { var training = new CVTraining(); training.Name = item.Name; training.Description = item.Description; training.Country = item.Country; training.TrainingTypeID = item.TrainingTypeID; training.NatureOfTrainingID = item.NatureOfTrainingID; training.TrainingCompletedFrom = item.TrainingCompletedFrom; training.InstitutionID = item.InstitutionID; training.Place = item.Place; training.Achievement = item.Achievement; training.Fees = item.Fees; training.OtherCost = item.OtherCost; training.FromDate = item.FromDate; training.ToDate = item.ToDate; cv.CVTrainings.Add(training); } } if (ercv.ErCVProfilePhoto != null) { cv.CVProfilePhoto = ercv.ErCVProfilePhoto; cv.CVProfilePhoto.FileType = EnumFileType.CVProfilePhoto; } if (ercv.IRFileAttacments != null && ercv.IRFileAttacments.Count > 0) { cv.IRFileAttacments = new List(); foreach (var item in ercv.IRFileAttacments) { item.FileType = EnumFileType.CV; cv.IRFileAttacments.Add(item); } } } else { throw new Exception("cv bank has been already created"); } if (cv != null) { string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; _cvService.Save(cv, connectionString); } else { throw new Exception("cv bank not saved"); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("createcvbankandcandidate")] public ActionResult createCvbankandCandidate(dynamic data) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); List oCVs = new List(); List _cvs = new List(); List educationLevels = new List(); educationLevels = _educationLevelService.Get(EnumStatus.Active); List disciplines = new List(); disciplines = _disciplineService.Get(EnumStatus.Active); var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); int recruitmentId = items["recruitmentId"] == null ? 0 : items["recruitmentId"].ToObject(); string cvids = items["cvIds"] == null ? 0 : items["cvIds"].ToObject(); try { if (!string.IsNullOrEmpty(cvids)) { oCVs = _ercvService.GetErCvByCvids(cvids); foreach(var ercv in oCVs) { var isCvAlreadyCreated = _cvService.GetByCvSearch(null, ercv.Email, ercv.Mobile); CV cv = null; if (ercv != null && (isCvAlreadyCreated == null || isCvAlreadyCreated.Count == 0)) { cv = new CV(); cv.FirstName = ercv.FirstName; cv.LastName = ercv.LastName; cv.Name = ercv.FirstName + " " + ercv.LastName; cv.Email = ercv.Email; cv.Mobile = ercv.Mobile; cv.Designation = ercv.Designation; cv.PresentAddress = ercv.PresentAddress; cv.PermanentAddress = ercv.PermanentAddress; cv.Gender = ercv.Gender; cv.MaritalStatus = ercv.MaritalStatus; cv.ReligionID = ercv.ReligionID; cv.SortStatus = ercv.SortStatus; cv.ErCvID = ercv.ID; cv.CreatedBy = currentUser.UserID; cv.CreatedDate = DateTime.Now; cv.PositionID = recruitmentId; string experienceSummary = ""; if (ercv.AllExperiences != null && ercv.AllExperiences.Count > 0) { cv.AllExperiences = new List(); foreach (var item in ercv.AllExperiences) { var experience = new CVExperience(); experience.Employeer = item.Employeer; experience.ContactPerson = item.ContactPerson; experience.Address = item.Address; experience.Industry = item.Industry; experience.FromDate = item.FromDate; experience.ToDate = item.ToDate; experience.Telephone = item.Telephone; experience.RoleDefination = item.RoleDefination; cv.AllExperiences.Add(experience); var diffDays = (item.ToDate - item.FromDate).TotalDays; experienceSummary += "Total Experince: " + diffDays + "\n" + "Company: " + item.Industry + "\n" + "Position: " + item.Designation + "\n" + "Role: " + item.RoleDefination + "\n"; } cv.Experience = experienceSummary; } string educationSummary = ""; if (ercv.AllEduQualifications != null && ercv.AllEduQualifications.Count > 0) { cv.AllEduQualifications = new List(); foreach (var item in ercv.AllEduQualifications) { var education = new CVEducation(); education.DegreeTitleID = item.DegreeTitleID; education.DegreeTitle = item.DegreeTitle; education.DisciplineID = item.DisciplineID; education.BoardID = item.BoardID; education.Boar = item.Boar; education.Name = item.Name; education.PassingYear = item.PassingYear; education.ResultID = item.ResultID; education.CGPA = item.CGPA; education.OutOF = item.OutOF; education.IsHighest = item.IsHighest; education.InstituteName = item.InstituteName; cv.AllEduQualifications.Add(education); if(item.DegreeTitleID > 0) { educationSummary +="Degree Title: " + educationLevels?.Find(c => c.ID == item.DegreeTitleID)?.Description + "\n" + "Department: " + disciplines?.Find(c => c.ID == item.DisciplineID)?.Description + "\n" + "Institute: " + item.InstituteName + "\n" + "Passing Year: " + item.PassingYear + "\n" + "CGPA: " + item.CGPA + "\n"; } } cv.Education = educationSummary; } string references = ""; if (ercv.CVReferences != null && ercv.CVReferences.Count > 0) { cv.CVReferences = new List(); foreach (var item in ercv.CVReferences) { var reference = new CVReference(); reference.Name = item.Name; reference.Occupation = item.Occupation; reference.Relation = item.Relation; reference.Address = item.Address; reference.Email = item.Email; reference.Telephone = item.Telephone; reference.Mobile = item.Mobile; cv.CVReferences.Add(reference); references += "Name: " + item.Name + "\n" + "Occupation: " + item.Occupation + "\n" + "Relation: " + item.Relation + "\n" + "Address: " + item.Address + "\n" + "Mobile: " + item.Mobile + "\n"; } cv.Reference = references; } if (ercv.CVTrainings != null && ercv.CVTrainings.Count > 0) { cv.CVTrainings = new List(); foreach (var item in ercv.CVTrainings) { var training = new CVTraining(); training.Name = item.Name; training.Description = item.Description; training.Country = item.Country; training.TrainingTypeID = item.TrainingTypeID; training.NatureOfTrainingID = item.NatureOfTrainingID; training.TrainingCompletedFrom = item.TrainingCompletedFrom; training.InstitutionID = item.InstitutionID; training.Place = item.Place; training.Achievement = item.Achievement; training.Fees = item.Fees; training.OtherCost = item.OtherCost; training.FromDate = item.FromDate; training.ToDate = item.ToDate; cv.CVTrainings.Add(training); } } if (ercv.ErCVProfilePhoto != null) { cv.CVProfilePhoto = ercv.ErCVProfilePhoto; cv.CVProfilePhoto.FileType = EnumFileType.CVProfilePhoto; } if (ercv.IRFileAttacments != null && ercv.IRFileAttacments.Count > 0) { cv.IRFileAttacments = new List(); foreach (var item in ercv.IRFileAttacments) { item.FileType = EnumFileType.CV; cv.IRFileAttacments.Add(item); } } _cvs.Add(cv); } else { throw new Exception("cv bank has been already created"); } } if (_cvs != null) { string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; _cvService.SaveCVs(_cvs, connectionString); } else { throw new Exception("cv bank not saved"); } } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oCVs); } [HttpGet] [Route("getErCvByRequisitionId/{recruitmentId}")] public ActionResult GetErCvByRequisitionId(int recruitmentId) { List appliedApplicants = new List(); try { appliedApplicants = _ercvService.GetErCvByRequisitionId(recruitmentId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(appliedApplicants); } [HttpGet] [Route("UpdateCvNameMobileEmail/{cvId}/{name}/{mobile}/{email}/{reference}/{education}/{experience}/{skill}")] public ActionResult UpdateCvNameMobileEmail(int cvId, string name, string mobile, string email, string reference, string education, string experience, string skill) { name = (name == "undefined" || name == "null") ? string.Empty : name; email = (email == "undefined" || email == "null") ? string.Empty : email; mobile = (mobile == "undefined" || mobile == "null") ? string.Empty : mobile; reference = (reference == "undefined" || reference == "null") ? string.Empty : reference; education = (education == "undefined" || education == "null") ? string.Empty : education; experience = (experience == "undefined" || experience == "null") ? string.Empty : experience; skill = (skill == "undefined" || skill == "null") ? string.Empty : skill; try { _cvService.UpdateCvNameMobileEmail(cvId, name, mobile, email, reference, education, experience, skill); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("EmailAndPhoneDuplicateCheck/{mobile}/{email}")] public ActionResult EmailAndPhoneDuplicateCheck(string mobile, string email) { List cvList = new List(); email = (email == "undefined" || email == "null") ? string.Empty : email; mobile = (mobile == "undefined" || mobile == "null") ? string.Empty : mobile; bool isDuplicate = false; try { cvList = _cvService.EmailAndPhoneDuplicateCheck(mobile, email); if (cvList != null && cvList.Count > 0) { isDuplicate = true; } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(isDuplicate); } [Route("getPrevErCircular/{recruitmentID}")] public ActionResult GetPrevErCircular(int recruitmentID) { ErCircular erCircular = null; try { erCircular = _erCircularService.GetByRequisition(recruitmentID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(erCircular); } [Route("getErCircularList")] public ActionResult GeAErCircular() { List erCircularList = new List(); try { erCircularList = _erCircularService.GetAll(); if (erCircularList != null && erCircularList.Count > 0) { foreach (var item in erCircularList) { if (item.RecruitmentDate != null && item.RecruitmentDate == DateTime.MinValue) { item.RecruitmentDate = null; } } } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(erCircularList); } [HttpPost("uploadFile")] [AllowAnonymous] public ActionResult uploadFile() { string base64String = ""; try { //var files = Request.Form.Files; //foreach (var formFile in files) //{ // var fileSize = formFile.Length; // var originalFile = formFile.FileName; // var fileExt = System.IO.Path.GetExtension(originalFile).Substring(1); // var fileName = _filePath + formFile.FileName; // var ms = new MemoryStream(); // formFile.CopyTo(ms); // byte[] textAsBytes = ms.ToArray(); // base64String = Convert.ToBase64String(textAsBytes); // using (PdfReader pdfReader = new PdfReader(ms)) // { // for (int page = 1; page <= pdfReader.NumberOfPages; page++) // { // ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); // string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy); // currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText))); // text.Append(currentText); // } // } //} } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(base64String); } [HttpPost("readPDf")] [AllowAnonymous] public ActionResult readPDF() { var remoteIpAddress = HttpContext.Connection.RemoteIpAddress; string base64String = ""; List cvList = new List(); List allCVs = new List(); var results = new List(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { const string MatchEmailPattern = @"(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@" + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\." + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|" + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})"; // string pdfPath1 = System.IO.Path.Combine(System.Environment.CurrentDirectory, _generatedPath, "CV_Ashek mahmud.pdf"); //PdfReader pdfReader = new PdfReader(pdfPath1); //for (int page = 1; page <= pdfReader.NumberOfPages; page++) //{ // ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); // string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy); // currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText))); // text.Append(currentText); //} var files = Request.Form.Files; var requisitionId = Convert.ToInt32(Request.Form["requisitionId"]); int serial = 0; foreach (var formFile in files) { byte[] profilePictures = null; StringBuilder text = new StringBuilder(); serial++; var fileSize = formFile.Length; var originalFile = formFile.FileName; var fileExt = System.IO.Path.GetExtension(originalFile).Substring(1); var fileName = _filePath + formFile.FileName; var ms = new MemoryStream(); formFile.CopyTo(ms); byte[] textAsBytes = ms.ToArray(); string fileType = null; base64String = Convert.ToBase64String(textAsBytes); using (PdfReader pdfReader = new PdfReader(textAsBytes)) { for (int page = 1; page <= pdfReader.NumberOfPages; page++) { ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy); currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText))); text.Append(currentText); } } using (MemoryStream pdfStream = new MemoryStream(textAsBytes)) // assuming pdfBytes is your byte array containing the PDF document { using (UglyToad.PdfPig.PdfDocument pdfDocument = UglyToad.PdfPig.PdfDocument.Open(pdfStream)) { int imageCount = 1; foreach (Page page in pdfDocument.GetPages()) { List images = page.GetImages().Cast().ToList(); foreach (XObjectImage image in images) { byte[] imageRawBytes = image.RawBytes.ToArray(); if (imageRawBytes != null) { profilePictures = imageRawBytes; fileType = GetFileType(imageRawBytes); break; } //using (FileStream stream = new FileStream($"{_filePath}\\{imageCount}.png", FileMode.Create, FileAccess.Write)) //using (BinaryWriter writer = new BinaryWriter(stream)) //{ // writer.Write(imageRawBytes); // writer.Flush(); //} imageCount++; } if (imageCount > 0) { break; } } } } var text1 = text.ToString(); string[] wordList = text1.Split(' '); string tempPhoneNumber = null; string tempEmail = null; string numericPart = null; for (var i = 0; i < wordList.Length; i++) { bool isNumber = false; // mobile Number if (string.IsNullOrEmpty(tempPhoneNumber)) { if (!string.IsNullOrEmpty(wordList[i])) { if (wordList[i].Trim().Any(char.IsDigit)) { var word = wordList[i]; //if (word.Length >= 2) //{ numericPart = new string(wordList[i].Where(char.IsDigit).ToArray()); if (wordList[i].Trim().Contains('+')) { if (wordList[i].Trim().Contains('+') && wordList[i].Trim().Contains('(')) { if (wordList[i].Trim().Contains('(') && wordList[i].Trim().Contains(')')) { var digitPart = wordList[i].Where(char.IsDigit).ToArray(); if (digitPart.Length == 13) { numericPart = new string(digitPart); } else { var digitPart1 = wordList[i + 1].Where(char.IsDigit).ToArray(); if ((digitPart.Length + digitPart1.Length) == 13) { numericPart = new string(digitPart) + new string(digitPart1); } } } numericPart = "+" + numericPart; } else { if ((wordList[i].Where(char.IsDigit).ToArray().Length) > 13) { int endIndex = Math.Min(13, wordList[i].Length); numericPart = string.Join(" ", wordList[i], 0, endIndex); } numericPart = "+" + numericPart; } } isNumber = true; // } } if (isNumber) { const string MatchPhonePattern = @"\b(\+?8801\d{9}|01\d{9})\b"; Regex rx = new Regex(MatchPhonePattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); MatchCollection matches = rx.Matches(numericPart); int noOfMatches = matches.Count; foreach (Match match in matches) { tempPhoneNumber = match.Value.ToString(); } if (tempPhoneNumber != null) { if (numericPart.Contains("+") && !tempPhoneNumber.Contains("+")) { tempPhoneNumber = "+" + tempPhoneNumber; } } } } } // email address if (wordList[i].Contains('@') && string.IsNullOrEmpty(tempEmail)) { Regex rx = new Regex( MatchEmailPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); MatchCollection matches = rx.Matches(wordList[i]); int noOfMatches = matches.Count; foreach (Match match in matches) { tempEmail = match.Value.ToString(); } } } var name = extractNames(wordList); var education = extractEducation(wordList); var experience = extractExperience(wordList); var skill = extractSkills(text1); // extractEducation(wordList); CvReaderAndExtractor cv = new CvReaderAndExtractor(); cv.SerialId = serial; cv.Name = (name == null || name== string.Empty) ? System.IO.Path.GetFileNameWithoutExtension(originalFile) : name; cv.Email = tempEmail; cv.MobileNumber = tempPhoneNumber; cv.FileName = originalFile; cv.FileAsByteArray = textAsBytes; cv.ProfilePicByteArray = profilePictures; cv.Ext = fileType; cv.Education = education; cv.Experience = experience; cv.Skill = skill; cv.Ext = fileExt; cvList.Add(cv); } if (cvList.Count > 0) { foreach (var cv in cvList) { string mobileNo = null; if (cv.MobileNumber != null) mobileNo = cv.MobileNumber = cv.MobileNumber.Replace("+88", ""); List existingCvList = new List(); if (!string.IsNullOrEmpty(mobileNo)) { existingCvList = _cvService.EmailAndPhoneDuplicateCheck(mobileNo, null); if (existingCvList != null && existingCvList.Count > 0) { cv.IsExisting = "Already Exist"; var existingCv = existingCvList.FirstOrDefault(); if (existingCv != null) { if (cv.Name != null) { if (!string.IsNullOrEmpty(cv.Name)) { existingCv.Name = cv.Name; string[] separated = cv.Name.Split(' '); if (separated.Length == 3) { existingCv.FirstName = separated[0] + " " + separated[1]; existingCv.LastName = separated[2]; } else if (separated.Length == 2) { existingCv.FirstName = separated[0]; existingCv.LastName = separated[1]; } else { existingCv.FirstName = cv.Name; } } } else { existingCv.FirstName = null; existingCv.LastName = null; } existingCv.Mobile = cv.MobileNumber; existingCv.Email = cv.Email; existingCv.ModifiedBy = -9; existingCv.ModifiedDate = DateTime.Today; existingCv.SerialId = cv.SerialId; existingCv.PositionID = requisitionId; existingCv.Education = cv.Education; existingCv.Experience = cv.Experience; existingCv.Skill = cv.Skill; existingCv.IRFileAttacments = new List(); FileAttachment fileAttachment = new FileAttachment(); fileAttachment.OriginalFileName = cv.FileName; fileAttachment.FileType = EnumFileType.CV; fileAttachment.FileAsByteArray = cv.FileAsByteArray; fileAttachment.isCvExtractorModule = true; fileAttachment.Extension = cv.Ext; if (cv.ProfilePicByteArray != null) { FileAttachment dp = new FileAttachment(); dp.OriginalFileName = cv.FileName; dp.FileType = EnumFileType.CVProfilePhoto; dp.FileAsByteArray = cv.ProfilePicByteArray; dp.isCvExtractorModule = true; dp.Extension = cv.Ext; existingCv.IRFileAttacments.Add(dp); } existingCv.IRFileAttacments.Add(fileAttachment); allCVs.Add(existingCv); } } else { cv.IsExisting = "New"; CV newCv = new CV(); if (cv.Name != null) { newCv.Name = cv.Name; string[] separated = cv.Name.Split(' '); if (separated.Length == 3) { newCv.FirstName = separated[0] + " " + separated[1]; newCv.LastName = separated[2]; } else if (separated.Length == 2) { newCv.FirstName = separated[0]; newCv.LastName = separated[1]; } else { newCv.FirstName = cv.Name; } } else { newCv.FirstName = null; newCv.LastName = null; } newCv.Mobile = cv.MobileNumber; newCv.Email = cv.Email; newCv.CreatedBy = -9; newCv.CreatedDate = DateTime.Today; newCv.SerialId = cv.SerialId; newCv.PositionID = requisitionId; newCv.Education = cv.Education; newCv.Experience = cv.Experience; newCv.Skill = cv.Skill; newCv.IRFileAttacments = new List(); FileAttachment fileAttachment = new FileAttachment(); fileAttachment.OriginalFileName = cv.FileName; fileAttachment.FileType = EnumFileType.CV; fileAttachment.isCvExtractorModule = true; fileAttachment.FileAsByteArray = cv.FileAsByteArray; fileAttachment.Extension = cv.Ext; if (cv.ProfilePicByteArray != null) { FileAttachment dp = new FileAttachment(); dp.OriginalFileName = cv.FileName; dp.FileType = EnumFileType.CVProfilePhoto; dp.FileAsByteArray = cv.ProfilePicByteArray; dp.isCvExtractorModule = true; dp.Extension = cv.Ext; newCv.IRFileAttacments.Add(dp); } newCv.IRFileAttacments.Add(fileAttachment); allCVs.Add(newCv); } } else { throw new Exception("Mobile number not found " + cv.Name); } } if (allCVs.Count > 0) { // results= new List(); string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value; results = _cvService.SaveCVs(allCVs, connectionString); foreach (var temp in results) { if (temp.ID > 0) { var cv = cvList?.Where(y => y.SerialId == temp.SerialId)? .FirstOrDefault(); if (cv != null) { cv.CVId = temp.ID; cv.CandidateId = temp.CandidateID; } } } } } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(cvList); } public static string GetFileType(byte[] bytes) { if (bytes == null || bytes.Length == 0) { return "Unknown"; } // JPEG if (bytes.Length >= 2 && bytes[0] == 0xFF && bytes[1] == 0xD8) { return "image/jpeg"; } // PNG if (bytes.Length >= 8 && bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47 && bytes[4] == 0x0D && bytes[5] == 0x0A && bytes[6] == 0x1A && bytes[7] == 0x0A) { return "image/png"; } // PDF if (bytes.Length >= 4 && bytes[0] == 0x25 && bytes[1] == 0x50 && bytes[2] == 0x44 && bytes[3] == 0x46) { return "application/pdf"; } // Add more checks for other file types as needed return "Unknown"; } public string extractEducation(string[] wordList) { string extractingWords = ""; bool isAllExtract = false; string[] educationalKeywords = { "education", "educational qualifications", "academic qualification", "academic" }; string[] extractingKeywords = { "secondary", "s.s.c", "ssc", "college" }; for (var i = 0; i < wordList.Length; i++) { string currentWord = wordList[i].ToString().ToLower(); if (!string.IsNullOrEmpty(currentWord) && !string.IsNullOrWhiteSpace(currentWord)) { foreach (string keyword in educationalKeywords) { if (currentWord.Contains(keyword)) { if (currentWord.Trim().Contains("educational") || currentWord.Trim().Contains("education") || currentWord.Trim().Contains("academic")) { bool isEducationFound = false; bool isSSCFound = false; string nextWord = null; int lineCount = 0; int isDigitCount = 0; if (currentWord.Trim().Contains("education")) { isEducationFound = true; } for (int j = i; j < wordList.Length; j++) { currentWord = wordList[j].ToString().ToLower(); if (isSSCFound) { if (currentWord.Trim().Any(char.IsDigit)) { isDigitCount++; extractingWords += " " + currentWord; if (isDigitCount == 2) break; else continue; } else if (currentWord.Contains("\n")) //serching for next new line { lineCount++; int newlineIndex = currentWord.IndexOf('\n'); string wordsBeforeNewLine = wordList[j].Substring(0, newlineIndex); extractingWords += " " + wordsBeforeNewLine; if (lineCount == 2) break; else continue; } else { extractingWords += " " + wordList[j]; continue; } } if (currentWord.Contains("qualification") && !isEducationFound) //serching for qualifications { isEducationFound = true; continue; } else { if (isEducationFound) { string wordsAfterIndex = ""; var nextword = wordList[j].Trim().ToLower(); string matchedKeyword = extractingKeywords.FirstOrDefault(keyword => nextword.Contains(keyword)); if (!string.IsNullOrEmpty(matchedKeyword)) { if (nextword.Contains("secondary") && wordList[j + 1].Trim().ToLower().Contains("school") || nextword.Contains("s.s.c") || nextword.Contains("ssc") || nextword.Contains("secondary school")) { extractingWords += " " + wordList[j]; isSSCFound = true; continue; //isAllExtract = true; //i = j; //break; } if (nextword.Contains("college")) { extractingWords += " " + wordList[j]; isSSCFound = true; continue; //isAllExtract = true; //i = j; //break; } } int index = wordList[j].ToLower().IndexOf("educational"); if (index != -1) { wordsAfterIndex = wordList[j].ToLower().Substring(index + "educational".Length); extractingWords += " " + wordsAfterIndex; int index2 = wordList[j + 1].ToLower().IndexOf("qualifications"); if (index2 != -1) { wordsAfterIndex = wordList[j + 1].ToLower().Substring(index2 + "qualifications".Length); extractingWords += " " + wordsAfterIndex; } } else { int index1 = wordList[j].ToLower().IndexOf("education"); if (index1 != -1) { wordsAfterIndex = wordList[j].ToLower().Substring(index1 + "education".Length); extractingWords += " " + wordsAfterIndex; } extractingWords += " " + wordList[j]; } continue; } continue; } } if (isAllExtract == true) break; } } } } } int lastIndex = extractingWords.LastIndexOfAny("0123456789".ToCharArray()); // If a digit is found, extract the substring from the beginning up to that index if (lastIndex != -1) { extractingWords = extractingWords.Substring(0, lastIndex + 1); // Adding 1 to include the last digit } return extractingWords.Trim(); } public string extractNames(string[] wordList) { bool extratxWords = false; bool newLineWords = false; string extractingWords = ""; int count = 0; for (var i = 0; i < wordList.Length; i++) { string currentWord = wordList[i].ToString().ToLower(); if (!string.IsNullOrEmpty(currentWord) && !string.IsNullOrWhiteSpace(currentWord)) { if (currentWord.Contains("resume") || currentWord.Contains("cv")) { if (wordList[i + 1].ToString().ToLower().Contains("of")) // if resume of found then looking for next words { i++; newLineWords = true; continue; } } else if (currentWord.Contains("name")) { extratxWords = true; } else if (newLineWords) // extended version of resume of { if (count > 0) { if (currentWord.Contains("\n")) //serching for next new line { int newlineIndex = currentWord.IndexOf('\n'); string wordsBeforeNewLine = wordList[i].Substring(0, newlineIndex); extractingWords += " " + wordsBeforeNewLine; break; } else { extractingWords += " " + wordList[i]; continue; } } extractingWords += " " + wordList[i]; //just extracting next word and not checking new line count++; continue; } else { if (extratxWords == false) { extratxWords = true; extractingWords += " " + wordList[i]; continue; } } } if (extratxWords && !newLineWords) { if (currentWord.Contains("\n")) //serching for next new line { int newlineIndex = currentWord.IndexOf('\n'); string wordsBeforeNewLine = wordList[i].Substring(0, newlineIndex); extractingWords += " " + wordsBeforeNewLine; extratxWords = false; break; } else { extractingWords += " " + wordList[i]; //extracting words before finding the new line } } } extractingWords = extractingWords.Trim(); if (extractingWords.Where(char.IsDigit).Any()) extractingWords = null; return extractingWords; } public string extractExperience(string[] wordList) { string extractingWords = ""; bool isAllExtract = false; bool isPrevWordWork = false; bool isExperienceFound = false; string[] next50Strings = null; string[] experienceKeywords = { "experience", "experinces" }; for (var i = 0; i < wordList.Length; i++) { string currentWord = wordList[i].ToString().ToLower(); if (isPrevWordWork) { if (currentWord.Trim().Contains("experience") || currentWord.Trim().Contains("experiences")) { isExperienceFound = true; continue; } } if (!string.IsNullOrEmpty(currentWord) && !string.IsNullOrWhiteSpace(currentWord)) { if (currentWord.Trim().Contains("work")) { if (currentWord.Trim().Contains("experience") || currentWord.Trim().Contains("experiences")) { isExperienceFound = true; break; } else { isPrevWordWork = true; continue; } } if (isExperienceFound) { next50Strings = new string[Math.Min(200, wordList.Length - i)]; Array.Copy(wordList, i, next50Strings, 0, next50Strings.Length); break; } } } int isDigitCount = 0; bool istilwordfound = false; string tillWords = null; if (next50Strings != null) { for (var i = 0; i < next50Strings.Length; i++) { string currentWord = next50Strings[i].ToString().ToLower(); //if (currentWord.Trim().Contains("present")) //{ // extractingWords += " " + next50Strings[i]; // for(var j = i; j < 5; j++) // { // extractingWords += " " + next50Strings[j]; // } // istilwordfound = true; // break; //} if (currentWord.Trim().Contains("till")) { tillWords += " " + next50Strings[i] + " " + next50Strings[i + 1]; for (var j = i; j < 5; j++) { tillWords += " " + next50Strings[j]; } istilwordfound = true; break; } else { tillWords += " " + next50Strings[i]; } } if (istilwordfound) { extractingWords = tillWords; } if (!istilwordfound) { string lastString = null; List digits = new List(); foreach (string str in next50Strings) { if (str.ToString().ToLower().Contains("present")) { digits.Add(str); } var numericPart = new string(str.Where(char.IsDigit).ToArray()); if (!string.IsNullOrEmpty(numericPart)) { digits.Add(numericPart); } } if (digits != null && digits.Count > 0) lastString = digits[digits.Count - 1]; if (!string.IsNullOrEmpty(lastString)) { for (var i = 0; i < next50Strings.Length; i++) { string currentWord = next50Strings[i].ToString().ToLower(); if (currentWord.Trim().Contains(lastString)) { extractingWords += " " + next50Strings[i]; bool isDigitinSameWord = false; string extractingWords1 = null; for (var j = i + 1; j < next50Strings.Length; j++) { string next = next50Strings[j].ToString().ToLower(); if (next.Trim().Contains(lastString)) { isDigitinSameWord = true; extractingWords1 += " " + next50Strings[j]; break; } else { extractingWords1 += " " + next50Strings[j]; } } if (isDigitinSameWord) { extractingWords = next50Strings + extractingWords1; } } else { extractingWords += " " + next50Strings[i]; } } } } } int index = extractingWords.IndexOf("education", StringComparison.OrdinalIgnoreCase); if (index != -1) { extractingWords = extractingWords.Substring(0, index); } return extractingWords.Trim(); } public string extractSkills(string input) { string extractWords = ""; int index = -1; string targetWord = ""; if (input.ToLower().Contains("skill")) { if (input.ToLower().Contains("skills")) { index = input.ToLower().IndexOf("skills"); targetWord = "skills"; } else if (input.ToLower().Contains("skill")) { index = input.ToLower().IndexOf("skill"); targetWord = "skill"; } if (index != -1) { //int newlineIndex = input.IndexOf('\n', index); // Extract the substring starting from the index of "MySql" to the next 200 characters string result = input.Substring(index + targetWord.Length, Math.Min(500, input.Length - (index + targetWord.Length))); string[] lines = result.Split('\n'); string[] firstFiveLines = new string[Math.Min(10, lines.Length)]; Array.Copy(lines, firstFiveLines, firstFiveLines.Length); foreach (string line in firstFiveLines) { extractWords += line; } } } //if (input.ToLower().Contains("skills")) //{ // int index = input.ToLower().IndexOf("skills"); // if (index != -1) // { // // Extract the substring starting from the index of "MySql" to the next 200 characters // string result = input.Substring(index + "skills".Length, Math.Min(500, input.Length - (index + "skills".Length))); // string[] lines = result.Split('\n'); // string[] firstFiveLines = new string[Math.Min(4, lines.Length)]; // Array.Copy(lines, firstFiveLines, firstFiveLines.Length); // foreach (string line in firstFiveLines) // { // extractWords += line; // } // } //} return extractWords.Trim(); } [HttpPost] [Route("saveJobTracking")] public ActionResult SaveJobTracking(RecJobTracking item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Today; try { this._recJobTrackingService.Save(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpGet] [Route("getByRecruitmentId/{recruitmentId}")] public ActionResult GetByRecruitmentId(int recruitmentId) { RecJobTracking item = null; try { item = _recJobTrackingService.GetByRecruitmentId(recruitmentId); if(item != null) { item.JobPostingDays=(item.JobPostingDate - item.TrackingStartDate).Days; item.CvCollectionDays = (item.CvCollectionDate - item.JobPostingDate).Days; item.InterviewStartDays = (item.InterviewStartDate - item.CvCollectionDate).Days; item.InterviewEndDays = (item.InterviewEndDate - item.InterviewStartDate).Days; item.OfferLetterSendDays = (item.OfferLetterSendDate - item.InterviewEndDate).Days; item.JoiningDays = (item.JoiningDate - item.OfferLetterSendDate).Days; } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(item); } //[HttpGet] //[Route("getByRecruitmentId/{recruitmentId}")] //public ActionResult GetByRecruitmenWithRecJob(int recruitmentId) //{ // RecJobTracking item = null; // try // { // item = _recJobTrackingService.GetByRecruitmentId(recruitmentId); // if (item != null) // { // item.JobPostingDays = (item.JobPostingDate - item.TrackingStartDate).Days; // item.CvCollectionDays = (item.CvCollectionDate - item.JobPostingDate).Days; // item.InterviewStartDays = (item.InterviewStartDate - item.CvCollectionDate).Days; // item.InterviewEndDays = (item.InterviewEndDate - item.InterviewStartDate).Days; // item.OfferLetterSendDays = (item.OfferLetterSendDate - item.InterviewEndDate).Days; // item.JoiningDays = (item.JoiningDate - item.OfferLetterSendDate).Days; // } // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(item); //} [HttpPost] [Route("getRecruitmentTracking")] public ActionResult GetRecruitmentTracking(dynamic data) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); DateTime? startDate = items["startDate"] == null ? null : (DateTime)items["startDate"].ToObject(); DateTime? endDate = items["endDate"] == null ? null : (DateTime)items["endDate"].ToObject(); int recruitmentId = items["recruitmentid"] == null ? 0 : items["recruitmentid"].ToObject(); int recruiterId = items["recruiterid"] == null ? 0 : items["recruiterid"].ToObject(); EnumOnBoradStatus? onBoardStatus = items["status"] == null ? null: (EnumOnBoradStatus)items["status"].ToObject(); DataSet ds = new DataSet(); try { ds = _internalRecruitmentService.GetRecruitment(startDate, endDate, onBoardStatus, recruitmentId, recruiterId, currentUser.UserID); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(ds); } [HttpPost] [Route("getGetRequisitionChart")] public ActionResult GetRequisitionChart(dynamic data) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); DateTime? startDate = items["fromDate"] == null ? null : (DateTime)items["fromDate"].ToObject(); DateTime? endDate = items["fromDate"] == null ? null : (DateTime)items["toDate"].ToObject(); DataSet ds = new DataSet(); try { ds = _internalRecruitmentService.GetRequisitionChart((DateTime)startDate, (DateTime)endDate); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(ds); } [HttpPost] [Route("deleteCvSort")] public ActionResult deleteCvSort(CVSort ob) { try { _cvService.DeleteCvsort(ob); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpPost] [Route("getRequisitionReports")] public ActionResult GetRequisitionReports(dynamic data) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); DateTime? startDate = items["fromDate"] == null ? null : (DateTime)items["fromDate"].ToObject(); DateTime? endDate = items["fromDate"] == null ? null : (DateTime)items["toDate"].ToObject(); DataSet ds = new DataSet(); try { ds = _internalRecruitmentService.GetRequisitionReports((DateTime)startDate, (DateTime)endDate); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(ds); } [HttpPost] [Route("getRequisitionCountReport")] public ActionResult GetRequisitionCountReport(dynamic data) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); DateTime? startDate = items["fromDate"] == null ? null : (DateTime)items["fromDate"].ToObject(); DateTime? endDate = items["fromDate"] == null ? null : (DateTime)items["toDate"].ToObject(); DataSet ds = new DataSet(); try { ds = _internalRecruitmentService.GetRequisitionAllCountReport((DateTime)startDate, (DateTime)endDate); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(ds); } [HttpGet] [Route("getInterviewAssesmentKpis")] public ActionResult GetInterviewAssesmentKpis() { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); List list= new List(); try { list = _interviewAssessmentKPIService.Get(); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(list); } [HttpPost] [Route("saveInterviewBoardKpi")] public ActionResult saveInterviewBoardKpi(List items) { try { _interviewAssessmentKPIService.SaveBoardKpis(items); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(); } [HttpPost] [Route("updateMarkInfo")] public void updateMarkInfo(RecruitmentMarkExtend item) { try { _recruitementProcessService.UpdateInterviewAssesmentMark(item); } catch (Exception ex) { StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } } } }