Exemplo n.º 1
0
        static TestBase()
        {
            Credentials data = JsonSerializer.Deserialize <Credentials>(File.ReadAllText("credentials.json"));

            GeocodeCredentials = new GeocodeCredentials()
            {
                Provider    = GeocodeProvider.Google,
                ProviderKey = data.GeocodeProviderKey
            };

            Client = new SovrenClient(data.AccountId, data.ServiceKey, new DataCenter("https://rest-local.sovren.com", "v10", true));

            ParseResumeResponseValue parseResumeResponseValue = Client.ParseResume(new ParseRequest(TestData.Resume)).Result.Value;

            TestParsedResume = parseResumeResponseValue.ResumeData;

            parseResumeResponseValue    = Client.ParseResume(new ParseRequest(TestData.ResumeWithAddress)).Result.Value;
            TestParsedResumeWithAddress = parseResumeResponseValue.ResumeData;

            ParseJobResponseValue parseJobResponseValue = Client.ParseJob(new ParseRequest(TestData.JobOrder)).Result.Value;

            TestParsedJob = parseJobResponseValue.JobData;

            parseJobResponseValue    = Client.ParseJob(new ParseRequest(TestData.JobOrderWithAddress)).Result.Value;
            TestParsedJobWithAddress = parseJobResponseValue.JobData;

            parseJobResponseValue = Client.ParseJob(new ParseRequest(TestData.JobOrderTech)).Result.Value;
            TestParsedJobTech     = parseJobResponseValue.JobData;
        }
Exemplo n.º 2
0
        private static void parseAndSavePageToStack(CrawledPage page)
        {
            var findedJobsTable = page.HtmlDocument.DocumentNode.SelectNodes(@"//table[@data-qa='vacancy-serp__results']/tbody/tr");

            foreach (var job in findedJobsTable)
            {
                var jobLink = job.SelectSingleNode(".//span[@class='b-marker']/a");
                if (jobLink != null)
                {
                    var jobParsed = new ParsedJob();

                    jobParsed.JobName  = jobLink.InnerText;
                    jobParsed.JobUrl   = jobLink.Attributes["href"].Value;
                    jobParsed.WebIdJob = jobParsed.JobUrl.Split('/').Last();

                    var postedDate = job.SelectSingleNode(".//span[@class='b-vacancy-list-date' and @data-qa='vacancy-serp__vacancy-date']");

                    jobParsed.Region = job.SelectSingleNode(".//span[@class='searchresult__address']").InnerText.Split(',').First();

                    var companyName = job.SelectSingleNode(".//a[@data-qa='vacancy-serp__vacancy-employer']");
                    if (companyName != null)
                    {
                        jobParsed.ComapnyName = companyName.InnerText;
                    }
                    else
                    {
                        jobParsed.ComapnyName = "Unknown";
                    }

                    var salary = job.SelectSingleNode(".//div[@class='b-vacancy-list-salary' and @data-qa='vacancy-serp__vacancy-compensation']");
                    if (salary != null)
                    {
                        var salaryCurrency =
                            salary.SelectNodes(".//meta").First(n => n.Attributes["itemprop"].Value == "salaryCurrency")
                            .Attributes["content"].Value;

                        var baseSalary =
                            salary.SelectNodes(".//meta").First(n => n.Attributes["itemprop"].Value == "baseSalary")
                            .Attributes["content"].Value;

                        jobParsed.Salary = extractSalary(baseSalary + " " + salaryCurrency);
                    }


                    /*   jobParsed.Description = job.SelectSingleNode(".//div[@class='d']").InnerText;
                     *
                     * var categories = job.SelectNodes(".//div[@class='tags']/a");
                     * /                    jobParsed.Categories = new List<string>();
                     * if (categories != null)
                     * {
                     *  foreach (var category in categories)
                     *  {
                     *      jobParsed.Categories.Add(category.InnerText);
                     *  }
                     * }*/
                    jobParsed.Portal = "hh.ua";
                    ParsedJobStack.Instance.Push(jobParsed);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a Matching UI session to find matches for a non-indexed job
        /// </summary>
        /// <param name="sovClient">The SovrenClient</param>
        /// <param name="job">The job (generated by the Sovren Job Parser) to use as the source for a match query</param>
        /// <param name="indexesToQuery">The indexes to find results in. These must all be of the same type (resumes or jobs)</param>
        /// <param name="preferredWeights">
        /// The preferred category weights for scoring the results. If none are provided,
        /// Sovren will determine the best values based on the source job
        /// </param>
        /// <param name="filters">Any filters to apply prior to the match (a result must satisfy all the filters)</param>
        /// <param name="settings">Settings for this match</param>
        /// <param name="numResults">The number of results to show. If not specified, the default will be used.</param>
        /// <exception cref="SovrenException">Thrown when an API error occurs</exception>
        public static async Task <GenerateUIResponse> Match(
            this SovrenClientWithUI sovClient,
            ParsedJob job,
            IEnumerable <string> indexesToQuery,
            CategoryWeights preferredWeights = null,
            FilterCriteria filters           = null,
            SearchMatchSettings settings     = null,
            int numResults = 0)
        {
            MatchJobRequest   request   = sovClient.InternalClient.CreateRequest(job, indexesToQuery, preferredWeights, filters, settings, numResults);
            UIMatchJobRequest uiRequest = new UIMatchJobRequest(request, sovClient.UISessionOptions);

            return(await sovClient.InternalClient.UIMatch(uiRequest));
        }
Exemplo n.º 4
0
        private static void parseAndSavePageToStack(CrawledPage page)
        {
            var findedJobsTable = page.HtmlDocument.DocumentNode.SelectNodes(@"//table[@id='centerZone_vacancyList_gridList']/tr");

            foreach (var job in findedJobsTable)
            {
                if (job.Attributes["id"] != null)
                {
                    ParsedJob jobParsed = new ParsedJob();

                    jobParsed.WebIdJob = job.Attributes["id"].Value;

                    var linkJob = job.SelectSingleNode(".//div[@class='rua-g-clearfix']/a");
                    jobParsed.JobName = linkJob.InnerText;
                    jobParsed.JobUrl  = linkJob.Attributes["href"].Value;

                    var JobInfo = job.SelectSingleNode(".//div[@class='rua-g-clearfix']/div[@class='s']").InnerText.Replace("\n", "").Replace("\r", "").Replace("\t", "").Split('•');

                    //JobInfo 3items  1 companyName 2 Region 3 Salary
                    if (JobInfo.Length > 0)
                    {
                        jobParsed.ComapnyName = JobInfo[0];
                    }
                    if (JobInfo.Length > 1)
                    {
                        jobParsed.Region = JobInfo[1];
                    }
                    if (JobInfo.Length > 2)
                    {
                        jobParsed.Salary = extractSalary(JobInfo[2]);
                    }

                    jobParsed.Description = job.SelectSingleNode(".//div[@class='d']").InnerText;

                    var categories = job.SelectNodes(".//div[@class='tags']/a");

                    jobParsed.Categories = new List <string>();
                    if (categories != null)
                    {
                        foreach (var category in categories)
                        {
                            jobParsed.Categories.Add(category.InnerText);
                        }
                    }
                    jobParsed.Portal = "rabota.ua";
                    ParsedJobStack.Instance.Push(jobParsed);
                }
            }
        }
Exemplo n.º 5
0
        public async Task TestJobLifeCycle()
        {
            const string documentId = "1";

            try
            {
                // verify can't retrieve a document that doesn't exist
                SovrenException sovrenException = Assert.ThrowsAsync <SovrenException>(async() => {
                    await Client.GetJob(jobIndexId, documentId);
                });
                Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode);

                // verify can't add document to an index that doesn't exist
                sovrenException = Assert.ThrowsAsync <SovrenException>(async() => {
                    await Client.IndexDocument(TestParsedJob, jobIndexId, documentId);
                });
                Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode);

                // create the index
                await Client.CreateIndex(IndexType.Job, jobIndexId);
                await DelayForIndexSync();

                // verify document still doesn't exist
                sovrenException = Assert.ThrowsAsync <SovrenException>(async() => {
                    await Client.GetJob(jobIndexId, documentId);
                });
                Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode);

                // add resume to index
                await Client.IndexDocument(TestParsedJob, jobIndexId, documentId);
                await DelayForIndexSync();

                // confirm you can now retrieve the resume
                await Client.GetJob(jobIndexId, documentId);

                // confirm the resume shows up in searches
                List <string> indexesToQuery = new List <string>()
                {
                    jobIndexId
                };
                FilterCriteria filterCriteria = new FilterCriteria()
                {
                    DocumentIds = new List <string>()
                    {
                        documentId
                    }
                };

                SearchResponseValue searchResponse = Client.Search(indexesToQuery, filterCriteria).Result.Value;
                Assert.AreEqual(1, searchResponse.TotalCount);
                Assert.AreEqual(1, searchResponse.CurrentCount);
                Assert.AreEqual(documentId, searchResponse.Matches[0].Id);

                // update the resume
                List <string> userDefinedTags = new List <string> {
                    "userDefinedTag1"
                };
                await Client.UpdateJobUserDefinedTags(jobIndexId, documentId,
                                                      userDefinedTags, UserDefinedTagsMethod.Overwrite);

                await DelayForIndexSync();

                // verify those updates have taken effect
                filterCriteria.UserDefinedTags = userDefinedTags;
                searchResponse = Client.Search(indexesToQuery, filterCriteria).Result.Value;
                Assert.AreEqual(1, searchResponse.TotalCount);
                Assert.AreEqual(1, searchResponse.CurrentCount);
                Assert.AreEqual(documentId, searchResponse.Matches[0].Id);

                // confirm you can retrieve the tags
                ParsedJob job = Client.GetJob(jobIndexId, documentId).Result.Value;
                Assert.AreEqual(1, job.UserDefinedTags.Count);
                Assert.AreEqual(userDefinedTags[0], job.UserDefinedTags[0]);

                // delete the document
                await Client.DeleteDocument(jobIndexId, documentId);
                await DelayForIndexSync();

                // verify can't retrieve a document that doesn't exist
                sovrenException = Assert.ThrowsAsync <SovrenException>(async() => {
                    await Client.GetJob(jobIndexId, documentId);
                });
                Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode);

                sovrenException = Assert.ThrowsAsync <SovrenException>(async() => {
                    await Client.DeleteDocument(jobIndexId, documentId);
                });
                Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode);

                await Client.DeleteIndex(jobIndexId);
                await DelayForIndexSync();

                sovrenException = Assert.ThrowsAsync <SovrenException>(async() => {
                    await Client.DeleteDocument(jobIndexId, documentId);
                });
                Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode);
            }
            finally
            {
                await CleanUpIndex(jobIndexId);
            }
        }
Exemplo n.º 6
0
        public void SaveParsedJob(ParsedJob jobParsed)
        {
            if (!Company.Any(f => f.Name.Equals(jobParsed.ComapnyName.Trim())))
            {
                Company.Add(new Company()
                {
                    Name = jobParsed.ComapnyName.Trim()
                });
                SaveChanges();
            }
            int idCompany = Company.First(c => c.Name.Equals(jobParsed.ComapnyName.Trim())).id;

            if (!Region.Any(r => r.Name.Equals(jobParsed.Region.Trim())))
            {
                Region.Add(new Region()
                {
                    Name = jobParsed.Region.Trim()
                });
                SaveChanges();
            }
            int idRegion = Region.First(r => r.Name.Equals(jobParsed.Region.Trim())).id;

            if (!Portal.Any(r => r.Name.Equals(jobParsed.Portal.Trim())))
            {
                Portal.Add(new Portal()
                {
                    Name = jobParsed.Portal.Trim()
                });
                SaveChanges();
            }
            int idPortal = Portal.First(r => r.Name.Equals(jobParsed.Portal.Trim())).id;

            if (!Job.Any(r => r.WebIdJob.Equals(jobParsed.WebIdJob.Trim()) && r.idPortal.Equals(idPortal)))
            {
                Job.Add(new Job()
                {
                    Name           = jobParsed.JobName.Trim(),
                    idCompany      = idCompany,
                    idRegion       = idRegion,
                    Description    = jobParsed.Description,
                    ParsedDateTime = DateTime.Now,
                    Url            = jobParsed.JobUrl,
                    Salary         = jobParsed.Salary,
                    WebIdJob       = jobParsed.WebIdJob,
                    idPortal       = idPortal
                });
                SaveChanges();
            }
            // int idJob = Job.Where(r => r.WebIdJob.Equals(jobParsed.WebIdJob.Trim())).First().id;
            if (jobParsed.Categories != null)
            {
                foreach (string keyword in jobParsed.Categories)
                {
                    if (!JobCategory.Any(r => r.Name.Equals(keyword.Trim())))
                    {
                        JobCategory.Add(new JobCategory()
                        {
                            Name = keyword.Trim()
                        });
                        SaveChanges();
                    }

                    var jobCategory = JobCategory.First(r => r.Name.Equals(keyword.Trim()));

                    var job = Job.First(r => r.WebIdJob.Equals(jobParsed.WebIdJob.Trim()));

                    if (!job.JobCategory.Any(jc => jc.Name.Equals(keyword.Trim())))
                    {
                        job.JobCategory.Add(jobCategory);
                        SaveChanges();
                    }
                }
            }
        }