public ActionResult ExportAllCandidateList([DataSourceRequest] DataSourceRequest request, Rec_CandidateSearchModel model) { string status = string.Empty; var service = new BaseService(); ListQueryModel lstModel = new ListQueryModel { PageIndex = request.Page, PageSize = int.MaxValue - 1, Filters = ExtractFilterAttributes(request), Sorts = ExtractSortAttributes(request), AdvanceFilters = ExtractAdvanceFilterAttributes(model) }; var listEntity = service.GetData<Rec_CandidateEntity>(lstModel, ConstantSql.hrm_rec_sp_get_Candidate, UserLogin, ref status); if (model.Evaluated == HRM.Infrastructure.Utilities.EnumDropDown.StatusHealth.E_ACCEPT.ToString()) { listEntity = listEntity.Where(s => s.PassFilterResume == true).ToList(); } if (model.Evaluated == HRM.Infrastructure.Utilities.EnumDropDown.StatusHealth.E_NOTACCEPT.ToString()) { listEntity = listEntity.Where(s => s.PassFilterResume == false).ToList(); } var listModel = new List<Rec_CandidateModel>(); if (listEntity != null) { foreach (var item in listEntity) { if (item.ReasonFailFilter != null) { List<string> lsititem = item.ReasonFailFilter.Split(',').ToList(); string Stringresult = string.Empty; foreach (var itemstring in lsititem) { Stringresult += itemstring.TranslateString() + ','; } Stringresult = Stringresult.Substring(0, Stringresult.Length - 1); item.ReasonFailFilter = Stringresult; } } } status = ExportService.Export(listEntity, model.GetPropertyValue("ValueFields").TryGetValue<string>().Split(',')); return Json(status); }
public ActionResult ExportCandidateListByTemplate([DataSourceRequest] DataSourceRequest request, Rec_CandidateSearchModel model) { string status = string.Empty; var isDataTable = false; object obj = new Rec_CandidateModel(); var baseService = new BaseService(); request.PageSize = int.MaxValue - 1; var result = GetListData<Rec_CandidateModel, Rec_CandidateEntity, Rec_CandidateSearchModel>(request, model, ConstantSql.hrm_rec_sp_get_Candidate, ref status); HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateExamFrom", Value = model.DateExamFrom == null ? DateTime.Now : model.DateExamFrom }; HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateExamTo", Value = model.DateExamTo == null ? DateTime.Now : model.DateExamTo }; List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 }; if (model.IsCreateTemplateForDynamicGrid) { obj = result; isDataTable = false; } if (model != null && model.IsCreateTemplate) { var path = Common.GetPath("Templates"); ExportService exportService = new ExportService(); ConfigExport cfgExport = new ConfigExport() { Object = obj, FileName = "Rec_CandidateModel", OutPutPath = path, HeaderInfo = listHeaderInfo, DownloadPath = Hrm_Main_Web + "Templates", IsDataTable = isDataTable }; var str = exportService.CreateTemplate(cfgExport); return Json(str); } var objInterview = new List<object>(); objInterview.AddRange(new object[2]); objInterview[0] = 1; objInterview[1] = int.MaxValue - 1; var lstInterView = baseService.GetData<Rec_InterviewModel>(objInterview, ConstantSql.hrm_rec_sp_get_InterviewDataReport,UserLogin, ref status).ToList(); foreach (var item in result) { if (lstInterView.Count > 0) { var dataLevel1 = lstInterView.Where(s => s.CandidateID == item.ID && s.LevelInterview == 1).OrderByDescending(s => s.DateUpdate).FirstOrDefault(); var dataLevel2 = lstInterView.Where(s => s.CandidateID == item.ID && s.LevelInterview == 2).OrderByDescending(s => s.DateUpdate).FirstOrDefault(); var dataLevel3 = lstInterView.Where(s => s.CandidateID == item.ID && s.LevelInterview == 3).OrderByDescending(s => s.DateUpdate).FirstOrDefault(); var dataLevel4 = lstInterView.Where(s => s.CandidateID == item.ID && s.LevelInterview == 4).OrderByDescending(s => s.DateUpdate).FirstOrDefault(); var dataLevel5 = lstInterView.Where(s => s.CandidateID == item.ID && s.LevelInterview == 5).OrderByDescending(s => s.DateUpdate).FirstOrDefault(); if (dataLevel1 != null) { item.Score1_1 = dataLevel1.Score1; item.Score1_2 = dataLevel1.Score2; item.Score1_3 = dataLevel1.Score3; item.KQ1 = dataLevel1.ResultInterviewView; item.LanguageCode1 = dataLevel1.LanguageCode; item.DateInterview1 = dataLevel1.DateInterview; } if (dataLevel2 != null) { item.Score2_1 = dataLevel2.Score1; item.Score2_2 = dataLevel2.Score2; item.Score2_3 = dataLevel2.Score3; item.KQ2 = dataLevel2.ResultInterviewView; item.LanguageCode2 = dataLevel2.LanguageCode; item.DateInterview2 = dataLevel2.DateInterview; } if (dataLevel3 != null) { item.Score3_1 = dataLevel3.Score1; item.Score3_2 = dataLevel3.Score2; item.Score3_3 = dataLevel3.Score3; item.KQ3 = dataLevel3.ResultInterviewView; item.LanguageCode3 = dataLevel3.LanguageCode; item.DateInterview3 = dataLevel3.DateInterview; } if (dataLevel4 != null) { item.Score4_1 = dataLevel4.Score1; item.Score4_2 = dataLevel4.Score2; item.Score4_3 = dataLevel4.Score3; item.KQ4 = dataLevel4.ResultInterviewView; item.LanguageCode4 = dataLevel4.LanguageCode; item.DateInterview4 = dataLevel4.DateInterview; } if (dataLevel5 != null) { item.Score5_1 = dataLevel5.Score1; item.Score5_2 = dataLevel5.Score2; item.Score5_3 = dataLevel5.Score3; item.KQ5 = dataLevel5.ResultInterviewView; item.LanguageCode5 = dataLevel5.LanguageCode; item.DateInterview5 = dataLevel5.DateInterview; } } } if (model.ExportId != Guid.Empty) { var fullPath = ExportService.Export(model.ExportId, result, listHeaderInfo, model.ExportType); return Json(fullPath); } return Json(result.ToDataSourceResult(request)); }
public ActionResult GetCandidateList([DataSourceRequest] DataSourceRequest request, Rec_CandidateSearchModel model) { if (model.Evaluated == HRM.Infrastructure.Utilities.EnumDropDown.StatusHealth.E_ACCEPT.ToString()) { model.IsEvaluated = true; } else if (model.Evaluated == HRM.Infrastructure.Utilities.EnumDropDown.StatusHealth.E_NOTACCEPT.ToString()) { model.IsEvaluated = false; } string status = string.Empty; var service = new BaseService(); ListQueryModel lstModel = new ListQueryModel { PageIndex = request.Page, PageSize = request.PageSize, Filters = ExtractFilterAttributes(request), Sorts = ExtractSortAttributes(request), AdvanceFilters = ExtractAdvanceFilterAttributes(model) }; var listEntity = service.GetData<Rec_CandidateEntity>(lstModel, ConstantSql.hrm_rec_sp_get_Candidate, UserLogin, ref status); var listModel = new List<Rec_CandidateModel>(); if (listEntity != null) { request.Page = 1; foreach (var item in listEntity) { if (item.ReasonFailFilter != null) { List<string> lsititem = item.ReasonFailFilter.Split(',').ToList(); string Stringresult = string.Empty; foreach (var itemstring in lsititem) { Stringresult += itemstring.TranslateString() + ','; } Stringresult = Stringresult.Substring(0, Stringresult.Length - 1); item.ReasonFailFilter = Stringresult; } var newModle = (Rec_CandidateModel)typeof(Rec_CandidateModel).CreateInstance(); foreach (var property in item.GetType().GetProperties()) { newModle.SetPropertyValue(property.Name, item.GetPropertyValue(property.Name)); } listModel.Add(newModle); } var dataSourceResult = listModel.ToDataSourceResult(request); if (listModel.FirstOrDefault().GetPropertyValue("TotalRow") != null) { dataSourceResult.Total = listModel.Count() <= 0 ? 0 : (int)listModel.FirstOrDefault().GetPropertyValue("TotalRow"); } return Json(dataSourceResult, JsonRequestBehavior.AllowGet); } var listModelNull = new List<Rec_CandidateModel>(); ModelState.AddModelError("Id", status); return Json(listModelNull.ToDataSourceResult(request, ModelState)); }