// GET: Favouritejobs public async Task <IActionResult> Index() { var modelContext = _context.Favouritejobs.Include(f => f.User); var favouritejoblist = await modelContext.Where(f => f.User.UserName == User.Identity.Name).ToListAsync(); List <ListJob> FavouritedJobs = new List <ListJob>(); foreach (var favouritejob in favouritejoblist) { var job = _jobService.Get(ObjectId.Parse(favouritejob.Jobid)); ListJob listjob = new ListJob(); listjob.Job_title = job.Job_title; listjob.company_name = job.company_name; listjob.Date_posted = job.Date_posted; listjob.Id = job.Id; listjob.Site_link = job.Site_link; listjob.location = job.location; listjob.Spoken_Languages = job.Spoken_Languages; listjob.payment_type = job.payment_type; listjob.Requirements = job.Requirements; listjob.job_Description = job.job_Description; listjob.FavouriteId = favouritejob.Favouriteid; FavouritedJobs.Add(listjob); //favouritejob.Jobid } return(View(FavouritedJobs)); }
/// <summary> /// 创建一个线程池去处理一个集合容器 /// </summary> /// <typeparam name="T">队列容器中对象的类型</typeparam> /// <param name="threadboxName">线程池名称</param> /// <param name="threadNum">线程池线程数量</param> /// <param name="handler">处理方法</param> /// <param name="list">集合容器</param> /// <param name="milliumsecondSleepTime">当容器为空时休息时间(毫秒),默认为100毫秒</param> /// <param name="isStopOnEmptyQueue">是否当队列为空时才关闭,默认为FALSE</param> public static void CreateColletionConsumerThreadBox <T>(string threadboxName, int threadNum, ThreadBoxHandler <T> handler, ICollection <T> list, int milliumsecondSleepTime = 100, bool isStopOnEmptyQueue = false) { if (threadboxName == "" || threadNum <= 0 || handler == null || list == null) { throw new ArgumentException(); } Box b = null; lock (dicBox) { if (dicBox.ContainsKey(threadboxName)) { throw new ArgumentException("threadboxName exist"); } b = new Box(threadNum); dicBox.Add(threadboxName, b); } ListJob <T> j = new ListJob <T>(); j.isStop = isStopOnEmptyQueue; j.sleepTime = milliumsecondSleepTime; j.list = list; j.handler = handler; b.Start(j); }
public List <ListJob> FilterDataJob(ref int recordFiltered, int start, int length, string search, int sortColumn, string sortDirection, string minday, string maxday, int fiterjob) { List <DangTinViecLam> list = new List <DangTinViecLam>(); var nghanhnghe = db.NghanhNghes.ToList(); var city = db.cities.ToList(); var company = db.CongTies.ToList(); var listjob = db.DangTinViecLams.ToList(); if (fiterjob <= 1 && fiterjob >= 0) { listjob = listjob.Where(x => x.Tinhtrang == fiterjob).ToList(); } else if (fiterjob != -1) { if (fiterjob == 2) { listjob = listjob.Where(x => x.Trangthai == 0).ToList(); } else if (fiterjob == 3) { listjob = listjob.Where(x => x.Trangthai == 1).ToList(); } else if (fiterjob == 4) { listjob = listjob.Where(x => x.Tinhtrang == -1).ToList();// việc làm đã xóa } else if (fiterjob == 5) { listjob = listjob.Where(x => x.Tinhtrang == -2).ToList();//việc làm đã hết hạn } } DateTime startday; bool trya = DateTime.TryParseExact(minday, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out startday); DateTime endday; bool tryb = DateTime.TryParseExact(maxday, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out endday); if (!string.IsNullOrEmpty(minday) && !string.IsNullOrEmpty(maxday) && trya != null && tryb != null) { listjob = listjob.Where(x => x.Ngaydang.Value.Date >= startday.Date && x.Ngaydang.Value.Date <= endday.Date).ToList(); } if (string.IsNullOrEmpty(minday) && !string.IsNullOrEmpty(maxday) && tryb == true) { listjob = listjob.Where(x => x.Ngaydang.Value.Date <= endday.Date).ToList(); } if (!string.IsNullOrEmpty(minday) && string.IsNullOrEmpty(maxday) && trya == true) { listjob = listjob.Where(x => x.Ngaydang.Value.Date >= startday.Date).ToList(); } var listdate = listjob; if (string.IsNullOrEmpty(search)) { list = listdate; } else { search = unicode.UnicodeNameModel(search.Trim()); foreach (var item in listdate) { string thoathuan; if (item.Luongthoathuan == 1) { thoathuan = "thoa thuan"; } else { thoathuan = item.Minluong + " - " + item.Maxluong; thoathuan = unicode.UnicodeNameModel(thoathuan); } string cat1 = nghanhnghe.Where(x => x.Id == item.Manghanh1).Select(x => x.Tennghanh).FirstOrDefault(); string cat2 = nghanhnghe.Where(x => x.Id == item.Manghanh2).Select(x => x.Tennghanh).FirstOrDefault(); string cat3 = nghanhnghe.Where(x => x.Id == item.Manghanh3).Select(x => x.Tennghanh).FirstOrDefault(); string city1 = city.Where(x => x.Id == item.MaTP1).Select(x => x.City1).FirstOrDefault(); string city2 = city.Where(x => x.Id == item.MaTP2).Select(x => x.City1).FirstOrDefault(); string city3 = city.Where(x => x.Id == item.MaTP3).Select(x => x.City1).FirstOrDefault(); string comp = item.CongTy.Tencongty; if (unicode.UnicodeNameModel(item.TenCV).Contains(search)) { list.Add(item); } else if (unicode.UnicodeNameModel(item.MACV.ToString()).Contains(search)) { list.Add(item); } else if (unicode.UnicodeNameModel(item.Ngaydang.Value.ToString("dd/MM/yyyy")).Contains(search)) { list.Add(item); } else if (unicode.UnicodeNameModel(comp).Contains(search)) { list.Add(item); } else if (unicode.UnicodeNameModel(cat1).Contains(search) || unicode.UnicodeNameModel(cat2).Contains(search) || unicode.UnicodeNameModel(cat3).Contains(search)) { list.Add(item); } else if (unicode.UnicodeNameModel(city1).Contains(search) || unicode.UnicodeNameModel(city2).Contains(search) || unicode.UnicodeNameModel(city3).Contains(search)) { list.Add(item); } else if (thoathuan.Contains(search)) { list.Add(item); } } } var listdatatable = new List <ListJob>(); foreach (var item in list) { string thoathuan; if (item.Luongthoathuan == 1) { thoathuan = "Thỏa Thuận"; } else { thoathuan = item.Minluong + " - " + item.Maxluong; } string img; if (item.CongTy.Logo == null) { img = "<img style='width:100%' src='/Employer_upload/noimgcompany.png' />"; } else { img = "<a href='/admin/ManagerMemberAdmin/EditEmployer?mact=" + item.MACT + "'><img style='width:100%' src='/Employer_upload/" + item.CongTy.Logo + "' /></a>"; } string topjob; if (item.Vieclamtotnhat == 1) { topjob = "<label class='custom-control custom-checkbox'>Show<input hidden type='checkbox' checked value='1' id='" + item.MACV + "' class='topjob custom-control-input'><span class='custom-control-indicator'></span></label>"; } else { topjob = "<label class='custom-control custom-checkbox'>Show<input type='checkbox' hidden value='1' id='" + item.MACV + "' class='topjob custom-control-input'><span class='custom-control-indicator'></span></label>"; } string hot; if (item.hot == 1) { hot = "<label class='custom-control custom-checkbox'>Hot<input hidden type='checkbox' checked value='1' id='" + item.MACV + "' class='hotjob custom-control-input'><span class='custom-control-indicator-hot'></span></label>"; } else { hot = "<label class='custom-control custom-checkbox'>Hot<input hidden type='checkbox' value='1' id='" + item.MACV + "' class='hotjob custom-control-input'><span class='custom-control-indicator-hot'></span></label>"; } string homepage; if (item.Vieclamgoiy == 1) { homepage = "<label class='custom-control custom-checkbox'>Show<input checked type='checkbox' hidden value='1' id='" + item.MACV + "' class='showjob custom-control-input'><span class='custom-control-indicator'></span></label>"; } else { homepage = "<label class='custom-control custom-checkbox'>Show<input type='checkbox' hidden value='1' id='" + item.MACV + "' class='showjob custom-control-input'><span class='custom-control-indicator'></span></label>"; } string status; if (item.Tinhtrang == 1) { status = "<label class='custom-control custom-checkbox'>Kích hoạt<input checked type='checkbox' hidden value='1' id='active_" + item.MACV + "' class='activejob custom-control-input'><span class='custom-control-indicator-active'></span></label>"; } else { status = "<label class='custom-control custom-checkbox'>Kích hoạt<input type='checkbox' hidden value='1' id='active_" + item.MACV + "' class='activejob custom-control-input'><span class='custom-control-indicator-active'></span></label>"; } string status1; if (item.Trangthai == 1) { status1 = "<label class='custom-control custom-checkbox'>Ẩn<input checked type='checkbox' hidden value='1' id='status_" + item.MACV + "' class='statusjob custom-control-input'><span class='custom-control-indicator'></span></label>"; } else { status1 = "<label class='custom-control custom-checkbox'>Ẩn<input type='checkbox' hidden value='1' id='status_" + item.MACV + "' class='statusjob custom-control-input'><span class='custom-control-indicator'></span></label>"; } string cat1 = nghanhnghe.Where(x => x.Id == item.Manghanh1).Select(x => x.Tennghanh).FirstOrDefault(); string cat2 = nghanhnghe.Where(x => x.Id == item.Manghanh2).Select(x => x.Tennghanh).FirstOrDefault(); string cat3 = nghanhnghe.Where(x => x.Id == item.Manghanh3).Select(x => x.Tennghanh).FirstOrDefault(); string city1 = city.Where(x => x.Id == item.MaTP1).Select(x => x.City1).FirstOrDefault(); string city2 = city.Where(x => x.Id == item.MaTP2).Select(x => x.City1).FirstOrDefault(); string city3 = city.Where(x => x.Id == item.MaTP3).Select(x => x.City1).FirstOrDefault(); string comp = item.CongTy.Tencongty; ListJob data = new ListJob(); data.ID = item.MACV + "<br /><input type='checkbox' class='checkchild' value='" + item.MACV + "' />"; data.JobName = "<a href='/Admin/ManagerJobAdmin/EditJobAdmin/" + item.MACV + "'>" + item.TenCV + "</a>"; data.Category = cat1 + " " + cat2 + " " + cat3; data.City = city1 + " " + city2 + " " + city3; data.Company = "<a href='/admin/ManagerMemberAdmin/EditEmployer?mact=" + item.MACT + "'>" + comp + "</a>"; data.Salary = "<span>" + thoathuan + "</span>"; data.LogoCompany = img; data.Datecreate = item.Ngaydang.Value.ToString("dd/MM/yyyy"); data.TopJob = topjob + hot; data.Homepage = homepage; data.Status = status + status1; data.UVDK = "<a href='/admin/ManagerMemberAdmin/ACEmployer?mact=" + item.MACT + "'><h3>" + db.UVDangKies.Where(x => x.MACV == item.MACV && x.Tinhtrang == 1).Count() + "</h3></a>"; data.Tinhtrang = item.Tinhtrang; data.mact = item.MACT; data.MACV = item.MACV; data.TenCV = item.TenCV; data.type = item.Type; data.Ngaydang = item.Ngaydang; listdatatable.Add(data); } // simulate sort if (sortColumn == 0) {// sort ID listdatatable = (sortDirection == "asc") ? listdatatable.OrderBy(x => x.MACV).ToList() : listdatatable.OrderByDescending(x => x.MACV).ToList(); } else if (sortColumn == 1) {// sort TÊN CÔNG VIỆC listdatatable = (sortDirection == "asc") ? listdatatable.OrderBy(x => x.TenCV).ToList() : listdatatable.OrderByDescending(x => x.TenCV).ToList(); } else if (sortColumn == 7) {// NGày đăng listdatatable = (sortDirection == "asc") ? listdatatable.OrderBy(x => x.Ngaydang).ToList() : listdatatable.OrderByDescending(x => x.Ngaydang).ToList(); } //recordFiltered = listdatatable.Count; //// get just one page of data //listdatatable = listdatatable.GetRange(start, Math.Min(length, listdatatable.Count - start)); return(listdatatable); }