private void Activation() { var AllSrf = _srf.GetAll().ToList(); var AllUser = _userProfile.GetAll().ToList(); var AllVacancy = _vacancy.GetAll().ToList(); var AllCandidate = _candidate.GetAll().ToList(); var AllEscalation = _escalation.GetAll().ToList(); var GetLastSrf = _srf.GetAll().OrderByDescending(x => x.CreatedAt).GroupBy(x => x.CandidateId).Select(x => x.Key).ToArray(); var SrfCandidate = _srf.GetAll().Where(x => GetLastSrf.Contains(x.CandidateId)).ToArray(); foreach (var srf in SrfCandidate) { // Set Active Srf To User var _temp = _srf.GetById(srf.Id); _temp.IsActive = true; // Set Terminate if (!string.IsNullOrEmpty(srf.TeriminateNote)) { var Candidate = _candidate.GetById(srf.CandidateId); if (Candidate.Account != null) { var pro = _userProfile.GetById(Candidate.AccountId); pro.IsBlacklist = false; pro.IsTerminate = true; _userProfile.Update(pro); } _temp.Status = SrfStatus.Terminate; } _srf.Update(_temp); } // Generate SRF NUMBER //foreach (var row in AllSrf) //{ // String SrfNumber = null; // if (string.IsNullOrEmpty(row.Number)) // { // SrfNumber = "0000"; // } // else // { // if (row.Number.Length > 4) // { // SrfNumber = row.Number.Substring(0, 4); // } // else // { // SrfNumber = row.Number; // } // } // var _temp = _srf.GetById(row.Id); // _temp.Number = SrfNumber; // _srf.Update(_temp); //} }
public void SetActive(Guid SrfId, Guid CandidateId, int UserProfileId) { var Candidate = _contractor.GetAll().Where(x => x.Id.Equals(CandidateId) && x.AccountId.Equals(UserProfileId)).FirstOrDefault(); var CandidateSrf = _repository.GetAll().Where(x => x.CandidateId.Equals(Candidate.Id)).ToList(); var ApproveGeneral = _repository.GetSingle(SrfId); var ApproveEscalasi = _escalation.GetAll().Where(x => x.SrfId.Equals(SrfId)).FirstOrDefault(); if (CandidateSrf != null) { foreach (var srf in CandidateSrf) { var Temp = _repository.GetSingle(srf.Id); Temp.IsActive = false; Temp.IsLocked = true; _repository.Update(Temp); } if (ApproveGeneral != null || ApproveEscalasi != null) { var Srf = _repository.GetSingle(SrfId); Srf.IsActive = true; Srf.IsLocked = false; _repository.Update(Srf); } } }
public override IActionResult Edit(Guid id) { try { var srf = Service.GetById(id); var item = _escalation.GetAll().Where(x => x.SrfId.Equals(id)).FirstOrDefault(); var Candidate = _candidate.GetById(srf.CandidateId); var Vacancy = _vacancy.GetById(Candidate.VacancyId); var CurrentSSO = _ssow.GetById(srf.ServicePackId); var Departement = _department.GetById(srf.DepartmentId); ViewBag.Candidate = Candidate; ViewBag.Vacancy = Vacancy; ViewBag.Departement = Departement; ViewBag.SSOW = CurrentSSO; ViewBag.SCategory = _ssowCategory.GetById(CurrentSSO.ServicePackCategoryId); ViewBag.JobsStage = _jobStage.GetById(Vacancy.JobStageId); ViewBag.ListDepartement = _department.GetAll().ToList(); if (Departement.OperateOrNon == 1) { ViewBag.HeadOperation = _userHelper.GetByRoleName("Head Of Operation").ToList(); } else { ViewBag.HeadOperation = _userHelper.GetByRoleName("Head Of Non Operation").ToList(); } ViewBag.ListServiceLine = _userHelper.GetByRoleName("Head Of Service Line").ToList(); ViewBag.ListServiceCordinator = _userHelper.GetByRoleName("Service Coordinator").ToList(); ViewBag.ListHeadOperation = _userHelper.GetByRoleName("Head Of Operation").ToList(); ViewBag.ListHeadNonOperation = _userHelper.GetByRoleName("Head Of Non Operation").ToList(); ViewBag.ListHeadSourcing = _userHelper.GetByRoleName("Head Of Sourcing").ToList(); ViewBag.ListAccount = _account.GetAll().ToList(); ViewBag.ListSubDepartment = _departmentSub.GetAll().Where(x => x.DepartmentId.Equals(srf.DepartmentId)).ToList(); ViewBag.ListCostCenter = _costCenter.GetAll().Where(x => x.DepartmentId.Equals(srf.DepartmentId)).ToList(); ViewBag.ListNetwork = _network.GetAll().Where(x => x.DepartmentId.Equals(srf.DepartmentId)).ToList(); //ViewBag.ListSSOW = _ssow.GetAll().Where(x => x.Type.Equals(CurrentSSO.Type)).ToList(); ViewBag.PackageType = _packageType.GetAll().ToList(); ViewBag.ServicePackCategory = _ssowCategory.GetAll().ToList(); ViewBag.BasicServiceLevel = new List <int>(new int[] { 0, 20, 30, 40 }).Select(x => new { Id = x, Name = x.ToString() }); Dictionary <string, bool> ws = new Dictionary <string, bool>(); ws.Add("No", false); ws.Add("Yes", true); Dictionary <string, bool> com = new Dictionary <string, bool>(); com.Add("No USIM", false); com.Add("USIM", true); ViewBag.WorkstationService = ws.Select(x => new { Id = x.Value, Name = x.Key.ToString() }).ToList(); ViewBag.CommunicationService = com.Select(x => new { Id = x.Value, Name = x.Key.ToString() }).ToList(); ViewBag.EscalationId = item.Id; ViewBag.ServiceCode = _ssow.GetById(item.ServicePackId).Code; ViewBag.SrfNumber = srf.Number; var PreofileId = _userHelper.GetUser(User).UserProfile.Id; ViewBag.PreofileId = PreofileId; ViewBag.LineManagerId = srf.ApproveOneId; ViewBag.ServiceLineId = srf.ApproveTwoId; ViewBag.HeadOpId = srf.ApproveThreeId; ViewBag.HeadNonId = srf.ApproveFourId; ViewBag.HeadOfSourceId = srf.ApproveFourId; ViewBag.ServiceCoordId = srf.ApproveSixId; ViewBag.WorkstationService = ws.Select(x => new { Id = x.Value, Name = x.Key.ToString() }).ToList(); ViewBag.CommunicationService = com.Select(x => new { Id = x.Value, Name = x.Key.ToString() }).ToList(); if (srf != null) { var Model = Mapper.Map <EscalationModelForm>(item); Model.Srf = Mapper.Map <SrfRequestModelForm>(srf); Model.SrfId = id; string typeName = CurrentSSO.Type.ToString(); Guid packageTypeId, servicePackCategoryId; if (Guid.TryParse(item.CustomField1, out packageTypeId)) { Model.PackageTypeId = packageTypeId; } if (Guid.TryParse(item.CustomField2, out servicePackCategoryId)) { Model.ServicePackCategoryId = servicePackCategoryId; } if (!string.IsNullOrEmpty(item.Files)) { var attachments = (JsonConvert.DeserializeObject <List <string> >(item.Files) ?? new List <string>()); Model.Files = string.Join("|", attachments.ToArray()) + "|"; } else { Model.Files = null; } return(View(Model)); } } catch (Exception e) { return(Content(e.ToString())); } return(NotFound()); }
public override IActionResult Edit(Guid id) { try { var item = Service.GetById(id); var Vacancy = _vacancy.GetById(_candidate.GetById(item.CandidateId).VacancyId); var Departement = _department.GetById(item.DepartmentId); var PackageType = _packageType.GetById(Vacancy.PackageTypeId); ViewBag.PriceType = PackageType.Name; ViewBag.Vacancy = Vacancy; ViewBag.Candidate = _candidate.GetById(item.CandidateId); ViewBag.Departement = _department.GetById(item.DepartmentId); ViewBag.SSOW = _ssow.GetById(item.ServicePackId); ViewBag.SCategory = _ssowCategory.GetById(_ssow.GetById(item.ServicePackId).ServicePackCategoryId); ViewBag.JobsStage = _jobStage.GetById(Vacancy.JobStageId); ViewBag.ListDepartement = _department.GetAll().ToList(); if (Departement.OperateOrNon == 1) { ViewBag.HeadOperation = _userHelper.GetByRoleName("Head Of Operation").ToList(); } else { ViewBag.HeadOperation = _userHelper.GetByRoleName("Head Of Non Operation").ToList(); } ViewBag.isOperation = Departement.OperateOrNon; ViewBag.ListServiceLine = _userHelper.GetByRoleName("Head Of Service Line").ToList(); ViewBag.ListServiceCordinator = _userHelper.GetByRoleName("Service Coordinator").ToList(); ViewBag.ListAccount = _account.GetAll().ToList(); ViewBag.ListSubDepartment = _departmentSub.GetAll().Where(x => x.DepartmentId.Equals(item.DepartmentId)).ToList(); ViewBag.ListCostCenter = _costCenter.GetAll().Where(x => x.DepartmentId.Equals(item.DepartmentId)).ToList(); ViewBag.ListNetwork = _network.GetAll().Where(x => x.DepartmentId.Equals(item.DepartmentId) && x.IsClosed == false).ToList(); ViewBag.Id = id; ViewBag.isOperation = Departement.OperateOrNon; ViewBag.txtOperaion = (Departement.OperateOrNon == 1) ? "Operational" : "Non Operational"; ViewBag.FormDisable = 1; ViewBag.SrfNumber = Service.GenerateNumnber(); ViewBag.NowYear = DateTime.Now.Year.ToString("yy"); // Aditional Dictionary<string, int> ws = new Dictionary<string, int>(); ws.Add("No", 0); ws.Add("Yes", 1); Dictionary<string, bool> com = new Dictionary<string, bool>(); com.Add("No USIM", false); com.Add("USIM", true); Dictionary<string, bool> sign = new Dictionary<string, bool>(); sign.Add("Non-HRMS", false); sign.Add("HRMS", true); Dictionary<string, bool> manager = new Dictionary<string, bool>(); manager.Add("Manager", true); manager.Add("Non Manager", false); ViewBag.PackageType = _packageType.GetAll().ToList(); ViewBag.ServicePackCategory = _ssowCategory.GetAll().ToList(); ViewBag.ServicePack = _ssow.GetAll().Where(x => x.Type == (PackageTypes)Enum.Parse(typeof(PackageTypes), PackageType.Name)).ToList(); ViewBag.BasicServiceLevel = new List<int>(new int[] { 0, 20, 30, 40 }).Select(x => new { Id = x, Name = x.ToString() }); ViewBag.WorkstationService = ws.Select(x => new { Id = x.Value, Name = x.Key.ToString() }).ToList(); ViewBag.CommunicationService = com.Select(x => new { Id = x.Value, Name = x.Key.ToString() }).ToList(); ViewBag.Signum = sign.Select(x => new { Id = x.Value, Name = x.Key.ToString() }).ToList(); ViewBag.IsManager = manager.Select(x => new { Id = x.Value, Name = x.Key.ToString() }).ToList(); ViewBag.Jobstage = _jobStage.GetAll().Where(x => !string.IsNullOrEmpty(x.Description)).ToList(); ViewBag.ListAgency = _userHelper.GetByRoleName("HR Agency").ToList(); ViewBag.ListActivity = _activity.GetAll().ToList(); ViewBag.ListExtended = Service.GetAll().Where(x => x.CandidateId.Equals(item.CandidateId) && x.SrfEnd >= item.SrfBegin).ToList(); ViewBag.ListLineManager = _userHelper.GetByRoleName("Line Manager").ToList(); ViewBag.ListHeadOfSourcing = _userHelper.GetByRoleName("Head Of Sourcing").ToList(); ViewBag.ListSrfStatus = new List<SrfApproveStatus>(new SrfApproveStatus[] { SrfApproveStatus.Waiting, SrfApproveStatus.Approved }).Select(x => new { Id = x, Name = x.ToString() }); ViewBag.ListTypeSRF = new List<SrfType>(new SrfType[] { SrfType.New, SrfType.Extension }).Select(x => new { Id = x, Name = x.ToString() }); ViewBag.LisStatusSrf = new List<SrfStatus>(new SrfStatus[] { SrfStatus.Done,SrfStatus.Terminate,SrfStatus.Blacklist }).Select(x => new { Id = x, Name = x.ToString() }); var Model = Mapper.Map<SrfRequestModelForm>(item); Model.FormVacancy = Mapper.Map<VacancyListFormModel>(Vacancy); if(item.Status == SrfStatus.Waiting) { Model.Status = SrfStatus.Done; } var CandidateInfo = _candidate.GetById(item.CandidateId); if(CandidateInfo!=null) { Model.AgencyId = CandidateInfo.AgencyId.Value; } var Esc = _escalation.GetAll().Where(x => x.SrfId.Equals(id)).FirstOrDefault(); if(Esc==null) { ViewBag.IsEscalation = false; } else { ViewBag.IsEscalation = true; } return View(Model); } catch (Exception e) { return Content(e.ToString()); } }
public override IActionResult Index() { var PreofileId = _userHelper.GetUser(User).UserProfile.Id; string sWebRootFolder = _env.WebRootPath; string sFileName = @"report/ContractorData.xlsx"; string URL = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, sFileName); FileInfo file = new FileInfo(Path.Combine(sWebRootFolder, sFileName)); if (file.Exists) { file.Delete(); file = new FileInfo(Path.Combine(sWebRootFolder, sFileName)); } using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Sheet1"); int i = 0; int index = 1; worksheet.Cells[index, i += 1].Value = "ID"; worksheet.Cells[index, i += 1].Value = "Type"; worksheet.Cells[index, i += 1].Value = "Contractor Name"; worksheet.Cells[index, i += 1].Value = "SRF Number"; worksheet.Cells[index, i += 1].Value = "Email"; worksheet.Cells[index, i += 1].Value = "Position"; worksheet.Cells[index, i += 1].Value = "Contractor Start"; worksheet.Cells[index, i += 1].Value = "Contractor End"; worksheet.Cells[index, i += 1].Value = "Status"; worksheet.Cells[index, i += 1].Value = "Rate"; worksheet.Cells[index, i += 1].Value = "Organization Unit"; worksheet.Cells[index, i += 1].Value = "Sub Organization Unit"; worksheet.Cells[index, i += 1].Value = "Line Manager"; worksheet.Cells[index, i += 1].Value = "Project Manager"; worksheet.Cells[index, i += 1].Value = "Supplier"; worksheet.Cells[index, i += 1].Value = "Terminate Note"; worksheet.Cells[index, i += 1].Value = "Blacklist Note"; worksheet.Cells[index, i += 1].Value = "Date"; worksheet.Cells[index, i += 1].Value = "Signum"; for (int i_temp = 1; i_temp <= i; i_temp++) { worksheet.Cells[index, i_temp].Style.Font.Bold = true; worksheet.Cells[index, i_temp].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; worksheet.Cells[index, i_temp].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.FromArgb(79, 129, 189)); worksheet.Cells[index, i_temp].Style.Font.Color.SetColor(System.Drawing.Color.White); } index += 1; Expression <Func <SrfRequest, object> >[] Includes = new Expression <Func <SrfRequest, object> > [11]; Includes[0] = pack => pack.Candidate; Includes[1] = pack => pack.Candidate.Account; Includes[2] = pack => pack.ServicePack; Includes[3] = pack => pack.ServicePack.ServicePackCategory; Includes[4] = pack => pack.Departement; Includes[5] = pack => pack.DepartementSub; Includes[6] = pack => pack.ApproveOneBy; Includes[7] = pack => pack.NetworkNumber; Includes[8] = pack => pack.NetworkNumber.ProjectManager; Includes[9] = pack => pack.Candidate.Agency; Includes[10] = pack => pack.Candidate.Vacancy.PackageType; var Data = (List <SrfRequest>)null; #region Approver if (User.IsInRole("Line Manager")) { Data = Service.GetAll(Includes).Where(x => x.ApproveOneId == PreofileId && x.IsLocked == false && x.Candidate.IsUser == true && x.IsActive == true).ToList(); } else if (User.IsInRole("Head Of Service Line")) { Data = Service.GetAll(Includes).Where(x => x.ApproveTwoId == PreofileId && x.IsLocked == false && x.Candidate.IsUser == true && x.IsActive == true).ToList(); } else if (User.IsInRole("Head Of Operation")) { Data = Service.GetAll(Includes).Where(x => x.ApproveThreeId == PreofileId && x.IsLocked == false && x.Candidate.IsUser == true && x.IsActive == true).ToList(); } else if (User.IsInRole("Head Of Non Operation")) { Data = Service.GetAll(Includes).Where(x => x.ApproveFourId == PreofileId && x.IsLocked == false && x.Candidate.IsUser == true && x.IsActive == true).ToList(); } else if (User.IsInRole("Head Of Sourcing")) { Data = Service.GetAll(Includes).Where(x => x.ApproveFiveId == PreofileId && x.IsLocked == false && x.Candidate.IsUser == true && x.IsActive == true).ToList(); } else if (User.IsInRole("Service Coordinator")) { Data = Service.GetAll(Includes).Where(x => x.ApproveSixId == PreofileId && x.IsLocked == false && x.Candidate.IsUser == true && x.IsActive == true).ToList(); } else if (User.IsInRole("HR Agency")) { Data = Service.GetAll(Includes).Where(x => x.Candidate.AgencyId == PreofileId && x.IsLocked == false && x.Candidate.IsUser == true && x.IsActive == true).ToList(); } else if (User.IsInRole("Sourcing")) { Data = Service.GetAll(Includes).Where(x => x.Candidate.Vacancy.ApproverTwoId == PreofileId && x.IsLocked == false && x.Candidate.IsUser == true && x.IsActive == true).ToList(); } else { Data = Service.GetAll(Includes).Where(x => x.IsLocked == false && x.Candidate.IsUser == true && x.IsActive == true).ToList(); } #endregion ` if (Data != null) { foreach (var row in Data) { int j = 0; worksheet.Cells[index, j += 1].Value = !string.IsNullOrWhiteSpace(row.Number) ? row.Number : "-"; worksheet.Cells[index, j += 1].Value = row.Candidate.Vacancy.PackageType == null ? "-" : row.Candidate.Vacancy.PackageType.Name; worksheet.Cells[index, j += 1].Value = row.Candidate.Account == null ? "-" : row.Candidate.Name; worksheet.Cells[index, j += 1].Value = !string.IsNullOrWhiteSpace(row.Number) ? "e-EID/KI-" + row.CreatedAt.Value.ToString("yy", CultureInfo.InvariantCulture) + ":SRF: " + row.Number + " UEN" : "-"; worksheet.Cells[index, j += 1].Value = row.Candidate.Account == null ? "-" : row.Candidate.Email; worksheet.Cells[index, j += 1].Value = row.ServicePack.ServicePackCategory == null ? "-" : row.ServicePack.ServicePackCategory.Name; worksheet.Cells[index, j += 1].Value = row.SrfBegin.Value.ToString("dd MMMM yyyy", CultureInfo.InvariantCulture); worksheet.Cells[index, j += 1].Value = row.SrfEnd.Value.ToString("dd MMMM yyyy", CultureInfo.InvariantCulture); if (row.Status == SrfStatus.Terminate || row.Status == SrfStatus.Blacklist) { if (row.Status == SrfStatus.Terminate) { worksheet.Cells[index, j += 1].Value = "Terminate"; } else { worksheet.Cells[index, j += 1].Value = "Blacklist"; } } else { worksheet.Cells[index, j += 1].Value = "Active"; } var Escalation = _escalation.GetAll().Where(x => x.SrfId.Equals(row.Id)).ToList(); if (Escalation.Any()) { worksheet.Cells[index, j += 1].Value = "Special Rate"; } else { worksheet.Cells[index, j += 1].Value = "Normal Rate"; } worksheet.Cells[index, j += 1].Value = row.Departement == null ? "-" : row.Departement.Name; worksheet.Cells[index, j += 1].Value = row.DepartementSub == null ? "-" : row.DepartementSub.SubName; worksheet.Cells[index, j += 1].Value = row.ApproveOneBy == null ? "-" : row.ApproveOneBy.Name; worksheet.Cells[index, j += 1].Value = row.NetworkNumber.ProjectManager == null ? "-" : row.NetworkNumber.ProjectManager.Name; worksheet.Cells[index, j += 1].Value = row.Candidate.Agency == null ? "-" : row.Candidate.Agency.Name; worksheet.Cells[index, j += 1].Value = row.TeriminateNote; worksheet.Cells[index, j += 1].Value = row.TeriminateNote; worksheet.Cells[index, j += 1].Value = row.CreatedAt.Value.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture); worksheet.Cells[index, j += 1].Value = row.Candidate.Account == null ? "-" : row.Candidate.Account.AhId; index++; } } worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns(); package.Save(); } return(Redirect(URL)); }