public string Index(Job data, out string auto_id) { auto_id = ""; int retry = 0; if (string.IsNullOrEmpty(data.id_auto)) { string _auto_id = Nanoid.Nanoid.Generate("0123456789", max_id_job); while (IsAutoIdExist(_auto_id, data.app_id) && retry++ < 10) { Task.Delay(TimeSpan.FromSeconds(1)); _auto_id = Nanoid.Nanoid.Generate("0123456789", max_id_job); } if (retry >= 10) { return(""); } data.id_auto = _auto_id; } else { while (IsIdAutoExist(data.id_auto, data.app_id) && retry++ < 10) { Task.Delay(TimeSpan.FromSeconds(1)); data.id_auto = Nanoid.Nanoid.Generate("0123456789", max_id_job); } if (retry >= 10) { return(""); } } auto_id = data.id_auto; return(Index(_default_index, data)); }
public bool Update(Job data) { string id = $"{data.id_job}"; data.id_job = string.Empty; data.ngay_sua = XMedia.XUtil.TimeInEpoch(DateTime.Now); data.auto_id = -Int32.MaxValue; data.ngay_tao = -Int32.MaxValue; data.id_auto = null; return(Update(_default_index, data, id)); }
public Job GetByAutoID(string app_id, string id_auto) { var re = client.Search <Job>(s => s.Query(q => q.Term(t => t.Field("app_id.keyword").Value(app_id)) && !q.Term(t => t.Field("trang_thai").Value(TrangThai.DELETED)) && q.Term(t => t.Field("id_auto.keyword").Value(id_auto)) ).Size(1)); if (re.Total > 0) { Job job = re.Hits.First().Source; job.id_job = re.Hits.First().Id; return(re.Documents.First()); } return(null); }
private Job ConvertDoc(IHit <Job> hit) { Job u = new Job(); try { u = hit.Source; u.id_job = hit.Id; } catch { } return(u); }
public IActionResult Get(string id) { var user_job = QLCUNL.BL.UserJobBL.GetById(id); var job_user = BL.JobBL.GetMany(app_id, new List <string>() { user_job.id_job }, new string[] { "chuc_danh", "so_luong", "cong_ty" }).ToDictionary(x => x.id_job, y => y); Models.UserJobMap data = new Models.UserJobMap(); data.id_user_job = user_job.id_user_job; data.id_job = user_job.id_job; data.ngay_nhan_job = user_job.ngay_nhan_job; var lst_id_thuoc_tinh = user_job.thuoc_tinh != null ? user_job.thuoc_tinh : new List <int>(); var data_thuoc_tinh = QLCUNL.BL.ThuocTinhBL.GetManyByGiaTri(app_id, lst_id_thuoc_tinh, LoaiThuocTinh.USER_JOB, ThuocTinhType.SHARED).ToDictionary(x => x.gia_tri, y => y); data.thuoc_tinh = user_job.thuoc_tinh; data.thuoc_tinh = user_job.thuoc_tinh != null?user_job.thuoc_tinh.Select(x => new { gia_tri = x, ten = data_thuoc_tinh.ContainsKey(x) ? data_thuoc_tinh[x].ten : x.ToString(), nhom = data_thuoc_tinh.ContainsKey(x) ? data_thuoc_tinh[x].nhom : 0 }).ToArray() : new dynamic[] { }; var cong_ty = new CongTy(); var jd = new Job(); if (job_user.TryGetValue(user_job.id_job, out jd)) { data.so_luong = jd.so_luong; data.chuc_danh = jd.chuc_danh; cong_ty = jd.cong_ty != null?CongTyBL.GetById(jd.cong_ty.id_cong_ty) : new CongTy(); jd.cong_ty = cong_ty; data.cong_ty = cong_ty.ten_cong_ty; } return(Ok(new { data = jd, extra = new { user_job.id_user, data.ngay_nhan_job, data.thuoc_tinh, user_job.nguoi_tao }, success = user_job != null, msg = "" })); }
public static bool Update(Job data) { return(JobRepository.Instance.Update(data)); }
public static string Index(Job data, out string auto_id) { return(JobRepository.Instance.Index(data, out auto_id)); }
public IActionResult MyJob(string id_job, string id_ung_vien, long ngay_nhan_job_from, long ngay_nhan_job_to, string thuoc_tinh, string thuoc_tinh_rieng, int page, int page_size) { List <int> lst_thuoc_tinh = new List <int>(); List <int> lst_thuoc_tinh_rieng = new List <int>(); List <string> lst_id = new List <string>(); bool is_find_thuoc_tinh_rieng = false; List <UserJob> data = new List <UserJob>(); List <Models.UserJobMap> lst = new List <Models.UserJobMap>(); long total_recs = 0; string msg = ""; if (!string.IsNullOrEmpty(thuoc_tinh)) { foreach (var tt in thuoc_tinh.Split(',')) { int t = -1; if (Int32.TryParse(tt, out t)) { lst_thuoc_tinh.Add(t); } } } if (!string.IsNullOrEmpty(thuoc_tinh_rieng)) { foreach (var tt in thuoc_tinh_rieng.Split(',')) { int t = -1; if (Int32.TryParse(tt, out t)) { lst_thuoc_tinh_rieng.Add(t); } } if (lst_thuoc_tinh_rieng.Count > 0) { is_find_thuoc_tinh_rieng = true; var lst_id_obj = BL.ThuocTinhDuLieuBL.Search(app_id, user, LoaiThuocTinh.CONG_TY, lst_thuoc_tinh_rieng, page, out long total_recs_thuoc_tinh, out _, 9999); lst_id = lst_id_obj.Select(x => x.id_obj).ToList(); } } if (is_find_thuoc_tinh_rieng && lst_id.Count == 0) { } else { data = QLCUNL.BL.UserJobBL.Search(app_id, user, group, new List <string>() { id_job }, id_ung_vien, ngay_nhan_job_from, ngay_nhan_job_to, lst_thuoc_tinh, lst_id, page, out total_recs, out msg, page_size); } if (data.Count > 0) { var job_user = BL.JobBL.GetMany(app_id, data.Select(x => x.id_job), new string[] { "chuc_danh", "so_luong", "cong_ty" }).ToDictionary(x => x.id_job, y => y); foreach (var item in data) { Models.UserJobMap m = new Models.UserJobMap(); m.id_user_job = item.id_user_job; m.id_job = item.id_job; m.ngay_nhan_job = item.ngay_nhan_job; m.thuoc_tinh = item.thuoc_tinh; var jd = new Job(); if (job_user.TryGetValue(item.id_job, out jd)) { m.so_luong = jd.so_luong; m.chuc_danh = jd.chuc_danh; m.cong_ty = jd.cong_ty.ten_cong_ty; m.auto_id = jd.auto_id; } lst.Add(m); } } return(Ok(new DataResponsePaging() { data = lst, total = total_recs, success = data != null, msg = msg })); }
public IActionResult Search(string term, string id_job, string id_ung_vien, long ngay_nhan_job_from, long ngay_nhan_job_to, string thuoc_tinh, string thuoc_tinh_rieng, int page, int page_size) { List <int> lst_thuoc_tinh = new List <int>(); List <int> lst_thuoc_tinh_rieng = new List <int>(); List <string> lst_id = new List <string>(); List <string> lst_id_job = new List <string>(); bool is_find_thuoc_tinh_rieng = false; List <UserJob> data = new List <UserJob>(); List <string> lst_id_job_filter = new List <string>(); List <Models.UserJobMap> lst = new List <Models.UserJobMap>(); long total_recs = 0; string msg = ""; if (!string.IsNullOrEmpty(thuoc_tinh)) { foreach (var tt in thuoc_tinh.Split(',')) { int t = -1; if (Int32.TryParse(tt, out t)) { lst_thuoc_tinh.Add(t); } } } if (!string.IsNullOrEmpty(thuoc_tinh_rieng)) { foreach (var tt in thuoc_tinh_rieng.Split(',')) { int t = -1; if (Int32.TryParse(tt, out t)) { lst_thuoc_tinh_rieng.Add(t); } } if (lst_thuoc_tinh_rieng.Count > 0) { is_find_thuoc_tinh_rieng = true; var lst_id_obj = BL.ThuocTinhDuLieuBL.Search(app_id, user, LoaiThuocTinh.CONG_TY, lst_thuoc_tinh_rieng, page, out long total_recs_thuoc_tinh, out _, 9999); lst_id = lst_id_obj.Select(x => x.id_obj).ToList(); } } if (!string.IsNullOrEmpty(term)) { var data_job_by_term = QLCUNL.BL.JobBL.Search(app_id, user, group, term, string.Empty, string.Empty, 0, 0, 0, 0, new List <int>(), new List <string>(), new List <string>(), 0, 0, 1, out _, out _, 200, (is_sys_admin || is_app_admin), new string[] { "id_job" }); lst_id_job = data_job_by_term.Select(x => x.id_job).ToList(); } if (!string.IsNullOrEmpty(id_job)) { lst_id_job.Add(id_job); } if (is_find_thuoc_tinh_rieng && lst_id.Count == 0) { } else { data = QLCUNL.BL.UserJobBL.Search(app_id, user, group, lst_id_job, id_ung_vien, ngay_nhan_job_from, ngay_nhan_job_to, lst_thuoc_tinh, lst_id, page, out total_recs, out msg, page_size, (is_sys_admin || is_app_admin)); } if (data.Count > 0) { var lst_id_thuoc_tinh = data.Where(x => x.thuoc_tinh != null).SelectMany(x => x.thuoc_tinh); var data_thuoc_tinh = QLCUNL.BL.ThuocTinhBL.GetManyByGiaTri(app_id, lst_id_thuoc_tinh, LoaiThuocTinh.USER_JOB, ThuocTinhType.SHARED).ToDictionary(x => x.gia_tri, y => y); var job_user = BL.JobBL.GetMany(app_id, data.Select(x => x.id_job), new string[] { "chuc_danh", "so_luong", "cong_ty" }).ToDictionary(x => x.id_job, y => y); var cong_ty = BL.CongTyBL.GetMany(job_user.Where(x => x.Value.cong_ty != null).Select(x => x.Value.cong_ty.id_cong_ty).Distinct()).ToDictionary(x => x.id_cong_ty, y => y.ten_cong_ty); foreach (var item in data) { Models.UserJobMap m = new Models.UserJobMap(); m.id_user_job = item.id_user_job; m.id_job = item.id_job; m.ngay_nhan_job = item.ngay_nhan_job; m.thuoc_tinh = item.thuoc_tinh != null?item.thuoc_tinh.Select(x => new { gia_tri = x, ten = data_thuoc_tinh.ContainsKey(x) ? data_thuoc_tinh[x].ten : x.ToString(), nhom = data_thuoc_tinh.ContainsKey(x) ? data_thuoc_tinh[x].nhom : 0 }).ToArray() : new dynamic[] { }; var jd = new Job(); if (job_user.TryGetValue(item.id_job, out jd)) { m.so_luong = jd.so_luong; m.chuc_danh = jd.chuc_danh; if (jd.cong_ty != null) { if (cong_ty.TryGetValue(jd.cong_ty.id_cong_ty, out string ten_cong_ty)) { m.cong_ty = ten_cong_ty; } } m.auto_id = jd.auto_id; } lst.Add(m); } } return(Ok(new DataResponsePaging() { data = lst, total = total_recs, success = data != null, msg = msg })); }