Beispiel #1
0
        private void navigate(int i)
        {
            if (!browserJobVite.IsBusy)
            {
                if (i > 0)
                {
                    string CategoryDecoded = "";
                    string CityDecoded = "";
                    string StatusDecoded = "";
                    string TitleHeadingDecoded = "";
                    string BriefDescriptionDecoded = "";
                    string DescriptionFieldDecoded = "";
                    string RecruiterDecoded = "";
                    string JobtypeDecoded = "";
                    string RequisitionLink = "";
                    source.LoadHtml(browserJobVite.DocumentText);
                    try
                    {
                        foreach (HtmlNode Category in source.DocumentNode.SelectNodes("//table[@class=\"tableContent\"]/tr/td"))
                        {
                            if (Category.InnerText == "Categoria:")
                            {

                                CategoryDecoded = System.Net.WebUtility.HtmlDecode(Category.NextSibling.InnerText);
                                //txtLog.Text = txtLog.Text + "Categoria: " + CategoryDecoded + Environment.NewLine;
                                break;
                            }
                        }
                    }
                    catch(Exception e)
                    {}
                    try
                    {
                        foreach (HtmlNode City in source.DocumentNode.SelectNodes("//table[@class=\"tableContent\"]/tr/td"))
                        {
                            if (City.InnerText == "Cidade:")
                            {
                                CityDecoded = System.Net.WebUtility.HtmlDecode(City.NextSibling.InnerText);
                                //txtLog.Text = txtLog.Text + "Cidade: " + CityDecoded + Environment.NewLine;
                            }
                        }
                    }
                    catch(Exception e)
                    {}
                    try
                    {
                        foreach (HtmlNode Status in source.DocumentNode.SelectNodes("//span[@id=\"Status\"]"))
                        {
                            StatusDecoded = System.Net.WebUtility.HtmlDecode(Status.InnerHtml);
                            //txtLog.Text = txtLog.Text + StatusDecoded + Environment.NewLine;
                        }
                    }
                    catch(Exception e)
                    {}
                    try
                    {
                        //Nome da Requisition
                        foreach (HtmlNode TitleHeading in source.DocumentNode.SelectNodes("//span[@id=\"TitleHeading\"]"))
                        {
                            TitleHeadingDecoded = System.Net.WebUtility.HtmlDecode(TitleHeading.InnerText);
                            //txtLog.Text = txtLog.Text + TitleHeadingDecoded + Environment.NewLine;
                        }
                    }
                    catch(Exception e)
                    {}
                    try
                    {
                        foreach (HtmlNode BriefDescription in source.DocumentNode.SelectNodes("//span[@id=\"BriefDescription\"]"))
                        {
                            BriefDescriptionDecoded = System.Net.WebUtility.HtmlDecode(BriefDescription.InnerText);
                            //txtLog.Text = txtLog.Text + BriefDescriptionDecoded + Environment.NewLine;
                        }
                    }
                    catch(Exception e)
                    {}
                    try
                    {
                        //Big Description
                        foreach (HtmlNode DescriptionField in source.DocumentNode.SelectNodes("//span[@id=\"DescriptionField\"]"))
                        {
                            DescriptionFieldDecoded = System.Net.WebUtility.HtmlDecode(DescriptionField.InnerText);
                            //txtLog.Text = txtLog.Text + DescriptionFieldDecoded + Environment.NewLine;
                        }
                    }
                    catch(Exception e)
                    {}
                    try
                    {
                        foreach (HtmlNode Recruiter in source.DocumentNode.SelectNodes("//table[@class=\"tableContent\"]/tr/td"))
                        {
                            if (Recruiter.InnerText == "Recrutador:")
                            {
                                RecruiterDecoded = System.Net.WebUtility.HtmlDecode(Recruiter.NextSibling.InnerText);
                                //txtLog.Text = txtLog.Text + "Recruiter: " + RecruiterDecoded + Environment.NewLine + Environment.NewLine + Environment.NewLine;
                            }
                        }

                    }
                    catch(Exception e)
                    {}
                    try
                    {
                        foreach (HtmlNode Jobtype in source.DocumentNode.SelectNodes("//table[@class=\"tableContent\"]/tr/td"))
                        {
                            if (Jobtype.InnerText == "Tipo da Vaga:")
                            {
                                JobtypeDecoded = System.Net.WebUtility.HtmlDecode(Jobtype.NextSibling.InnerText);
                                //txtLog.Text = txtLog.Text + JobtypeDecoded + Environment.NewLine;
                            }
                        }
                    }
                    catch (Exception ex)
                    { }

                    try
                    {
                        foreach (HtmlNode RequisitionLinks in source.DocumentNode.SelectNodes("//table[@class=\"tableContent\"]/tr/td"))
                        {
                            if (RequisitionLinks.InnerText == "Candidates:")
                            {
                                RequisitionLink = RequisitionLinks.NextSibling.FirstChild.Attributes["href"].Value;
                                txtLog.Text = RequisitionLink;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    try
                    {
                        //ADICIONAR AO BANCO
                        int CategoryId = 25;
                        int RecruiterId = 466;
                        int CityId = 5508;
                        int JobtypeId = 5;
                        using (grouponjobsdevEntities context = new grouponjobsdevEntities())
                        {
                            Requisition_Log log = new Requisition_Log();
                            try
                            {
                                CategoryId = context.Categories.Where(c => c.Name == CategoryDecoded).Select(c => c.CategoryId).First();
                            }
                            catch (Exception ex)
                            {
                                log.Adicionar(i.ToString(),TitleHeadingDecoded, "Category", CategoryDecoded, ex.Message);
                            }
                            try
                            {
                                RecruiterId = context.Recruiters.Where(r => r.Name == RecruiterDecoded).Select(r => r.RecruiterId).First();
                            }
                            catch (Exception ex)
                            {
                                log.Adicionar(i.ToString(),TitleHeadingDecoded, "Recruiter", RecruiterDecoded, ex.Message);
                            }
                            try
                            {
                                CityId = context.Cities.Where(c => c.Name == CityDecoded).Select(c => c.CityId).First();
                            }
                            catch (Exception ex)
                            {
                                log.Adicionar(i.ToString(),TitleHeadingDecoded, "City", CityDecoded, ex.Message);
                            }
                            try
                            {
                                JobtypeId = context.Jobtypes.Where(j => j.Name == JobtypeDecoded).Select(j => j.JobtypeId).First();
                            }
                            catch (Exception ex)
                            {
                                //log.Adicionar(i.ToString(),TitleHeadingDecoded, "Jobtype", JobtypeDecoded, ex.Message);
                            }
                            //txtLog.Text = CategoryId.ToString() + " " + RecruiterId.ToString() + " " + CityId.ToString() + " " + JobtypeId.ToString();
                            Requisition req = new Requisition();
                            req.Adicionar(TitleHeadingDecoded, RecruiterId, StatusDecoded, BriefDescriptionDecoded, DescriptionFieldDecoded, CityId, CategoryId, JobtypeId, RequisitionLink);

                        }
                    }
                    catch (Exception ex)
                    {
                        txtLog.Text = ex.ToString();
                    }

                }
                browserJobVite.Navigate(new Uri("https://hire.jobvite.com/Hiring/ViewJob.aspx?v=4&js=1023&vr=1&id=" + i));
            }
        }
Beispiel #2
0
 public void Adicionar(string NavigateId,string RequisitionName, string CampoErrado, string ValorErrado, string ex)
 {
     using (grouponjobsdevEntities context = new grouponjobsdevEntities())
     {
         Requisition_Log log = new Requisition_Log();
         log.NavigateId = int.Parse(NavigateId);
         log.RequisitionName = RequisitionName;
         log.CampoErrado = CampoErrado;
         log.ValorErrado = ValorErrado;
         log.Exception = ex;
         context.Requisition_Log.AddObject(log);
         context.SaveChanges();
     }
 }