Esempio n. 1
0
        public List <JobLink> ExtractJobLink(CauHinh ch, string link, string app_id, out string msg)
        {
            is_authenticated = false;
            msg = "";
            List <JobLink> lst = new List <JobLink>();

            using (var browser = new XBrowser(user_profile_path, string.Empty, false, show_browser))
            {
                string url        = browser.GoTo(ch.url_login);
                string wait_xpath = ".//div[@class='kv_login']/div/span";
                System.Threading.Thread.Sleep(2000);
                var home = browser.GetUrl();
                if (browser.Find(wait_xpath).Count > 0)
                {
                    is_authenticated = true;
                }
                else
                {
                    is_authenticated = home == "https://careerbuilder.vn/vi/employers/hrcentral" || (link != url
                        ? browser.Login(ch.url_login, ch.username, ch.password, ch.xpath_username,
                                        ch.xpath_password, out msg, wait_xpath, false)
                        : browser.GetUrl().Contains(url));
                }

                if (is_authenticated)
                {
                    browser.GoTo(link);
                    System.Threading.Thread.Sleep(2000);
                    List <string> lst_links = new List <string>();

                    var ds_tin =
                        browser.Find(
                            "//div[@id='gird_standard']//dd//span[@class='rc_col_title3 info_jobseeker']/a[1]");

                    foreach (var tin in ds_tin)
                    {
                        var get_tin = browser.GetAttribute(tin, "href");
                        var ten_job = tin.Text;

                        if (!string.IsNullOrEmpty(get_tin))
                        {
                            JobLink job = new JobLink(LoaiLink.JOB_LINK)
                            {
                                app_id           = app_id,
                                link             = get_tin,
                                trang_thai       = TrangThai.DANG_SU_DUNG,
                                trang_thai_xu_ly = TrangThaiXuLy.CHUA_XU_LY,
                                nguoi_tao        = ch.username,
                                ten_job          = ten_job
                            };
                            lst.Add(job);
                        }
                    }
                }
            }
            return(lst);
        }
Esempio n. 2
0
        public List <UngVien> Run(CauHinh ch, List <JobLink> lst_job_link, ToolStripStatusLabel label)
        {
            is_authenticated = false;
            List <UngVien> lst_ung_vien = new List <UngVien>();
            string         wait_xpath   = ".//div[@class='kv_login']/div/span";

            using (var browser = new XBrowser(user_profile_path, cv_save_path, string.Empty, false, show_browser))
            {
                if (lst_job_link.Count < 1)
                {
                    label.Text = "Không có tin nào đang được đăng trực tuyến";
                }
                else
                {
                    foreach (var job in lst_job_link)
                    {
                        string url = browser.GoTo(job.link);
                        is_authenticated = url.Contains(ch.url_login) ? browser.Login(ch.url_login, ch.username, ch.password, ch.xpath_username, ch.xpath_password, out string msg, wait_xpath, false) : browser.GetUrl().Contains(url);
                        if (is_authenticated)
                        {
                            //string r_url = browser.GoTo(job.link);
                            System.Threading.Thread.Sleep(1000);
                            browser.FindAndClick("//div[@class='top']/ul//div/a");
                            System.Threading.Thread.Sleep(1000);
                            var lst_url_uv = new List <string>();
                            var ung_vien   =
                                browser.Find(".//form[@id='editFrm1']/dd/span[@class='rc_col_310px info_jobseeker']/div/a");
                            if (ung_vien.Count > 0)
                            {
                                foreach (var uv in ung_vien)
                                {
                                    var url_uv = browser.GetAttribute(uv, "href");
                                    lst_url_uv.Add(url_uv);
                                }
                            }
                            if (lst_url_uv.Count > 0)
                            {
                                foreach (var item in lst_url_uv)
                                {
                                    label.Text = $"Đang xử lý link: {job.link}";
                                    browser.GoTo(item);
                                    var lst_cv_by_job = XuLyCV(browser, job);
                                    lst_ung_vien.AddRange(lst_cv_by_job);
                                }
                            }
                            job.tong_so_cv = lst_url_uv.Count;
                            ES.JobLinkRepository.Instance.UpdateTrangThaiXuLy(job);
                        }
                    }
                }
            }

            return(new List <UngVien>(lst_ung_vien));
        }
Esempio n. 3
0
        public List <UngVien> Run(CauHinh ch, List <JobLink> lst_job_link)
        {
            is_authenticated = false;
            List <UngVien> lst_ung_vien = new List <UngVien>();

            using (var browser = new XBrowser(user_profile_path, cv_save_path, string.Empty, false, show_browser))
            {
                foreach (var job in lst_job_link)
                {
                    string url = browser.GoTo(job.link);
                    if (url.Contains(ch.url_login))
                    {
                        is_authenticated = browser.Login(ch.url_login, ch.username, ch.password, ch.xpath_username, ch.xpath_password, out string msg);
                    }
                    else
                    {
                        is_authenticated = browser.GetUrl().Contains(url);
                    }
                    if (is_authenticated)
                    {
                        string r_url = browser.GoTo(job.link);

                        if (r_url.Contains(job.link))
                        {
                            var lst_cv_by_job = XuLyCV(browser, job);
                            //Phân trang CV
                            ////ul[@class='pagination']//a
                            var cv_paging_eles = browser.Find("//ul[@class='pagination']//a");
                            if (cv_paging_eles.Count > 0)
                            {
                                var lst_link_paging = new List <string>();
                                foreach (var pg_ele in cv_paging_eles)
                                {
                                    lst_link_paging.Add(browser.GetAttribute(pg_ele, "href"));
                                }
                                lst_link_paging = lst_link_paging.Distinct().ToList();
                                foreach (var item in lst_link_paging)
                                {
                                    browser.GoTo(item);
                                    lst_cv_by_job.AddRange(XuLyCV(browser, job));
                                    ES.JobLinkRepository.Instance.UpdateTrangThaiXuLy(job);
                                }
                            }

                            job.tong_so_cv = lst_cv_by_job.Count;
                            lst_ung_vien.AddRange(lst_cv_by_job);
                        }
                    }
                }
            }

            return(new List <UngVien>(lst_ung_vien));
        }
Esempio n. 4
0
        public List <UngVien> Run(CauHinh ch, List <JobLink> lst_job_link, ToolStripStatusLabel toolStripStatusLabel1)
        {
            is_authenticated = false;
            List <UngVien> lst_ung_vien = new List <UngVien>();
            string         wait_xpath   = ".//li[@class='dropdown dropdown-user']";

            using (var browser = new XBrowser(user_profile_path, cv_save_path, string.Empty, false, show_browser))
            {
                foreach (var job in lst_job_link)
                {
                    string url = browser.GoTo(job.link);
                    is_authenticated = url.Contains(ch.url_login) ? browser.Login(ch.url_login, ch.username, ch.password, ch.xpath_username, ch.xpath_password, out string msg, wait_xpath, false) : browser.GetUrl().Contains(url);
                    if (is_authenticated)
                    {
                        //string r_url = browser.GoTo(job.link);
                        System.Threading.Thread.Sleep(1000);
                        browser.FindAndClick(".//a[@href='#tab2']");

                        var ung_vien      = browser.Find(".//tbody[@id='applied']//strong/a");
                        var url_detail_uv = new List <string>();
                        foreach (var uv in ung_vien)
                        {
                            var link_uv = browser.GetAttribute(uv, "href");
                            url_detail_uv.Add(link_uv);
                        }

                        if (url_detail_uv.Count > 0)
                        {
                            foreach (var u_v in url_detail_uv)
                            {
                                browser.GoTo(u_v);
                                toolStripStatusLabel1.Text = $"Đang xử lý link:{job.link}";
                                var lst_cv_by_job = XuLyCV(browser, job);
                                lst_ung_vien.AddRange(lst_cv_by_job);
                            }
                        }
                        else
                        {
                            job.trang_thai_xu_ly       = TrangThaiXuLy.DA_XU_LY;
                            job.ngay_xu_ly             = XUtil.TimeInEpoch();
                            toolStripStatusLabel1.Text = $"Không tìm thấy ứng viên link:{job.link}";
                        }
                        job.tong_so_cv = url_detail_uv.Count;
                        ES.JobLinkRepository.Instance.UpdateTrangThaiXuLy(job);
                    }
                }
            }

            return(new List <UngVien>(lst_ung_vien));
        }
Esempio n. 5
0
        public List <JobLink> ExtractJobLink(CauHinh ch, string link, string app_id, out string msg)
        {
            is_authenticated = false;
            msg = "";
            List <JobLink> lst = new List <JobLink>();

            using (var browser = new XBrowser(user_profile_path, string.Empty, false, show_browser))
            {
                string url = browser.GoTo(link);

                string wait_xpath = ".//a[@data-test-key='accountMenuItem']";
                is_authenticated = link != url?browser.Login(ch.url_login, ch.username, ch.password, ch.xpath_username, ch.xpath_password, out msg, wait_xpath, false) : browser.GetUrl().Contains(url);

                if (is_authenticated)
                {
                    browser.GoTo(link);

                    var eles = browser.Find("//div[@class='Dashboard__dashboard']//a[@class='JobCard__clickable']");

                    if (eles != null)
                    {
                        foreach (var item in eles)
                        {
                            var url_tin = browser.GetAttribute(item, "href");
                            var ten_job = item.FindElement(By.XPath(".//strong[@class='BoldedText__regular JobCard__jobTitle']")).Text;

                            if (!string.IsNullOrEmpty(url_tin))
                            {
                                JobLink job = new JobLink(LoaiLink.JOB_LINK)
                                {
                                    app_id           = app_id,
                                    link             = url_tin,
                                    trang_thai       = TrangThai.DANG_SU_DUNG,
                                    trang_thai_xu_ly = TrangThaiXuLy.CHUA_XU_LY,
                                    nguoi_tao        = ch.username,
                                    ten_job          = ten_job
                                };
                                lst.Add(job);
                            }
                        }
                    }
                }
            }
            return(lst);
        }
Esempio n. 6
0
        public List <JobLink> ExtractJobLink(CauHinh ch, string link, string app_id, out string msg)
        {
            is_authenticated = false;
            msg = "";
            List <JobLink> lst = new List <JobLink>();

            using (var browser = new XBrowser(user_profile_path, string.Empty, false, show_browser))
            {
                string url        = browser.GoTo(link);
                string wait_xpath = ".//span[@id='currentCredit']";
                is_authenticated = url.Contains(ch.url_login) ? browser.Login(ch.url_login, ch.username, ch.password, ch.xpath_username, ch.xpath_password, out msg, wait_xpath, false) : browser.GetUrl().Contains(url);
                if (is_authenticated)
                {
                    browser.GoTo(link);
                    var eles = browser.Find("//tbody[@class='tbody-job']//td[3]/a");

                    if (eles.Count > 0)
                    {
                        foreach (var item in eles)
                        {
                            var url_tin = browser.GetAttribute(item, "href");
                            if (!string.IsNullOrEmpty(url_tin))
                            {
                                JobLink job = new JobLink(LoaiLink.JOB_LINK);
                                job.app_id           = app_id;
                                job.link             = url_tin;
                                job.trang_thai       = TrangThai.DANG_SU_DUNG;
                                job.trang_thai_xu_ly = TrangThaiXuLy.CHUA_XU_LY;
                                job.nguoi_tao        = ch.username;
                                lst.Add(job);
                            }
                        }
                    }
                }
            }
            return(lst);
        }
Esempio n. 7
0
        public List <UngVien> XuLyCV(XBrowser browser, JobLink job, string url_ung_vien)
        {
            job.trang_thai_xu_ly = TrangThaiXuLy.DA_XU_LY;

            List <UngVien> lst_ung_vien = new List <UngVien>();

            try
            {
                //var eles_ung_vien = browser.Find("//table[@class='el-table__body']//tbody//div/div/div[1]/a");
                //if (eles_ung_vien.Count <= 0)
                //{
                //    job.thong_tin_xu_ly = Common.KHONG_TIM_THAY_UNG_VIEN;
                //}

                try
                {
                    UngVien ung_vien = new UngVien();
                    ung_vien.vi_tri         = job.ten_job;
                    ung_vien.ngay_tao       = ung_vien.ngay_sua = XMedia.XUtil.TimeInEpoch();
                    ung_vien.app_id         = job.app_id;
                    ung_vien.job_link       = job.link;
                    ung_vien.ho_ten         = browser.GetInnerText("//div[@class='panel-body']//h5/span", 2000);
                    ung_vien.link_cv_online = browser.GetAttribute("//div[@class='panel-footer']//div[@class='pull-right']//a", "href");
                    ThongTinChungUngVien ttuv = new ThongTinChungUngVien();
                    ttuv.domain = "mywork.com";
                    ung_vien.thong_tin_chung = ttuv;
                    //Bóc tách XPATH để lấy được thông tin này nếu có
                    ung_vien.kinh_nghiem   = browser.GetInnerText("//div[@class='list-item']");
                    ung_vien.ky_nang       = browser.GetInnerText("//div[@class='panel-body']/div[7]");
                    ung_vien.so_dien_thoai = browser.GetInnerText("//div[@class='info']//div/div[2]/p[2]/span");
                    ung_vien.email         = browser.GetInnerText("//div[@class='info']//div[2]/p[1]/a");
                    Uri uri = new Uri(url_ung_vien);
                    ung_vien.domain    = uri.Host;
                    ung_vien.custom_id = url_ung_vien.Split('/').Last();
                    ung_vien.hoc_van   = "";
                    ung_vien.ngay_sinh = 0;
                    //Tai file
                    var cv_byte = browser.DownloadFile(ung_vien.link_cv_online, out string cv_file_name);
                    if (cv_byte != null)
                    {
                        ung_vien.cv_byte = cv_byte;
                        WriteFile($"{cv_save_path}\\{cv_file_name}", cv_byte);
                        ung_vien.link_cv_offline = cv_file_name;
                    }

                    ung_vien.full_text = browser.GetPageSource();
                    ung_vien.nguoi_tao = job.nguoi_tao;
                    lst_ung_vien.Add(ung_vien);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
            catch (Exception ex)
            {
                job.trang_thai_xu_ly = TrangThaiXuLy.LOI;
                job.thong_tin_xu_ly  = ex.Message;
            }
            job.ngay_xu_ly = XUtil.TimeInEpoch();
            return(lst_ung_vien);
        }
Esempio n. 8
0
        private List <UngVien> XuLyCV(XBrowser browser, JobLink job)
        {
            job.trang_thai_xu_ly = TrangThaiXuLy.DA_XU_LY;

            List <UngVien> lst_ung_vien = new List <UngVien>();

            try
            {
                var eles_ung_vien = browser.Find("//div[@class='table-responsive']/table//td[2]/a");
                if (eles_ung_vien.Count > 0)
                {
                    foreach (var item_ung_vien in eles_ung_vien)
                    {
                        try
                        {
                            browser.Click(item_ung_vien);
                            UngVien ung_vien = new UngVien();
                            ung_vien.vi_tri         = job.ten_job;
                            ung_vien.ngay_tao       = ung_vien.ngay_sua = XMedia.XUtil.TimeInEpoch();
                            ung_vien.app_id         = job.app_id;
                            ung_vien.job_link       = job.link;
                            ung_vien.ho_ten         = browser.GetInnerText("//div[@id='action-box']//tr[1]//td[1]", 2000);
                            ung_vien.link_cv_online = browser.GetAttribute("//a[@id='btn-download-candidate']", "href");
                            ThongTinChungUngVien ttuv = new ThongTinChungUngVien();
                            ttuv.domain              = "topcv.vn";
                            ttuv.full_text           = browser.GetInnerHtml("//div[@id='action-box']/table");
                            ung_vien.thong_tin_chung = ttuv;
                            //Bóc tách XPATH để lấy được thông tin này nếu có
                            ung_vien.kinh_nghiem = browser.GetInnerText("//div[@class='info']//div/div[1]/p[3]/strong");
                            ung_vien.ky_nang     = "";
                            ung_vien.hoc_van     = "";
                            ung_vien.ngay_sinh   = 0;
                            //Tai file

                            var cv_byte = browser.DownloadFile(ung_vien.link_cv_online, out string cv_file_name);
                            if (cv_byte != null)
                            {
                                ung_vien.cv_byte = cv_byte;
                                WriteFile($"{cv_save_path}\\{cv_file_name}", cv_byte);
                                ung_vien.link_cv_offline = cv_file_name;
                            }
                            ung_vien.full_text = browser.GetPageSource();
                            ung_vien.nguoi_tao = job.nguoi_tao;
                            lst_ung_vien.Add(ung_vien);
                            browser.FindAndClick("//div[@title='Đóng lại']");
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                else
                {
                    job.thong_tin_xu_ly = Common.KHONG_TIM_THAY_UNG_VIEN;
                }
            }
            catch (Exception ex)
            {
                job.trang_thai_xu_ly = TrangThaiXuLy.LOI;
                job.thong_tin_xu_ly  = ex.Message;
            }
            job.ngay_xu_ly = XUtil.TimeInEpoch();
            return(lst_ung_vien);
        }
Esempio n. 9
0
        private List <UngVien> XuLyCV(XBrowser browser, JobLink job)
        {
            job.trang_thai_xu_ly = TrangThaiXuLy.DA_XU_LY;

            List <UngVien> lst_ung_vien = new List <UngVien>();

            try
            {
                var eles_ung_vien = browser.Find("//div[@class='col-sm-9']//form//div[@class='list-group-item-heading']");
                if (eles_ung_vien.Count > 0)
                {
                    Dictionary <string, string> dic_cv_ung_vien = new Dictionary <string, string>();
                    foreach (var item_ung_vien in eles_ung_vien)
                    {
                        try
                        {
                            var ho_ten_ele  = browser.FindChildElement(item_ung_vien, ".//span[@class='text-accent']");
                            var link_cv_ele = browser.FindChildElement(item_ung_vien, ".//a");

                            if (ho_ten_ele != null && link_cv_ele != null)
                            {
                                string href   = browser.GetAttribute(link_cv_ele, "href").Trim();
                                string ho_ten = browser.GetAttribute(ho_ten_ele, "innerText").Trim();
                                if (!dic_cv_ung_vien.ContainsKey(href))
                                {
                                    dic_cv_ung_vien.Add(href, ho_ten);
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                    foreach (var item in dic_cv_ung_vien)
                    {
                        browser.GoTo(item.Key);
                        UngVien ung_vien = new UngVien();
                        ung_vien.ngay_tao  = ung_vien.ngay_sua = XMedia.XUtil.TimeInEpoch();
                        ung_vien.app_id    = job.app_id;
                        ung_vien.job_link  = job.link;
                        ung_vien.ho_ten    = item.Value;
                        ung_vien.full_text = browser.GetPageSource();
                        ung_vien.vi_tri    = job.ten_job;
                        ThongTinChungUngVien ttuv = new ThongTinChungUngVien();
                        ttuv.domain              = UrlToDomain(item.Key);
                        ttuv.full_text           = browser.GetInnerHtml("//div[@class='resume-show']//div[@class='media']", 200);
                        ttuv.full_text          += browser.GetInnerHtml("//div[@id='divResumeContactInformation']", 200);
                        ung_vien.thong_tin_chung = ttuv;
                        //Bóc tách XPATH để lấy được thông tin này nếu có
                        ung_vien.kinh_nghiem   = browser.GetInnerHtml("//h4[contains(text(),'Kinh nghiệm')]/following-sibling::dl", 200);
                        ung_vien.ky_nang       = "";
                        ung_vien.hoc_van       = browser.GetInnerHtml("//h4[contains(text(),'Học vấn')]/following-sibling::dl", 200);
                        ung_vien.email         = browser.GetInnerHtml("//a[contains(@href,'mailto')]", 200);
                        ung_vien.so_dien_thoai = browser.GetInnerHtml("//div[@id='divResumeContactInformation']//dt[contains(text(),'Điện')]/following-sibling::dd[1]", 200);
                        string ngay_sinh = browser.GetInnerText("//span[@class='confidential-birth-day']", 500);
                        ung_vien.domain    = UrlToDomain(item.Key);
                        ung_vien.custom_id = item.Key.Substring(item.Key.LastIndexOf("/") + 1);
                        ung_vien.nguoi_tao = job.nguoi_tao;
                        if (!string.IsNullOrEmpty(ngay_sinh))
                        {
                            //Convert ngay sinh
                            System.Globalization.DateTimeFormatInfo dtfi = new System.Globalization.DateTimeFormatInfo();
                            dtfi.ShortDatePattern = "dd/MM/yyyy";
                            dtfi.DateSeparator    = "/";
                            try
                            {
                                var bird_day = Convert.ToDateTime(ngay_sinh, dtfi);

                                ung_vien.ngay_sinh = XMedia.XUtil.TimeInEpoch(bird_day);
                            }
                            catch (Exception)
                            {
                            }
                        }
                        var ifr = browser.FindFirst("//iframe");
                        if (ifr != null)
                        {
                            ung_vien.link_cv_offline = browser.DownloadByBrowserInIFrame("//iframe", "//button[@id='download']");
                            if (!string.IsNullOrEmpty(ung_vien.link_cv_offline))
                            {
                                ung_vien.cv_byte = File.ReadAllBytes($"{cv_save_path}\\{ung_vien.link_cv_offline}");
                            }
                        }

                        lst_ung_vien.Add(ung_vien);
                    }
                }
                else
                {
                    job.thong_tin_xu_ly = Common.KHONG_TIM_THAY_UNG_VIEN;
                }
            }
            catch (Exception ex)
            {
                job.trang_thai_xu_ly = TrangThaiXuLy.LOI;
                job.thong_tin_xu_ly  = ex.Message;
            }
            job.ngay_xu_ly = XMedia.XUtil.TimeInEpoch();
            return(lst_ung_vien);
        }
Esempio n. 10
0
      public bool ExtractThongTin(CauHinh ch, string link, string app_id, out string msg, UngVienJobModel.ChiTietTinModel ct, bool is_debug = false)
      {
          _logger.Info("START POST TOPCV");
          is_authenticated = false;
          msg = "";
          //string username = XUtil.ConfigurationManager.AppSetting["TopCv:username"];
          //string password = XUtil.ConfigurationManager.AppSetting["TopCv:password"];
          using (var browser = new XBrowser(user_profile_path, string.Empty, false, is_debug))
          {
              browser.GoTo(ch.url_login);
              var login_form = browser.Find(".//div[@id='page-login']");
              if (login_form.Count >= 1)
              {
                  foreach (var element in login_form)
                  {
                      try
                      {
                          element.FindElement(By.XPath(ch.xpath_username)).SendKeys(ch.username);
                          element.FindElement(By.XPath(ch.xpath_password)).SendKeys(XUtil.DecodeToken(ch.password));
                          element.FindElement(By.XPath(ch.xpath_password)).SendKeys(Keys.Enter);
                      }
                      catch (Exception)
                      {
                      }
                  }
              }
              else
              {
                  _logger.Error("LOGIN TOPCV FAILED OR WAS LOGIN!");
              }

              browser.GoTo(link);

              if (browser.GetUrl() == link)
              {
                  _logger.Info("LOGIN TOPCV SUCCESS");
                  is_authenticated = true;
              }

              //is_authenticated = link != url ? browser.Login(ch.url_login, ch.username, ch.password, ch.xpath_username, ch.xpath_password, out msg) : browser.GetUrl().Contains(url);

              if (is_authenticated)
              {
                  var parent = browser.Find(".//div[@class='panel form-job panel-light']");
                  if (parent != null)
                  {
                      try
                      {
                          foreach (var element in parent)
                          {
                              // chức danh
                              var send_nganh_nghe = element.FindElement(By.Id("jobTitle"));
                              if (send_nganh_nghe != null)
                              {
                                  send_nganh_nghe.SendKeys(ct.chuc_danh);
                                  _logger.Info($"da send nganh nghe {ct.chuc_danh}");
                              }
                              else
                              {
                                  _logger.Error($"khong tim thay xpath {ct.chuc_danh}");
                              }
                              System.Threading.Thread.Sleep(1000);
                              var choose_nganh_nghe =
                                  element.FindElement(By.XPath("//input[@id='jobTitle']/preceding-sibling::div"));
                              if (choose_nganh_nghe != null)
                              {
                                  choose_nganh_nghe.Click();
                              }
                              var nganh_nghe_topcv = browser.Find(".//input[@placeholder='Chọn ngành nghề']")?.First();
                              if (nganh_nghe_topcv != null)
                              {
                                  nganh_nghe_topcv.Click();
                                  _logger.Info("chon nganh nghe topcv");
                                  foreach (var work in ct.nganh_nghe)
                                  {
                                      System.Threading.Thread.Sleep(2000);
                                      var nganh_nghe = browser.Find($".//ul[@id='select2-categoryIds-results']/li[text()='{work.Trim()}']")?.First();
                                      if (nganh_nghe == null)
                                      {
                                          browser.FindAndClick(".//input[@placeholder='Chọn ngành nghề']");
                                          System.Threading.Thread.Sleep(2000);
                                          browser.Find($".//ul[@id='select2-categoryIds-results']/li[text()='{work}']")
                                          ?.First().Click();
                                          _logger.Info($"da chon nganh nghe {work}");
                                      }
                                      else
                                      {
                                          browser.FindAndClick(
                                              $".//ul[@id='select2-categoryIds-results']/li[text()='{work}']");
                                          _logger.Info($"da chon nganh nghe {work}");
                                      }
                                  }
                              }

                              // địa điểm
                              var dia_diem = element.FindElement(By.XPath(".//input[@placeholder='Chọn địa điểm']"));
                              if (dia_diem != null)
                              {
                                  dia_diem.Click();
                                  _logger.Info("chon dia diem topcv");
                                  System.Threading.Thread.Sleep(2000);
                                  var choose_dia_chi = browser.Find($".//ul[@id='select2-cityIds-results']/li[text()='{ct.dia_chi}']")?.First();
                                  if (choose_dia_chi != null)
                                  {
                                      choose_dia_chi.Click();
                                      _logger.Info($"da chon dia chi top cv {ct.dia_chi}");
                                  }
                                  else
                                  {
                                      _logger.Error("khong tim thay xpath dia chi");
                                  }
                              }

                              // số lượng
                              var so_luong = element.FindElement(By.Id("quantity"));
                              if (so_luong != null)
                              {
                                  so_luong.SendKeys(ct.so_luong_tuyen.ToString());
                                  _logger.Info($"da send so luong top cv {ct.so_luong_tuyen}");
                              }
                              else
                              {
                                  _logger.Error("khong tim thay xpath so luong");
                              }
                              // cấp bậc
                              var cap_bac = element.FindElement(By.XPath("//select[@name='position_id']/following::span[@class='select2 select2-container select2-container--bootstrap'][1]"));
                              if (cap_bac != null)
                              {
                                  cap_bac.Click();
                                  System.Threading.Thread.Sleep(2000);
                                  var choose_cap_bac = browser.Find($".//span[@class='select2-container select2-container--bootstrap select2-container--open']//li[text()='{ct.cap_bac}']")?.First();
                                  if (choose_cap_bac != null)
                                  {
                                      choose_cap_bac.Click();
                                      _logger.Info($"da chon cap bac {ct.cap_bac}");
                                  }
                                  else
                                  {
                                      _logger.Error("khong tim thay xpath cap bac");
                                  }
                              }

                              // find textbox
                              var textbox = browser.Find(".//div[@class='note-editable panel-body']");
                              if (textbox.Count > 0)
                              {
                                  // mô tả công việc
                                  var mo_ta_cong_viec = textbox[0];
                                  if (mo_ta_cong_viec != null)
                                  {
                                      mo_ta_cong_viec.SendKeys(ct.mo_ta_cong_viec);
                                      _logger.Info($"da send mo ta cong viec {ct.mo_ta_cong_viec}");
                                  }
                                  else
                                  {
                                      _logger.Error("khong tim thay xpath mo ta cong viec");
                                  }
                                  // yêu cầu ứng viên
                                  var yeu_cau_ung_vien = textbox[1];
                                  if (yeu_cau_ung_vien != null)
                                  {
                                      yeu_cau_ung_vien.SendKeys(ct.yeu_cau_cong_viec);
                                      _logger.Info($"da send yeu_cau_cong_viec {ct.yeu_cau_cong_viec}");
                                  }
                                  else
                                  {
                                      _logger.Error("khong tim thay xpath yeu_cau_cong_viec");
                                  }
                                  var quyen_loi_ung_vien = textbox[2];
                                  if (quyen_loi_ung_vien != null)
                                  {
                                      quyen_loi_ung_vien.SendKeys(ct.quyen_loi_ung_vien);
                                      _logger.Info($"da send quyen_loi_ung_vien {ct.quyen_loi_ung_vien}");
                                  }
                                  else
                                  {
                                      _logger.Error("khong tim thay xpath quyen_loi_ung_vien");
                                  }
                              }

                              element.FindElement(By.Id("btn-submit")).Click();
                              System.Threading.Thread.Sleep(1500);
                              var yc_publish = browser.Find(".//div[@id='suggestPublishRequestModal']");
                              if (yc_publish.Count > 0)
                              {
                                  foreach (var item in yc_publish)
                                  {
                                      item.FindElement(By.XPath(".//button[@class='btn btn-primary']")).Click();
                                      System.Threading.Thread.Sleep(1000);
                                  }
                              }
                              System.Threading.Thread.Sleep(1000);
                              string link_post = "";

                              var find_title_new = browser.Find(".//tbody[@class='tbody-job']/tr[1]");
                              if (find_title_new.Count > 0)
                              {
                                  foreach (var title in find_title_new)
                                  {
                                      title.FindElement(By.XPath(".//button")).Click();
                                      var els = browser.Find(".//ul/li/a[contains(text(),'Xem CV ứng tuyển')]");
                                      foreach (var e in els)
                                      {
                                          link_post = browser.GetAttribute(e, "href");
                                      }
                                  }
                              }

                              if (!string.IsNullOrEmpty(link_post))
                              {
                                  List <JobLink> lst_saved = new List <JobLink>();
                                  JobLink        saved     = new JobLink(LoaiLink.JOB_LINK)
                                  {
                                      ten_job          = ct.chuc_danh,
                                      app_id           = app_id,
                                      link             = link_post,
                                      trang_thai       = TrangThai.DANG_SU_DUNG,
                                      trang_thai_xu_ly = TrangThaiXuLy.CHUA_XU_LY,
                                      nguoi_tao        = ch.username
                                  };
                                  lst_saved.Add(saved);
                                  _logger.Info("POST TOPCV SUCCESS");
                                  return(ES.JobLinkRepository.Instance.IndexMany(lst_saved) > 0);
                              }
                          }
                      }
                      catch (Exception ex)
                      {
                          _logger.Error(ex);
                      }
                  }
                  else
                  {
                      _logger.Error("CAN'T FOUND FORM POST TOPCV");
                  }
              }
          }
          _logger.Error("POST TOPCV FAILED!");
          return(false);
      }
Esempio n. 11
0
        public List <JobLink> ExtractJobLink(CauHinh ch, List <string> lst_link, string app_id, out string msg)
        {
            is_authenticated = false;
            msg = "";
            List <JobLink> lst        = new List <JobLink>();
            string         wait_xpath = ".//li[@class='dropdown dropdown-user']";

            //ch.username = "******";
            //ch.password = "******";
            using (var browser = new XBrowser(user_profile_path, string.Empty, false, show_browser))
            {
                foreach (var link in lst_link)
                {
                    string url = browser.GoTo(link);
                    is_authenticated = link != url?browser.Login(ch.url_login, ch.username, ch.password, ch.xpath_username, ch.xpath_password, out msg, wait_xpath, false) : browser.GetUrl().Contains(url);

                    browser.GoTo(link);
                    try
                    {
                        var find_modal = browser.Find("//div[@id='modal']");
                        if (find_modal.Count > 0)
                        {
                            foreach (var modal in find_modal)
                            {
                                modal.FindElement(By.ClassName("close"))?.Click();
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }

                    if (is_authenticated)
                    {
                        var check_paging = browser.Find(".//ul[@class='pagination']/li/a");
                        if (check_paging.Count() > 0)
                        {
                            var list_url_page = new List <string>();
                            foreach (var loop in check_paging)
                            {
                                var url_page = browser.GetAttribute(loop, "href");
                                list_url_page.Add(url_page);
                            }

                            list_url_page = list_url_page.Distinct().ToList();
                            foreach (var go_url in list_url_page)
                            {
                                browser.GoTo(go_url);
                                System.Threading.Thread.Sleep(1500);
                                var eles_paging = browser.Find(".//table[@class='kv-grid-table table table-hover table-bordered table-striped']//tbody/tr/td[2]/strong/a[@title='Xem chi tiết việc làm và các ứng viên']");
                                if (eles_paging.Count > 0)
                                {
                                    foreach (var item in eles_paging)
                                    {
                                        var url_tin = browser.GetAttribute(item, "href");

                                        var ten_job = item.Text;

                                        if (!string.IsNullOrEmpty(url_tin))
                                        {
                                            var job = new JobLink(LoaiLink.JOB_LINK)
                                            {
                                                app_id           = app_id,
                                                link             = url_tin,
                                                trang_thai       = TrangThai.DANG_SU_DUNG,
                                                trang_thai_xu_ly = TrangThaiXuLy.CHUA_XU_LY,
                                                nguoi_tao        = ch.username,
                                                ten_job          = ten_job
                                            };
                                            lst.Add(job);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            var eles = browser.Find(".//table[@class='kv-grid-table table table-hover table-bordered table-striped']//tbody/tr/td[2]/strong/a[@title='Xem chi tiết việc làm và các ứng viên']");
                            if (eles.Count > 0)
                            {
                                foreach (var item in eles)
                                {
                                    var url_tin = browser.GetAttribute(item, "href");

                                    var ten_job = item.Text;

                                    if (!string.IsNullOrEmpty(url_tin))
                                    {
                                        JobLink job = new JobLink(LoaiLink.JOB_LINK)
                                        {
                                            app_id           = app_id,
                                            link             = url_tin,
                                            trang_thai       = TrangThai.DANG_SU_DUNG,
                                            trang_thai_xu_ly = TrangThaiXuLy.CHUA_XU_LY,
                                            nguoi_tao        = ch.username,
                                            ten_job          = ten_job
                                        };
                                        lst.Add(job);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(lst);
        }
Esempio n. 12
0
        private List <UngVien> XuLyCV(XBrowser browser, JobLink job)
        {
            job.trang_thai_xu_ly = TrangThaiXuLy.DA_XU_LY;

            List <UngVien> lst_ung_vien = new List <UngVien>();

            try
            {
                UngVien ung_vien = new UngVien();

                ung_vien.ngay_tao = ung_vien.ngay_sua = XUtil.TimeInEpoch(DateTime.Now);
                ung_vien.app_id   = job.app_id;
                ung_vien.job_link = job.link;
                ung_vien.vi_tri   = job.ten_job;

                ThongTinChungUngVien ttuv = new ThongTinChungUngVien();
                ttuv.domain = "jobsgo.vn";
                //ttuv.full_text = block_ung_vien.FindElement(By.XPath("//div[@class='Card__root ApplicationCard__root']")).;
                ung_vien.thong_tin_chung = ttuv;
                ung_vien.ho_ten          = browser.GetInnerText(".//div[@title='Họ tên ứng viên']", 200);
                ung_vien.link_cv_online  = browser.GetAttribute("//div[@class='lnks']/a[@class='btn-download-cv lnk cv']", "href");
                ung_vien.ky_nang         = browser.GetInnerText("//div[@class='skills-list']");
                ung_vien.hoc_van         = browser.GetInnerText("//div[@class='resume-items']//div[@class='name']");

                //div[@class='info-list']/ul/li[1]
                ung_vien.ngay_sinh     = 0;
                ung_vien.so_dien_thoai = browser.GetInnerText("//div[@class='info-list']/ul/li[3]/span[@class='tel']");
                ung_vien.email         = browser.GetInnerText("//div[@class='info-list']/ul/li[4]/span[@class='email']");
                ung_vien.dia_chi       = browser.GetInnerText("//div[@class='info-list']/ul/li[5]/span[@class='address']");

                Uri uri = new Uri(job.link);
                ung_vien.domain = uri.Host;
                var id = string.Join("/", job.link.Split('/').Skip(5));
                //id = id.Substring(0, id.LastIndexOf('/'));
                ung_vien.custom_id = id;
                //Tai file
                //javascript:void(0)

                var link_cv = browser.GetAttribute("//div[@class='lnks']/a[@class='btn-download-cv lnk cv']", "href");

                if (link_cv.Contains("javascript:void(0)"))
                {
                    System.Threading.Thread.Sleep(2500);
                    link_cv = browser.GetAttribute("//div[@class='lnks']/a[@class='btn-download-cv lnk cv']", "href");
                    ung_vien.link_cv_online = link_cv;
                }
                else
                {
                    System.Threading.Thread.Sleep(2500);
                    ung_vien.link_cv_online = link_cv;
                }

                var cv_byte = browser.DownloadFile(ung_vien.link_cv_online, out string cv_file_name);
                if (cv_byte != null)
                {
                    ung_vien.cv_byte = cv_byte;
                    WriteFile($"{cv_save_path}\\{cv_file_name}", cv_byte);
                    ung_vien.link_cv_offline = cv_file_name;
                }
                ung_vien.full_text = browser.GetPageSource();
                ung_vien.nguoi_tao = job.nguoi_tao;
                lst_ung_vien.Add(ung_vien);
                var count = lst_ung_vien.Count;
                System.Threading.Thread.Sleep(2000);
            }
            catch (Exception ex)
            {
                job.trang_thai_xu_ly = TrangThaiXuLy.LOI;
                job.thong_tin_xu_ly  = ex.Message;
            }
            job.ngay_xu_ly = XUtil.TimeInEpoch();

            return(lst_ung_vien);
        }
Esempio n. 13
0
        public List <JobLink> ExtractJobLink(CauHinh ch, string link, string app_id, out string msg)
        {
            is_authenticated = false;
            msg = "";
            List <JobLink> lst = new List <JobLink>();

            using (var browser = new XBrowser(user_profile_path, string.Empty, false, show_browser))
            {
                string url        = browser.GoTo(link);
                string wait_xpath = ".//a[@class='user-image']";
                is_authenticated = url.Contains(ch.url_login)
                    ? browser.Login(ch.url_login, ch.username, ch.password, ch.xpath_username, ch.xpath_password,
                                    out msg, wait_xpath, false)
                    : browser.GetUrl().Contains(url);
                if (is_authenticated)
                {
                    browser.GoTo(link);
                    var eles_tin_tuyen_dung = browser.Find("//form[@id='employer-job-manage']//a[contains(@href,'thu-xin-viec-da-nhan')]");

                    if (eles_tin_tuyen_dung != null)
                    {
                        foreach (var item in eles_tin_tuyen_dung)
                        {
                            var ten_job = item.FindElement(By.XPath(".//parent::div/parent::div/parent::div/parent::div/following-sibling::div/ul[@class='fa-ul']//li[1]")).Text;
                            var url_tin = browser.GetAttribute(item, "href");
                            if (!string.IsNullOrEmpty(url_tin))
                            {
                                JobLink job = new JobLink(LoaiLink.JOB_LINK)
                                {
                                    app_id           = app_id,
                                    link             = url_tin,
                                    trang_thai       = TrangThai.DANG_SU_DUNG,
                                    trang_thai_xu_ly = TrangThaiXuLy.CHUA_XU_LY,
                                    nguoi_tao        = ch.username,
                                    ten_job          = ten_job
                                };

                                lst.Add(job);
                            }
                        }
                    }
                    var ele_paging = browser.Find("//ul[@class='pagination']//a");
                    if (ele_paging != null)
                    {
                        var lst_url_paging = new List <string>();
                        foreach (var ele in ele_paging)
                        {
                            lst_url_paging.Add(browser.GetAttribute(ele, "href"));
                        }
                        lst_url_paging = lst_url_paging.Distinct().ToList();
                        foreach (var lnk_paging in lst_url_paging)
                        {
                            browser.GoTo(lnk_paging);

                            eles_tin_tuyen_dung = browser.Find("//form[@id='employer-job-manage']//a[contains(@href,'thu-xin-viec-da-nhan')]");

                            if (eles_tin_tuyen_dung != null)
                            {
                                foreach (var item in eles_tin_tuyen_dung)
                                {
                                    var ten_job = item.FindElement(By.XPath("//parent::div/parent::div/parent::div/parent::div/following-sibling::div/ul[@class='fa-ul']//li[1]")).Text;
                                    var url_tin = browser.GetAttribute(item, "href");
                                    if (!string.IsNullOrEmpty(url_tin))
                                    {
                                        JobLink job = new JobLink(LoaiLink.JOB_LINK);
                                        job.app_id           = app_id;
                                        job.link             = url_tin;
                                        job.trang_thai       = TrangThai.DANG_SU_DUNG;
                                        job.trang_thai_xu_ly = TrangThaiXuLy.CHUA_XU_LY;
                                        job.nguoi_tao        = XMedia.XUtil.DecodeToken(ch.username);
                                        job.ten_job          = ten_job;
                                        lst.Add(job);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            lst = lst.GroupBy(x => x.link).Select(s => s.First()).ToList();
            return(lst);
        }
Esempio n. 14
0
        public List <JobLink> ExtractJobLink(CauHinh ch, string link, string app_id, out string msg)
        {
            is_authenticated = false;
            msg = "";
            List <JobLink> lst = new List <JobLink>();

            using (var browser = new XBrowser(user_profile_path, string.Empty, false, show_browser))
            {
                string url        = browser.GoTo("https://mywork.com.vn/nha-tuyen-dung/dang-nhap");
                string wait_xpath = ".//div[@class='icon_menu user-info text-center']";
                System.Threading.Thread.Sleep(2000);
                var home = browser.GetUrl();
                is_authenticated = home == "https://mywork.com.vn/" || (link != url
                    ? browser.Login(ch.url_login, ch.username, ch.password, ch.xpath_username,
                                    ch.xpath_password, out msg, wait_xpath, false)
                    : browser.GetUrl().Contains(url));

                if (is_authenticated)
                {
                    browser.GoTo(link);
                    System.Threading.Thread.Sleep(5000);
                    List <string> lst_links      = new List <string>();
                    var           cv_paging_eles = browser.Find("//ul[@class='page-01-lst']//a").Where(x => x.Text != "Trang trước" && x.Text != "Trang sau");

                    if (cv_paging_eles.Count() > 0)
                    {
                        var lst_link_paging = new List <string>();
                        foreach (var pg_ele in cv_paging_eles)
                        {
                            browser.Click(pg_ele);
                            System.Threading.Thread.Sleep(3000);
                            var e = browser.Find(".//ul[@class='jobslist-01-ul']/li/div/div/ul/li[1]/a");

                            try
                            {
                                foreach (var item_href in e)
                                {
                                    var ten_job = item_href.Text;
                                    var url_tin = browser.GetAttribute(item_href, "href");
                                    lst_links.Add(url_tin);
                                    if (!string.IsNullOrEmpty(url_tin))
                                    {
                                        JobLink job = new JobLink(LoaiLink.JOB_LINK)
                                        {
                                            app_id           = app_id,
                                            link             = url_tin,
                                            trang_thai       = TrangThai.DANG_SU_DUNG,
                                            trang_thai_xu_ly = TrangThaiXuLy.CHUA_XU_LY,
                                            nguoi_tao        = ch.username,
                                            ten_job          = ten_job
                                        };
                                        lst.Add(job);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                            }
                        }
                    }
                }
            }
            return(lst);
        }
Esempio n. 15
0
        //public MyWorkPost()
        //{
        //}

        public bool ExtractThongTin(CauHinh ch, string link, string app_id, out string msg, UngVienJobModel.ChiTietTinModel ct, bool is_debug = false)
        {
            _logger.Info("START POST MYWORK");
            is_authenticated = false;
            msg = "";
            //string username = XUtil.ConfigurationManager.AppSetting["MyWork:username"];
            //string password = XUtil.ConfigurationManager.AppSetting["MyWork:password"];

            using (var browser = new XBrowser(user_profile_path, string.Empty, false, is_debug))
            {
                browser.GoTo(ch.url_login);
                var login_form = browser.Find(".//form[@class='form-hook']");
                if (login_form.Count > 0)
                {
                    try
                    {
                        foreach (var element in login_form)
                        {
                            element.FindElement(By.XPath(ch.xpath_username)).SendKeys(ch.username);
                            element.FindElement(By.XPath(ch.xpath_password)).SendKeys(ch.password);
                            //element.FindElement(By.XPath(".//button[@class='el-button full-width el-button--primary']")).Click();
                            element.FindElement(By.XPath(ch.xpath_password)).SendKeys(Keys.Enter);
                            //wait element nao do xuat hien
                            _logger.Info("LOGIN MYWORK SUCCESS");
                            Thread.Sleep(4000);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }

                browser.GoTo(link);
                if (browser.GetUrl() == link)
                {
                    System.Threading.Thread.Sleep(2000);
                    //is_authenticated = link != url ? browser.Login(ch.url_login, ch.username, ch.password, ch.xpath_username, ch.xpath_password, out msg) : browser.GetUrl().Contains(url);
                    is_authenticated = true;
                    _logger.Info("LOGIN MYWORK SUCCESS");
                }

                if (is_authenticated)
                {
                    //Thông tin công việc
                    try
                    {
                        var thong_tin_cong_viec = browser.Find(".//div[@class='create-cnt-box'][1]");
                        if (thong_tin_cong_viec != null)
                        {
                            foreach (var element in thong_tin_cong_viec)
                            {
                                var chuc_danh = element.FindElement(By.XPath(
                                                                        ".//input[@name='title']"));
                                if (chuc_danh != null)
                                {
                                    chuc_danh.SendKeys(ct.chuc_danh);
                                    _logger.Info($"da send chuc danh {ct.chuc_danh}");
                                }
                                else
                                {
                                    _logger.Error("khong tim thay xpath chuc danh");
                                }

                                // số lượng tuyển
                                var so_luong = element.FindElement(By.XPath(".//input[@name='vacancy_quantity']"));
                                so_luong.SendKeys(Keys.Control + "a");
                                so_luong.SendKeys(Keys.Delete);
                                so_luong?.SendKeys(ct.so_luong_tuyen.ToString());

                                var cap_bac =
                                    element.FindElement(By.XPath("div[2]/div/div[5]/div/div[2]/div/div/span/span"));
                                if (cap_bac != null)
                                {
                                    cap_bac.Click();
                                    _logger.Info($"da send cap bac : {ct.cap_bac}");
                                    System.Threading.Thread.Sleep(2000);
                                    string str_vi_tri = ct.cap_bac;
                                    char[] spearator0 = { ',', '/', '-', ' ' };
                                    foreach (string s in str_vi_tri.Split(spearator0, StringSplitOptions.None))
                                    {
                                        if (!string.IsNullOrWhiteSpace(s))
                                        {
                                            var industry = browser.Find($".//div/div[contains(text(),'{s}')]");
                                            if (industry.Count > 0)
                                            {
                                                foreach (var item in industry)
                                                {
                                                    if (!string.IsNullOrWhiteSpace(item.Text))
                                                    {
                                                        item.Click();
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }

                                //

                                // loại hình công việc
                                var loai_hinh =
                                    element.FindElement(By.XPath("div[2]/div/div[6]/div/div[2]/div/div/span/span"));
                                if (loai_hinh != null)
                                {
                                    loai_hinh.Click();
                                    System.Threading.Thread.Sleep(1000);
                                    var choose_loai_hinh = browser.Find($".//div/div[contains(text(),'{ct.loai_hinh_cong_viec}')]");
                                    if (choose_loai_hinh != null)
                                    {
                                        foreach (var choose in choose_loai_hinh)
                                        {
                                            if (!string.IsNullOrWhiteSpace(choose.Text))
                                            {
                                                choose.Click();
                                                break;
                                            }
                                        }
                                        _logger.Info($"da chon loai hinh cong viec: {ct.loai_hinh_cong_viec}");
                                    }
                                    else
                                    {
                                        _logger.Error("khong tim thay xpath loai hinh cong viec");
                                    }
                                }

                                // mức lương
                                var muc_luong = element.FindElement(By.XPath("div[2]/div/div[7]/div/div[2]/div/div/span/span"));
                                if (muc_luong != null)
                                {
                                    muc_luong.Click();
                                    _logger.Info($"chon muc luong");
                                    System.Threading.Thread.Sleep(1000);
                                    var choose_muc_luong = browser.Find($".//div/div[text()='{ct.muc_luong}']")?.First();
                                    if (choose_muc_luong != null)
                                    {
                                        choose_muc_luong.Click();
                                        _logger.Info($"da chon muc luong {ct.muc_luong}");
                                    }
                                    else
                                    {
                                        _logger.Error("khong tim thay xpath, khong tim thay muc luong phu hop");
                                    }
                                }

                                // địa điểm làm việc
                                var dia_diem = element.FindElement(By.XPath("div[2]/div/div[9]/div/div[2]/div/div/span/span"));

                                if (dia_diem != null)
                                {
                                    dia_diem.Click();
                                    System.Threading.Thread.Sleep(1000);
                                    var choose_dia_diem = browser.Find($".//div/div[contains(text(),'{ct.dia_chi}')]")?.First();
                                    if (choose_dia_diem != null)
                                    {
                                        choose_dia_diem.Click();
                                        _logger.Info($"da chon dia diem {ct.dia_chi}");
                                    }
                                    else
                                    {
                                        _logger.Error("khong tim thay xpath dia diem");
                                    }
                                }

                                // ngành nghề
                                var nganh_nghe = element.FindElement(By.XPath("div[2]/div/div[10]/div/div[2]/div/div/span/span"));
                                if (nganh_nghe != null)
                                {
                                    nganh_nghe.Click();
                                    _logger.Info("chon nganh nghe phu hop");
                                    System.Threading.Thread.Sleep(1000);
                                    foreach (string nghe in ct.nganh_nghe)
                                    {
                                        var nn = browser.Find($".//div/div[text()='{nghe}']")?.First();
                                        if (nn != null)
                                        {
                                            nn.Click();
                                            _logger.Info($"da chon nganh nghe {nn}");
                                        }
                                        else
                                        {
                                            _logger.Error($"khong tim thay xpath nganh nghe {nn}]");
                                        }
                                    }
                                }

                                // mô tả công việc
                                var mo_ta = element.FindElement(By.XPath(".//textarea[@name='description']"));
                                if (mo_ta != null)
                                {
                                    mo_ta.SendKeys(ct.mo_ta_cong_viec);
                                    _logger.Info($"da send mo ta cong viec {ct.mo_ta_cong_viec}");
                                }
                                else
                                {
                                    _logger.Error("khong tim thay xpath mo ta cong viec");
                                }

                                var quyen_loi = element.FindElement(By.XPath(".//textarea[@name='benefit']"));
                                if (quyen_loi != null)
                                {
                                    quyen_loi.SendKeys(ct.quyen_loi_ung_vien);
                                    _logger.Info($"da send quyen loi ung vien {ct.quyen_loi_ung_vien}");
                                }
                                else
                                {
                                    _logger.Error("khong tim thay xpath quyen_loi_ung_vien");
                                }
                            }

                            // Yêu cầu công việc
                            var yeu_cau_cong_viec = browser.Find(".//div[@class='create-cnt-box'][2]");
                            if (yeu_cau_cong_viec != null)
                            {
                                foreach (var element in yeu_cau_cong_viec)
                                {
                                    //kinh nghiem lam viec
                                    var ele_kn = element.FindElement(By.XPath("div[2]/div/div[1]/div/div[2]/div/div/span/span"));
                                    if (ele_kn != null)
                                    {
                                        ele_kn.Click();
                                        if (!string.IsNullOrEmpty(ct.yeu_cau_kinh_nghiem))
                                        {
                                            var choose_kinh_nghiem = browser.Find($".//div/div[contains(text(),'{ct.yeu_cau_kinh_nghiem}')]")?.First();
                                            choose_kinh_nghiem?.Click();
                                            _logger.Info($"da send yeu cau kinh nghiem {ct.yeu_cau_kinh_nghiem}");
                                        }
                                        else
                                        {
                                            browser.ScrollIntoView(ele_kn);
                                            browser.SetAttribute(ele_kn, "readonly", "");
                                            ele_kn.SendKeys("Đã có nhiều kinh nghiệm trong nghề");
                                            _logger.Info($"da send yeu cau kinh nghiem {ct.yeu_cau_kinh_nghiem}");
                                        }
                                    }

                                    // bang cap
                                    var ele_bcap = element.FindElement(By.XPath("div[2]/div/div[2]/div/div[2]/div/div/span/span"));
                                    if (ele_bcap != null)
                                    {
                                        ele_bcap.Click();

                                        var choose_bang_cap = browser.Find($".//div/div[contains(text(),'{ct.bang_cap}')]")?.First();
                                        choose_bang_cap?.Click();
                                        _logger.Info($"da send bang cap {ct.bang_cap}");
                                    }
                                    // giới tính
                                    var ele_gtinh = element.FindElement(By.XPath("div[2]/div/div[3]/div/div[2]/div/div/span/span"));
                                    if (ele_gtinh != null)
                                    {
                                        ele_gtinh.Click();

                                        var choose_gender = browser
                                                            .Find($".//div/div[contains(text(),'{ct.gioi_tinh}')]")?.First();
                                        choose_gender?.Click();
                                        _logger.Info($"da send gioi tinh {ct.gioi_tinh}");
                                    }

                                    // hạn nộp hồ sơ

                                    var date_now = DateTime.Today.AddMonths(1).ToString("dd/MM/yyyy");

                                    var han_nop_hs =
                                        element.FindElement(By.XPath("div[2]/div/div[4]/div/div[2]/div/div//input"));
                                    if (han_nop_hs != null)
                                    {
                                        han_nop_hs.SendKeys(Keys.Control + "a");
                                        han_nop_hs.SendKeys(Keys.Delete);
                                        han_nop_hs.SendKeys(date_now);
                                        _logger.Info($"da send han nop ho so {date_now}");
                                    }
                                    else
                                    {
                                        _logger.Error($"khong tim thay xpath han nop ho so");
                                    }

                                    // ngon ngu ho so

                                    var ngon_ngu_ho_so = element.FindElement(By.XPath("div[2]/div/div[5]/div/div[2]/div/div/span/span"));
                                    if (ngon_ngu_ho_so != null)
                                    {
                                        ngon_ngu_ho_so.Click();
                                        var choose_ngon_ngu = browser.Find($".//div/div[contains(text(),'Tiếng Việt')]")?.First();
                                        choose_ngon_ngu?.Click();
                                        _logger.Info($"da send gioi tinh {ct.gioi_tinh}");
                                    }

                                    // yeu cau cong viec
                                    var yc = element.FindElement(By.XPath(".//textarea[@name='job_requirement']"));
                                    if (yc != null)
                                    {
                                        yc.SendKeys(ct.yeu_cau_cong_viec);
                                        _logger.Info($"da send yeu cau cong viec {ct.yeu_cau_cong_viec}");
                                    }
                                    else
                                    {
                                        _logger.Error("khong tim thay xpath yeu cau cong viec");
                                    }
                                }
                            }

                            //Thông tin liên hệ(Bắt buộc)
                            var thong_tin_lien_he = browser.Find(".//div[@class='create-cnt-box'][3]");
                            if (thong_tin_lien_he != null)
                            {
                                foreach (var element in thong_tin_lien_he)
                                {
                                    // ten nguoi lien he
                                    var nguoi_lien_he = element.FindElement(By.XPath(".//input[@name='contact_name']"));
                                    if (nguoi_lien_he != null)
                                    {
                                        //IWebElement textBox = nguoi_lien_he;
                                        //textBox.SendKeys(Keys.Control + "a");
                                        nguoi_lien_he.SendKeys(ct.lien_he);
                                        _logger.Info($"da send nguoi lien he {ct.lien_he}");
                                    }
                                    else
                                    {
                                        _logger.Error($"khong tim thay xpath lien he");
                                    }

                                    // dia chi lien he
                                    var dia_chi_lien_he =
                                        element.FindElement(By.XPath(".//input[@name='contact_address']"));

                                    if (dia_chi_lien_he != null)
                                    {
                                        //IWebElement textBox = nguoi_lien_he;
                                        //textBox.SendKeys(Keys.Control + "a");
                                        dia_chi_lien_he.SendKeys(ct.dia_chi_chi_tiet);
                                        _logger.Info($"da send dia_chi lien he {ct.dia_chi_chi_tiet}");
                                    }
                                    else
                                    {
                                        _logger.Error($"khong tim thay xpath lien he");
                                    }

                                    //so dien thoai lien he
                                    var sdt_lien_he = element.FindElement(By.XPath(".//input[@name='contact_phone']"));
                                    if (sdt_lien_he != null)
                                    {
                                        sdt_lien_he.SendKeys(Keys.Control + "a");
                                        sdt_lien_he.SendKeys(ct.so_dien_thoai);
                                        _logger.Info($"da send so dien thoai {ct.so_dien_thoai}");
                                    }
                                    else
                                    {
                                        _logger.Error($"khong tim thay xpath so dien thoai");
                                    }

                                    // email lien he

                                    var email_lien_he =
                                        element.FindElement(By.XPath(".//input[@name='contact_email']"));
                                    if (sdt_lien_he != null)
                                    {
                                        email_lien_he.SendKeys(ct.email);
                                        _logger.Error($"da sendkey email");
                                    }
                                    else
                                    {
                                        _logger.Error($"khong tim thay email");
                                    }
                                }
                            }

                            //var dich_vu =
                            //    element.FindElement(
                            //        By.XPath(".//input[@placeholder='Chọn dịch vụ cho tin đăng']"));
                            //dich_vu?.Click();



                            browser.FindAndClick(".//button[@class='btn btn-orange-56 ex-upload']");
                            _logger.Info("POST MYWORK SUCCESS");
                            Thread.Sleep(5000);

                            string url_home = browser.GetUrl();

                            if (url_home == "https://mywork.com.vn/nha-tuyen-dung/tao-tin-tuyen-dung-thanh-cong")
                            {
                                browser.FindAndClick(".//a[@class='btn btn-orange-46 w370 w-100-mb font17']");
                                Thread.Sleep(1000);
                                if (browser.GetUrl() == "https://mywork.com.vn/nha-tuyen-dung/quan-ly-tin-dang?")
                                {
                                    var els = browser.Find($".//div[@class='jobslist-01-cont']//a[text()='{ct.chuc_danh}']");

                                    string link_post = "";
                                    foreach (var r_url in els)
                                    {
                                        link_post = browser.GetAttribute(r_url, "href");
                                        break;
                                    }
                                    string id = link_post.Replace("https://mywork.com.vn/nha-tuyen-dung/xem-truoc-tin-dang?id=", "").Split('/').First();

                                    if (!string.IsNullOrEmpty(link_post))
                                    {
                                        List <JobLink> lst_saved = new List <JobLink>();
                                        JobLink        saved     = new JobLink(LoaiLink.JOB_LINK)
                                        {
                                            ten_job          = ct.chuc_danh,
                                            app_id           = app_id,
                                            link             = $"https://mywork.com.vn/nha-tuyen-dung/ho-so-da-ung-tuyen?job_id={id}",
                                            trang_thai       = TrangThai.DANG_SU_DUNG,
                                            trang_thai_xu_ly = TrangThaiXuLy.CHUA_XU_LY,
                                            nguoi_tao        = ch.username
                                        };
                                        lst_saved.Add(saved);
                                        _logger.Info("POST MYWORK SUCCESS!");
                                        return(ES.JobLinkRepository.Instance.IndexMany(lst_saved) > 0);
                                    }
                                }
                            }
                            else
                            {
                                _logger.Error("POST MY WORK FAILED! CAN'T GET LINK POST OR JOB NAME IS EXISTED");
                                return(false);
                            }
                        }

                        //else
                        //{
                        //    _logger.Error("CAN'T FOUND FORM POST MYWORK");
                        //}
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(ex);
                    }
                }
            }

            _logger.Error("POST MYWORK FAILED!");
            return(false);
        }
Esempio n. 16
0
        public List <UngVien> Run(CauHinh ch, List <JobLink> lst_job_link)
        {
            is_authenticated = false;
            List <UngVien> lst_ung_vien = new List <UngVien>();

            using (var browser = new XBrowser(user_profile_path, cv_save_path, string.Empty, false, show_browser))
            {
                foreach (var job in lst_job_link)
                {
                    string url        = browser.GoTo(job.link);
                    string wait_xpath = ".//div[@class='icon_menu user-info text-center']";
                    if (url.Contains(ch.url_login) || browser.GetUrl() == "https://mywork.com.vn/")
                    {
                        is_authenticated = browser.Login(ch.url_login, ch.username, ch.password, ch.xpath_username, ch.xpath_password, out string msg, wait_xpath, true);
                    }
                    else
                    {
                        is_authenticated = browser.GetUrl().Contains(url);
                    }
                    if (is_authenticated)
                    {
                        string r_url = browser.GoTo(job.link);
                        System.Threading.Thread.Sleep(3000);

                        if (r_url.Contains(job.link))
                        {
                            int sleep         = 30000;
                            var find_ung_vien = browser.Find(".//div/span[text()='Không có dữ liệu']");
                            if (find_ung_vien.Count < 1)
                            {
                                while (sleep > 0)
                                {
                                    sleep -= 500;
                                    System.Threading.Thread.Sleep(500);
                                    List <string> lst_cv_ung_vien = new List <string>();
                                    var           lst_cv_by_job   = new List <UngVien>();
                                    var           lst_new         = browser.Find("//table[@class='el-table__body']//tbody//div/div/div[1]/a");
                                    if (lst_new.Count < 1)
                                    {
                                        job.thong_tin_xu_ly = Common.KHONG_TIM_THAY_UNG_VIEN;
                                    }
                                    var element = browser.Find("//ul[@class='pagination']//a");

                                    if (element.Count > 0)
                                    {
                                        var cv_paging_eles = element.Where(x => x.Text != null && x.Text != "Trang trước" && x.Text != "Trang sau");

                                        if (cv_paging_eles.Count() > 0)
                                        {
                                            var all_links_in_page = new List <string>();
                                            var links_process     = new List <string>();
                                            foreach (var pg_ele in cv_paging_eles)
                                            {
                                                browser.Click(pg_ele);
                                                System.Threading.Thread.Sleep(2000);
                                                lst_new = browser.Find("//table[@class='el-table__body']//tbody//div/div/div[1]/a");

                                                foreach (var lst_ung_vien_new in lst_new)
                                                {
                                                    var url_ung_vien = browser.GetAttribute(lst_ung_vien_new, "href");
                                                    links_process.Add(url_ung_vien);
                                                }
                                            }
                                            foreach (var item in links_process)
                                            {
                                                browser.GoTo(item);
                                                System.Threading.Thread.Sleep(3000);
                                                lst_cv_by_job.AddRange(XuLyCV(browser, job, item));
                                            }
                                        }
                                    }
                                    else
                                    {
                                        var current_href = new List <string>();
                                        foreach (var item in lst_new)
                                        {
                                            var url_ung_vien = browser.GetAttribute(item, "href");
                                            current_href.Add(url_ung_vien);
                                        }
                                        foreach (var items in current_href)
                                        {
                                            browser.GoTo(items);
                                            lst_cv_by_job.AddRange(XuLyCV(browser, job, items));

                                            job.tong_so_cv = lst_cv_by_job.Count;
                                        }
                                    }

                                    if (lst_new != null && lst_new.Count > 0)
                                    {
                                        sleep = 0;
                                    }
                                    job.tong_so_cv       = lst_cv_by_job.Count;
                                    job.ngay_xu_ly       = XMedia.XUtil.TimeInEpoch();
                                    job.trang_thai_xu_ly = TrangThaiXuLy.DA_XU_LY;
                                    lst_ung_vien.AddRange(lst_cv_by_job);
                                    ES.JobLinkRepository.Instance.UpdateTrangThaiXuLy(job);
                                }
                            }
                        }
                    }
                }
            }

            return(new List <UngVien>(lst_ung_vien));
        }
Esempio n. 17
0
        public bool ExtractThongTin(CauHinh ch, string link, UngVienJobModel.ChiTietTinModel ct, string app_id, out string msg, bool is_debug = false)
        {
            _logger.Info("START POST JOBSGO");
            msg = "";
            is_authenticated = false;
            using (var browser = new XBrowser(user_profile_path, string.Empty, false, is_debug))
            {
                string url        = browser.GoTo(ch.url_login);
                var    login_form = browser.Find(".//div[@class='panel panel-body login-form']");
                if (browser.Find("//div[@id='modal']//button").Count > 0)
                {
                    browser.FindAndClick("//div[@id='modal']//button");
                }
                if (login_form.Count > 0)
                {
                    try
                    {
                        foreach (var element in login_form)
                        {
                            element.FindElement(By.XPath(ch.xpath_username)).SendKeys(ch.username);
                            element.FindElement(By.XPath(ch.xpath_password)).SendKeys(ch.password);
                            element.FindElement(By.XPath(".//button[@class='display-block btn btn-primary btn-ladda btn-ladda-spinner btn-ladda-progress']")).Click();
                            System.Threading.Thread.Sleep(2000);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(ex);
                    }
                }

                browser.GoTo(link);

                is_authenticated = true;

                if (is_authenticated)
                {
                    _logger.Info("LOGIN JOBSGO SUCCESS");
                    try
                    {
                        var tab1 = browser.Find(".//div[@id='tab1']");
                        if (tab1.Count > 0)
                        {
                            foreach (var tab in tab1)
                            {
                                var chuc_danh = tab.FindElement(By.Id("jobformcreate-job_title"));
                                if (chuc_danh != null)
                                {
                                    chuc_danh.SendKeys(ct.chuc_danh);
                                    _logger.Info("da send chuc danh");
                                }
                                else
                                {
                                    _logger.Error("khong tim thay xpath chuc danh");
                                }

                                var mo_ta = tab.FindElement(By.Id("jobformcreate-job_description_ifr"));
                                if (mo_ta != null)
                                {
                                    mo_ta.SendKeys(ct.mo_ta_cong_viec);
                                    _logger.Info("da send mo ta cong viec");
                                }
                                else
                                {
                                    _logger.Error("khong tim thay xpath mo ta cong viec");
                                }

                                var yeu_cau = tab.FindElement(By.Id("jobformcreate-job_requirement_ifr"));
                                if (yeu_cau != null)
                                {
                                    yeu_cau.SendKeys(ct.yeu_cau_cong_viec);
                                    _logger.Info("da send yeu cau cong viec");
                                }
                                else
                                {
                                    _logger.Error("khong tim thay xpath yeu cau cong viec");
                                }

                                var quyen_loi = tab.FindElement(By.Id("jobformcreate-job_benefit_ifr"));
                                if (quyen_loi != null)
                                {
                                    quyen_loi.SendKeys(ct.quyen_loi_ung_vien);
                                    _logger.Info("da send quyen loi ung vien");
                                }
                                else
                                {
                                    _logger.Error("khong tim thay xpath quyen loi ung vien");
                                }

                                var next_tab = tab.FindElement(By.XPath(".//button[@class='btn btn-primary btn-next btn-ladda btn-ladda-spinner btn-ladda-progress']"));
                                if (next_tab != null)
                                {
                                    next_tab.Click();
                                    _logger.Info("luu tab 1 de toi tab 2");
                                }
                                else
                                {
                                    _logger.Error("luu tab 1 de toi tab 2");
                                }

                                System.Threading.Thread.Sleep(2000);
                            }
                        }

                        var tab2 = browser.Find(".//div[@id='tab2']");
                        if (tab2.Count > 0)
                        {
                            foreach (var tab in tab2)
                            {
                                var detail_address =
                                    tab.FindElement(By.XPath(".//input[@placeholder='Nhập địa điểm']"));
                                if (detail_address != null)
                                {
                                    detail_address.SendKeys(ct.dia_chi_chi_tiet);
                                    _logger.Info("da send dia chi chi tiet");
                                }
                                else
                                {
                                    _logger.Error("khong tim thay xpath dia chi chi tiet");
                                }
                                System.Threading.Thread.Sleep(3000);
                                try
                                {
                                    foreach (var ele in browser.Find(".//div[@class='pac-container pac-logo hdpi']/div"))
                                    {
                                        ele.Click();
                                        _logger.Info($"chon dia chi {ele}");
                                        break;
                                    }
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(e.Message);
                                }
                                var dia_chi = browser.Find("//table[@id='tableAddRow']/tbody/tr/td[3]/span")?.First();
                                if (dia_chi != null)
                                {
                                    dia_chi.Click();
                                    System.Threading.Thread.Sleep(1500);
                                    var ins_dia_chi = browser.Find($"//span[@class='select2-container select2-container--default select2-container--open']//ul/li[text()='{ct.dia_chi}']")?.First();
                                    if (ins_dia_chi != null)
                                    {
                                        ins_dia_chi.Click();
                                        _logger.Info($"da send dia chi {ct.dia_chi}");
                                    }
                                    else
                                    {
                                        _logger.Error("khong tim thay xpath dia chi");
                                    }
                                    System.Threading.Thread.Sleep(1000);
                                }

                                //Ngành nghề
                                System.Threading.Thread.Sleep(1000);
                                //browser.FindAndClick("//div[@class='form-group field-jobformnew-job_category required']/div/span");
                                var nganh_nghe = browser.Find("//div[contains(@class,'field-jobformnew-job_category')]")?.First();
                                if (nganh_nghe != null)
                                {
                                    nganh_nghe.Click();
                                    _logger.Info("chon it nhat mot nganh nghe");
                                    foreach (var nn in ct.nganh_nghe)
                                    {
                                        _logger.Info("Tim nganh nghe");
                                        browser.FindAndClick($"//span[@class='select2-container select2-container--default select2-container--open']//ul/li[text()='{nn}']");
                                        _logger.Info($"da chon nganh nghe: {nn}");
                                        System.Threading.Thread.Sleep(1000);
                                        //browser.FindAndClick("//div[@class='form-group field-jobformnew-job_category required has-success']/div/span");
                                    }
                                    System.Threading.Thread.Sleep(1000);
                                }

                                // Năm kinh nghiệm

                                if (!string.IsNullOrEmpty(ct.kinh_nghiem_from) &&
                                    !string.IsNullOrEmpty(ct.kinh_nghiem_to))
                                {
                                    var min_year_exp = browser.Find(".//input[@name='JobFormNew[exp_min_require_year]']")?.First();
                                    if (min_year_exp != null)
                                    {
                                        min_year_exp.SendKeys(Keys.Control + "a");
                                        min_year_exp.SendKeys(ct.kinh_nghiem_from);
                                        _logger.Info("da send nam kinh nghiem from");
                                    }
                                    else
                                    {
                                        _logger.Error("khong tim thay xpath nam kinh nghiem from");
                                    }
                                    var max_year_exp = browser.Find(".//input[@name='JobFormNew[exp_max_require_year]']")?.First();
                                    if (max_year_exp != null)
                                    {
                                        max_year_exp.SendKeys(Keys.Control + "a");
                                        max_year_exp.SendKeys(ct.kinh_nghiem_to);
                                        _logger.Info("da send nam kinh nghiem to");
                                    }
                                    else
                                    {
                                        _logger.Error("khong tim thay xpath nam kinh nghiem to");
                                    }
                                }
                                else
                                {
                                    browser.FindAndClick("//input[@id='checkbox1']");
                                    _logger.Info("cong viec khong yeu cau kinh nghiem");
                                }
                                //
                                // Mức lương
                                char[] cut_luong  = { ',', '/', '-', ' ' };
                                var    arr_luong  = ct.muc_luong.Split(cut_luong, StringSplitOptions.RemoveEmptyEntries);
                                var    luong_from = arr_luong[0];
                                var    luong_to   = arr_luong[1];
                                System.Threading.Thread.Sleep(1000);
                                var min_salary = browser.Find(".//input[@name='JobFormNew[min_expect_salary]']")?.First();
                                if (min_salary != null)
                                {
                                    min_salary.SendKeys(Keys.Control + "a");
                                    min_salary.SendKeys(luong_from);
                                    _logger.Info($"da send luong from {luong_from}");
                                }
                                else
                                {
                                    _logger.Error("khong tim thay xpath luong from");
                                }

                                System.Threading.Thread.Sleep(1000);
                                var max_salary = browser.Find(".//input[@name='JobFormNew[max_expect_salary]']")?.First();

                                if (max_salary != null)
                                {
                                    max_salary.SendKeys(Keys.Control + "a");
                                    max_salary.SendKeys(luong_to);
                                    _logger.Info($"da send luong to {luong_to}");
                                }
                                else
                                {
                                    _logger.Error("khong tim thay xpath luong to");
                                }
                                // Bằng cấp
                                System.Threading.Thread.Sleep(1000);

                                var bang_cap = browser.Find("//div[contains(@class,'field-jobformnew-degree')]/div/span")?.First();
                                if (bang_cap != null)
                                {
                                    bang_cap.Click();
                                    _logger.Info("da send bang cap");
                                    System.Threading.Thread.Sleep(1000);
                                    var choose_bc = browser.Find($"//span[@class='select2-container select2-container--default select2-container--open']//ul/li[text()='{ct.bang_cap}']")?.First();
                                    if (choose_bc != null)
                                    {
                                        choose_bc.Click();
                                        _logger.Info($"da chon bang cap {ct.bang_cap}");
                                    }
                                    else
                                    {
                                        _logger.Error("khong tim thay xpath bang cap");
                                    }
                                }

                                // loại hình công việc / Tính chất công việc
                                System.Threading.Thread.Sleep(1000);
                                var loai_hinh_cv = browser.Find("//div[contains(@class,'field-jobformnew-job_type')]/div/span")?.First();
                                if (loai_hinh_cv != null)
                                {
                                    loai_hinh_cv.Click();
                                    _logger.Info("chon loai hinh cong viec");
                                    var choose_loai_hinh = browser.Find(
                                        $"//span[@class='select2-container select2-container--default select2-container--open']//ul/li[text()='{ct.loai_hinh_cong_viec}']")?.First();
                                    if (choose_loai_hinh != null)
                                    {
                                        choose_loai_hinh.Click();
                                        _logger.Info($"da chon loai hinh cong viec {ct.loai_hinh_cong_viec}");
                                    }
                                    else
                                    {
                                        _logger.Error("khong tim thay xpath loai hinh cong viec");
                                    }
                                }
                                System.Threading.Thread.Sleep(1000);

                                // Vị trí
                                System.Threading.Thread.Sleep(1000);
                                var vi_tri = browser.Find("//div[contains(@class,'field-jobformnew-job_position_id')]/div/span")?.First();
                                if (vi_tri != null)
                                {
                                    vi_tri.Click();
                                    _logger.Info("chon vi tri cong viec");
                                    System.Threading.Thread.Sleep(1000);
                                    var choose_vi_tri = browser.Find($"//span[@class='select2-container select2-container--default select2-container--open']//ul/li[text()='{ct.cap_bac}']")?.First();
                                    if (choose_vi_tri != null)
                                    {
                                        choose_vi_tri.Click();
                                        _logger.Info($"da chon vi tri {ct.cap_bac}");
                                    }
                                    else
                                    {
                                        _logger.Error($"khong tim thay xpath vi tri");
                                    }
                                }

                                var save = browser.Find("//button[@class='btn btn-primary btn-next btn-ladda btn-ladda-spinner btn-ladda-progress']")?.First();
                                if (save != null)
                                {
                                    save.Click();
                                    _logger.Info("luu lai cong viec thanh cong");
                                }
                                else
                                {
                                    _logger.Error("khong the luu lai cong viec");
                                }
                                System.Threading.Thread.Sleep(2000);
                            }
                        }

                        browser.GoTo("https://employer.jobsgo.vn/job/inactive");
                        var url_tin =
                            browser.Find(
                                $".//table[@class='kv-grid-table table table-hover table-bordered table-striped']//tbody/tr/td[2]/strong/a[@title='Xem chi tiết việc làm và các ứng viên'][text()='{ct.chuc_danh} ']")?.First();

                        string href = browser.GetAttribute(url_tin, "href");
                        _logger.Info($"da lay link cua tin tuc : {href}");
                        var lst_saved = new List <JobLink>();
                        if (!string.IsNullOrEmpty(href))
                        {
                            JobLink saved = new JobLink(LoaiLink.JOB_LINK)
                            {
                                ten_job          = ct.chuc_danh,
                                app_id           = app_id,
                                link             = href,
                                trang_thai       = TrangThai.DANG_SU_DUNG,
                                trang_thai_xu_ly = TrangThaiXuLy.CHUA_XU_LY,
                                nguoi_tao        = ch.username
                            };
                            lst_saved.Add(saved);
                            return(ES.JobLinkRepository.Instance.IndexMany(lst_saved) > 0);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
            }

            return(false);
        }